mediawiki-extensions-Popups/tests/node-qunit/ui/settingsDialogRenderer.test.js
Nick Ray c64497e5df Upgrade elint-config-wikimedia (drop eslint-plugin-qunit)
The following upgrade was made:

eslint-config-wikimedia | 0.8.1 | 0.9.0

The upgrade of eslint-config-wikimedia removes the need of
eslint-plugin-qunit as a peerDependency because it is now a hard
dependency [1] so it was removed in our package.json.

It appears the biggest change in the upgrade was the use of separate
profiles [2]. Given this, our root .eslintrc.json was updated to extend
from 'wikimedia/client'.

Several test files were flagged by the upgraded linter and were fixed in
this patch. Additionally, our build file was flagged for having too many
statements on one line. This rule was turned off in .eslintrc.es5.json

[1] https://github.com/wikimedia/eslint-config-wikimedia/blob/master/package.json#L48
[2] https://github.com/wikimedia/eslint-config-wikimedia/blob/master/CHANGELOG.md#090--2018-11-19

Bug: T209314
Change-Id: I29db72e77f04a327bc9c2b558c6d53849287bb80
2018-12-13 14:12:06 -07:00

49 lines
1 KiB
JavaScript

import createSettingsDialogRenderer from '../../../src/ui/settingsDialogRenderer';
QUnit.module( 'ext.popups/settingsDialogRenderer', {
beforeEach() {
function render() {
return $( '<div>' );
}
function getTemplate() {
return { render };
}
mediaWiki.html = { escape: ( str ) => str };
mediaWiki.template = { get: getTemplate };
mediaWiki.config = { get() {} };
mediaWiki.msg = () => {};
},
afterEach() {
mediaWiki.msg = null;
mediaWiki.config = null;
mediaWiki.template = null;
mediaWiki.html = null;
}
} );
QUnit.test( '#render', ( assert ) => {
const boundActions = {
saveSettings() {},
hideSettings() {}
},
expected = {
appendTo() {},
show() {},
hide() {},
toggleHelp() {},
setEnabled() {}
},
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.