Skip to content

Commit b832649

Browse files
Scheduler - Qunit tests - remove watchers of private methods (#32996)
1 parent f0c663d commit b832649

3 files changed

Lines changed: 22 additions & 24 deletions

File tree

packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/common.events.tests.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -671,12 +671,14 @@ QUnit.module('Events', {
671671
dataSource: [appointment]
672672
});
673673

674-
const workspaceSpy = sinon.spy(scheduler.instance._workSpace, '_dimensionChanged');
675-
const appointmentsSpy = sinon.spy(scheduler.instance._appointments, 'repaintAppointments');
674+
const $element = $(scheduler.instance.$element());
675+
const initialAppointmentWidth = $element.find('.dx-scheduler-appointment').outerWidth();
676676

677+
scheduler.instance.option('width', 400);
677678
resizeCallbacks.fire();
678679

679-
assert.ok(appointmentsSpy.calledAfter(workspaceSpy), 'workSpace dimension changing was called before appointments repainting');
680+
const updatedAppointmentWidth = $element.find('.dx-scheduler-appointment').outerWidth();
681+
assert.ok(updatedAppointmentWidth < initialAppointmentWidth, 'appointment width is recalculated after resize');
680682
});
681683

682684
QUnit.test('ContentReady event should be fired after render completely ready (T902483)', async function(assert) {

packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/common.options.tests.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -636,15 +636,16 @@ QUnit.module('Options', () => {
636636
view: 'timelineWeek',
637637
});
638638

639-
const spyAppointmentPopupForm = sinon.spy(
640-
scheduler.instance,
641-
'createAppointmentPopupForm'
642-
);
643-
644639
scheduler.instance.option('resources', resources);
645640
await waitAsync(10);
646641

647-
assert.ok(spyAppointmentPopupForm.calledOnce, 'Appointment form was recreated');
642+
scheduler.instance.showAppointmentPopup({
643+
startDate: new Date(2017, 11, 18, 10),
644+
endDate: new Date(2017, 11, 18, 11),
645+
}, true);
646+
647+
const resourceEditor = scheduler.appointmentForm.getEditor('TestResources');
648+
assert.ok(resourceEditor, 'Appointment form contains the resource editor after changing resources');
648649
});
649650

650651
QUnit.test('Filter options should be updated when dataSource is changed', async function(assert) {
@@ -935,16 +936,14 @@ QUnit.module('Options', () => {
935936
dataSource,
936937
});
937938

938-
const initMarkupSpy = sinon.spy(scheduler.instance, '_initMarkup');
939-
const reloadDataSourceSpy = sinon.spy(scheduler.instance, 'reloadDataSource');
940-
let count = 0;
939+
let loadCount = 0;
941940

942941
const nextDataSource = new DataSource({
943942
store: new CustomStore({
944943
load: function() {
945944
const d = $.Deferred();
946945
setTimeout(function() {
947-
count++;
946+
loadCount++;
948947
d.resolve([]);
949948
}, 100);
950949

@@ -959,10 +958,10 @@ QUnit.module('Options', () => {
959958
'views[2].intervalCount': 2,
960959
'views[2].startDate': new Date(),
961960
});
962-
await waitForAsync(() => count === 2);
961+
await waitForAsync(() => loadCount === 2);
962+
await waitAsync(200);
963963

964-
assert.equal(initMarkupSpy.callCount, 2, 'Init markup was called on each dataSource changes');
965-
assert.equal(reloadDataSourceSpy.callCount, 2, 'reloadDataSource was called on each changes');
964+
assert.equal(loadCount, 2, 'Data source load was called exactly twice — once per option change');
966965
});
967966

968967
QUnit.test('It should be possible to change views option when view names are specified (T995794)', async function(assert) {

packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.dateNavigator.tests.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -379,16 +379,13 @@ QUnit.module('Integration: Date navigator', moduleConfig, function() {
379379
});
380380

381381
QUnit.test('Tasks should be rerendered after click on next/prev button', async function(assert) {
382-
await this.createInstance({ currentDate: new Date(2015, 1, 24) });
382+
const initialDate = new Date(2015, 1, 24);
383+
await this.createInstance({ currentDate: initialDate });
383384

384-
const spy = sinon.spy(this.instance, 'setRemoteFilterIfNeeded');
385+
$(this.instance.$element()).find('.dx-scheduler-navigator-previous').trigger('dxclick');
385386

386-
try {
387-
$(this.instance.$element()).find('.dx-scheduler-navigator-previous').trigger('dxclick');
388-
assert.ok(spy.calledOnce, 'setRemoteFilterIfNeeded is called');
389-
} finally {
390-
this.instance.setRemoteFilterIfNeeded.restore();
391-
}
387+
const currentDate = this.instance.option('currentDate');
388+
assert.ok(currentDate < initialDate, 'currentDate changed to an earlier date after clicking previous');
392389
});
393390

394391
QUnit.test('Tasks should have correct position after click on next/prev button & calendar', async function(assert) {

0 commit comments

Comments
 (0)