Skip to content

Commit 849f0fa

Browse files
authored
QUnit: synchronized executeAsyncMock setups and terminates (#31442)
1 parent 8aaebc0 commit 849f0fa

File tree

9 files changed

+76
-26
lines changed

9 files changed

+76
-26
lines changed

.github/workflows/qunit_tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,19 @@ jobs:
110110
include:
111111
- CONSTEL: ui.scheduler(1/2)
112112
TIMEZONE: US/Pacific
113+
useJQuery: 'false'
113114
- CONSTEL: ui.scheduler(2/2)
114115
TIMEZONE: US/Pacific
116+
useJQuery: 'false'
115117
- CONSTEL: misc
116118
CSP: 'false'
117119
useJQuery: 'true'
118120
- CONSTEL: ui.widgets(1/2)
119121
CSP: 'false'
122+
useJQuery: 'false'
120123
- CONSTEL: ui.widgets(2/2)
121124
CSP: 'false'
125+
useJQuery: 'false'
122126

123127
steps:
124128
- name: Get sources

packages/devextreme/testing/tests/Bootstrap Integration/widget_bundled.tests.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ QUnit.testStart(function() {
1313
$('#qunit-fixture').html(markup);
1414
});
1515

16-
executeAsyncMock.setup();
17-
1816
const BOOTSTRAP_CSS_URL = window.ROOT_URL + 'packages/devextreme-themebuilder/node_modules/bootstrap/dist/css/bootstrap.css';
1917

2018
const applyBootstrap = (function() {

packages/devextreme/testing/tests/DevExpress.knockout/collectionWidget.tests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ class TestComponent extends CollectionWidget {
123123

124124
moduleWithoutCsp('render', {
125125
beforeEach: function() {
126+
executeAsyncMock.setup();
126127
this.element = $('#cmp');
127128
this.clock = sinon.useFakeTimers();
128129
},

packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/columnsController.tests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9334,6 +9334,7 @@ QUnit.module('Customization of the command columns', {
93349334
setupModule.apply(this, [['adaptivity']]);
93359335
},
93369336
afterEach: function() {
9337+
teardownModule.apply(this);
93379338
this.dispose && this.dispose();
93389339
}
93399340
}, function() {

packages/devextreme/testing/tests/DevExpress.ui.widgets/gallery.tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,6 @@ QUnit.module('options changed callbacks', {
11441144

11451145
},
11461146
afterEach() {
1147-
executeAsyncMock.teardown();
11481147
fx.off = false;
11491148
this.clock.restore();
11501149
}
@@ -1177,6 +1176,7 @@ QUnit.module('options changed callbacks', {
11771176
const store = new ArrayStore([11, 22]);
11781177
this.instance.option('dataSource', new DataSource(store));
11791178
assert.equal(getImageSources(this.$element), '1122');
1179+
executeAsyncMock.teardown();
11801180
});
11811181

11821182
QUnit.test('selectedIndex', function(assert) {

packages/devextreme/testing/tests/DevExpress.ui.widgets/popup.materialTheme.tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ QUnit.testStart(function() {
2727
$('#qunit-fixture').html(markup);
2828
});
2929

30-
executeAsyncMock.setup();
31-
3230
QUnit.module('popover content size', {
3331
beforeEach: function() {
3432
viewPort($('#qunit-fixture').addClass('dx-viewport'));
3533

3634
fx.off = true;
35+
executeAsyncMock.setup();
3736
},
3837
afterEach: function() {
3938
fx.off = false;
39+
executeAsyncMock.teardown();
4040
}
4141
}, () => {
4242
QUnit.test('popover content has correct size switch', function(assert) {

packages/devextreme/testing/tests/DevExpress.ui.widgets/popup.tests.js

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ QUnit.testStart(function() {
117117
$('#qunit-fixture').html(markup);
118118
});
119119

120-
executeAsyncMock.setup();
121-
122120
const POPUP_CLASS = 'dx-popup';
123121
const POPUP_WRAPPER_CLASS = 'dx-popup-wrapper';
124122
const POPUP_CONTENT_CLASS = 'dx-popup-content';
@@ -143,7 +141,14 @@ const VIEWPORT_CLASS = 'dx-viewport';
143141

144142
const viewport = function() { return $(`.${VIEWPORT_CLASS}`); };
145143

146-
QUnit.module('basic', () => {
144+
QUnit.module('basic', {
145+
beforeEach: function() {
146+
executeAsyncMock.setup();
147+
},
148+
afterEach: function() {
149+
executeAsyncMock.teardown();
150+
}
151+
}, () => {
147152
QUnit.test('markup init', function(assert) {
148153
const $element = $('#popup').dxPopup();
149154
assert.ok($element.hasClass(POPUP_CLASS));
@@ -649,9 +654,11 @@ QUnit.module('basic', () => {
649654
QUnit.module('dimensions', {
650655
beforeEach: function() {
651656
fx.off = true;
657+
executeAsyncMock.setup();
652658
},
653659
afterEach: function() {
654660
fx.off = false;
661+
executeAsyncMock.teardown();
655662
}
656663
}, () => {
657664
QUnit.test('content must not overlap bottom buttons', function(assert) {
@@ -931,12 +938,15 @@ QUnit.module('options changed callbacks', {
931938
};
932939
this.init();
933940

941+
executeAsyncMock.setup();
942+
934943
return new Promise((resolve) => themes.initialized(resolve));
935944
},
936945

937946
afterEach: function() {
938947
fx.off = false;
939948
this.clock.restore();
949+
executeAsyncMock.teardown();
940950
}
941951
}, () => {
942952
QUnit.test('width/height', function(assert) {
@@ -2084,6 +2094,11 @@ QUnit.module('drag', {
20842094
};
20852095

20862096
this.init();
2097+
2098+
executeAsyncMock.setup();
2099+
},
2100+
afterEach: function() {
2101+
executeAsyncMock.teardown();
20872102
}
20882103
}, () => {
20892104
QUnit.test('class should be added if drag is enabled', function(assert) {
@@ -2356,6 +2371,11 @@ QUnit.module('resize', {
23562371
};
23572372

23582373
this.init();
2374+
2375+
executeAsyncMock.setup();
2376+
},
2377+
afterEach: function() {
2378+
executeAsyncMock.teardown();
23592379
}
23602380
}, () => {
23612381
QUnit.test('popup should have resizable component on overlay content', function(assert) {
@@ -2565,6 +2585,10 @@ QUnit.module('keyboard navigation', {
25652585
this.position = this.$overlayContent.position();
25662586
this.keyboard = keyboardMock(this.$overlayContent);
25672587
};
2588+
executeAsyncMock.setup();
2589+
},
2590+
afterEach: function() {
2591+
executeAsyncMock.teardown();
25682592
}
25692593
}, () => {
25702594
QUnit.test('arrows handling', function(assert) {
@@ -2662,7 +2686,11 @@ QUnit.module('rendering', {
26622686
this.element = $('#popup').dxPopup();
26632687
this.instance = this.element.dxPopup('instance');
26642688
devices.current('desktop');
2689+
executeAsyncMock.setup();
26652690
return new Promise((resolve) => themes.initialized(resolve));
2691+
},
2692+
afterEach: function() {
2693+
executeAsyncMock.teardown();
26662694
}
26672695
}, () => {
26682696
QUnit.test('anonymous content template rendering', function(assert) {
@@ -2795,7 +2823,14 @@ QUnit.module('rendering', {
27952823
});
27962824
});
27972825

2798-
QUnit.module('templates', () => {
2826+
QUnit.module('templates', {
2827+
beforeEach: function() {
2828+
executeAsyncMock.setup();
2829+
},
2830+
afterEach: function() {
2831+
executeAsyncMock.teardown();
2832+
}
2833+
}, () => {
27992834
QUnit.test('titleTemplate', function(assert) {
28002835
assert.expect(6);
28012836

@@ -3026,6 +3061,10 @@ QUnit.module('renderGeometry', {
30263061

30273062
this.init();
30283063

3064+
executeAsyncMock.setup();
3065+
},
3066+
afterEach: function() {
3067+
executeAsyncMock.teardown();
30293068
}
30303069
}, () => {
30313070
QUnit.test('toolbar should update geometry after toolbarItems visibility option change', function(assert) {
@@ -3141,6 +3180,10 @@ QUnit.module('positioning', {
31413180
this.init(options);
31423181
};
31433182
this.init();
3183+
executeAsyncMock.setup();
3184+
},
3185+
afterEach: function() {
3186+
executeAsyncMock.teardown();
31443187
}
31453188
}, () => {
31463189
QUnit.module('after fullScreen option change', () => {
@@ -3525,9 +3568,11 @@ QUnit.module('animation', {
35253568
},
35263569
fullScreen: true,
35273570
}).dxPopup('instance');
3571+
executeAsyncMock.setup();
35283572
},
35293573
afterEach: function() {
35303574
this.animateStub.restore();
3575+
executeAsyncMock.teardown();
35313576
}
35323577
}, () => {
35333578
QUnit.test('animation.show.to should have position.of=window if fullScreen=true even if popup position.of is set', function(assert) {

packages/devextreme/testing/tests/DevExpress.ui.widgets/tabPanel.tests.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import fx from 'common/core/animation/fx';
22
import config from 'core/config';
3-
import devices from '__internal/core/m_devices';
43
import { deferUpdate } from 'core/utils/common';
54
import support from '__internal/core/utils/m_support';
65
import { isRenderer } from 'core/utils/type';
@@ -11,6 +10,7 @@ import keyboardMock from '../../helpers/keyboardMock.js';
1110
import pointerMock from '../../helpers/pointerMock.js';
1211
import registerKeyHandlerTestHelper from '../../helpers/registerKeyHandlerTestHelper.js';
1312
import translator from 'common/core/animation/translator';
13+
import { current as currentTheme } from 'ui/themes';
1414
import {
1515
TABPANEL_TABS_ITEM_CLASS,
1616
TABPANEL_CONTAINER_CLASS,
@@ -1118,37 +1118,38 @@ QUnit.module('keyboard navigation', {
11181118
assert.equal(tabsFocusedIndex, $(this.instance.option('focusedElement')).index(), 'multiView focused element is equal tabs focused element');
11191119
});
11201120

1121-
QUnit.skip('looping should work on keyboard navigation after loop runtime change to true and swipe', function(assert) {
1121+
QUnit.test('looping should work on keyboard navigation after loop runtime change to true and swipe', function(assert) {
11221122
this.instance.option({
11231123
items: [1, 2, 3],
11241124
loop: false,
11251125
swipeEnabled: true,
11261126
});
11271127
this.instance.option('loop', true);
11281128
const pointer = pointerMock(this.$element);
1129-
const keyDownEvent = $.Event('keydown', { key: 'ArrowRight' });
11301129

11311130
pointer.start().swipeStart().swipe(-0.5).swipeEnd(-1);
1132-
this.$element.trigger(keyDownEvent).trigger(keyDownEvent);
1131+
assert.strictEqual(this.instance.option('selectedIndex'), 1, 'at second element after swipe');
11331132

1133+
this.$element.trigger($.Event('keydown', { key: 'ArrowRight' }));
1134+
assert.strictEqual(this.instance.option('selectedIndex'), 2, 'at third element after first keydown');
1135+
1136+
this.$element.trigger($.Event('keydown', { key: 'ArrowRight' }));
11341137
assert.strictEqual(this.instance.option('selectedIndex'), 0, 'loop comes back to first element');
11351138
});
11361139

1137-
if(devices.current().deviceType === 'desktop') {
1138-
const createWidget = ($element) => {
1139-
const widget = $element.dxTabPanel({
1140-
focusStateEnabled: true,
1141-
items: [{ text: 'text' }]
1142-
}).dxTabPanel('instance');
1140+
const createWidget = ($element) => {
1141+
const widget = $element.dxTabPanel({
1142+
focusStateEnabled: true,
1143+
items: [{ text: 'text' }]
1144+
}).dxTabPanel('instance');
11431145

1144-
$element.attr('tabIndex', 1);
1146+
$element.attr('tabIndex', 1);
11451147

1146-
return widget;
1147-
};
1148+
return widget;
1149+
};
11481150

1149-
registerKeyHandlerTestHelper.runTests({ createWidget: createWidget, checkInitialize: false });
1150-
registerKeyHandlerTestHelper.runTests({ createWidget: createWidget, keyPressTargetElement: (widget) => widget._tabs.$element().eq(0), checkInitialize: false, testNamePrefix: 'Tabs: ' });
1151-
}
1151+
registerKeyHandlerTestHelper.runTests({ createWidget: createWidget, checkInitialize: false });
1152+
registerKeyHandlerTestHelper.runTests({ createWidget: createWidget, keyPressTargetElement: (widget) => widget._tabs.$element().eq(0), checkInitialize: false, testNamePrefix: 'Tabs: ' });
11521153
});
11531154

11541155
QUnit.module('Disabled items', {

packages/devextreme/testing/tests/DevExpress.ui/collectionWidget.tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ module('render', {
9696
this.clock = sinon.useFakeTimers();
9797
},
9898
afterEach: function() {
99-
executeAsyncMock.teardown();
10099
this.clock.restore();
101100
}
102101
}, () => {
@@ -538,6 +537,7 @@ module('render', {
538537
});
539538

540539
assert.equal(this.element.find('.' + EMPTY_MESSAGE_CLASS).length, 0);
540+
executeAsyncMock.teardown();
541541
});
542542

543543
test('No data text message - value', function(assert) {

0 commit comments

Comments
 (0)