-/*global CompletenessTest, sinon */
+/* global sinon */
( function ( $, mw, QUnit ) {
'use strict';
- var mwTestIgnore, mwTester, addons;
+ var addons;
/**
* Add bogus to url to prevent IE crazy caching
QUnit.config.testTimeout = 60 * 1000;
// Reduce default animation duration from 400ms to 0ms for unit tests
+ // eslint-disable-next-line no-underscore-dangle
$.fx.speeds._default = 0;
// Add a checkbox to QUnit header to toggle MediaWiki ResourceLoader debug mode.
value: 'true'
} );
- /**
- * CompletenessTest
- *
- * Adds toggle checkbox to header
- */
- QUnit.config.urlConfig.push( {
- id: 'completenesstest',
- label: 'Run CompletenessTest',
- tooltip: 'Run the completeness test'
- } );
-
/**
* SinonJS
*
};
}() );
- // Initiate when enabled
- if ( QUnit.urlParams.completenesstest ) {
-
- // Return true to ignore
- mwTestIgnore = function ( val, tester ) {
-
- // Don't record methods of the properties of constructors,
- // to avoid getting into a loop (prototype.constructor.prototype..).
- // Since we're therefor skipping any injection for
- // "new mw.Foo()", manually set it to true here.
- if ( val instanceof mw.Map ) {
- tester.methodCallTracker.Map = true;
- return true;
- }
- if ( val instanceof mw.Title ) {
- tester.methodCallTracker.Title = true;
- return true;
- }
-
- // Don't record methods of the properties of a jQuery object
- if ( val instanceof $ ) {
- return true;
- }
-
- // Don't iterate over the module registry (the 'script' references would
- // be listed as untested methods otherwise)
- if ( val === mw.loader.moduleRegistry ) {
- return true;
- }
-
- return false;
- };
-
- mwTester = new CompletenessTest( mw, mwTestIgnore );
- }
-
/**
* Reset mw.config and others to a fresh copy of the live config for each test(),
* and restore it back to the live one afterwards.
}
function freshMessagesCopy( custom ) {
- return $.extend( /*deep=*/true, {}, liveMessages.get(), custom );
+ return $.extend( /* deep */true, {}, liveMessages.get(), custom );
}
/**
}
} ) );
- QUnit.test( 'Setup', 3, function ( assert ) {
+ QUnit.test( 'Setup', function ( assert ) {
assert.equal( mw.html.escape( 'foo' ), 'mocked', 'setup() callback was ran.' );
assert.equal( mw.config.get( 'testVar' ), 'foo', 'config object applied' );
assert.equal( mw.messages.get( 'testMsg' ), 'Foo.', 'messages object applied' );
mw.messages.set( 'testMsg', 'Bar.' );
} );
- QUnit.test( 'Teardown', 2, function ( assert ) {
+ QUnit.test( 'Teardown', function ( assert ) {
assert.equal( mw.config.get( 'testVar' ), 'foo', 'config object restored and re-applied after test()' );
assert.equal( mw.messages.get( 'testMsg' ), 'Foo.', 'messages object restored and re-applied after test()' );
} );
- QUnit.test( 'Loader status', 2, function ( assert ) {
+ QUnit.test( 'Loader status', function ( assert ) {
var i, len, state,
modules = mw.loader.getModuleNames(),
error = [],
assert.deepEqual( missing, [], 'Modules in missing state' );
} );
- QUnit.test( 'htmlEqual', 8, function ( assert ) {
+ QUnit.test( 'htmlEqual', function ( assert ) {
assert.htmlEqual(
'<div><p class="some classes" data-length="10">Child paragraph with <a href="http://example.com">A link</a></p>Regular text<span>A span</span></div>',
'<div><p data-length=\'10\' class=\'some classes\'>Child paragraph with <a href=\'http://example.com\' >A link</a></p>Regular text<span>A span</span></div>',
QUnit.module( 'test.mediawiki.qunit.testrunner-after', QUnit.newMwEnvironment() );
- QUnit.test( 'Teardown', 3, function ( assert ) {
+ QUnit.test( 'Teardown', function ( assert ) {
assert.equal( mw.html.escape( '<' ), '<', 'teardown() callback was ran.' );
assert.equal( mw.config.get( 'testVar' ), null, 'config object restored to live in next module()' );
assert.equal( mw.messages.get( 'testMsg' ), null, 'messages object restored to live in next module()' );