Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lookup: remove deprecates from tests (#13073) #13102

Merged
merged 1 commit into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module('Lookup', {
this.clock = sinon.useFakeTimers();

this.element = $('#lookup');
this.instance = this.element.dxLookup({ fullScreen: false }).dxLookup('instance');
this.instance = this.element.dxLookup({ 'dropDownOptions.fullScreen': false }).dxLookup('instance');
this.$field = $(this.instance._$field);
},
afterEach: function() {
Expand Down
106 changes: 59 additions & 47 deletions testing/tests/DevExpress.ui.widgets.editors/lookup.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ QUnit.module('Lookup', {
this.clock = sinon.useFakeTimers();

this.element = $('#lookup');
this.instance = this.element.dxLookup({ fullScreen: false }).dxLookup('instance');
this.instance = this.element.dxLookup({ 'dropDownOptions.fullScreen': false }).dxLookup('instance');
this.$field = $(this.instance._$field);

this.togglePopup = function() {
Expand Down Expand Up @@ -239,7 +239,7 @@ QUnit.module('Lookup', {
},
deferRendering: false,
searchTimeout: 0,
animation: {},
'dropDownOptions.animation': {},
cleanSearchOnOpening: false
}).dxLookup('instance');
count = 0;
Expand Down Expand Up @@ -273,7 +273,7 @@ QUnit.module('Lookup', {
dataSource: [1, 2, 3],
deferRendering: false,
searchTimeout: searchTimeout,
animation: null,
'dropDownOptions.animation': null,
cleanSearchOnOpening: true,
opened: true
}).dxLookup('instance');
Expand All @@ -296,7 +296,7 @@ QUnit.module('Lookup', {
}
}),
searchTimeout: searchTimeout,
animation: null,
'dropDownOptions.animation': null,
cleanSearchOnOpening: true,
opened: true
}).dxLookup('instance');
Expand All @@ -318,7 +318,7 @@ QUnit.module('Lookup', {
.dxLookup({
items: [111, 222, 333],
searchTimeout: 0,
animation: {},
'dropDownOptions.animation': {},
minSearchLength: 2,
onContentReady: function() { count++; }
}).dxLookup('instance');
Expand Down Expand Up @@ -1112,7 +1112,7 @@ QUnit.module('Lookup', {
const popupHeight = 500;
this.instance.option({
usePopover: true,
popupHeight: popupHeight
'dropDownOptions.height': popupHeight
});

this.togglePopup();
Expand Down Expand Up @@ -1381,7 +1381,11 @@ QUnit.module('Lookup', {

try {
const lookup = $lookup
.dxLookup({ dataSource: ['blue', 'orange', 'lime', 'purple'], value: 'orange', fullScreen: true })
.dxLookup({
dataSource: ['blue', 'orange', 'lime', 'purple'],
value: 'orange',
'dropDownOptions.fullScreen': true
})
.dxLookup('instance');

$(lookup.field()).trigger('dxclick');
Expand Down Expand Up @@ -1428,7 +1432,7 @@ QUnit.module('Lookup', {
displayExpr: 'Name',
valueExpr: 'ID',
value: 1,
title: 'Select employee'
'dropDownOptions.title': 'Select employee'
});

setTimeout(() => {
Expand Down Expand Up @@ -1482,29 +1486,29 @@ QUnit.module('options', {
}, () => {
QUnit.test('popupWidth', function(assert) {
const instance = $('#lookup').dxLookup({
popupWidth: 100,
'dropDownOptions.width': 100,
usePopover: false
}).dxLookup('instance');

$(instance._$field).trigger('dxclick');

assert.equal(instance._popup.option('width'), 100, 'Option initialized correctly');

instance.option('popupWidth', 200);
instance.option('dropDownOptions.width', 200);
assert.equal(instance._popup.option('width'), 200, 'Option set correctly');
});

QUnit.test('popupWidth option test for usePopover mode', function(assert) {
const instance = $('#lookup').dxLookup({
popupWidth: 100,
'dropDownOptions.width': 100,
usePopover: true
}).dxLookup('instance');

$(instance._$field).trigger('dxclick');

assert.equal(instance._popup.option('width'), 100, 'Option initialized correctly');

instance.option('popupWidth', 200);
instance.option('dropDownOptions.width', 200);
assert.equal(instance._popup.option('width'), 200, 'Option set correctly');
});

Expand Down Expand Up @@ -1534,9 +1538,9 @@ QUnit.module('options', {
initialValue = initialValue();
}

instance.option('popupWidth', initialValue + 1);
instance.option('dropDownOptions.width', initialValue + 1);

instance.option('popupWidth', 'auto');
instance.option('dropDownOptions.width', 'auto');
let autoValue = popup.option('width');
if($.isFunction(autoValue)) {
autoValue = autoValue();
Expand All @@ -1546,13 +1550,13 @@ QUnit.module('options', {
});

QUnit.test('popupHeight', function(assert) {
const instance = $('#lookup').dxLookup({ popupHeight: 100, usePopover: false }).dxLookup('instance');
const instance = $('#lookup').dxLookup({ 'dropDownOptions.height': 100, usePopover: false }).dxLookup('instance');

$(instance._$field).trigger('dxclick');

assert.equal(instance._popup.option('height'), 100, 'Option initialized correctly');

instance.option('popupHeight', 200);
instance.option('dropDownOptions.height', 200);
assert.equal(instance._popup.option('height'), 200, 'Option set correctly');
});

Expand All @@ -1568,9 +1572,9 @@ QUnit.module('options', {
initialValue = initialValue();
}

instance.option('popupHeight', initialValue + 1);
instance.option('dropDownOptions.height', initialValue + 1);

instance.option('popupHeight', 'auto');
instance.option('dropDownOptions.height', 'auto');
let autoValue = popup.option('height');
if($.isFunction(autoValue)) {
autoValue = autoValue();
Expand Down Expand Up @@ -1866,21 +1870,21 @@ QUnit.module('options', {
QUnit.test('title', function(assert) {
const instance = $('#lookup').dxLookup({
dataSource: [],
title: 'title'
'dropDownOptions.title': 'title'
}).dxLookup('instance');

$(instance._$field).trigger('dxclick');

assert.equal(instance._popup.option('title'), 'title', 'title sets to popup correctly on init');

instance.option('title', 'title2');
instance.option('dropDownOptions.title', 'title2');
assert.equal(instance._popup.option('title'), 'title2', 'title sets to popup correctly on change');
});

QUnit.test('fullScreen', function(assert) {
const instance = $('#lookup').dxLookup({
dataSource: [],
fullScreen: true,
'dropDownOptions.fullScreen': true,
usePopover: false
}).dxLookup('instance');

Expand All @@ -1891,7 +1895,7 @@ QUnit.module('options', {
popup = instance._popup;
assert.equal(popup.option('fullScreen'), true, 'fullScreen sets to popup correctly on init');

instance.option('fullScreen', false);
instance.option('dropDownOptions.fullScreen', false);
$(instance._$field).trigger('dxclick');
popup = instance._popup;
assert.equal(popup.option('fullScreen'), false, 'fullScreen sets to popup correctly on change');
Expand Down Expand Up @@ -2035,7 +2039,7 @@ QUnit.module('popup options', {
const $lookup = $('#lookupOptions');

const instance = $lookup.dxLookup({
shading: true,
'dropDownOptions.shading': true,
visible: true,
usePopover: false
}).dxLookup('instance');
Expand All @@ -2045,7 +2049,7 @@ QUnit.module('popup options', {

assert.ok($wrapper.hasClass(OVERLAY_SHADER_CLASS));

instance.option('shading', false);
instance.option('dropDownOptions.shading', false);
assert.ok(!$wrapper.hasClass(OVERLAY_SHADER_CLASS));
});

Expand All @@ -2066,7 +2070,7 @@ QUnit.module('popup options', {
QUnit.test('lookup popup should be hidden after click outside was present', function(assert) {
const $lookup = $('#lookupOptions');
const instance = $lookup.dxLookup({
closeOnOutsideClick: true,
'dropDownOptions.closeOnOutsideClick': true,
visible: true,
usePopover: false
}).dxLookup('instance');
Expand All @@ -2084,7 +2088,7 @@ QUnit.module('popup options', {

QUnit.test('custom titleTemplate option', function(assert) {
const $lookup = $('#lookupOptions').dxLookup({
titleTemplate: 'customTitle',
'dropDownOptions.titleTemplate': 'customTitle',
visible: true,
showCancelButton: false
});
Expand All @@ -2098,7 +2102,7 @@ QUnit.module('popup options', {

QUnit.test('custom titleTemplate option is set correctly on init', function(assert) {
const $lookup = $('#lookupOptions').dxLookup({
titleTemplate: function(titleElement) {
'dropDownOptions.titleTemplate': function(titleElement) {
assert.equal(isRenderer(titleElement), !!config().useJQuery, 'titleElement is correct');
let result = '<div class=\'test-title-renderer\'>';
result += '<h1>Title</h1>';
Expand All @@ -2120,11 +2124,11 @@ QUnit.module('popup options', {

const $lookup = $('#lookupOptions').dxLookup(); const instance = $lookup.dxLookup('instance');

instance.option('onTitleRendered', function(e) {
instance.option('dropDownOptions.onTitleRendered', function(e) {
assert.ok(true, 'option \'onTitleRendered\' successfully passed to the popup widget raised on titleTemplate');
});

instance.option('titleTemplate', function(titleElement) {
instance.option('dropDownOptions.titleTemplate', function(titleElement) {
let result = '<div class=\'changed-test-title-renderer\'>';
result += '<h1>Title</h1>';
result += '</div>';
Expand Down Expand Up @@ -2182,9 +2186,11 @@ QUnit.module('popup options', {
QUnit.test('popup height should be saved after configuration', function(assert) {
$('#lookup').dxLookup({
dataSource: [1, 2, 3, 4, 5],
popupHeight: $(window).height() * 0.8,
opened: true,
fullScreen: false,
dropDownOptions: {
fullScreen: false,
height: $(window).height() * 0.8
},
usePopover: false
});

Expand Down Expand Up @@ -2261,10 +2267,10 @@ QUnit.module('popup options', {
width: 300,
searchEnabled: false,
dropDownOptions: {
position: 'center',
container: $('body')
},
target: $('body'),
position: 'center',
usePopover: true,
opened: true
}).dxLookup('instance');
Expand Down Expand Up @@ -2390,11 +2396,13 @@ QUnit.module('Native scrolling', () => {
paginate: true,
pageSize: 40
},
fullScreen: false,
dropDownOptions: {
fullScreen: false,
height: '50%'
},
searchTimeout: 0,
width: 200,
usePopover: false,
popupHeight: '50%'
usePopover: false
});

$lookup.dxLookup('instance').open();
Expand Down Expand Up @@ -2434,8 +2442,10 @@ QUnit.module('Native scrolling', () => {
searchTimeout: 0,
width: 200,
usePopover: false,
popupHeight: 'auto',
fullScreen: false
dropDownOptions: {
fullScreen: false,
height: 'auto'
}
});

$lookup.dxLookup('instance').open();
Expand Down Expand Up @@ -3182,11 +3192,11 @@ QUnit.module('default options', {

const lookup = $lookup.dxLookup({ dataSource: ['blue', 'orange', 'lime', 'purple'] }).dxLookup('instance');

assert.equal(lookup.option('popupWidth')(), $lookup.outerWidth(), 'popup width match with lookup field width');
assert.equal(lookup.option('dropDownOptions.width')(), $lookup.outerWidth(), 'popup width match with lookup field width');

$(lookup.field()).trigger('dxclick');

assert.equal(lookup.option('popupHeight')(), $('.dx-list-item').height() * 4 + 16, 'popup height contains 4 list items and 2 paddings (8px)');
assert.equal(lookup.option('dropDownOptions.height')(), $('.dx-list-item').height() * 4 + 16, 'popup height contains 4 list items and 2 paddings (8px)');

lookup.close();

Expand All @@ -3195,16 +3205,16 @@ QUnit.module('default options', {

$(lookup.field()).trigger('dxclick');

assert.equal(lookup.option('popupHeight')(), $('.dx-lookup-search-wrapper').outerHeight() + $('.dx-list-item').height() * 4 + $('.dx-toolbar').outerHeight() + 16, 'popup height contains 4 list items when there are search and cancel button');
assert.equal(lookup.option('dropDownOptions.height')(), $('.dx-lookup-search-wrapper').outerHeight() + $('.dx-list-item').height() * 4 + $('.dx-toolbar').outerHeight() + 16, 'popup height contains 4 list items when there are search and cancel button');

lookup.close();
lookup.option('popupWidth', 200);
lookup.option('popupHeight', 300);
lookup.option('dropDownOptions.width', 200);
lookup.option('dropDownOptions.height', 300);

$(lookup.field()).trigger('dxclick');

assert.equal(lookup.option('popupHeight'), 300, 'popup height changed if change popupHeight option value');
assert.equal(lookup.option('popupWidth'), 200, 'popup width changed if change popupWidth option value');
assert.equal(lookup.option('dropDownOptions.height'), 300, 'popup height changed if change popupHeight option value');
assert.equal(lookup.option('dropDownOptions.width'), 200, 'popup width changed if change popupWidth option value');

lookup.close();

Expand Down Expand Up @@ -3294,7 +3304,7 @@ QUnit.module('default options', {

assert.roughEqual($popup.find('.dx-overlay-content').position().top, ($(window).height() - $popup.find('.dx-overlay-content').outerHeight()) / 2, 1, 'default popup position of window');

lookup.option('position', 'top');
lookup.option('dropDownOptions.position', 'top');

assert.roughEqual($popup.find('.dx-overlay-content').position().top, 0, 1, 'popup position of window after change position');

Expand Down Expand Up @@ -3372,8 +3382,10 @@ QUnit.module('default options', {
Lookup.defaultOptions({
options: {
usePopover: true,
fullScreen: false,
popupWidth: defaultWidth
dropDownOptions: {
fullScreen: false,
width: defaultWidth
}
}
});
const $lookup = $('<div>').prependTo('body');
Expand Down