diff --git a/js/ui/lookup.js b/js/ui/lookup.js
index 2aac043c3821..c9cb9aa5bbd0 100644
--- a/js/ui/lookup.js
+++ b/js/ui/lookup.js
@@ -1195,6 +1195,7 @@ var Lookup = DropDownList.inherit({
_renderInputValue: function() {
return this.callBase().always((function() {
+ this._renderField();
this._refreshSelected();
this._setSubmitValue();
}).bind(this));
diff --git a/testing/tests/DevExpress.ui.widgets.editors/lookup.markup.tests.js b/testing/tests/DevExpress.ui.widgets.editors/lookup.markup.tests.js
index f7f0bcef2545..9bb7a58c68f2 100644
--- a/testing/tests/DevExpress.ui.widgets.editors/lookup.markup.tests.js
+++ b/testing/tests/DevExpress.ui.widgets.editors/lookup.markup.tests.js
@@ -1,30 +1,29 @@
-import $ from "jquery";
-import Lookup from "ui/lookup";
-import executeAsyncMock from "../../helpers/executeAsyncMock.js";
-import fx from "animation/fx";
-
-import "common.css!";
-import "generic_light.css!";
-
-const { test, module, testStart } = QUnit;
-
-testStart(() => {
- const markup =
- `
"));
- $("#widthRootStyle").dxLookup({
- fieldTemplate: fieldTemplateStub,
- dataSource: [1, 2, 3],
- value: 2
- });
-
- assert.ok(fieldTemplateStub.calledOnce, "field template called once");
- });
+ this.clock.tick(0);
+ assert.equal($element.find("." + LOOKUP_FIELD_CLASS).text(), fieldTemplateText, "field template is used");
});
-module("hidden input", () => {
- test("a hidden input should be rendered", (assert) => {
- const $element = $("#lookup").dxLookup();
- const $input = $element.find("input[type='hidden']");
+QUnit.module("hidden input");
- assert.equal($input.length, 1, "a hidden input is rendered");
- });
+QUnit.test("a hidden input should be rendered", function(assert) {
+ var $element = $("#lookup").dxLookup(),
+ $input = $element.find("input[type='hidden']");
- test("the hidden input should have correct value on widget init", (assert) => {
- const $element = $("#lookup").dxLookup({
+ assert.equal($input.length, 1, "a hidden input is rendered");
+});
+
+QUnit.test("the hidden input should have correct value on widget init", function(assert) {
+ var $element = $("#lookup").dxLookup({
items: [1, 2, 3],
value: 2
- });
- const $input = $element.find("input[type='hidden']");
+ }),
+ $input = $element.find("input[type='hidden']");
- assert.equal($input.val(), "2", "input value is correct");
- });
+ assert.equal($input.val(), "2", "input value is correct");
+});
- test("the hidden input should get display text as value if widget value is an object", (assert) => {
- const items = [{ id: 1, text: "one" }];
- const $element = $("#lookup").dxLookup({
+QUnit.test("the hidden input should get display text as value if widget value is an object", function(assert) {
+ var items = [{ id: 1, text: "one" }],
+ $element = $("#lookup").dxLookup({
items: items,
value: items[0],
valueExpr: "this",
displayExpr: "text"
- });
- const $input = $element.find("input[type='hidden']");
+ }),
+ $input = $element.find("input[type='hidden']");
- assert.equal($input.val(), items[0].text, "input value is correct");
- });
+ assert.equal($input.val(), items[0].text, "input value is correct");
+});
- test("the hidden input should get value in respect of the 'valueExpr' option", (assert) => {
- const items = [{ id: 1, text: "one" }];
- const $element = $("#lookup").dxLookup({
+QUnit.test("the hidden input should get value in respect of the 'valueExpr' option", function(assert) {
+ var items = [{ id: 1, text: "one" }],
+ $element = $("#lookup").dxLookup({
items: items,
value: items[0].id,
valueExpr: "id",
displayExpr: "text"
- });
- const $input = $element.find("input[type='hidden']");
+ }),
+ $input = $element.find("input[type='hidden']");
- assert.equal($input.val(), items[0].id, "input value is correct");
- });
+ assert.equal($input.val(), items[0].id, "input value is correct");
});
-module("options", {
- beforeEach: () => {
+QUnit.module("options", {
+ beforeEach: function() {
fx.off = true;
executeAsyncMock.setup();
this.clock = sinon.useFakeTimers();
},
- afterEach: () => {
+ afterEach: function() {
executeAsyncMock.teardown();
fx.off = false;
this.clock.restore();
}
-}, () => {
- test("hidden input should get the 'name' attribute with a correct value", (assert) => {
- const expectedName = "lookup";
- const $element = $("#lookup").dxLookup({
+});
+
+QUnit.test("hidden input should get the 'name' attribute with a correct value", function(assert) {
+ var expectedName = "lookup",
+ $element = $("#lookup").dxLookup({
name: expectedName
- });
- const $input = $element.find("input[type='hidden']");
+ }),
+ $input = $element.find("input[type='hidden']");
- assert.equal($input.attr("name"), expectedName, "input has correct 'name' attribute");
- });
+ assert.equal($input.attr("name"), expectedName, "input has correct 'name' attribute");
+});
- test("displayExpr, valueExpr as functions (regression B230600)", (assert) => {
- const instance = $("#lookup").dxLookup({
+QUnit.test("displayExpr, valueExpr as functions (regression B230600)", function(assert) {
+ var instance = $("#lookup").dxLookup({
dataSource: [1, 2],
valueExpr: function(item) {
return item * 2;
@@ -195,90 +183,89 @@ module("options", {
return "number " + item;
},
value: 2
- }).dxLookup("instance");
- const $field = instance._$field;
+ }).dxLookup("instance"),
+ $field = instance._$field;
- assert.equal($field.text(), "number 1");
- });
+ assert.equal($field.text(), "number 1");
+});
- test("value", (assert) => {
- const items = [1, 2, 3];
- const instance = $("#lookup").dxLookup({ dataSource: items, value: 1 }).dxLookup("instance");
- const $field = $(instance._$field);
+QUnit.test("value", function(assert) {
+ var items = [1, 2, 3],
+ instance = $("#lookup").dxLookup({ dataSource: items, value: 1 }).dxLookup("instance"),
+ $field = $(instance._$field);
- assert.equal($field.text(), 1, "field text is selected item value");
- assert.equal(instance.option("displayValue"), 1, "displayValue is selected item value");
- });
+ assert.equal($field.text(), 1, "field text is selected item value");
+ assert.equal(instance.option("displayValue"), 1, "displayValue is selected item value");
+});
- test("value should be assigned by reference", (assert) => {
- const items = [{ name: "name" }];
- const instance = $("#lookup").dxLookup({
+QUnit.test("value should be assigned by reference", function(assert) {
+ var items = [{ name: "name" }],
+ instance = $("#lookup").dxLookup({
dataSource: items,
value: items[0],
displayExpr: "name"
- }).dxLookup("instance");
- const $field = $(instance._$field);
+ }).dxLookup("instance"),
+ $field = $(instance._$field);
- assert.equal($field.text(), "name", "item was found in items by reference");
- });
+ assert.equal($field.text(), "name", "item was found in items by reference");
+});
- test("placeholder", (assert) => {
- const instance = $("#lookup").dxLookup({
- dataSource: []
- }).dxLookup("instance");
+QUnit.test("placeholder", function(assert) {
+ var instance = $("#lookup").dxLookup({
+ dataSource: []
+ })
+ .dxLookup("instance");
- assert.equal($(instance._$field).text(), "Select...", "default value");
- });
+ assert.equal($(instance._$field).text(), "Select...", "default value");
+});
- test("fieldTemplate should be rendered", (assert) => {
- $("#lookupFieldTemplate").dxLookup({ fieldTemplate: "field" });
+QUnit.test("fieldTemplate should be rendered", function(assert) {
+ $("#lookupFieldTemplate").dxLookup({ fieldTemplate: "field" });
- assert.equal($.trim($("#lookupFieldTemplate").text()), "test", "test was be rendered");
- });
+ assert.equal($.trim($("#lookupFieldTemplate").text()), "test", "test was be rendered");
+});
- test("selected item should be passed as first argument if fieldTemplate is a function", (assert) => {
- const items = [{ id: 1, text: "one", data: 11 }, { id: 2, text: "two", data: 22 }];
+QUnit.test("selected item should be passed as first argument if fieldTemplate is a function", function(assert) {
+ var items = [{ id: 1, text: "one", data: 11 }, { id: 2, text: "two", data: 22 }];
- $("#lookup").dxLookup({
- items: items,
- valueExpr: "id",
- displayExpr: "text",
- value: items[1].id,
- fieldTemplate: function(item) {
- assert.deepEqual(item, items[1], "selected item is passed to fieldTemplate function");
+ $("#lookup").dxLookup({
+ items: items,
+ valueExpr: "id",
+ displayExpr: "text",
+ value: items[1].id,
+ fieldTemplate: function(item) {
+ assert.deepEqual(item, items[1], "selected item is passed to fieldTemplate function");
- return $("
").dxTextBox();
- }
- });
+ return $("
").dxTextBox();
+ }
});
});
-module("widget sizing render", () => {
- test("constructor", (assert) => {
- const $element = $("#lookup").dxLookup({ width: 400 });
- const instance = $element.dxLookup("instance");
+QUnit.module("widget sizing render");
- assert.strictEqual(instance.option("width"), 400);
- assert.strictEqual($element.get(0).style.width, "400px", "outer width of the element must be equal to custom width");
- });
+QUnit.test("constructor", function(assert) {
+ var $element = $("#lookup").dxLookup({ width: 400 }),
+ instance = $element.dxLookup("instance");
+
+ assert.strictEqual(instance.option("width"), 400);
+ assert.strictEqual($element.get(0).style.width, "400px", "outer width of the element must be equal to custom width");
+});
- test("root with custom width", (assert) => {
- const $element = $("#widthRootStyle").dxLookup();
- const instance = $element.dxLookup("instance");
+QUnit.test("root with custom width", function(assert) {
+ var $element = $("#widthRootStyle").dxLookup(),
+ instance = $element.dxLookup("instance");
- assert.strictEqual(instance.option("width"), undefined);
- assert.strictEqual($element.get(0).style.width, "300px", "outer width of the element must be equal to custom width");
- });
+ assert.strictEqual(instance.option("width"), undefined);
+ assert.strictEqual($element.get(0).style.width, "300px", "outer width of the element must be equal to custom width");
});
-module("aria accessibility", () => {
- test("aria role", (assert) => {
- const $element = $("#lookup").dxLookup();
- const $field = $element.find(`.${LOOKUP_FIELD_CLASS}:first`);
+QUnit.module("aria accessibility");
- assert.equal($field.attr("role"), "combobox", "aria role is on the field");
- });
+QUnit.test("aria role", function(assert) {
+ var $element = $("#lookup").dxLookup(),
+ $field = $element.find("." + LOOKUP_FIELD_CLASS + ":first");
+ assert.equal($field.attr("role"), "combobox", "aria role is on the field");
});