mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-24 07:34:11 +00:00
Tests: Migrate settingsDialog.test.js to node qunit
Additional changes: * Mock usage of global mw.{msg,template,config} Change-Id: I67e5cdd5bb275b9083eae0df80af2195c41a7f8e
This commit is contained in:
parent
4f71f6f740
commit
fb4649d469
42
tests/node-qunit/settingsDialog.test.js
Normal file
42
tests/node-qunit/settingsDialog.test.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
var createSettingsDialogRenderer = require( '../../src/settingsDialog' );
|
||||
|
||||
QUnit.module( 'ext.popups/settingsDialog', {
|
||||
beforeEach: function () {
|
||||
function render() { return $( '<div>' ); }
|
||||
function getTemplate() { return { render: render }; }
|
||||
|
||||
mediaWiki.template = { get: getTemplate };
|
||||
mediaWiki.config = { get: function () {} };
|
||||
mediaWiki.msg = function () {};
|
||||
},
|
||||
afterEach: function () {
|
||||
mediaWiki.config = null;
|
||||
mediaWiki.template = null;
|
||||
mediaWiki.msg = null;
|
||||
}
|
||||
} );
|
||||
|
||||
QUnit.test( '#render', function ( assert ) {
|
||||
var boundActions = {
|
||||
saveSettings: function () {},
|
||||
hideSettings: function () {}
|
||||
},
|
||||
expected = {
|
||||
appendTo: function () {},
|
||||
show: function () {},
|
||||
hide: function () {},
|
||||
toggleHelp: function () {},
|
||||
setEnabled: function () {}
|
||||
},
|
||||
result = createSettingsDialogRenderer()( boundActions );
|
||||
|
||||
// Specifically NOT a deep equal. Only structure.
|
||||
assert.propEqual(
|
||||
result,
|
||||
expected,
|
||||
'Interface exposed has the expected methods'
|
||||
);
|
||||
} );
|
||||
|
||||
// FIXME: Add Qunit integration tests about the rendering and the behavior of
|
||||
// the settings dialog.
|
|
@ -1,28 +0,0 @@
|
|||
( function ( $, mw ) {
|
||||
QUnit.module( 'ext.popups/settingsDialog' );
|
||||
|
||||
QUnit.test( '#render', function ( assert ) {
|
||||
var boundActions = {
|
||||
saveSettings: function () {},
|
||||
hideSettings: function () {}
|
||||
},
|
||||
expected = {
|
||||
appendTo: function () {},
|
||||
show: function () {},
|
||||
hide: function () {},
|
||||
toggleHelp: function () {},
|
||||
setEnabled: function () {}
|
||||
},
|
||||
result = mw.popups.createSettingsDialogRenderer()( boundActions );
|
||||
|
||||
// Specifically NOT a deep equal. Only structure.
|
||||
assert.propEqual(
|
||||
result,
|
||||
expected
|
||||
);
|
||||
} );
|
||||
|
||||
// FIXME: Add Qunit integration tests about the rendering and the behavior of
|
||||
// the settings dialog.
|
||||
|
||||
} )( jQuery, mediaWiki );
|
Loading…
Reference in a new issue