From fb4649d46952c662ff88766ef69cf28000eb1a50 Mon Sep 17 00:00:00 2001 From: joakin Date: Wed, 22 Feb 2017 11:22:58 +0100 Subject: [PATCH] Tests: Migrate settingsDialog.test.js to node qunit Additional changes: * Mock usage of global mw.{msg,template,config} Change-Id: I67e5cdd5bb275b9083eae0df80af2195c41a7f8e --- tests/node-qunit/settingsDialog.test.js | 42 +++++++++++++++++++ tests/qunit/ext.popups/settingsDialog.test.js | 28 ------------- 2 files changed, 42 insertions(+), 28 deletions(-) create mode 100644 tests/node-qunit/settingsDialog.test.js delete mode 100644 tests/qunit/ext.popups/settingsDialog.test.js diff --git a/tests/node-qunit/settingsDialog.test.js b/tests/node-qunit/settingsDialog.test.js new file mode 100644 index 000000000..93e773d81 --- /dev/null +++ b/tests/node-qunit/settingsDialog.test.js @@ -0,0 +1,42 @@ +var createSettingsDialogRenderer = require( '../../src/settingsDialog' ); + +QUnit.module( 'ext.popups/settingsDialog', { + beforeEach: function () { + function render() { return $( '
' ); } + 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. diff --git a/tests/qunit/ext.popups/settingsDialog.test.js b/tests/qunit/ext.popups/settingsDialog.test.js deleted file mode 100644 index db93a103d..000000000 --- a/tests/qunit/ext.popups/settingsDialog.test.js +++ /dev/null @@ -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 );