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

Add missing tests on events for Popup and Overlay #11719

Merged
merged 1 commit into from
Jan 28, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions testing/tests/DevExpress.ui.widgets/overlay.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,23 @@ testModule('content', moduleConfig, () => {
assert.ok(newContentReadyStub.calledOnce);
});

test('content ready action should be fired if was set thought method', function(assert) {
const contentReadyStub = sinon.stub();
const instance = $('#overlay').dxOverlay({
onContentReady: contentReadyStub
}).dxOverlay('instance');

const newContentReadyStub = sinon.stub();
instance.on('contentReady', newContentReadyStub);

instance.show();
instance.hide();
instance.show();

assert.ok(contentReadyStub.calledOnce);
assert.ok(newContentReadyStub.calledOnce);
});

test('content should be rendered only once after repaint', function(assert) {
const contentReadyStub = sinon.stub();
const instance = $('#overlay').dxOverlay({
Expand Down
60 changes: 51 additions & 9 deletions testing/tests/DevExpress.ui.widgets/popup.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1217,16 +1217,16 @@ QUnit.module('resize', {
});

QUnit.test('resize callbacks', function(assert) {
let onResizeStartFired = 0;
let onResizeFired = 0;
let onResizeEndFired = 0;
const onResizeStartStub = sinon.stub();
const onResizeStub = sinon.stub();
const onResizeEndStub = sinon.stub();

const instance = $('#popup').dxPopup({
resizeEnabled: true,
visible: true,
onResizeStart: function() { onResizeStartFired++; },
onResize: function() { onResizeFired++; },
onResizeEnd: function() { onResizeEndFired++; }
onResizeStart: onResizeStartStub,
onResize: onResizeStub,
onResizeEnd: onResizeEndStub
}).dxPopup('instance');

const $content = instance.overlayContent();
Expand All @@ -1235,9 +1235,34 @@ QUnit.module('resize', {

pointer.start().dragStart().drag(0, 50).dragEnd();

assert.equal(onResizeStartFired, 1, 'onResizeStart fired');
assert.equal(onResizeFired, 1, 'onResize fired');
assert.equal(onResizeEndFired, 1, 'onResizeEnd fired');
assert.ok(onResizeStartStub.calledOnce, 'onResizeStart fired');
assert.ok(onResizeStub.calledOnce, 'onResize fired');
assert.ok(onResizeEndStub.calledOnce, 'onResizeEnd fired');
});

QUnit.test('resize event handlers should correctly added via "on" method', function(assert) {
const onResizeStartStub = sinon.stub();
const onResizeStub = sinon.stub();
const onResizeEndStub = sinon.stub();

const instance = $('#popup').dxPopup({
resizeEnabled: true
}).dxPopup('instance');

instance.on('resize', onResizeStub);
instance.on('resizeStart', onResizeStartStub);
instance.on('resizeEnd', onResizeEndStub);
instance.show();

const $content = instance.overlayContent();
const $handle = $content.find('.dx-resizable-handle-top');
const pointer = pointerMock($handle);

pointer.start().dragStart().drag(0, 50).dragEnd();

assert.ok(onResizeStartStub.calledOnce, 'onResizeStart fired');
assert.ok(onResizeStub.calledOnce, 'onResize fired');
assert.ok(onResizeEndStub.calledOnce, 'onResizeEnd fired');
});
});

Expand Down Expand Up @@ -1453,6 +1478,23 @@ QUnit.module('templates', () => {
assert.equal($popupContent.find(toSelector('changed-test-title-renderer')).length, 1, 'option \'titleTemplate\' successfully passed to the popup widget');
});

QUnit.test('titleRendered event should be fired if was set thought method', function(assert) {
assert.expect(1);

const $element = $('#popup').dxPopup({
visible: true,
showTitle: true
});
const instance = $element.dxPopup('instance');

instance.on('titleRendered', function(e) {
DokaRus marked this conversation as resolved.
Show resolved Hide resolved
assert.ok(true, 'titleRendered event handled');
});

instance.option('titleTemplate', () => $('<div>').text('new title'));
instance.show();
});

QUnit.test('\'bottomTemplate\' options test', function(assert) {
const $element = $('#popup').dxPopup({
visible: true,
Expand Down