Skip to content

Commit

Permalink
Form: combine test cases in forEach (T1257945)
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-shakhova committed Dec 12, 2024
1 parent 610c734 commit 1e392d2
Showing 1 changed file with 4 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4543,8 +4543,9 @@ QUnit.test('form should be dirty when some editors are dirty', function(assert)
});

[true, false].forEach((openOnFieldClick) => {
[true, false].forEach((hideOnOutsideClick) => {
[true, false, undefined].forEach((hideOnOutsideClick) => {
QUnit.test(`Opened DropDownList must hide on input label click, openOnFieldClick: ${openOnFieldClick}, hideOnOutsideClick: ${hideOnOutsideClick} (T1257945)`, function(assert) {
const dropDownOptions = hideOnOutsideClick === undefined ? {} : { hideOnOutsideClick };
const $form = $('#form').dxForm({
formData: { CustomerID: 'VINET' },
items: [{
Expand All @@ -4557,9 +4558,7 @@ QUnit.test('form should be dirty when some editors are dirty', function(assert)
items: ['VINET', 'VALUE', 'VINS'],
value: '',
openOnFieldClick,
dropDownOptions: {
hideOnOutsideClick,
}
dropDownOptions,
},
}],
}],
Expand All @@ -4577,44 +4576,11 @@ QUnit.test('form should be dirty when some editors are dirty', function(assert)

pointerMock($label).click();

const willHideByInput = openOnFieldClick || !hideOnOutsideClick;
const willHideByInput = openOnFieldClick || (hideOnOutsideClick === false);

assert.equal(editorInstance.option('opened'), willHideByInput, `drop down list is hidden by ${willHideByInput ? 'triggered input click' : 'label click'}`);
});
});

QUnit.test(`Opened DropDownList must hide on input label click, openOnFieldClick: ${openOnFieldClick}, hideOnOutsideClick not defined (T1257945)`, function(assert) {
const $form = $('#form').dxForm({
formData: { CustomerID: 'VINET' },
items: [{
itemType: 'group',
colCount: 2,
items: [{
dataField: 'CustomerID',
editorType: 'dxSelectBox',
editorOptions: {
items: ['VINET', 'VALUE', 'VINS'],
value: '',
openOnFieldClick,
},
}],
}],
});

const $dropDownButton = $form.find(`.${DROP_DOWN_EDITOR_BUTTON_CLASS}`);

pointerMock($dropDownButton).click();

const editorInstance = $form.dxForm('instance').getEditor('CustomerID');

assert.true(editorInstance.option('opened'), 'drop down list is visible');

const $label = $form.find(`.${FIELD_ITEM_LABEL_TEXT_CLASS}`);

pointerMock($label).click();

assert.equal(editorInstance.option('opened'), openOnFieldClick, `drop down list is hidden by ${openOnFieldClick ? 'triggered input click' : 'label click'}`);
});
});

QUnit.module('reset', () => {
Expand Down

0 comments on commit 1e392d2

Please sign in to comment.