(bug 37390) Clean up QUnit test suites
authorTimo Tijhof <ttijhof@wikimedia.org>
Mon, 30 Jul 2012 23:46:50 +0000 (16:46 -0700)
committerTimo Tijhof <ttijhof@wikimedia.org>
Mon, 30 Jul 2012 23:46:50 +0000 (16:46 -0700)
* Use new QUnit 1.8.0+ pattern:
 - no-globals (only QUnit itself)
 - assert-object pattern
 - Remove pointless '-- Initial check' assertions.
   I introduced this pattern last year for no particular reason and
   everybody just copied it. There is no reason for it, it works fine
   without it. And the rest of the world that uses QUnit doesn't do
   it either. Exceptions are caught by QUnit and error handling there
   is much better than a dull '!ok()' assertion.

* .jshintrc:
 - Tolerate "mulistr" (this is used in many extensions, test suites
   as well as in MediaWiki core)
   "foo\
   bar"
 - Use "jquery: true" instead of "jQuery" so that JSHint can optimize
   for jQuery edge cases.

Misc issues fixed:
 * Trailing comma's in jquery.tablesorter.test
 * Missing semi-colon in testrunner.js
 * Remove backwards-compatible line for "equals()" and "same()".
   These have been deprecated in QUnit since 2009 (which is way
   before we even started looking at QUnit).
   Inside QUnit itself is a deprecation notice, I don't know why
   I added this compatibility line, it is stupid and overrides the
   nice deprecation-warning that QUnit has built in for it).
 * Use QUnit.push inside assertTrue and assertFalse.
   QUnit assertion methods must not call each other, in order to keep
   the call stack length as expected so that QUnit can report the
   file and line number of the caller of the assertion in case of
   failure etc.

Change-Id: I5cded6e8c32dba39170a02bdd3236c8b7b04d269

25 files changed:
.jshintrc
tests/qunit/data/qunitOkCall.js
tests/qunit/data/testrunner.js
tests/qunit/suites/resources/jquery/jquery.autoEllipsis.test.js
tests/qunit/suites/resources/jquery/jquery.byteLength.test.js
tests/qunit/suites/resources/jquery/jquery.byteLimit.test.js
tests/qunit/suites/resources/jquery/jquery.client.test.js
tests/qunit/suites/resources/jquery/jquery.colorUtil.test.js
tests/qunit/suites/resources/jquery/jquery.delayedBind.test.js
tests/qunit/suites/resources/jquery/jquery.getAttrs.test.js
tests/qunit/suites/resources/jquery/jquery.highlightText.test.js
tests/qunit/suites/resources/jquery/jquery.localize.test.js
tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js
tests/qunit/suites/resources/jquery/jquery.tabIndex.test.js
tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
tests/qunit/suites/resources/jquery/jquery.textSelection.test.js
tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js
tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.jscompat.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.user.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js

index 3c801c2..5fb1173 100644 (file)
--- a/.jshintrc
+++ b/.jshintrc
@@ -1,7 +1,7 @@
 {
        "predef": [
                "mediaWiki",
-               "jQuery",
+               "mw",
                "QUnit"
        ],
 
@@ -17,6 +17,8 @@
 
        "laxbreak": true,
        "smarttabs": true,
+       "multistr": true,
 
-       "browser": true
+       "browser": true,
+       "jquery": true
 }
index 2fb6e01..25c42d6 100644 (file)
@@ -1,2 +1,2 @@
-start();
-ok( true, 'Successfully loaded!');
+QUnit.start();
+QUnit.assert.ok( true, 'Successfully loaded!');
index 57b1acb..efa6549 100644 (file)
@@ -1,5 +1,7 @@
 ( function ( $, mw, QUnit, undefined ) {
-"use strict";
+/*global CompletenessTest */
+/*jshint evil:true */
+'use strict';
 
 var mwTestIgnore, mwTester, addons;
 
@@ -138,7 +140,7 @@ QUnit.newMwEnvironment = ( function () {
                                mw.config.values = freshConfigCopy( localEnv.config );
                                mw.messages.values = freshMessagesCopy( localEnv.messages );
 
-                               localEnv.setup()
+                               localEnv.setup();
                        },
 
                        teardown: function () {
@@ -181,12 +183,12 @@ addons = {
 
        // Expect boolean true
        assertTrue: function ( actual, message ) {
-               strictEqual( actual, true, message );
+               QUnit.push( actual === true, actual, true, message );
        },
 
        // Expect boolean false
        assertFalse: function ( actual, message ) {
-               strictEqual( actual, false, message );
+               QUnit.push( actual === false, actual, false, message );
        },
 
        // Expect numerical value less than X
@@ -207,22 +209,17 @@ addons = {
        // Expect numerical value greater than or equal to X
        gtOrEq: function ( actual, expected, message ) {
                QUnit.push( actual >= expected, actual, 'greater than or equal to ' + expected, message );
-       },
-
-       // Backwards compatible with new verions of QUnit
-       equals: window.equal,
-       same: window.deepEqual
+       }
 };
 
-$.extend( QUnit, addons );
-$.extend( window, addons );
+$.extend( QUnit.assert, addons );
 
 /**
  * Small test suite to confirm proper functionality of the utilities and
  * initializations in this file.
  */
 var envExecCount = 0;
-module( 'mediawiki.tests.qunit.testrunner', QUnit.newMwEnvironment({
+QUnit.module( 'mediawiki.tests.qunit.testrunner', QUnit.newMwEnvironment({
        setup: function () {
                envExecCount += 1;
                this.mwHtmlLive = mw.html;
@@ -243,33 +240,27 @@ module( 'mediawiki.tests.qunit.testrunner', QUnit.newMwEnvironment({
        }
 }) );
 
-test( 'Setup', function () {
-       expect( 3 );
-
-       equal( mw.html.escape( 'foo' ), 'mocked-1', 'extra setup() callback was ran.' );
-       equal( mw.config.get( 'testVar' ), 'foo', 'config object applied' );
-       equal( mw.messages.get( 'testMsg' ), 'Foo.', 'messages object applied' );
+QUnit.test( 'Setup', 3, function ( assert ) {
+       assert.equal( mw.html.escape( 'foo' ), 'mocked-1', 'extra 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.config.set( 'testVar', 'bar' );
        mw.messages.set( 'testMsg', 'Bar.' );
 });
 
-test( 'Teardown', function () {
-       expect( 3 );
-
-       equal( mw.html.escape( 'foo' ), 'mocked-2', 'extra setup() callback was re-ran.' );
-       equal( mw.config.get( 'testVar' ), 'foo', 'config object restored and re-applied after test()' );
-       equal( mw.messages.get( 'testMsg' ), 'Foo.', 'messages object restored and re-applied after test()' );
+QUnit.test( 'Teardown', 3, function ( assert ) {
+       assert.equal( mw.html.escape( 'foo' ), 'mocked-2', 'extra setup() callback was re-ran.' );
+       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()' );
 });
 
-module( 'mediawiki.tests.qunit.testrunner-after', QUnit.newMwEnvironment() );
-
-test( 'Teardown', function () {
-       expect( 3 );
+QUnit.module( 'mediawiki.tests.qunit.testrunner-after', QUnit.newMwEnvironment() );
 
-       equal( mw.html.escape( '<' ), '&lt;', 'extra teardown() callback was ran.' );
-       equal( mw.config.get( 'testVar' ), null, 'config object restored to live in next module()' );
-       equal( mw.messages.get( 'testMsg' ), null, 'messages object restored to live in next module()' );
+QUnit.test( 'Teardown', 3, function ( assert ) {
+       assert.equal( mw.html.escape( '<' ), '&lt;', 'extra 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()' );
 });
 
-})( jQuery, mediaWiki, QUnit );
+}( jQuery, mediaWiki, QUnit ) );
index 6e37138..0dee2ef 100644 (file)
@@ -1,9 +1,6 @@
-module( 'jquery.autoEllipsis', QUnit.newMwEnvironment() );
+( function ( mw, $ ) {
 
-test( '-- Initial check', function() {
-       expect(1);
-       ok( $.fn.autoEllipsis, 'jQuery.fn.autoEllipsis defined' );
-});
+QUnit.module( 'jquery.autoEllipsis', QUnit.newMwEnvironment() );
 
 function createWrappedDiv( text, width ) {
        var $wrapper = $( '<div>' ).css( 'width', width );
@@ -14,15 +11,13 @@ function createWrappedDiv( text, width ) {
 
 function findDivergenceIndex( a, b ) {
        var i = 0;
-       while ( i < a.length && i < b.length && a[i] == b[i] ) {
+       while ( i < a.length && i < b.length && a[i] === b[i] ) {
                i++;
        }
        return i;
 }
 
-test( 'Position right', function() {
-       expect(4);
-
+QUnit.test( 'Position right', 4, function ( assert ) {
        // We need this thing to be visible, so append it to the DOM
        var origText = 'This is a really long random string and there is no way it fits in 100 pixels.';
        var $wrapper = createWrappedDiv( origText, '100px' );
@@ -31,25 +26,27 @@ test( 'Position right', function() {
 
        // Verify that, and only one, span element was created
        var $span = $wrapper.find( '> span' );
-       strictEqual( $span.length, 1, 'autoEllipsis wrapped the contents in a span element' );
+       assert.strictEqual( $span.length, 1, 'autoEllipsis wrapped the contents in a span element' );
 
        // Check that the text fits by turning on word wrapping
        $span.css( 'whiteSpace', 'nowrap' );
-       ltOrEq( $span.width(), $span.parent().width(), "Text fits (making the span 'white-space:nowrap' does not make it wider than its parent)" );
+       assert.ltOrEq( $span.width(), $span.parent().width(), "Text fits (making the span 'white-space:nowrap' does not make it wider than its parent)" );
 
        // Add two characters using scary black magic
        var spanText = $span.text();
        var d = findDivergenceIndex( origText, spanText );
        var spanTextNew = spanText.substr( 0, d ) + origText[d] + origText[d] + '...';
 
-       gt( spanTextNew.length, spanText.length, 'Verify that the new span-length is indeed greater' );
+       assert.gt( spanTextNew.length, spanText.length, 'Verify that the new span-length is indeed greater' );
 
        // Put this text in the span and verify it doesn't fit
        $span.text( spanTextNew );
        // In IE6 width works like min-width, allow IE6's width to be "equal to"
        if ( $.browser.msie && Number( $.browser.version ) === 6 ) {
-               gtOrEq( $span.width(), $span.parent().width(), 'Fit is maximal (adding two characters makes it not fit any more) - IE6: Maybe equal to as well due to width behaving like min-width in IE6' );
+               assert.gtOrEq( $span.width(), $span.parent().width(), 'Fit is maximal (adding two characters makes it not fit any more) - IE6: Maybe equal to as well due to width behaving like min-width in IE6' );
        } else {
-               gt( $span.width(), $span.parent().width(), 'Fit is maximal (adding two characters makes it not fit any more)' );
+               assert.gt( $span.width(), $span.parent().width(), 'Fit is maximal (adding two characters makes it not fit any more)' );
        }
 });
+
+}( mediaWiki, jQuery ) );
index 15fac69..8d4ac03 100644 (file)
@@ -1,30 +1,21 @@
-module( 'jquery.byteLength', QUnit.newMwEnvironment() );
-
-test( '-- Initial check', function() {
-       expect(1);
-       ok( $.byteLength, 'jQuery.byteLength defined' );
-} );
-
-test( 'Simple text', function() {
-       expect(5);
+QUnit.module( 'jquery.byteLength', QUnit.newMwEnvironment() );
 
+QUnit.test( 'Simple text', 5, function ( assert ) {
        var     azLc = 'abcdefghijklmnopqrstuvwxyz',
                azUc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                num = '0123456789',
                x = '*',
                space = '   ';
 
-       equal( $.byteLength( azLc ), 26, 'Lowercase a-z' );
-       equal( $.byteLength( azUc ), 26, 'Uppercase A-Z' );
-       equal( $.byteLength( num ), 10, 'Numbers 0-9' );
-       equal( $.byteLength( x ), 1, 'An asterisk' );
-       equal( $.byteLength( space ), 3, '3 spaces' );
+       assert.equal( $.byteLength( azLc ), 26, 'Lowercase a-z' );
+       assert.equal( $.byteLength( azUc ), 26, 'Uppercase A-Z' );
+       assert.equal( $.byteLength( num ), 10, 'Numbers 0-9' );
+       assert.equal( $.byteLength( x ), 1, 'An asterisk' );
+       assert.equal( $.byteLength( space ), 3, '3 spaces' );
 
 } );
 
-test( 'Special text', window.foo = function() {
-       expect(5);
-
+QUnit.test( 'Special text', 5, function ( assert ) {
        // http://en.wikipedia.org/wiki/UTF-8
        var     U_0024 = '\u0024',
                U_00A2 = '\u00A2',
@@ -34,9 +25,9 @@ test( 'Special text', window.foo = function() {
                // according to http://www.fileformat.info/info/unicode/char/24B62/index.htm
                U_024B62_alt = '\uD852\uDF62';
 
-       strictEqual( $.byteLength( U_0024 ), 1, 'U+0024: 1 byte. \u0024 (dollar sign)' );
-       strictEqual( $.byteLength( U_00A2 ), 2, 'U+00A2: 2 bytes. \u00A2 (cent sign)' );
-       strictEqual( $.byteLength( U_20AC ), 3, 'U+20AC: 3 bytes. \u20AC (euro sign)' );
-       strictEqual( $.byteLength( U_024B62 ), 4, 'U+024B62: 4 bytes. \uD852\uDF62 (a Han character)' );
-       strictEqual( $.byteLength( U_024B62_alt ), 4, 'U+024B62: 4 bytes. \uD852\uDF62 (a Han character) - alternative method' );
+       assert.strictEqual( $.byteLength( U_0024 ), 1, 'U+0024: 1 byte. \u0024 (dollar sign)' );
+       assert.strictEqual( $.byteLength( U_00A2 ), 2, 'U+00A2: 2 bytes. \u00A2 (cent sign)' );
+       assert.strictEqual( $.byteLength( U_20AC ), 3, 'U+20AC: 3 bytes. \u20AC (euro sign)' );
+       assert.strictEqual( $.byteLength( U_024B62 ), 4, 'U+024B62: 4 bytes. \uD852\uDF62 (a Han character)' );
+       assert.strictEqual( $.byteLength( U_024B62_alt ), 4, 'U+024B62: 4 bytes. \uD852\uDF62 (a Han character) - alternative method' );
 } );
index 2cb94d1..23a93a7 100644 (file)
@@ -1,7 +1,7 @@
 ( function ( $ ) {
        var simpleSample, U_20AC, mbSample;
 
-       module( 'jquery.byteLimit', QUnit.newMwEnvironment() );
+       QUnit.module( 'jquery.byteLimit', QUnit.newMwEnvironment() );
 
        // Simple sample (20 chars, 20 bytes)
        simpleSample = '12345678901234567890';
@@ -54,7 +54,7 @@
                        limit: null
                }, options);
 
-               test( opt.description, function () {
+               QUnit.test( opt.description, function ( assert ) {
                        var rawVal, fn, newVal;
 
                        opt.$input.appendTo( '#qunit-fixture' );
                        newVal = $.isFunction( fn ) ? fn( rawVal ) : rawVal;
 
                        if ( opt.hasLimit ) {
-                               expect(3);
+                               QUnit.expect(3);
 
-                               QUnit.ltOrEq(
+                               assert.ltOrEq(
                                        $.byteLength( newVal ),
                                        opt.limit,
                                        'Prevent keypresses after byteLimit was reached, length never exceeded the limit'
                                );
-                               equal(
+                               assert.equal(
                                        $.byteLength( rawVal ),
                                        $.byteLength( opt.expected ),
                                        'Not preventing keypresses too early, length has reached the expected length'
                                );
-                               equal( rawVal, opt.expected, 'New value matches the expected string' );
+                               assert.equal( rawVal, opt.expected, 'New value matches the expected string' );
 
                        } else {
-                               expect(2);
-                               equal( newVal, opt.expected, 'New value matches the expected string' );
-                               equal(
+                               QUnit.expect(2);
+                               assert.equal( newVal, opt.expected, 'New value matches the expected string' );
+                               assert.equal(
                                        $.byteLength( newVal ),
                                        $.byteLength( opt.expected ),
                                        'Unlimited scenarios are not affected, expected length reached'
                } );
        }
 
-       test( '-- Initial check', function () {
-               expect(1);
-               ok( $.fn.byteLimit, 'jQuery.fn.byteLimit defined' );
-       } );
-
        byteLimitTest({
                description: 'Plain text input',
                $input: $( '<input>' )
                expected: 'User:Sample'
        });
 
-       test( 'Confirm properties and attributes set', function () {
+       QUnit.test( 'Confirm properties and attributes set', 5, function ( assert ) {
                var $el, $elA, $elB;
 
-               expect(5);
-
                $el = $( '<input>' )
                        .attr( 'type', 'text' )
                        .prop( 'maxLength', '7' )
                        .appendTo( '#qunit-fixture' )
                        .byteLimit();
 
-               strictEqual( $el.prop( 'maxLength' ), 7, 'Pre-set maxLength property unchanged' );
+               assert.strictEqual( $el.prop( 'maxLength' ), 7, 'Pre-set maxLength property unchanged' );
 
                $el = $( '<input>' )
                        .attr( 'type', 'text' )
                        .appendTo( '#qunit-fixture' )
                        .byteLimit( 12 );
 
-               strictEqual( $el.prop( 'maxLength' ), 12, 'maxLength property updated if value was passed to $.fn.byteLimit' );
+               assert.strictEqual( $el.prop( 'maxLength' ), 12, 'maxLength property updated if value was passed to $.fn.byteLimit' );
 
                $elA = $( '<input>' )
                        .addClass( 'mw-test-byteLimit-foo' )
 
                $el = $( '.mw-test-byteLimit-foo' );
 
-               strictEqual( $el.length, 2, 'Verify that there are no other elements clashing with this test suite' );
+               assert.strictEqual( $el.length, 2, 'Verify that there are no other elements clashing with this test suite' );
 
                $el.byteLimit();
 
                // because $.fn.byteLimit sets:
                // `limit = limitArg || this.prop( 'maxLength' ); this.prop( 'maxLength', limit )`
                // and did so outside the each() loop.
-               strictEqual( $elA.prop( 'maxLength' ), 7, 'maxLength was not incorrectly set on #1 when calling byteLimit on multiple elements (bug 35294)' );
-               strictEqual( $elB.prop( 'maxLength' ), 12, 'maxLength was not incorrectly set on #2 when calling byteLimit on multiple elements (bug 35294)' );
+               assert.strictEqual( $elA.prop( 'maxLength' ), 7, 'maxLength was not incorrectly set on #1 when calling byteLimit on multiple elements (bug 35294)' );
+               assert.strictEqual( $elB.prop( 'maxLength' ), 12, 'maxLength was not incorrectly set on #2 when calling byteLimit on multiple elements (bug 35294)' );
        });
 
 }( jQuery ) );
index 2c0b8e3..bf62b39 100644 (file)
@@ -1,14 +1,9 @@
-module( 'jquery.client', QUnit.newMwEnvironment() );
-
-test( '-- Initial check', function() {
-       expect(1);
-       ok( jQuery.client, 'jQuery.client defined' );
-});
+QUnit.module( 'jquery.client', QUnit.newMwEnvironment() );
 
 /** Number of user-agent defined */
 var uacount = 0;
 
-var uas = (function() {
+var uas = (function () {
 
        // Object keyed by userAgent. Value is an array (human-readable name, client-profile object, navigator.platform value)
        // Info based on results from http://toolserver.org/~krinkle/testswarm/job/174/
@@ -225,40 +220,39 @@ var uas = (function() {
                        }
                }
        };
-       $.each( uas, function() { uacount++ });
+       $.each( uas, function () {
+               uacount++;
+       });
        return uas;
-})();
-
-test( 'profile userAgent support', function() {
-       expect(uacount);
+}());
 
+QUnit.test( 'profile userAgent support', uacount, function ( assert ) {
        // Generate a client profile object and compare recursively
        var uaTest = function( rawUserAgent, data ) {
                var ret = $.client.profile( {
                        userAgent: rawUserAgent,
                        platform: data.platform
                } );
-               deepEqual( ret, data.profile, 'Client profile support check for ' + data.title + ' (' + data.platform + '): ' + rawUserAgent );
+               assert.deepEqual( ret, data.profile, 'Client profile support check for ' + data.title + ' (' + data.platform + '): ' + rawUserAgent );
        };
 
        // Loop through and run tests
        $.each( uas, uaTest );
 } );
 
-test( 'profile return validation for current user agent', function() {
-       expect(7);
+QUnit.test( 'profile return validation for current user agent', 7, function ( assert ) {
        var p = $.client.profile();
-       var unknownOrType = function( val, type, summary ) {
-               return ok( typeof val === type || val === 'unknown', summary );
-       };
+       function unknownOrType( val, type, summary ) {
+               assert.ok( typeof val === type || val === 'unknown', summary );
+       }
 
-       equal( typeof p, 'object', 'profile returns an object' );
+       assert.equal( typeof p, 'object', 'profile returns an object' );
        unknownOrType( p.layout, 'string', 'p.layout is a string (or "unknown")' );
        unknownOrType( p.layoutVersion, 'number', 'p.layoutVersion is a number (or "unknown")' );
        unknownOrType( p.platform, 'string', 'p.platform is a string (or "unknown")' );
        unknownOrType( p.version, 'string', 'p.version is a string (or "unknown")' );
        unknownOrType( p.versionBase, 'string', 'p.versionBase is a string (or "unknown")' );
-       equal( typeof p.versionNumber, 'number', 'p.versionNumber is a number' );
+       assert.equal( typeof p.versionNumber, 'number', 'p.versionNumber is a number' );
 });
 
 // Example from WikiEditor
@@ -289,20 +283,16 @@ var testMap = {
        }
 };
 
-test( 'test', function() {
-       expect(1);
-
+QUnit.test( 'test', 1, function ( assert ) {
        // .test() uses eval, make sure no exceptions are thrown
        // then do a basic return value type check
        var testMatch = $.client.test( testMap );
 
-       equal( typeof testMatch, 'boolean', 'test returns a boolean value' );
+       assert.equal( typeof testMatch, 'boolean', 'test returns a boolean value' );
 
 });
 
-test( 'User-agent matches against WikiEditor\'s compatibility map', function() {
-       expect( uacount * 2 ); // double since we test both LTR and RTL
-
+QUnit.test( 'User-agent matches against WikiEditor\'s compatibility map', uacount * 2, function ( assert ) {
        var     $body = $( 'body' ),
                bodyClasses = $body.attr( 'class' );
 
@@ -317,7 +307,7 @@ test( 'User-agent matches against WikiEditor\'s compatibility map', function() {
                        var testMatch = $.client.test( testMap, profile );
                        $body.removeClass( dir );
 
-                       equal( testMatch, data.wikiEditor[dir], 'testing comparison based on ' + dir + ', ' + agent );
+                       assert.equal( testMatch, data.wikiEditor[dir], 'testing comparison based on ' + dir + ', ' + agent );
                });
        });
 
index 655ee56..7b37f5a 100644 (file)
@@ -1,40 +1,31 @@
-module( 'jquery.colorUtil', QUnit.newMwEnvironment() );
-
-test( '-- Initial check', function() {
-       expect(1);
-       ok( $.colorUtil, '$.colorUtil defined' );
-});
-
-test( 'getRGB', function() {
-       expect(18);
-
-       strictEqual( $.colorUtil.getRGB(), undefined, 'No arguments' );
-       strictEqual( $.colorUtil.getRGB( '' ), undefined, 'Empty string' );
-       deepEqual( $.colorUtil.getRGB( [0, 100, 255] ), [0, 100, 255], 'Parse array of rgb values' );
-       deepEqual( $.colorUtil.getRGB( 'rgb(0,100,255)' ), [0, 100, 255], 'Parse simple rgb string' );
-       deepEqual( $.colorUtil.getRGB( 'rgb(0, 100, 255)' ), [0, 100, 255], 'Parse simple rgb string with spaces' );
-       deepEqual( $.colorUtil.getRGB( 'rgb(0%,20%,40%)' ), [0, 51, 102], 'Parse rgb string with percentages' );
-       deepEqual( $.colorUtil.getRGB( 'rgb(0%, 20%, 40%)' ), [0, 51, 102], 'Parse rgb string with percentages and spaces' );
-       deepEqual( $.colorUtil.getRGB( '#f2ddee' ), [242, 221, 238], 'Hex string: 6 char lowercase' );
-       deepEqual( $.colorUtil.getRGB( '#f2DDEE' ), [242, 221, 238], 'Hex string: 6 char uppercase' );
-       deepEqual( $.colorUtil.getRGB( '#f2DdEe' ), [242, 221, 238], 'Hex string: 6 char mixed' );
-       deepEqual( $.colorUtil.getRGB( '#eee' ), [238, 238, 238], 'Hex string: 3 char lowercase' );
-       deepEqual( $.colorUtil.getRGB( '#EEE' ), [238, 238, 238], 'Hex string: 3 char uppercase' );
-       deepEqual( $.colorUtil.getRGB( '#eEe' ), [238, 238, 238], 'Hex string: 3 char mixed' );
-       deepEqual( $.colorUtil.getRGB( 'rgba(0, 0, 0, 0)' ), [255, 255, 255], 'Zero rgba for Safari 3; Transparent (whitespace)' );
+QUnit.module( 'jquery.colorUtil', QUnit.newMwEnvironment() );
+
+QUnit.test( 'getRGB', 18, function ( assert ) {
+       assert.strictEqual( $.colorUtil.getRGB(), undefined, 'No arguments' );
+       assert.strictEqual( $.colorUtil.getRGB( '' ), undefined, 'Empty string' );
+       assert.deepEqual( $.colorUtil.getRGB( [0, 100, 255] ), [0, 100, 255], 'Parse array of rgb values' );
+       assert.deepEqual( $.colorUtil.getRGB( 'rgb(0,100,255)' ), [0, 100, 255], 'Parse simple rgb string' );
+       assert.deepEqual( $.colorUtil.getRGB( 'rgb(0, 100, 255)' ), [0, 100, 255], 'Parse simple rgb string with spaces' );
+       assert.deepEqual( $.colorUtil.getRGB( 'rgb(0%,20%,40%)' ), [0, 51, 102], 'Parse rgb string with percentages' );
+       assert.deepEqual( $.colorUtil.getRGB( 'rgb(0%, 20%, 40%)' ), [0, 51, 102], 'Parse rgb string with percentages and spaces' );
+       assert.deepEqual( $.colorUtil.getRGB( '#f2ddee' ), [242, 221, 238], 'Hex string: 6 char lowercase' );
+       assert.deepEqual( $.colorUtil.getRGB( '#f2DDEE' ), [242, 221, 238], 'Hex string: 6 char uppercase' );
+       assert.deepEqual( $.colorUtil.getRGB( '#f2DdEe' ), [242, 221, 238], 'Hex string: 6 char mixed' );
+       assert.deepEqual( $.colorUtil.getRGB( '#eee' ), [238, 238, 238], 'Hex string: 3 char lowercase' );
+       assert.deepEqual( $.colorUtil.getRGB( '#EEE' ), [238, 238, 238], 'Hex string: 3 char uppercase' );
+       assert.deepEqual( $.colorUtil.getRGB( '#eEe' ), [238, 238, 238], 'Hex string: 3 char mixed' );
+       assert.deepEqual( $.colorUtil.getRGB( 'rgba(0, 0, 0, 0)' ), [255, 255, 255], 'Zero rgba for Safari 3; Transparent (whitespace)' );
 
        // Perhaps this is a bug in colorUtil, but it is the current behaviour so, let's keep
        // track of it, so we will know in case it would ever change.
-       strictEqual( $.colorUtil.getRGB( 'rgba(0,0,0,0)' ), undefined, 'Zero rgba without whitespace' );
+       assert.strictEqual( $.colorUtil.getRGB( 'rgba(0,0,0,0)' ), undefined, 'Zero rgba without whitespace' );
 
-       deepEqual( $.colorUtil.getRGB( 'lightGreen' ), [144, 238, 144], 'Color names (lightGreen)' );
-       deepEqual( $.colorUtil.getRGB( 'transparent' ), [255, 255, 255], 'Color names (transparent)' );
-       strictEqual( $.colorUtil.getRGB( 'mediaWiki' ), undefined, 'Inexisting color name' );
+       assert.deepEqual( $.colorUtil.getRGB( 'lightGreen' ), [144, 238, 144], 'Color names (lightGreen)' );
+       assert.deepEqual( $.colorUtil.getRGB( 'transparent' ), [255, 255, 255], 'Color names (transparent)' );
+       assert.strictEqual( $.colorUtil.getRGB( 'mediaWiki' ), undefined, 'Inexisting color name' );
 });
 
-test( 'rgbToHsl', function() {
-       expect(1);
-
+QUnit.test( 'rgbToHsl', 1, function ( assert ) {
        var hsl = $.colorUtil.rgbToHsl( 144, 238, 144 );
 
        // Cross-browser differences in decimals...
@@ -45,27 +36,23 @@ test( 'rgbToHsl', function() {
        // Re-create the rgbToHsl return array items, limited to two decimals.
        var ret = [dualDecimals(hsl[0]), dualDecimals(hsl[1]), dualDecimals(hsl[2])];
 
-       deepEqual( ret, [0.33, 0.73, 0.75], 'rgb(144, 238, 144): hsl(0.33, 0.73, 0.75)' );
+       assert.deepEqual( ret, [0.33, 0.73, 0.75], 'rgb(144, 238, 144): hsl(0.33, 0.73, 0.75)' );
 });
 
-test( 'hslToRgb', function() {
-       expect(1);
-
+QUnit.test( 'hslToRgb', 1, function ( assert ) {
        var rgb = $.colorUtil.hslToRgb( 0.3, 0.7, 0.8 );
 
        // Cross-browser differences in decimals...
        // Re-create the hslToRgb return array items, rounded to whole numbers.
        var ret = [Math.round(rgb[0]), Math.round(rgb[1]), Math.round(rgb[2])];
 
-       deepEqual( ret ,[183, 240, 168], 'hsl(0.3, 0.7, 0.8): rgb(183, 240, 168)' );
+       assert.deepEqual( ret ,[183, 240, 168], 'hsl(0.3, 0.7, 0.8): rgb(183, 240, 168)' );
 });
 
-test( 'getColorBrightness', function() {
-       expect(2);
-
+QUnit.test( 'getColorBrightness', 2, function ( assert ) {
        var a = $.colorUtil.getColorBrightness( 'red', +0.1 );
-       equal( a, 'rgb(255,50,50)', 'Start with named color "red", brighten 10%' );
+       assert.equal( a, 'rgb(255,50,50)', 'Start with named color "red", brighten 10%' );
 
        var b = $.colorUtil.getColorBrightness( 'rgb(200,50,50)', -0.2 );
-       equal( b, 'rgb(118,29,29)', 'Start with rgb string "rgb(200,50,50)", darken 20%' );
+       assert.equal( b, 'rgb(118,29,29)', 'Start with rgb string "rgb(200,50,50)", darken 20%' );
 });
index 6489a1f..a307983 100644 (file)
@@ -1,41 +1,35 @@
-test('jquery.delayedBind with data option', function() {
+QUnit.asyncTest('jquery.delayedBind with data option', 2, function ( assert ) {
        var $fixture = $('<div>').appendTo('#qunit-fixture'),
                data = { magic: "beeswax" },
                delay = 50;
 
-       $fixture.delayedBind(delay, 'testevent', data, function(event) {
-               start(); // continue!
-               ok(true, 'testevent fired');
-               ok(event.data === data, 'data is passed through delayedBind');
+       $fixture.delayedBind(delay, 'testevent', data, function ( e ) {
+               QUnit.start(); // continue!
+               assert.ok( true, 'testevent fired');
+               assert.ok( e.data === data, 'data is passed through delayedBind');
        });
 
-       expect(2);
-       stop(); // async!
-
        // We'll trigger it thrice, but it should only happen once.
-       $fixture.trigger('testevent', {});
-       $fixture.trigger('testevent', {});
-       $fixture.trigger('testevent', {});
-       $fixture.trigger('testevent', {});
+       $fixture.trigger( 'testevent', {} );
+       $fixture.trigger( 'testevent', {} );
+       $fixture.trigger( 'testevent', {} );
+       $fixture.trigger( 'testevent', {} );
 });
 
-test('jquery.delayedBind without data option', function() {
+QUnit.asyncTest('jquery.delayedBind without data option', 1, function ( assert ) {
        var $fixture = $('<div>').appendTo('#qunit-fixture'),
                data = { magic: "beeswax" },
                delay = 50;
 
-       $fixture.delayedBind(delay, 'testevent', function(event) {
-               start(); // continue!
-               ok(true, 'testevent fired');
+       $fixture.delayedBind(delay, 'testevent', function ( e ) {
+               QUnit.start(); // continue!
+               assert.ok(true, 'testevent fired');
        });
 
-       expect(1);
-       stop(); // async!
-
        // We'll trigger it thrice, but it should only happen once.
-       $fixture.trigger('testevent', {});
-       $fixture.trigger('testevent', {});
-       $fixture.trigger('testevent', {});
-       $fixture.trigger('testevent', {});
+       $fixture.trigger( 'testevent', {} );
+       $fixture.trigger( 'testevent', {} );
+       $fixture.trigger( 'testevent', {} );
+       $fixture.trigger( 'testevent', {} );
 });
 
index 9377a2f..6eef1ab 100644 (file)
@@ -1,17 +1,11 @@
-module( 'jquery.getAttrs', QUnit.newMwEnvironment() );
+QUnit.module( 'jquery.getAttrs', QUnit.newMwEnvironment() );
 
-test( '-- Initial check', function() {
-       expect(1);
-       ok( $.fn.getAttrs, 'jQuery.fn.getAttrs defined' );
-} );
-
-test( 'Check', function() {
-       expect(1);
+QUnit.test( 'Check', 1, function ( assert ) {
        var     attrs = {
                        foo: 'bar',
                        'class': 'lorem'
                },
-               $el = $( '<div>', attrs );
+               $el = jQuery( '<div>', attrs );
 
-       deepEqual( $el.getAttrs(), attrs, 'getAttrs() return object should match the attributes set, no more, no less' );
+       assert.deepEqual( $el.getAttrs(), attrs, 'getAttrs() return object should match the attributes set, no more, no less' );
 } );
index 4750d2b..a94dca3 100644 (file)
@@ -1,12 +1,7 @@
-module( 'jquery.highlightText', QUnit.newMwEnvironment() );
+QUnit.module( 'jquery.highlightText', QUnit.newMwEnvironment() );
 
-test( '-- Initial check', function() {
-       expect(1);
-       ok( $.fn.highlightText, 'jQuery.fn.highlightText defined' );
-} );
-
-test( 'Check', function() {
-       var cases = [
+QUnit.test( 'Check', function ( assert ) {
+       var $fixture, cases = [
                {
                        desc: 'Test 001',
                        text: 'Blue Öyster Cult',
@@ -224,16 +219,14 @@ test( 'Check', function() {
                        expected: '<span class="highlight">بو</span>ل إيردوس'
                }
        ];
-       expect(cases.length);
-       var $fixture;
+       QUnit.expect( cases.length );
 
-       $.each(cases, function( i, item ) {
-               $fixture = $( '<p></p>' ).text( item.text );
-               $fixture.highlightText( item.highlight );
-               equals(
+       $.each( cases, function ( i, item ) {
+               $fixture = $( '<p>' ).text( item.text ).highlightText( item.highlight );
+               assert.equal(
                        $fixture.html(),
-                       $('<p>' + item.expected + '</p>').html(), // re-parse to normalize!
+                       $( '<p>' ).html( item.expected ).html(), // re-parse to normalize!
                        item.desc || undefined
-                       );
+               );
        } );
 } );
index cd82863..1b38010 100644 (file)
@@ -1,13 +1,6 @@
-module( 'jquery.localize', QUnit.newMwEnvironment() );
-
-test( '-- Initial check', function() {
-       expect(1);
-       ok( $.fn.localize, 'jQuery.fn.localize defined' );
-} );
-
-test( 'Handle basic replacements', function() {
-       expect(3);
+QUnit.module( 'jquery.localize', QUnit.newMwEnvironment() );
 
+QUnit.test( 'Handle basic replacements', 3, function ( assert ) {
        var html, $lc;
        mw.messages.set( 'basic', 'Basic stuff' );
 
@@ -15,24 +8,22 @@ test( 'Handle basic replacements', function() {
        html = '<div><span><html:msg key="basic" /></span></div>';
        $lc = $( html ).localize().find( 'span' );
 
-       strictEqual( $lc.text(), 'Basic stuff', 'Tag: html:msg' );
+       assert.strictEqual( $lc.text(), 'Basic stuff', 'Tag: html:msg' );
 
        // Attribute: title-msg
        html = '<div><span title-msg="basic" /></span></div>';
        $lc = $( html ).localize().find( 'span' );
 
-       strictEqual( $lc.attr( 'title' ), 'Basic stuff', 'Attribute: title-msg' );
+       assert.strictEqual( $lc.attr( 'title' ), 'Basic stuff', 'Attribute: title-msg' );
 
        // Attribute: alt-msg
        html = '<div><span alt-msg="basic" /></span></div>';
        $lc = $( html ).localize().find( 'span' );
 
-       strictEqual( $lc.attr( 'alt' ), 'Basic stuff', 'Attribute: alt-msg' );
+       assert.strictEqual( $lc.attr( 'alt' ), 'Basic stuff', 'Attribute: alt-msg' );
 } );
 
-test( 'Proper escaping', function() {
-       expect(2);
-
+QUnit.test( 'Proper escaping', 2, function ( assert ) {
        var html, $lc;
        mw.messages.set( 'properfoo', '<proper esc="test">' );
 
@@ -43,18 +34,16 @@ test( 'Proper escaping', function() {
        html = '<div><span><html:msg key="properfoo" /></span></div>';
        $lc = $( html ).localize().find( 'span' );
 
-       strictEqual( $lc.text(), mw.msg( 'properfoo' ), 'Content is inserted as text, not as html.' );
+       assert.strictEqual( $lc.text(), mw.msg( 'properfoo' ), 'Content is inserted as text, not as html.' );
 
        // Attribute escaping
        html = '<div><span title-msg="properfoo" /></span></div>';
        $lc = $( html ).localize().find( 'span' );
 
-       strictEqual( $lc.attr( 'title' ), mw.msg( 'properfoo' ), 'Attributes are not inserted raw.' );
+       assert.strictEqual( $lc.attr( 'title' ), mw.msg( 'properfoo' ), 'Attributes are not inserted raw.' );
 } );
 
-test( 'Options', function() {
-       expect(7);
-
+QUnit.test( 'Options', 7, function ( assert ) {
        mw.messages.set( {
                'foo-lorem': 'Lorem',
                'foo-ipsum': 'Ipsum',
@@ -72,8 +61,8 @@ test( 'Options', function() {
                prefix: 'foo-'
        } ).find( 'span' );
 
-       strictEqual( $lc.attr( 'title' ), 'Lorem', 'Message key prefix - attr' );
-       strictEqual( $lc.text(), 'Ipsum', 'Message key prefix - text' );
+       assert.strictEqual( $lc.attr( 'title' ), 'Lorem', 'Message key prefix - attr' );
+       assert.strictEqual( $lc.text(), 'Ipsum', 'Message key prefix - text' );
 
        // Variable keys mapping
        x = 'bar';
@@ -85,8 +74,8 @@ test( 'Options', function() {
                }
        } ).find( 'span' );
 
-       strictEqual( $lc.attr( 'title' ), 'Read more about bars', 'Variable keys mapping - attr' );
-       strictEqual( $lc.text(), 'The Bars', 'Variable keys mapping - text' );
+       assert.strictEqual( $lc.attr( 'title' ), 'Read more about bars', 'Variable keys mapping - attr' );
+       assert.strictEqual( $lc.text(), 'The Bars', 'Variable keys mapping - text' );
 
        // Passing parameteters to mw.msg
        html = '<div><span><html:msg key="foo-welcome" /></span></div>';
@@ -96,7 +85,7 @@ test( 'Options', function() {
                }
        } ).find( 'span' );
 
-       strictEqual( $lc.text(), 'Welcome to Wikipedia! (last visit: yesterday)', 'Passing parameteters to mw.msg' );
+       assert.strictEqual( $lc.text(), 'Welcome to Wikipedia! (last visit: yesterday)', 'Passing parameteters to mw.msg' );
 
        // Combination of options prefix, params and keys
        x = 'bazz';
@@ -114,6 +103,6 @@ test( 'Options', function() {
                }
        } ).find( 'span' );
 
-       strictEqual( $lc.text(), 'The Bazz (Wikipedia)', 'Combination of options prefix, params and keys - text' );
-       strictEqual( $lc.attr( 'title' ), 'Read more about bazz at Wikipedia (last modified: 3 minutes ago)', 'Combination of options prefix, params and keys - attr' );
+       assert.strictEqual( $lc.text(), 'The Bazz (Wikipedia)', 'Combination of options prefix, params and keys - text' );
+       assert.strictEqual( $lc.attr( 'title' ), 'Read more about bazz at Wikipedia (last modified: 3 minutes ago)', 'Combination of options prefix, params and keys - attr' );
 } );
index 3a2d0d8..5b566ae 100644 (file)
@@ -1,58 +1,58 @@
-module( 'jquery.mwExtension', QUnit.newMwEnvironment() );
+QUnit.module( 'jquery.mwExtension', QUnit.newMwEnvironment() );
 
-test( 'String functions', function() {
+QUnit.test( 'String functions', function ( assert ) {
 
-       equal( $.trimLeft( '  foo bar  ' ), 'foo bar  ', 'trimLeft' );
-       equal( $.trimRight( '  foo bar  ' ), '  foo bar', 'trimRight' );
-       equal( $.ucFirst( 'foo' ), 'Foo', 'ucFirst' );
+       assert.equal( $.trimLeft( '  foo bar  ' ), 'foo bar  ', 'trimLeft' );
+       assert.equal( $.trimRight( '  foo bar  ' ), '  foo bar', 'trimRight' );
+       assert.equal( $.ucFirst( 'foo' ), 'Foo', 'ucFirst' );
 
-       equal( $.escapeRE( '<!-- ([{+mW+}]) $^|?>' ),
+       assert.equal( $.escapeRE( '<!-- ([{+mW+}]) $^|?>' ),
         '<!\\-\\- \\(\\[\\{\\+mW\\+\\}\\]\\) \\$\\^\\|\\?>', 'escapeRE - Escape specials' );
-       equal( $.escapeRE( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ),
+       assert.equal( $.escapeRE( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ),
         'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'escapeRE - Leave uppercase alone' );
-       equal( $.escapeRE( 'abcdefghijklmnopqrstuvwxyz' ),
+       assert.equal( $.escapeRE( 'abcdefghijklmnopqrstuvwxyz' ),
         'abcdefghijklmnopqrstuvwxyz', 'escapeRE - Leave lowercase alone' );
-       equal( $.escapeRE( '0123456789' ), '0123456789', 'escapeRE - Leave numbers alone' );
+       assert.equal( $.escapeRE( '0123456789' ), '0123456789', 'escapeRE - Leave numbers alone' );
 });
 
-test( 'Is functions', function() {
+QUnit.test( 'Is functions', function ( assert ) {
 
-       strictEqual( $.isDomElement( document.getElementById( 'qunit-header' ) ), true,
+       assert.strictEqual( $.isDomElement( document.getElementById( 'qunit-header' ) ), true,
         'isDomElement: #qunit-header Node' );
-       strictEqual( $.isDomElement( document.getElementById( 'random-name' ) ), false,
+       assert.strictEqual( $.isDomElement( document.getElementById( 'random-name' ) ), false,
         'isDomElement: #random-name (null)' );
-       strictEqual( $.isDomElement( document.getElementsByTagName( 'div' ) ), false,
+       assert.strictEqual( $.isDomElement( document.getElementsByTagName( 'div' ) ), false,
         'isDomElement: getElementsByTagName Array' );
-       strictEqual( $.isDomElement( document.getElementsByTagName( 'div' )[0] ), true,
+       assert.strictEqual( $.isDomElement( document.getElementsByTagName( 'div' )[0] ), true,
         'isDomElement: getElementsByTagName(..)[0] Node' );
-       strictEqual( $.isDomElement( $( 'div' ) ), false,
+       assert.strictEqual( $.isDomElement( $( 'div' ) ), false,
         'isDomElement: jQuery object' );
-       strictEqual( $.isDomElement( $( 'div' ).get(0) ), true,
+       assert.strictEqual( $.isDomElement( $( 'div' ).get(0) ), true,
         'isDomElement: jQuery object > Get node' );
-       strictEqual( $.isDomElement( document.createElement( 'div' ) ), true,
+       assert.strictEqual( $.isDomElement( document.createElement( 'div' ) ), true,
         'isDomElement: createElement' );
-       strictEqual( $.isDomElement( { foo: 1 } ), false,
+       assert.strictEqual( $.isDomElement( { foo: 1 } ), false,
         'isDomElement: Object' );
 
-       strictEqual( $.isEmpty( 'string' ), false, 'isEmptry: "string"' );
-       strictEqual( $.isEmpty( '0' ), true, 'isEmptry: "0"' );
-       strictEqual( $.isEmpty( '' ), true, 'isEmptry: ""' );
-       strictEqual( $.isEmpty( 1 ), false, 'isEmptry: 1' );
-       strictEqual( $.isEmpty( [] ), true, 'isEmptry: []' );
-       strictEqual( $.isEmpty( {} ), true, 'isEmptry: {}' );
+       assert.strictEqual( $.isEmpty( 'string' ), false, 'isEmptry: "string"' );
+       assert.strictEqual( $.isEmpty( '0' ), true, 'isEmptry: "0"' );
+       assert.strictEqual( $.isEmpty( '' ), true, 'isEmptry: ""' );
+       assert.strictEqual( $.isEmpty( 1 ), false, 'isEmptry: 1' );
+       assert.strictEqual( $.isEmpty( [] ), true, 'isEmptry: []' );
+       assert.strictEqual( $.isEmpty( {} ), true, 'isEmptry: {}' );
 
        // Documented behaviour
-       strictEqual( $.isEmpty( { length: 0 } ), true, 'isEmptry: { length: 0 }' );
+       assert.strictEqual( $.isEmpty( { length: 0 } ), true, 'isEmptry: { length: 0 }' );
 });
 
-test( 'Comparison functions', function() {
+QUnit.test( 'Comparison functions', function ( assert ) {
 
-       ok( $.compareArray( [0, 'a', [], [2, 'b'] ], [0, "a", [], [2, "b"] ] ),
+       assert.ok( $.compareArray( [0, 'a', [], [2, 'b'] ], [0, "a", [], [2, "b"] ] ),
         'compareArray: Two deep arrays that are excactly the same' );
-       ok( !$.compareArray( [1], [2] ), 'compareArray: Two different arrays (false)' );
+       assert.ok( !$.compareArray( [1], [2] ), 'compareArray: Two different arrays (false)' );
 
-       ok( $.compareObject( {}, {} ), 'compareObject: Two empty objects' );
-       ok( $.compareObject( { foo: 1 }, { foo: 1 } ), 'compareObject: Two the same objects' );
-       ok( !$.compareObject( { bar: true }, { baz: false } ),
+       assert.ok( $.compareObject( {}, {} ), 'compareObject: Two empty objects' );
+       assert.ok( $.compareObject( { foo: 1 }, { foo: 1 } ), 'compareObject: Two the same objects' );
+       assert.ok( !$.compareObject( { bar: true }, { baz: false } ),
         'compareObject: Two different objects (false)' );
 });
index 98ff550..161f0cd 100644 (file)
@@ -1,15 +1,6 @@
-module( 'jquery.tabIndex', QUnit.newMwEnvironment() );
-
-test( '-- Initial check', function() {
-       expect(2);
-
-       ok( $.fn.firstTabIndex, '$.fn.firstTabIndex defined' );
-       ok( $.fn.lastTabIndex, '$.fn.lastTabIndex defined' );
-});
-
-test( 'firstTabIndex', function() {
-       expect(2);
+QUnit.module( 'jquery.tabIndex', QUnit.newMwEnvironment() );
 
+QUnit.test( 'firstTabIndex', 2, function ( assert ) {
        var testEnvironment =
 '<form>' +
        '<input tabindex="7" />' +
@@ -19,15 +10,13 @@ test( 'firstTabIndex', function() {
 '</form>';
 
        var $testA = $( '<div>' ).html( testEnvironment ).appendTo( '#qunit-fixture' );
-       strictEqual( $testA.firstTabIndex(), 2, 'First tabindex should be 2 within this context.' );
+       assert.strictEqual( $testA.firstTabIndex(), 2, 'First tabindex should be 2 within this context.' );
 
        var $testB = $( '<div>' );
-       strictEqual( $testB.firstTabIndex(), null, 'Return null if none available.' );
+       assert.strictEqual( $testB.firstTabIndex(), null, 'Return null if none available.' );
 });
 
-test( 'lastTabIndex', function() {
-       expect(2);
-
+QUnit.test( 'lastTabIndex', 2, function ( assert ) {
        var testEnvironment =
 '<form>' +
        '<input tabindex="7" />' +
@@ -37,8 +26,8 @@ test( 'lastTabIndex', function() {
 '</form>';
 
        var $testA = $( '<div>' ).html( testEnvironment ).appendTo( '#qunit-fixture' );
-       strictEqual( $testA.lastTabIndex(), 9, 'Last tabindex should be 9 within this context.' );
+       assert.strictEqual( $testA.lastTabIndex(), 9, 'Last tabindex should be 9 within this context.' );
 
        var $testB = $( '<div>' );
-       strictEqual( $testB.lastTabIndex(), null, 'Return null if none available.' );
+       assert.strictEqual( $testB.lastTabIndex(), null, 'Return null if none available.' );
 });
index df0144c..2ec0941 100644 (file)
@@ -7,12 +7,7 @@ var config = {
        wgContentLanguage: 'en'
 };
 
-module( 'jquery.tablesorter', QUnit.newMwEnvironment({ config: config }) );
-
-test( '-- Initial check', function() {
-       expect(1);
-       ok( $.tablesorter, '$.tablesorter defined' );
-});
+QUnit.module( 'jquery.tablesorter', QUnit.newMwEnvironment({ config: config }) );
 
 /**
  * Create an HTML table from an array of row arrays containing text strings.
@@ -22,28 +17,29 @@ test( '-- Initial check', function() {
  * @param {String[][]} data
  * @return jQuery
  */
-var tableCreate = function( header, data ) {
-       var $table = $( '<table class="sortable"><thead></thead><tbody></tbody></table>' ),
+function tableCreate(  header, data ) {
+       var i,
+               $table = $( '<table class="sortable"><thead></thead><tbody></tbody></table>' ),
                $thead = $table.find( 'thead' ),
                $tbody = $table.find( 'tbody' ),
                $tr = $( '<tr>' );
 
-       $.each( header, function( i, str ) {
+       $.each( header, function ( i, str ) {
                var $th = $( '<th>' );
                $th.text( str ).appendTo( $tr );
        });
        $tr.appendTo( $thead );
 
-       for (var i = 0; i < data.length; i++) {
+       for ( i = 0; i < data.length; i++ ) {
                $tr = $( '<tr>' );
-               $.each( data[i], function( j, str ) {
+               $.each( data[i], function ( j, str ) {
                        var $td = $( '<td>' );
                        $td.text( str ).appendTo( $tr );
                });
                $tr.appendTo( $tbody );
        }
        return $table;
-};
+}
 
 /**
  * Extract text from table.
@@ -51,7 +47,7 @@ var tableCreate = function( header, data ) {
  * @param {jQuery} $table
  * @return String[][]
  */
-var tableExtract = function( $table ) {
+function tableExtract( $table ) {
        var data = [];
 
        $table.find( 'tbody' ).find( 'tr' ).each( function( i, tr ) {
@@ -62,7 +58,7 @@ var tableExtract = function( $table ) {
                data.push( row );
        });
        return data;
-};
+}
 
 /**
  * Run a table test by building a table with the given data,
@@ -74,10 +70,8 @@ var tableExtract = function( $table ) {
  * @param {String[][]} expected rows/cols to compare against at end
  * @param {function($table)} callback something to do with the table before we compare
  */
-var tableTest = function( msg, header, data, expected, callback ) {
-       test( msg, function() {
-               expect(1);
-
+function tableTest( msg, header, data, expected, callback ) {
+       QUnit.test( msg, 1, function ( assert ) {
                var $table = tableCreate( header, data );
 
                // Give caller a chance to set up sorting and manipulate the table.
@@ -86,15 +80,18 @@ var tableTest = function( msg, header, data, expected, callback ) {
                // Table sorting is done synchronously; if it ever needs to change back
                // to asynchronous, we'll need a timeout or a callback here.
                var extracted = tableExtract( $table );
-               deepEqual( extracted, expected, msg );
+               assert.deepEqual( extracted, expected, msg );
        });
-};
+}
 
-var reversed = function(arr) {
+function reversed(arr) {
+       // Clone array
        var arr2 = arr.slice(0);
+
        arr2.reverse();
+
        return arr2;
-};
+}
 
 // Sample data set using planets named and their radius
 var header  = [ 'Planet' , 'Radius (km)'],
@@ -115,7 +112,7 @@ tableTest(
        header,
        planets,
        ascendingName,
-       function( $table ) {
+       function ( $table ) {
                $table.tablesorter();
                $table.find( '.headerSort:eq(0)' ).click();
        }
@@ -125,7 +122,7 @@ tableTest(
        header,
        planets,
        ascendingName,
-       function( $table ) {
+       function ( $table ) {
                $table.tablesorter();
                $table.find( '.headerSort:eq(0)' ).click();
        }
@@ -135,7 +132,7 @@ tableTest(
        header,
        planets,
        reversed(ascendingName),
-       function( $table ) {
+       function ( $table ) {
                $table.tablesorter();
                $table.find( '.headerSort:eq(0)' ).click().click();
        }
@@ -145,7 +142,7 @@ tableTest(
        header,
        planets,
        ascendingRadius,
-       function( $table ) {
+       function ( $table ) {
                $table.tablesorter();
                $table.find( '.headerSort:eq(1)' ).click();
        }
@@ -155,7 +152,7 @@ tableTest(
        header,
        planets,
        reversed(ascendingRadius),
-       function( $table ) {
+       function ( $table ) {
                $table.tablesorter();
                $table.find( '.headerSort:eq(1)' ).click().click();
        }
@@ -180,7 +177,7 @@ tableTest(
                ['09.11.2011'],
                ['11.11.2011']
        ],
-       function( $table ) {
+       function ( $table ) {
                mw.config.set( 'wgDefaultDateFormat', 'dmy' );
                mw.config.set( 'wgContentLanguage', 'de' );
 
@@ -206,7 +203,7 @@ tableTest(
                ['09.11.2011'],
                ['11.11.2011']
        ],
-       function( $table ) {
+       function ( $table ) {
                mw.config.set( 'wgDefaultDateFormat', 'mdy' );
 
                $table.tablesorter();
@@ -242,7 +239,7 @@ tableTest(
        ['IP'],
        ipv4,
        ipv4Sorted,
-       function( $table ) {
+       function ( $table ) {
                $table.tablesorter();
                $table.find( '.headerSort:eq(0)' ).click();
        }
@@ -252,7 +249,7 @@ tableTest(
        ['IP'],
        ipv4,
        reversed(ipv4Sorted),
-       function( $table ) {
+       function ( $table ) {
                $table.tablesorter();
                $table.find( '.headerSort:eq(0)' ).click().click();
        }
@@ -287,7 +284,7 @@ tableTest(
        ['Name'],
        umlautWords,
        umlautWordsSorted,
-       function( $table ) {
+       function ( $table ) {
                mw.config.set( 'tableSorterCollation', {
                        'ä': 'ae',
                        'ö': 'oe',
@@ -308,7 +305,7 @@ tableTest(
        header,
        planets,
        planetsRowspan,
-       function( $table ) {
+       function ( $table ) {
                // Modify the table to have a multiuple-row-spanning cell:
                // - Remove 2nd cell of 4th row, and, 2nd cell or 5th row.
                $table.find( 'tr:eq(3) td:eq(1), tr:eq(4) td:eq(1)' ).remove();
@@ -325,7 +322,7 @@ tableTest(
        header,
        planets,
        planetsRowspanII,
-       function( $table ) {
+       function ( $table ) {
                // Modify the table to have a multiuple-row-spanning cell:
                // - Remove 1st cell of 4th row, and, 1st cell or 5th row.
                $table.find( 'tr:eq(3) td:eq(0), tr:eq(4) td:eq(0)' ).remove();
@@ -360,7 +357,7 @@ tableTest(
        ['date'],
        complexMDYDates,
        complexMDYSorted,
-       function( $table ) {
+       function ( $table ) {
                mw.config.set( 'wgDefaultDateFormat', 'mdy' );
 
                $table.tablesorter();
@@ -385,7 +382,7 @@ tableTest(
 );
 
 /** FIXME: the diff output is not very readeable. */
-test( 'bug 32047 - caption must be before thead', function() {
+QUnit.test( 'bug 32047 - caption must be before thead', function ( assert ) {
        var $table;
        $table = $(
                '<table class="sortable">' +
@@ -398,14 +395,14 @@ test( 'bug 32047 - caption must be before thead', function() {
                );
        $table.tablesorter();
 
-       equals(
+       assert.equal(
                $table.children( ).get( 0 ).nodeName,
                'CAPTION',
                'First element after <thead> must be <caption> (bug 32047)'
        );
 });
 
-test( 'data-sort-value attribute, when available, should override sorting position', function() {
+QUnit.test( 'data-sort-value attribute, when available, should override sorting position', function ( assert ) {
        var $table, data;
 
        // Example 1: All cells except one cell without data-sort-value,
@@ -432,7 +429,7 @@ test( 'data-sort-value attribute, when available, should override sorting positi
                });
        });
 
-       deepEqual( data, [
+       assert.deepEqual( data, [
                {
                        data: 'Apple',
                        text: 'Bird'
@@ -465,8 +462,8 @@ test( 'data-sort-value attribute, when available, should override sorting positi
        $table.tablesorter().find( '.headerSort:eq(0)' ).click();
 
        data = [];
-       $table.find( 'tbody > tr' ).each( function( i, tr ) {
-               $( tr ).find( 'td' ).each( function( i, td ) {
+       $table.find( 'tbody > tr' ).each( function ( i, tr ) {
+               $( tr ).find( 'td' ).each( function ( i, td ) {
                        data.push( {
                                data: $( td ).data( 'sortValue' ),
                                text: $( td ).text()
@@ -474,7 +471,7 @@ test( 'data-sort-value attribute, when available, should override sorting positi
                });
        });
 
-       deepEqual( data, [
+       assert.deepEqual( data, [
                {
                        data: undefined,
                        text: 'B'
@@ -532,7 +529,7 @@ test( 'data-sort-value attribute, when available, should override sorting positi
                });
        });
 
-       deepEqual( data, [
+       assert.deepEqual( data, [
                {
                        data: 1,
                        text: "B"
@@ -587,9 +584,7 @@ tableTest( 'bug 8115: sort numbers with commas (descending)',
 );
 // TODO add numbers sorting tests for bug 8115 with a different language
 
-test( 'bug 32888 - Tables inside a tableheader cell', function() {
-       expect(2);
-
+QUnit.test( 'bug 32888 - Tables inside a tableheader cell', 2, function ( assert ) {
        var $table;
        $table = $(
                '<table class="sortable" id="mw-bug-32888">' +
@@ -602,12 +597,12 @@ test( 'bug 32888 - Tables inside a tableheader cell', function() {
                );
        $table.tablesorter();
 
-       equals(
+       assert.equal(
                $table.find('> thead:eq(0) > tr > th.headerSort').length,
                1,
                'Child tables inside a headercell should not interfere with sortable headers (bug 32888)'
        );
-       equals(
+       assert.equal(
                $( '#mw-bug-32888-2' ).find('th.headerSort').length,
                0,
                'The headers of child tables inside a headercell should not be sortable themselves (bug 32888)'
@@ -618,13 +613,13 @@ test( 'bug 32888 - Tables inside a tableheader cell', function() {
 var correctDateSorting1 = [
        ['01 January 2010'],
        ['05 February 2010'],
-       ['16 January 2010'],
+       ['16 January 2010']
 ];
 
 var correctDateSortingSorted1 = [
        ['01 January 2010'],
        ['16 January 2010'],
-       ['05 February 2010'],
+       ['05 February 2010']
 ];
 
 tableTest(
@@ -643,13 +638,13 @@ tableTest(
 var correctDateSorting2 = [
        ['January 01 2010'],
        ['February 05 2010'],
-       ['January 16 2010'],
+       ['January 16 2010']
 ];
 
 var correctDateSortingSorted2 = [
        ['January 01 2010'],
        ['January 16 2010'],
-       ['February 05 2010'],
+       ['February 05 2010']
 ];
 
 tableTest(
@@ -665,4 +660,4 @@ tableTest(
        }
 );
 
-})( jQuery );
+}( jQuery ) );
index e01f217..f0a210f 100644 (file)
@@ -1,9 +1,4 @@
-module( 'jquery.textSelection', QUnit.newMwEnvironment() );
-
-test( '-- Initial check', function() {
-       expect(1);
-       ok( $.fn.textSelection, 'jQuery.fn.textSelection defined' );
-} );
+QUnit.module( 'jquery.textSelection', QUnit.newMwEnvironment() );
 
 /**
  * Test factory for $.fn.textSelection( 'encapsulateText' )
@@ -16,7 +11,7 @@ test( '-- Initial check', function() {
  *   end {int} ending char for selection
  *   params {object} add'l parameters for $().textSelection( 'encapsulateText' )
  */
-var encapsulateTest = function( options ) {
+function encapsulateTest( options ) {
        var opt = $.extend({
                description: '',
                before: {},
@@ -34,12 +29,12 @@ var encapsulateTest = function( options ) {
                selected: null
        }, opt.after);
 
-       test( opt.description, function() {
+       QUnit.test( opt.description, function ( assert ) {
                var tests = 1;
                if ( opt.after.selected !== null ) {
                        tests++;
                }
-               expect( tests );
+               QUnit.expect( tests );
 
                var $textarea = $( '<textarea>' );
 
@@ -65,15 +60,15 @@ var encapsulateTest = function( options ) {
 
                var text = $textarea.textSelection( 'getContents' ).replace( /\r\n/g, "\n" );
 
-               equal( text, opt.after.text, 'Checking full text after encapsulation' );
+               assert.equal( text, opt.after.text, 'Checking full text after encapsulation' );
 
                if (opt.after.selected !== null) {
                        var selected = $textarea.textSelection( 'getSelection' );
-                       equal( selected, opt.after.selected, 'Checking selected text after encapsulation.' );
+                       assert.equal( selected, opt.after.selected, 'Checking selected text after encapsulation.' );
                }
 
        } );
-};
+}
 
 var sig = {
        'pre': "--~~~~"
@@ -86,7 +81,7 @@ var sig = {
        'peri': 'Heading 2',
        'post': ' ==',
        'regex': /^(\s*)(={1,6})(.*?)\2(\s*)$/,
-       'regexReplace': "\$1==\$3==\$4",
+       'regexReplace': "$1==$3==$4",
        'ownline': true
 }, ulist = {
        'pre': "* ",
@@ -222,28 +217,26 @@ encapsulateTest({
 });
 
 
-var caretTest = function(options) {
-       test(options.description, function() {
-               expect(2);
-
-               var $textarea = $( '<textarea>' ).text(options.text);
+function caretTest( options ) {
+       QUnit.test( options.description, 2, function ( assert ) {
+               var $textarea = $( '<textarea>' ).text( options.text );
 
                $( '#qunit-fixture' ).append( $textarea );
 
-               if (options.mode == 'set') {
+               if ( options.mode === 'set' ) {
                        $textarea.textSelection('setSelection', {
                                start: options.start,
                                end: options.end
                        });
                }
 
-               var among = function(actual, expected, message) {
-                       if ($.isArray(expected)) {
-                               ok($.inArray(actual, expected) !== -1 , message + ' (got ' + actual + '; expected one of ' + expected.join(', ') + ')');
+               function among( actual, expected, message ) {
+                       if ( $.isArray( expected ) ) {
+                               assert.ok( $.inArray( actual, expected ) !== -1 , message + ' (got ' + actual + '; expected one of ' + expected.join(', ') + ')' );
                        } else {
-                               equal(actual, expected, message);
+                               assert.equal( actual, expected, message );
                        }
-               };
+               }
 
                var pos = $textarea.textSelection('getCaretPosition', {startAndEnd: true});
                among(pos[0], options.start, 'Caret start should be where we set it.');
index 246b74a..f33edb0 100644 (file)
@@ -9,7 +9,7 @@ QUnit.asyncTest( 'Simple', function ( assert ) {
        api.parse( "'''Hello world'''" )
                .done( function ( html ) {
                        // Html also contains "NewPP report", so only check the first part
-                       assert.equal( html.substr( 0, 26 ), '<p><b>Hello world</b>\n</p>',
+                       assert.equal( html.substr( 0, 25 ), '<p><b>Hello world</b></p>',
                                'Wikitext to html parsing works.'
                        );
 
index d73fe5a..7fe7baf 100644 (file)
@@ -1,13 +1,8 @@
-module( 'mediawiki.special.recentchanges', QUnit.newMwEnvironment() );
+QUnit.module( 'mediawiki.special.recentchanges', QUnit.newMwEnvironment() );
 
-test( '-- Initial check', function() {
-       expect( 2 );
-       ok( mw.special.recentchanges.init, 'mw.special.recentchanges.init defined' );
-       ok( mw.special.recentchanges.updateCheckboxes, 'mw.special.recentchanges.updateCheckboxes defined' );
-       // TODO: verify checkboxes == [ 'nsassociated', 'nsinvert' ]
-});
+// TODO: verify checkboxes == [ 'nsassociated', 'nsinvert' ]
 
-test( '"all" namespace disable checkboxes', function() {
+QUnit.test( '"all" namespace disable checkboxes', function ( assert ) {
 
        // from Special:Recentchanges
        var select =
@@ -33,15 +28,15 @@ test( '"all" namespace disable checkboxes', function() {
        // TODO abstract the double strictEquals
 
        // At first checkboxes are enabled
-       strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
-       strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
+       assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
+       assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
 
        // Initiate the recentchanges module
        mw.special.recentchanges.init();
 
        // By default
-       strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
-       strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
+       assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
+       assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
 
        // select second option...
        var $options = $( '#namespace' ).find( 'option' );
@@ -50,8 +45,8 @@ test( '"all" namespace disable checkboxes', function() {
        $( '#namespace' ).change();
 
        // ... and checkboxes should be enabled again
-       strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
-       strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
+       assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
+       assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
 
        // select first option ( 'all' namespace)...
        $options.eq(1).removeProp( 'selected' );
@@ -59,8 +54,8 @@ test( '"all" namespace disable checkboxes', function() {
        $( '#namespace' ).change();
 
        // ... and checkboxes should now be disabled
-       strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
-       strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
+       assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
+       assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
 
        // DOM cleanup
        $env.remove();
index 7ff0fb8..6360925 100644 (file)
@@ -55,147 +55,127 @@ var config = {
        "wgCaseSensitiveNamespaces": []
 };
 
-module( 'mediawiki.Title', QUnit.newMwEnvironment({ config: config }) );
+QUnit.module( 'mediawiki.Title', QUnit.newMwEnvironment({ config: config }) );
 
-test( '-- Initial check', function () {
-       expect(1);
-       ok( mw.Title, 'mw.Title defined' );
-});
-
-test( 'Transformation', function () {
-       expect(8);
 
+QUnit.test( 'Transformation', 8, function ( assert ) {
        var title;
 
        title = new mw.Title( 'File:quux pif.jpg' );
-       equal( title.getName(), 'Quux_pif' );
+       assert.equal( title.getName(), 'Quux_pif' );
 
        title = new mw.Title( 'File:Glarg_foo_glang.jpg' );
-       equal( title.getNameText(), 'Glarg foo glang' );
+       assert.equal( title.getNameText(), 'Glarg foo glang' );
 
        title = new mw.Title( 'User:ABC.DEF' );
-       equal( title.toText(), 'User:ABC.DEF' );
-       equal( title.getNamespaceId(), 2 );
-       equal( title.getNamespacePrefix(), 'User:' );
+       assert.equal( title.toText(), 'User:ABC.DEF' );
+       assert.equal( title.getNamespaceId(), 2 );
+       assert.equal( title.getNamespacePrefix(), 'User:' );
 
        title = new mw.Title( 'uSEr:hAshAr' );
-       equal( title.toText(), 'User:HAshAr' );
-       equal( title.getNamespaceId(), 2 );
+       assert.equal( title.toText(), 'User:HAshAr' );
+       assert.equal( title.getNamespaceId(), 2 );
 
        title = new mw.Title( '   MediaWiki:  Foo   bar   .js   ' );
        // Don't ask why, it's the way the backend works. One space is kept of each set
-       equal( title.getName(), 'Foo_bar_.js', "Merge multiple spaces to a single space." );
+       assert.equal( title.getName(), 'Foo_bar_.js', "Merge multiple spaces to a single space." );
 });
 
-test( 'Main text for filename', function () {
-       expect(8);
-
+QUnit.test( 'Main text for filename', 8, function ( assert ) {
        var title = new mw.Title( 'File:foo_bar.JPG' );
 
-       equal( title.getNamespaceId(), 6 );
-       equal( title.getNamespacePrefix(), 'File:' );
-       equal( title.getName(), 'Foo_bar' );
-       equal( title.getNameText(), 'Foo bar' );
-       equal( title.getMain(), 'Foo_bar.JPG' );
-       equal( title.getMainText(), 'Foo bar.JPG' );
-       equal( title.getExtension(), 'JPG' );
-       equal( title.getDotExtension(), '.JPG' );
+       assert.equal( title.getNamespaceId(), 6 );
+       assert.equal( title.getNamespacePrefix(), 'File:' );
+       assert.equal( title.getName(), 'Foo_bar' );
+       assert.equal( title.getNameText(), 'Foo bar' );
+       assert.equal( title.getMain(), 'Foo_bar.JPG' );
+       assert.equal( title.getMainText(), 'Foo bar.JPG' );
+       assert.equal( title.getExtension(), 'JPG' );
+       assert.equal( title.getDotExtension(), '.JPG' );
 });
 
-test( 'Namespace detection and conversion', function () {
-       expect(6);
-
+QUnit.test( 'Namespace detection and conversion', 6, function ( assert ) {
        var title;
 
        title = new mw.Title( 'something.PDF', 6 );
-       equal( title.toString(), 'File:Something.PDF' );
+       assert.equal( title.toString(), 'File:Something.PDF' );
 
        title = new mw.Title( 'NeilK', 3 );
-       equal( title.toString(), 'User_talk:NeilK' );
-       equal( title.toText(), 'User talk:NeilK' );
+       assert.equal( title.toString(), 'User_talk:NeilK' );
+       assert.equal( title.toText(), 'User talk:NeilK' );
 
        title = new mw.Title( 'Frobisher', 100 );
-       equal( title.toString(), 'Penguins:Frobisher' );
+       assert.equal( title.toString(), 'Penguins:Frobisher' );
 
        title = new mw.Title( 'antarctic_waterfowl:flightless_yet_cute.jpg' );
-       equal( title.toString(), 'Penguins:Flightless_yet_cute.jpg' );
+       assert.equal( title.toString(), 'Penguins:Flightless_yet_cute.jpg' );
 
        title = new mw.Title( 'Penguins:flightless_yet_cute.jpg' );
-       equal( title.toString(), 'Penguins:Flightless_yet_cute.jpg' );
+       assert.equal( title.toString(), 'Penguins:Flightless_yet_cute.jpg' );
 });
 
-test( 'Throw error on invalid title', function () {
-       expect(1);
-
-       raises(function () {
+QUnit.test( 'Throw error on invalid title', 1, function ( assert ) {
+       assert.throws(function () {
                var title = new mw.Title( '' );
        }, 'Throw error on empty string' );
 });
 
-test( 'Case-sensivity', function () {
-       expect(3);
-
+QUnit.test( 'Case-sensivity', 3, function ( assert ) {
        var title;
 
        // Default config
        mw.config.set( 'wgCaseSensitiveNamespaces', [] );
 
        title = new mw.Title( 'article' );
-       equal( title.toString(), 'Article', 'Default config: No sensitive namespaces by default. First-letter becomes uppercase' );
+       assert.equal( title.toString(), 'Article', 'Default config: No sensitive namespaces by default. First-letter becomes uppercase' );
 
        // $wgCapitalLinks = false;
        mw.config.set( 'wgCaseSensitiveNamespaces', [0, -2, 1, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15] );
 
        title = new mw.Title( 'article' );
-       equal( title.toString(), 'article', '$wgCapitalLinks=false: Article namespace is sensitive, first-letter case stays lowercase' );
+       assert.equal( title.toString(), 'article', '$wgCapitalLinks=false: Article namespace is sensitive, first-letter case stays lowercase' );
 
        title = new mw.Title( 'john', 2 );
-       equal( title.toString(), 'User:John', '$wgCapitalLinks=false: User namespace is insensitive, first-letter becomes uppercase' );
+       assert.equal( title.toString(), 'User:John', '$wgCapitalLinks=false: User namespace is insensitive, first-letter becomes uppercase' );
 });
 
-test( 'toString / toText', function () {
-       expect(2);
-
+QUnit.test( 'toString / toText', 2, function ( assert ) {
        var title = new mw.Title( 'Some random page' );
 
-       equal( title.toString(), title.getPrefixedDb() );
-       equal( title.toText(), title.getPrefixedText() );
+       assert.equal( title.toString(), title.getPrefixedDb() );
+       assert.equal( title.toText(), title.getPrefixedText() );
 });
 
-test( 'Exists', function () {
-       expect(3);
-
+QUnit.test( 'Exists', 3, function ( assert ) {
        var title;
 
        // Empty registry, checks default to null
 
        title = new mw.Title( 'Some random page', 4 );
-       strictEqual( title.exists(), null, 'Return null with empty existance registry' );
+       assert.strictEqual( title.exists(), null, 'Return null with empty existance registry' );
 
        // Basic registry, checks default to boolean
        mw.Title.exist.set( ['Does_exist', 'User_talk:NeilK', 'Wikipedia:Sandbox_rules'], true );
        mw.Title.exist.set( ['Does_not_exist', 'User:John', 'Foobar'], false );
 
        title = new mw.Title( 'Project:Sandbox rules' );
-       assertTrue( title.exists(), 'Return true for page titles marked as existing' );
+       assert.assertTrue( title.exists(), 'Return true for page titles marked as existing' );
        title = new mw.Title( 'Foobar' );
-       assertFalse( title.exists(), 'Return false for page titles marked as nonexistent' );
+       assert.assertFalse( title.exists(), 'Return false for page titles marked as nonexistent' );
 
 });
 
-test( 'Url', function () {
-       expect(2);
-
+QUnit.test( 'Url', 2, function ( assert ) {
        var title;
 
        // Config
        mw.config.set( 'wgArticlePath', '/wiki/$1' );
 
        title = new mw.Title( 'Foobar' );
-       equal( title.getUrl(), '/wiki/Foobar', 'Basic functionally, toString passing to wikiGetlink' );
+       assert.equal( title.getUrl(), '/wiki/Foobar', 'Basic functionally, toString passing to wikiGetlink' );
 
        title = new mw.Title( 'John Doe', 3 );
-       equal( title.getUrl(), '/wiki/User_talk:John_Doe', 'Escaping in title and namespace for urls' );
+       assert.equal( title.getUrl(), '/wiki/User_talk:John_Doe', 'Escaping in title and namespace for urls' );
 });
 
 }() );
\ No newline at end of file
index 9ab5c78..b2026c1 100644 (file)
@@ -1,29 +1,23 @@
-module( 'mediawiki.Uri', QUnit.newMwEnvironment() );
-
-test( '-- Initial check', function () {
-       expect( 2 );
-
-       // Ensure we have a generic mw.Uri constructor. By default mediawiki.uri,
-       // will use the currrent window ocation as base. But for testing we need
-       // to have a generic one, so that it doens't return false negatives if
-       // we run the test suite from an https server.
-       mw.Uri = mw.UriRelative( 'http://example.org/w/index.php' );
-
-       ok( mw.UriRelative, 'mw.UriRelative defined' );
-       ok( mw.Uri, 'mw.Uri defined' );
-} );
+QUnit.module( 'mediawiki.Uri', QUnit.newMwEnvironment({
+       setup: function () {
+               this.mwUriOrg = mw.Uri;
+               mw.Uri = mw.UriRelative( 'http://example.org/w/index.php' );
+       },
+       teardown: function () {
+               mw.Uri = this.mwUriOrg;
+               delete this.mwUriOrg;
+       }
+}) );
 
 $.each( [true, false], function ( i, strictMode ) {
-       test( 'Basic mw.Uri object test in ' + ( strictMode ? '' : 'non-' ) + 'strict mode for a simple HTTP URI', function () {
+       QUnit.test( 'Basic mw.Uri object test in ' + ( strictMode ? '' : 'non-' ) + 'strict mode for a simple HTTP URI', 2, function ( assert ) {
                var uriString, uri;
-               expect( 2 );
-
                uriString = 'http://www.ietf.org/rfc/rfc2396.txt';
                uri = new mw.Uri( uriString, {
                        strictMode: strictMode
                });
 
-               deepEqual(
+               assert.deepEqual(
                        {
                                protocol: uri.protocol,
                                host: uri.host,
@@ -42,7 +36,7 @@ $.each( [true, false], function ( i, strictMode ) {
                        'basic object properties'
                );
 
-               deepEqual(
+               assert.deepEqual(
                        {
                                userInfo: uri.getUserInfo(),
                                authority: uri.getAuthority(),
@@ -65,13 +59,10 @@ $.each( [true, false], function ( i, strictMode ) {
        });
 });
 
-test( 'Parse an ftp URI correctly with user and password', function () {
-       var uri;
-       expect( 1 );
-
-       uri = new mw.Uri( 'ftp://usr:pwd@192.0.2.16/' );
+QUnit.test( 'Parse an ftp URI correctly with user and password', 1, function ( assert ) {
+       var uri = new mw.Uri( 'ftp://usr:pwd@192.0.2.16/' );
 
-       deepEqual(
+       assert.deepEqual(
                {
                        protocol: uri.protocol,
                        user: uri.user,
@@ -96,13 +87,10 @@ test( 'Parse an ftp URI correctly with user and password', function () {
        );
 } );
 
-test( 'Parse a uri with simple querystring', function () {
-       var uri;
-       expect( 1 );
-
-       uri = new mw.Uri( 'http://www.google.com/?q=uri' );
+QUnit.test( 'Parse a uri with simple querystring', 1, function ( assert ) {
+       var uri = new mw.Uri( 'http://www.google.com/?q=uri' );
 
-       deepEqual(
+       assert.deepEqual(
                {
                        protocol: uri.protocol,
                        host: uri.host,
@@ -125,67 +113,60 @@ test( 'Parse a uri with simple querystring', function () {
        );
 } );
 
-test( 'Handle multiple query parameter (overrideKeys on)', function () {
-       var uri;
-       expect( 5 );
-
-       uri = new mw.Uri( 'http://www.example.com/dir/?m=foo&m=bar&n=1', {
+QUnit.test( 'Handle multiple query parameter (overrideKeys on)', 5, function ( assert ) {
+       var uri = new mw.Uri( 'http://www.example.com/dir/?m=foo&m=bar&n=1', {
                overrideKeys: true
        });
 
-       equal( uri.query.n, '1', 'multiple parameters are parsed' );
-       equal( uri.query.m, 'bar', 'last key overrides earlier keys' );
+       assert.equal( uri.query.n, '1', 'multiple parameters are parsed' );
+       assert.equal( uri.query.m, 'bar', 'last key overrides earlier keys' );
 
        uri.query.n = [ 'x', 'y', 'z' ];
 
        // Verify parts and total length instead of entire string because order
        // of iteration can vary.
-       ok( uri.toString().indexOf( 'm=bar' ), 'toString preserves other values' );
-       ok( uri.toString().indexOf( 'n=x&n=y&n=z' ), 'toString parameter includes all values of an array query parameter' );
-       equal( uri.toString().length, 'http://www.example.com/dir/?m=bar&n=x&n=y&n=z'.length, 'toString matches expected string' );
+       assert.ok( uri.toString().indexOf( 'm=bar' ), 'toString preserves other values' );
+       assert.ok( uri.toString().indexOf( 'n=x&n=y&n=z' ), 'toString parameter includes all values of an array query parameter' );
+       assert.equal( uri.toString().length, 'http://www.example.com/dir/?m=bar&n=x&n=y&n=z'.length, 'toString matches expected string' );
 } );
 
-test( 'Handle multiple query parameter (overrideKeys off)', function () {
-       var uri;
-       expect( 9 );
-
-       uri = new mw.Uri( 'http://www.example.com/dir/?m=foo&m=bar&n=1', {
+QUnit.test( 'Handle multiple query parameter (overrideKeys off)', 9, function ( assert ) {
+       var uri = new mw.Uri( 'http://www.example.com/dir/?m=foo&m=bar&n=1', {
                overrideKeys: false
        });
 
        // Strict comparison so that types are also verified (n should be string '1')
-       strictEqual( uri.query.m.length, 2, 'multi-value query should be an array with 2 items' );
-       strictEqual( uri.query.m[0], 'foo', 'order and value is correct' );
-       strictEqual( uri.query.m[1], 'bar', 'order and value is correct' );
-       strictEqual( uri.query.n, '1', 'n=1 is parsed with the correct value of the expected type' );
+       assert.strictEqual( uri.query.m.length, 2, 'multi-value query should be an array with 2 items' );
+       assert.strictEqual( uri.query.m[0], 'foo', 'order and value is correct' );
+       assert.strictEqual( uri.query.m[1], 'bar', 'order and value is correct' );
+       assert.strictEqual( uri.query.n, '1', 'n=1 is parsed with the correct value of the expected type' );
 
        // Change query values
        uri.query.n = [ 'x', 'y', 'z' ];
 
        // Verify parts and total length instead of entire string because order
        // of iteration can vary.
-       ok( uri.toString().indexOf( 'm=foo&m=bar' ) >= 0, 'toString preserves other values' );
-       ok( uri.toString().indexOf( 'n=x&n=y&n=z' ) >= 0, 'toString parameter includes all values of an array query parameter' );
-       equal( uri.toString().length, 'http://www.example.com/dir/?m=foo&m=bar&n=x&n=y&n=z'.length, 'toString matches expected string' );
+       assert.ok( uri.toString().indexOf( 'm=foo&m=bar' ) >= 0, 'toString preserves other values' );
+       assert.ok( uri.toString().indexOf( 'n=x&n=y&n=z' ) >= 0, 'toString parameter includes all values of an array query parameter' );
+       assert.equal( uri.toString().length, 'http://www.example.com/dir/?m=foo&m=bar&n=x&n=y&n=z'.length, 'toString matches expected string' );
 
        // Remove query values
        uri.query.m.splice( 0, 1 );
        delete uri.query.n;
 
-       equal( uri.toString(), 'http://www.example.com/dir/?m=bar', 'deletion properties' );
+       assert.equal( uri.toString(), 'http://www.example.com/dir/?m=bar', 'deletion properties' );
 
        // Remove more query values, leaving an empty array
        uri.query.m.splice( 0, 1 );
-       equal( uri.toString(), 'http://www.example.com/dir/', 'empty array value is ommitted' );
+       assert.equal( uri.toString(), 'http://www.example.com/dir/', 'empty array value is ommitted' );
 } );
 
-test( 'All-dressed URI with everything', function () {
+QUnit.test( 'All-dressed URI with everything', 11, function ( assert ) {
        var uri, queryString, relativePath;
-       expect( 11 );
 
        uri = new mw.Uri( 'http://auth@www.example.com:81/dir/dir.2/index.htm?q1=0&&test1&test2=value+%28escaped%29#top' );
 
-       deepEqual(
+       assert.deepEqual(
                {
                        protocol: uri.protocol,
                        user: uri.user,
@@ -209,59 +190,55 @@ test( 'All-dressed URI with everything', function () {
                'basic object properties'
        );
 
-       equal( uri.getUserInfo(), 'auth', 'user info' );
+       assert.equal( uri.getUserInfo(), 'auth', 'user info' );
 
-       equal( uri.getAuthority(), 'auth@www.example.com:81', 'authority equal to auth@hostport' );
+       assert.equal( uri.getAuthority(), 'auth@www.example.com:81', 'authority equal to auth@hostport' );
 
-       equal( uri.getHostPort(), 'www.example.com:81', 'hostport equal to host:port' );
+       assert.equal( uri.getHostPort(), 'www.example.com:81', 'hostport equal to host:port' );
 
        queryString = uri.getQueryString();
-       ok( queryString.indexOf( 'q1=0' ) >= 0, 'query param with numbers' );
-       ok( queryString.indexOf( 'test1' ) >= 0, 'query param with null value is included' );
-       ok( queryString.indexOf( 'test1=' ) === -1, 'query param with null value does not generate equals sign' );
-       ok( queryString.indexOf( 'test2=value+%28escaped%29' ) >= 0, 'query param is url escaped' );
+       assert.ok( queryString.indexOf( 'q1=0' ) >= 0, 'query param with numbers' );
+       assert.ok( queryString.indexOf( 'test1' ) >= 0, 'query param with null value is included' );
+       assert.ok( queryString.indexOf( 'test1=' ) === -1, 'query param with null value does not generate equals sign' );
+       assert.ok( queryString.indexOf( 'test2=value+%28escaped%29' ) >= 0, 'query param is url escaped' );
 
        relativePath = uri.getRelativePath();
-       ok( relativePath.indexOf( uri.path ) >= 0, 'path in relative path' );
-       ok( relativePath.indexOf( uri.getQueryString() ) >= 0, 'query string in relative path' );
-       ok( relativePath.indexOf( uri.fragment ) >= 0, 'fragement in relative path' );
+       assert.ok( relativePath.indexOf( uri.path ) >= 0, 'path in relative path' );
+       assert.ok( relativePath.indexOf( uri.getQueryString() ) >= 0, 'query string in relative path' );
+       assert.ok( relativePath.indexOf( uri.fragment ) >= 0, 'fragement in relative path' );
 } );
 
-test( 'Cloning', function () {
+QUnit.test( 'Cloning', 6, function ( assert ) {
        var original, clone;
-       expect( 6 );
 
        original = new mw.Uri( 'http://foo.example.org/index.php?one=1&two=2' );
        clone = original.clone();
 
-       deepEqual( clone, original, 'clone has equivalent properties' );
-       equal( original.toString(), clone.toString(), 'toString matches original' );
+       assert.deepEqual( clone, original, 'clone has equivalent properties' );
+       assert.equal( original.toString(), clone.toString(), 'toString matches original' );
 
-       notStrictEqual( clone, original, 'clone is a different object when compared by reference' );
+       assert.notStrictEqual( clone, original, 'clone is a different object when compared by reference' );
 
        clone.host = 'bar.example.org';
-       notEqual( original.host, clone.host, 'manipulating clone did not effect original' );
-       notEqual( original.toString(), clone.toString(), 'Stringified url no longer matches original' );
+       assert.notEqual( original.host, clone.host, 'manipulating clone did not effect original' );
+       assert.notEqual( original.toString(), clone.toString(), 'Stringified url no longer matches original' );
 
        clone.query.three = 3;
 
-       deepEqual(
+       assert.deepEqual(
                original.query,
                { 'one': '1', 'two': '2' },
                'Properties is deep cloned (bug 37708)'
        );
 } );
 
-test( 'Constructing mw.Uri from plain object', function () {
-       var uri;
-       expect( 3 );
-
-       uri = new mw.Uri({
+QUnit.test( 'Constructing mw.Uri from plain object', 3, function ( assert ) {
+       var uri = new mw.Uri({
                protocol: 'http',
                host: 'www.foo.local',
                path: '/this'
        });
-       equal( uri.toString(), 'http://www.foo.local/this', 'Basic properties' );
+       assert.equal( uri.toString(), 'http://www.foo.local/this', 'Basic properties' );
 
        uri = new mw.Uri({
                protocol: 'http',
@@ -270,9 +247,9 @@ test( 'Constructing mw.Uri from plain object', function () {
                query: { hi: 'there' },
                fragment: 'blah'
        });
-       equal( uri.toString(), 'http://www.foo.local/this?hi=there#blah', 'More complex properties' );
+       assert.equal( uri.toString(), 'http://www.foo.local/this?hi=there#blah', 'More complex properties' );
 
-       raises(
+       assert.throws(
                function () {
                        var uri = new mw.Uri({
                                protocol: 'http',
@@ -286,67 +263,64 @@ test( 'Constructing mw.Uri from plain object', function () {
        );
 } );
 
-test( 'Manipulate properties', function () {
+QUnit.test( 'Manipulate properties', 8, function ( assert ) {
        var uriBase, uri;
-       expect( 8 );
 
        uriBase = new mw.Uri( 'http://en.wiki.local/w/api.php' );
 
        uri = uriBase.clone();
        uri.fragment = 'frag';
-       equal( uri.toString(), 'http://en.wiki.local/w/api.php#frag', 'add a fragment' );
+       assert.equal( uri.toString(), 'http://en.wiki.local/w/api.php#frag', 'add a fragment' );
 
        uri = uriBase.clone();
        uri.host = 'fr.wiki.local';
        uri.port = '8080';
-       equal( uri.toString(), 'http://fr.wiki.local:8080/w/api.php', 'change host and port' );
+       assert.equal( uri.toString(), 'http://fr.wiki.local:8080/w/api.php', 'change host and port' );
 
        uri = uriBase.clone();
        uri.query.foo = 'bar';
-       equal( uri.toString(), 'http://en.wiki.local/w/api.php?foo=bar', 'add query arguments' );
+       assert.equal( uri.toString(), 'http://en.wiki.local/w/api.php?foo=bar', 'add query arguments' );
 
        delete uri.query.foo;
-       equal( uri.toString(), 'http://en.wiki.local/w/api.php', 'delete query arguments' );
+       assert.equal( uri.toString(), 'http://en.wiki.local/w/api.php', 'delete query arguments' );
 
        uri = uriBase.clone();
        uri.query.foo = 'bar';
-       equal( uri.toString(), 'http://en.wiki.local/w/api.php?foo=bar', 'extend query arguments' );
+       assert.equal( uri.toString(), 'http://en.wiki.local/w/api.php?foo=bar', 'extend query arguments' );
        uri.extend({
                foo: 'quux',
                pif: 'paf'
        });
-       ok( uri.toString().indexOf( 'foo=quux' ) >= 0, 'extend query arguments' );
-       ok( uri.toString().indexOf( 'foo=bar' ) === -1, 'extend query arguments' );
-       ok( uri.toString().indexOf( 'pif=paf' ) >= 0 , 'extend query arguments' );
+       assert.ok( uri.toString().indexOf( 'foo=quux' ) >= 0, 'extend query arguments' );
+       assert.ok( uri.toString().indexOf( 'foo=bar' ) === -1, 'extend query arguments' );
+       assert.ok( uri.toString().indexOf( 'pif=paf' ) >= 0 , 'extend query arguments' );
 } );
 
-test( 'Handle protocol-relative URLs', function () {
+QUnit.test( 'Handle protocol-relative URLs', 5, function ( assert ) {
        var UriRel, uri;
-       expect( 5 );
 
        UriRel = mw.UriRelative( 'glork://en.wiki.local/foo.php' );
 
        uri = new UriRel( '//en.wiki.local/w/api.php' );
-       equal( uri.protocol, 'glork', 'create protocol-relative URLs with same protocol as document' );
+       assert.equal( uri.protocol, 'glork', 'create protocol-relative URLs with same protocol as document' );
 
        uri = new UriRel( '/foo.com' );
-       equal( uri.toString(), 'glork://en.wiki.local/foo.com', 'handle absolute paths by supplying protocol and host from document in loose mode' );
+       assert.equal( uri.toString(), 'glork://en.wiki.local/foo.com', 'handle absolute paths by supplying protocol and host from document in loose mode' );
 
        uri = new UriRel( 'http:/foo.com' );
-       equal( uri.toString(), 'http://en.wiki.local/foo.com', 'handle absolute paths by supplying host from document in loose mode' );
+       assert.equal( uri.toString(), 'http://en.wiki.local/foo.com', 'handle absolute paths by supplying host from document in loose mode' );
 
        uri = new UriRel( '/foo.com', true );
-       equal( uri.toString(), 'glork://en.wiki.local/foo.com', 'handle absolute paths by supplying protocol and host from document in strict mode' );
+       assert.equal( uri.toString(), 'glork://en.wiki.local/foo.com', 'handle absolute paths by supplying protocol and host from document in strict mode' );
 
        uri = new UriRel( 'http:/foo.com', true );
-       equal( uri.toString(), 'http://en.wiki.local/foo.com', 'handle absolute paths by supplying host from document in strict mode' );
+       assert.equal( uri.toString(), 'http://en.wiki.local/foo.com', 'handle absolute paths by supplying host from document in strict mode' );
 } );
 
-test( 'Bad calls', function () {
+QUnit.test( 'Bad calls', 3, function ( assert ) {
        var uri;
-       expect( 3 );
 
-       raises(
+       assert.throws(
                function () {
                        new mw.Uri( 'glaswegian penguins' );
                },
@@ -356,7 +330,7 @@ test( 'Bad calls', function () {
                'throw error on non-URI as argument to constructor'
        );
 
-       raises(
+       assert.throws(
                function () {
                        new mw.Uri( 'foo.com/bar/baz', {
                                strictMode: true
@@ -371,12 +345,10 @@ test( 'Bad calls', function () {
        uri = new mw.Uri( 'foo.com/bar/baz', {
                strictMode: false
        });
-       equal( uri.toString(), 'http://foo.com/bar/baz', 'normalize URI without protocol or // in loose mode' );
+       assert.equal( uri.toString(), 'http://foo.com/bar/baz', 'normalize URI without protocol or // in loose mode' );
 });
 
-test( 'bug 35658', function () {
-       expect( 2 );
-
+QUnit.test( 'bug 35658', 2, function ( assert ) {
        var testProtocol, testServer, testPort, testPath, UriClass, uri, href;
 
        testProtocol = 'https://';
@@ -387,18 +359,17 @@ test( 'bug 35658', function () {
        UriClass = mw.UriRelative( testProtocol + testServer + '/some/path/index.html' );
        uri = new UriClass( testPath );
        href = uri.toString();
-       equal( href, testProtocol + testServer + testPath, 'Root-relative URL gets host & protocol supplied' );
+       assert.equal( href, testProtocol + testServer + testPath, 'Root-relative URL gets host & protocol supplied' );
 
        UriClass = mw.UriRelative( testProtocol + testServer + ':' + testPort + '/some/path.php' );
        uri = new UriClass( testPath );
        href = uri.toString();
-       equal( href, testProtocol + testServer + ':' + testPort + testPath, 'Root-relative URL gets host, protocol, and port supplied' );
+       assert.equal( href, testProtocol + testServer + ':' + testPort + testPath, 'Root-relative URL gets host, protocol, and port supplied' );
 
 } );
 
-QUnit.test( 'Constructor falls back to default location', function (assert) {
+QUnit.test( 'Constructor falls back to default location', 4, function ( assert ) {
        var testuri, MyUri, uri;
-       QUnit.expect( 4 );
 
        testuri = 'http://example.org/w/index.php';
        MyUri = mw.UriRelative( testuri );
index 481a5bb..b8193a9 100644 (file)
@@ -1,23 +1,16 @@
-module( 'mediawiki.jqueryMsg' );
+QUnit.module( 'mediawiki.jqueryMsg' );
 
-test( '-- Initial check', function () {
-       expect( 1 );
-       ok( mw.jqueryMsg, 'mw.jqueryMsg defined' );
-} );
-
-test( 'mw.jqueryMsg Plural', function () {
-       expect( 3 );
+QUnit.test( 'mw.jqueryMsg Plural', 3, function ( assert ) {
        var parser = mw.jqueryMsg.getMessageFunction();
 
        mw.messages.set( 'plural-msg', 'Found $1 {{PLURAL:$1|item|items}}' );
-       equal( parser( 'plural-msg', 0 ), 'Found 0 items', 'Plural test for english with zero as count' );
-       equal( parser( 'plural-msg', 1 ), 'Found 1 item', 'Singular test for english' );
-       equal( parser( 'plural-msg', 2 ), 'Found 2 items', 'Plural test for english' );
+       assert.equal( parser( 'plural-msg', 0 ), 'Found 0 items', 'Plural test for english with zero as count' );
+       assert.equal( parser( 'plural-msg', 1 ), 'Found 1 item', 'Singular test for english' );
+       assert.equal( parser( 'plural-msg', 2 ), 'Found 2 items', 'Plural test for english' );
 } );
 
 
-test( 'mw.jqueryMsg Gender', function () {
-       expect( 11 );
+QUnit.test( 'mw.jqueryMsg Gender', 11, function ( assert ) {
        // TODO: These tests should be for mw.msg once mw.msg integrated with mw.jqueryMsg
        // TODO: English may not be the best language for these tests. Use a language like Arabic or Russian
        var user = mw.user,
@@ -28,31 +21,31 @@ test( 'mw.jqueryMsg Gender', function () {
        mw.messages.set( 'gender-msg', '$1: {{GENDER:$2|blue|pink|green}}' );
 
        user.options.set( 'gender', 'male' );
-       equal(
+       assert.equal(
                parser( 'gender-msg', 'Bob', 'male' ),
                'Bob: blue',
                'Masculine from string "male"'
        );
-       equal(
+       assert.equal(
                parser( 'gender-msg', 'Bob', user ),
                'Bob: blue',
                'Masculine from mw.user object'
        );
 
        user.options.set( 'gender', 'unknown' );
-       equal(
+       assert.equal(
                parser( 'gender-msg', 'Foo', user ),
                'Foo: green',
                'Neutral from mw.user object' );
-       equal(
+       assert.equal(
                parser( 'gender-msg', 'Alice', 'female' ),
                'Alice: pink',
                'Feminine from string "female"' );
-       equal(
+       assert.equal(
                parser( 'gender-msg', 'User' ),
                'User: green',
                'Neutral when no parameter given' );
-       equal(
+       assert.equal(
                parser( 'gender-msg', 'User', 'unknown' ),
                'User: green',
                'Neutral from string "unknown"'
@@ -60,31 +53,31 @@ test( 'mw.jqueryMsg Gender', function () {
 
        mw.messages.set( 'gender-msg-one-form', '{{GENDER:$1|User}}: $2 {{PLURAL:$2|edit|edits}}' );
 
-       equal(
+       assert.equal(
                parser( 'gender-msg-one-form', 'male', 10 ),
                'User: 10 edits',
                'Gender neutral and plural form'
        );
-       equal(
+       assert.equal(
                parser( 'gender-msg-one-form', 'female', 1 ),
                'User: 1 edit',
                'Gender neutral and singular form'
        );
 
        mw.messages.set( 'gender-msg-lowercase', '{{gender:$1|he|she}} is awesome' );
-       equal(
+       assert.equal(
                parser( 'gender-msg-lowercase', 'male' ),
                'he is awesome',
                'Gender masculine'
        );
-       equal(
+       assert.equal(
                parser( 'gender-msg-lowercase', 'female' ),
                'she is awesome',
                'Gender feminine'
        );
 
        mw.messages.set( 'gender-msg-wrong', '{{gender}} test' );
-       equal(
+       assert.equal(
                parser( 'gender-msg-wrong', 'female' ),
                ' test',
                'Invalid syntax should result in {{gender}} simply being stripped away'
@@ -92,14 +85,13 @@ test( 'mw.jqueryMsg Gender', function () {
 } );
 
 
-test( 'mw.jqueryMsg Grammar', function () {
-       expect( 2 );
+QUnit.test( 'mw.jqueryMsg Grammar', 2, function ( assert ) {
        var parser = mw.jqueryMsg.getMessageFunction();
 
        // Assume the grammar form grammar_case_foo is not valid in any language
        mw.messages.set( 'grammar-msg', 'Przeszukaj {{GRAMMAR:grammar_case_foo|{{SITENAME}}}}' );
-       equal( parser( 'grammar-msg' ), 'Przeszukaj ' + mw.config.get( 'wgSiteName' ), 'Grammar Test with sitename' );
+       assert.equal( parser( 'grammar-msg' ), 'Przeszukaj ' + mw.config.get( 'wgSiteName' ), 'Grammar Test with sitename' );
 
        mw.messages.set( 'grammar-msg-wrong-syntax', 'Przeszukaj {{GRAMMAR:grammar_case_xyz}}' );
-       equal( parser( 'grammar-msg-wrong-syntax' ), 'Przeszukaj ' , 'Grammar Test with wrong grammar template syntax' );
+       assert.equal( parser( 'grammar-msg-wrong-syntax' ), 'Przeszukaj ' , 'Grammar Test with wrong grammar template syntax' );
 } );
index 24005b6..2baa4f3 100644 (file)
@@ -1,24 +1,24 @@
 /* Some misc JavaScript compatibility tests, just to make sure the environments we run in are consistent */
 
-module( 'mediawiki.jscompat', QUnit.newMwEnvironment() );
+QUnit.module( 'mediawiki.jscompat', QUnit.newMwEnvironment() );
 
-test( 'Variable with Unicode letter in name', function() {
-       expect(3);
+QUnit.test( 'Variable with Unicode letter in name', 3, function ( assert ) {
        var orig = "some token";
        var ŝablono = orig;
-       deepEqual( ŝablono, orig, 'ŝablono' );
-       deepEqual( \u015dablono, orig, '\\u015dablono' );
-       deepEqual( \u015Dablono, orig, '\\u015Dablono' );
+
+       assert.deepEqual( ŝablono, orig, 'ŝablono' );
+       assert.deepEqual( \u015dablono, orig, '\\u015dablono' );
+       assert.deepEqual( \u015Dablono, orig, '\\u015Dablono' );
 });
 
 /*
 // Not that we need this. ;)
 // This fails on IE 6-8
 // Works on IE 9, Firefox 6, Chrome 14
-test( 'Keyword workaround: "if" as variable name using Unicode escapes', function() {
+QUnit.test( 'Keyword workaround: "if" as variable name using Unicode escapes', function ( assert ) {
        var orig = "another token";
        \u0069\u0066 = orig;
-       deepEqual( \u0069\u0066, orig, '\\u0069\\u0066' );
+       assert.deepEqual( \u0069\u0066, orig, '\\u0069\\u0066' );
 });
 */
 
@@ -26,37 +26,37 @@ test( 'Keyword workaround: "if" as variable name using Unicode escapes', functio
 // Not that we need this. ;)
 // This fails on IE 6-9
 // Works on Firefox 6, Chrome 14
-test( 'Keyword workaround: "if" as member variable name using Unicode escapes', function() {
+QUnit.test( 'Keyword workaround: "if" as member variable name using Unicode escapes', function ( assert ) {
        var orig = "another token";
        var foo = {};
        foo.\u0069\u0066 = orig;
-       deepEqual( foo.\u0069\u0066, orig, 'foo.\\u0069\\u0066' );
+       assert.deepEqual( foo.\u0069\u0066, orig, 'foo.\\u0069\\u0066' );
 });
 */
 
-test( 'Stripping of single initial newline from textarea\'s literal contents (bug 12130)', function() {
+QUnit.test( 'Stripping of single initial newline from textarea\'s literal contents (bug 12130)', function ( assert ) {
        var maxn = 4;
-       expect(maxn * 2);
+       QUnit.expect( maxn * 2 );
 
-       var repeat = function(str, n) {
-               if (n <= 0) {
+       function repeat( str, n ) {
+               if ( n <= 0 ) {
                        return '';
                } else {
-                       var out = Array(n);
-                       for (var i = 0; i < n; i++) {
+                       var out = new Array(n);
+                       for ( var i = 0; i < n; i++ ) {
                                out[i] = str;
                        }
                        return out.join('');
                }
-       };
+       }
 
-       for (var n = 0; n < maxn; n++) {
+       for ( var n = 0; n < maxn; n++ ) {
                var expected = repeat('\n', n) + 'some text';
 
                var $textarea = $('<textarea>\n' + expected + '</textarea>');
-               equal($textarea.val(), expected, 'Expecting ' + n + ' newlines (HTML contained ' + (n + 1) + ')');
+               assert.equal( $textarea.val(), expected, 'Expecting ' + n + ' newlines (HTML contained ' + (n + 1) + ')' );
 
                var $textarea2 = $('<textarea>').val(expected);
-               equal($textarea2.val(), expected, 'Expecting ' + n + ' newlines (from DOM set with ' + n + ')');
+               assert.equal( $textarea2.val(), expected, 'Expecting ' + n + ' newlines (from DOM set with ' + n + ')' );
        }
 });
index bd6c8a7..58e56ad 100644 (file)
@@ -1,24 +1,21 @@
-module( 'mediawiki', QUnit.newMwEnvironment() );
-
-test( '-- Initial check', function() {
-       expect(8);
-
-       ok( window.jQuery, 'jQuery defined' );
-       ok( window.$, '$j defined' );
-       ok( window.$j, '$j defined' );
-       strictEqual( window.$, window.jQuery, '$ alias to jQuery' );
-       strictEqual( window.$j, window.jQuery, '$j alias to jQuery' );
-
-       ok( window.mediaWiki, 'mediaWiki defined' );
-       ok( window.mw, 'mw defined' );
-       strictEqual( window.mw, window.mediaWiki, 'mw alias to mediaWiki' );
+QUnit.module( 'mediawiki', QUnit.newMwEnvironment() );
+
+QUnit.test( '-- Initial check', 8, function ( assert ) {
+       assert.ok( window.jQuery, 'jQuery defined' );
+       assert.ok( window.$, '$j defined' );
+       assert.ok( window.$j, '$j defined' );
+       assert.strictEqual( window.$, window.jQuery, '$ alias to jQuery' );
+       assert.strictEqual( window.$j, window.jQuery, '$j alias to jQuery' );
+
+       assert.ok( window.mediaWiki, 'mediaWiki defined' );
+       assert.ok( window.mw, 'mw defined' );
+       assert.strictEqual( window.mw, window.mediaWiki, 'mw alias to mediaWiki' );
 });
 
-test( 'mw.Map', function() {
+QUnit.test( 'mw.Map', 17, function ( assert ) {
        var arry, conf, funky, globalConf, nummy, someValues;
-       expect(17);
 
-       ok( mw.Map, 'mw.Map defined' );
+       assert.ok( mw.Map, 'mw.Map defined' );
 
        conf = new mw.Map();
        // Dummy variables
@@ -27,14 +24,14 @@ test( 'mw.Map', function() {
        nummy = 7;
 
        // Tests for input validation
-       strictEqual( conf.get( 'inexistantKey' ), null, 'Map.get returns null if selection was a string and the key was not found' );
-       strictEqual( conf.set( 'myKey', 'myValue' ), true, 'Map.set returns boolean true if a value was set for a valid key string' );
-       strictEqual( conf.set( funky, 'Funky' ), false, 'Map.set returns boolean false if key was invalid (Function)' );
-       strictEqual( conf.set( arry, 'Arry' ), false, 'Map.set returns boolean false if key was invalid (Array)' );
-       strictEqual( conf.set( nummy, 'Nummy' ), false, 'Map.set returns boolean false if key was invalid (Number)' );
-       equal( conf.get( 'myKey' ), 'myValue', 'Map.get returns a single value value correctly' );
-       strictEqual( conf.get( nummy ), null, 'Map.get ruturns null if selection was invalid (Number)' );
-       strictEqual( conf.get( funky ), null, 'Map.get ruturns null if selection was invalid (Function)' );
+       assert.strictEqual( conf.get( 'inexistantKey' ), null, 'Map.get returns null if selection was a string and the key was not found' );
+       assert.strictEqual( conf.set( 'myKey', 'myValue' ), true, 'Map.set returns boolean true if a value was set for a valid key string' );
+       assert.strictEqual( conf.set( funky, 'Funky' ), false, 'Map.set returns boolean false if key was invalid (Function)' );
+       assert.strictEqual( conf.set( arry, 'Arry' ), false, 'Map.set returns boolean false if key was invalid (Array)' );
+       assert.strictEqual( conf.set( nummy, 'Nummy' ), false, 'Map.set returns boolean false if key was invalid (Number)' );
+       assert.equal( conf.get( 'myKey' ), 'myValue', 'Map.get returns a single value value correctly' );
+       assert.strictEqual( conf.get( nummy ), null, 'Map.get ruturns null if selection was invalid (Number)' );
+       assert.strictEqual( conf.get( funky ), null, 'Map.get ruturns null if selection was invalid (Function)' );
 
        // Multiple values at once
        someValues = {
@@ -42,31 +39,31 @@ test( 'mw.Map', function() {
                'lorem': 'ipsum',
                'MediaWiki': true
        };
-       strictEqual( conf.set( someValues ), true, 'Map.set returns boolean true if multiple values were set by passing an object' );
-       deepEqual( conf.get( ['foo', 'lorem'] ), {
+       assert.strictEqual( conf.set( someValues ), true, 'Map.set returns boolean true if multiple values were set by passing an object' );
+       assert.deepEqual( conf.get( ['foo', 'lorem'] ), {
                'foo': 'bar',
                'lorem': 'ipsum'
        }, 'Map.get returns multiple values correctly as an object' );
 
-       deepEqual( conf.get( ['foo', 'notExist'] ), {
+       assert.deepEqual( conf.get( ['foo', 'notExist'] ), {
                'foo': 'bar',
                'notExist': null
        }, 'Map.get return includes keys that were not found as null values' );
 
-       strictEqual( conf.exists( 'foo' ), true, 'Map.exists returns boolean true if a key exists' );
-       strictEqual( conf.exists( 'notExist' ), false, 'Map.exists returns boolean false if a key does not exists' );
+       assert.strictEqual( conf.exists( 'foo' ), true, 'Map.exists returns boolean true if a key exists' );
+       assert.strictEqual( conf.exists( 'notExist' ), false, 'Map.exists returns boolean false if a key does not exists' );
 
        // Interacting with globals and accessing the values object
-       strictEqual( conf.get(), conf.values, 'Map.get returns the entire values object by reference (if called without arguments)' );
+       assert.strictEqual( conf.get(), conf.values, 'Map.get returns the entire values object by reference (if called without arguments)' );
 
        conf.set( 'globalMapChecker', 'Hi' );
 
-       ok( false === 'globalMapChecker' in window, 'new mw.Map did not store its values in the global window object by default' );
+       assert.ok( false === 'globalMapChecker' in window, 'new mw.Map did not store its values in the global window object by default' );
 
        globalConf = new mw.Map( true );
        globalConf.set( 'anotherGlobalMapChecker', 'Hello' );
 
-       ok( 'anotherGlobalMapChecker' in window, 'new mw.Map( true ) did store its values in the global window object' );
+       assert.ok( 'anotherGlobalMapChecker' in window, 'new mw.Map( true ) did store its values in the global window object' );
 
        // Whitelist this global variable for QUnit's 'noglobal' mode
        if ( QUnit.config.noglobals ) {
@@ -74,87 +71,78 @@ test( 'mw.Map', function() {
        }
 });
 
-test( 'mw.config', function() {
-       expect(1);
-
-       ok( mw.config instanceof mw.Map, 'mw.config instance of mw.Map' );
+QUnit.test( 'mw.config', 1, function ( assert ) {
+       assert.ok( mw.config instanceof mw.Map, 'mw.config instance of mw.Map' );
 });
 
-test( 'mw.message & mw.messages', function() {
+QUnit.test( 'mw.message & mw.messages', 20, function ( assert ) {
        var goodbye, hello, pluralMessage;
-       expect(20);
 
-       ok( mw.messages, 'messages defined' );
-       ok( mw.messages instanceof mw.Map, 'mw.messages instance of mw.Map' );
-       ok( mw.messages.set( 'hello', 'Hello <b>awesome</b> world' ), 'mw.messages.set: Register' );
+       assert.ok( mw.messages, 'messages defined' );
+       assert.ok( mw.messages instanceof mw.Map, 'mw.messages instance of mw.Map' );
+       assert.ok( mw.messages.set( 'hello', 'Hello <b>awesome</b> world' ), 'mw.messages.set: Register' );
 
        hello = mw.message( 'hello' );
 
-       equal( hello.format, 'plain', 'Message property "format" defaults to "plain"' );
-       strictEqual( hello.map, mw.messages, 'Message property "map" defaults to the global instance in mw.messages' );
-       equal( hello.key, 'hello', 'Message property "key" (currect key)' );
-       deepEqual( hello.parameters, [], 'Message property "parameters" defaults to an empty array' );
+       assert.equal( hello.format, 'plain', 'Message property "format" defaults to "plain"' );
+       assert.strictEqual( hello.map, mw.messages, 'Message property "map" defaults to the global instance in mw.messages' );
+       assert.equal( hello.key, 'hello', 'Message property "key" (currect key)' );
+       assert.deepEqual( hello.parameters, [], 'Message property "parameters" defaults to an empty array' );
 
        // Todo
-       ok( hello.params, 'Message prototype "params"' );
+       assert.ok( hello.params, 'Message prototype "params"' );
 
        hello.format = 'plain';
-       equal( hello.toString(), 'Hello <b>awesome</b> world', 'Message.toString returns the message as a string with the current "format"' );
+       assert.equal( hello.toString(), 'Hello <b>awesome</b> world', 'Message.toString returns the message as a string with the current "format"' );
 
-       equal( hello.escaped(), 'Hello &lt;b&gt;awesome&lt;/b&gt; world', 'Message.escaped returns the escaped message' );
-       equal( hello.format, 'escaped', 'Message.escaped correctly updated the "format" property' );
+       assert.equal( hello.escaped(), 'Hello &lt;b&gt;awesome&lt;/b&gt; world', 'Message.escaped returns the escaped message' );
+       assert.equal( hello.format, 'escaped', 'Message.escaped correctly updated the "format" property' );
 
        hello.parse();
-       equal( hello.format, 'parse', 'Message.parse correctly updated the "format" property' );
+       assert.equal( hello.format, 'parse', 'Message.parse correctly updated the "format" property' );
 
        hello.plain();
-       equal( hello.format, 'plain', 'Message.plain correctly updated the "format" property' );
+       assert.equal( hello.format, 'plain', 'Message.plain correctly updated the "format" property' );
 
-       strictEqual( hello.exists(), true, 'Message.exists returns true for existing messages' );
+       assert.strictEqual( hello.exists(), true, 'Message.exists returns true for existing messages' );
 
        goodbye = mw.message( 'goodbye' );
-       strictEqual( goodbye.exists(), false, 'Message.exists returns false for nonexistent messages' );
+       assert.strictEqual( goodbye.exists(), false, 'Message.exists returns false for nonexistent messages' );
 
-       equal( goodbye.plain(), '<goodbye>', 'Message.toString returns plain <key> if format is "plain" and key does not exist' );
+       assert.equal( goodbye.plain(), '<goodbye>', 'Message.toString returns plain <key> if format is "plain" and key does not exist' );
        // bug 30684
-       equal( goodbye.escaped(), '&lt;goodbye&gt;', 'Message.toString returns properly escaped &lt;key&gt; if format is "escaped" and key does not exist' );
+       assert.equal( goodbye.escaped(), '&lt;goodbye&gt;', 'Message.toString returns properly escaped &lt;key&gt; if format is "escaped" and key does not exist' );
 
-       ok( mw.messages.set( 'pluraltestmsg', 'There {{PLURAL:$1|is|are}} $1 {{PLURAL:$1|result|results}}' ), 'mw.messages.set: Register' );
+       assert.ok( mw.messages.set( 'pluraltestmsg', 'There {{PLURAL:$1|is|are}} $1 {{PLURAL:$1|result|results}}' ), 'mw.messages.set: Register' );
        pluralMessage = mw.message( 'pluraltestmsg' , 6 );
-       equal( pluralMessage.plain(), 'There are 6 results', 'plural get resolved when format is plain' );
-       equal( pluralMessage.parse(), 'There are 6 results', 'plural get resolved when format is parse' );
+       assert.equal( pluralMessage.plain(), 'There are 6 results', 'plural get resolved when format is plain' );
+       assert.equal( pluralMessage.parse(), 'There are 6 results', 'plural get resolved when format is parse' );
 
 });
 
-test( 'mw.msg', function() {
-       expect(11);
+QUnit.test( 'mw.msg', 11, function ( assert ) {
+       assert.ok( mw.messages.set( 'hello', 'Hello <b>awesome</b> world' ), 'mw.messages.set: Register' );
+       assert.equal( mw.msg( 'hello' ), 'Hello <b>awesome</b> world', 'Gets message with default options (existing message)' );
+       assert.equal( mw.msg( 'goodbye' ), '<goodbye>', 'Gets message with default options (nonexistent message)' );
 
-       ok( mw.messages.set( 'hello', 'Hello <b>awesome</b> world' ), 'mw.messages.set: Register' );
-       equal( mw.msg( 'hello' ), 'Hello <b>awesome</b> world', 'Gets message with default options (existing message)' );
-       equal( mw.msg( 'goodbye' ), '<goodbye>', 'Gets message with default options (nonexistent message)' );
+       assert.ok( mw.messages.set( 'plural-item' , 'Found $1 {{PLURAL:$1|item|items}}' ) );
+       assert.equal( mw.msg( 'plural-item', 5 ), 'Found 5 items', 'Apply plural for count 5' );
+       assert.equal( mw.msg( 'plural-item', 0 ), 'Found 0 items', 'Apply plural for count 0' );
+       assert.equal( mw.msg( 'plural-item', 1 ), 'Found 1 item', 'Apply plural for count 1' );
 
-       ok( mw.messages.set( 'plural-item' , 'Found $1 {{PLURAL:$1|item|items}}' ) );
-       equal( mw.msg( 'plural-item', 5 ), 'Found 5 items', 'Apply plural for count 5' );
-       equal( mw.msg( 'plural-item', 0 ), 'Found 0 items', 'Apply plural for count 0' );
-       equal( mw.msg( 'plural-item', 1 ), 'Found 1 item', 'Apply plural for count 1' );
-
-       ok( mw.messages.set('gender-plural-msg' , '{{GENDER:$1|he|she|they}} {{PLURAL:$2|is|are}} awesome' ) );
-       equal( mw.msg( 'gender-plural-msg', 'male', 1 ), 'he is awesome', 'Gender test for male, plural count 1' );
-       equal( mw.msg( 'gender-plural-msg', 'female', '1' ), 'she is awesome', 'Gender test for female, plural count 1' );
-       equal( mw.msg( 'gender-plural-msg', 'unknown', 10 ), 'they are awesome', 'Gender test for neutral, plural count 10' );
+       assert.ok( mw.messages.set('gender-plural-msg' , '{{GENDER:$1|he|she|they}} {{PLURAL:$2|is|are}} awesome' ) );
+       assert.equal( mw.msg( 'gender-plural-msg', 'male', 1 ), 'he is awesome', 'Gender test for male, plural count 1' );
+       assert.equal( mw.msg( 'gender-plural-msg', 'female', '1' ), 'she is awesome', 'Gender test for female, plural count 1' );
+       assert.equal( mw.msg( 'gender-plural-msg', 'unknown', 10 ), 'they are awesome', 'Gender test for neutral, plural count 10' );
 
 });
 
-test( 'mw.loader', function() {
+QUnit.asyncTest( 'mw.loader', 2, function ( assert ) {
        var isAwesomeDone;
-       expect(2);
-
-       // Async ahead
-       stop();
 
        mw.loader.testCallback = function () {
-               start();
-               strictEqual( isAwesomeDone, undefined, 'Implementing module is.awesome: isAwesomeDone should still be undefined');
+               QUnit.start();
+               assert.strictEqual( isAwesomeDone, undefined, 'Implementing module is.awesome: isAwesomeDone should still be undefined');
                isAwesomeDone = true;
        };
 
@@ -164,21 +152,17 @@ test( 'mw.loader', function() {
 
                // /sample/awesome.js declares the "mw.loader.testCallback" function
                // which contains a call to start() and ok()
-               strictEqual( isAwesomeDone, true, "test.callback module should've caused isAwesomeDone to be true" );
+               assert.strictEqual( isAwesomeDone, true, "test.callback module should've caused isAwesomeDone to be true" );
                delete mw.loader.testCallback;
 
        }, function () {
-               start();
-               ok( false, 'Error callback fired while loader.using "test.callback" module' );
+               QUnit.start();
+               assert.ok( false, 'Error callback fired while loader.using "test.callback" module' );
        });
 });
 
-test( 'mw.loader.implement', function () {
+QUnit.asyncTest( 'mw.loader.implement', 5, function ( assert ) {
        var isJsExecuted, $element, styleTestUrl;
-       expect(5);
-
-       // Async ahead
-       stop();
 
        styleTestUrl = QUnit.fixurl(
                mw.config.get( 'wgScriptPath' )
@@ -195,14 +179,14 @@ test( 'mw.loader.implement', function () {
                function () {
                        var styleTestTimeout, styleTestStart, styleTestSince;
 
-                       strictEqual( isJsExecuted, undefined, 'javascript not executed multiple times' );
+                       assert.strictEqual( isJsExecuted, undefined, 'javascript not executed multiple times' );
                        isJsExecuted = true;
 
-                       equal( mw.loader.getState( 'test.implement' ), 'ready', 'module state is "ready" while implement() is executing javascript' );
+                       assert.equal( mw.loader.getState( 'test.implement' ), 'ready', 'module state is "ready" while implement() is executing javascript' );
 
                        $element = $( '<div class="mw-test-loaderimplement">Foo bar</div>' ).appendTo( '#qunit-fixture' );
 
-                       equal( mw.msg( 'test-foobar' ), 'Hello Foobar, $1!', 'Messages are loaded before javascript execution' );
+                       assert.equal( mw.msg( 'test-foobar' ), 'Hello Foobar, $1!', 'Messages are loaded before javascript execution' );
 
                        // The @import test. This is, in a way, also an open bug for ResourceLoader
                        // ("execute js after styles are loaded"), but browsers don't offer a way to
@@ -225,16 +209,16 @@ test( 'mw.loader.implement', function () {
                                styleTestSince = new Date().getTime() - styleTestStart;
                                // If it is passing or if we timed out, run the real test and stop the loop
                                if ( isCssImportApplied() || styleTestSince > styleTestTimeout ) {
-                                       equal( $element.css( 'float' ), 'right',
+                                       assert.equal( $element.css( 'float' ), 'right',
                                                'CSS stylesheet via @import was applied (after ' + styleTestSince + 'ms) (bug 34669). ("float: right")'
                                        );
 
-                                       equal( $element.css( 'text-align' ),'center',
+                                       assert.equal( $element.css( 'text-align' ),'center',
                                                'CSS styles after the @import are working ("text-align: center")'
                                        );
 
                                        // Async done
-                                       start();
+                                       QUnit.start();
 
                                        return;
                                }
@@ -261,80 +245,77 @@ test( 'mw.loader.implement', function () {
 
 });
 
-test( 'mw.loader erroneous indirect dependency', function() {
-       expect( 3 );
+QUnit.test( 'mw.loader erroneous indirect dependency', 3, function ( assert ) {
        mw.loader.register( [
                ['test.module1', '0'],
                ['test.module2', '0', ['test.module1']],
                ['test.module3', '0', ['test.module2']]
        ] );
-       mw.loader.implement( 'test.module1', function() { throw new Error( 'expected' ); }, {}, {} );
-       strictEqual( mw.loader.getState( 'test.module1' ), 'error', 'Expected "error" state for test.module1' );
-       strictEqual( mw.loader.getState( 'test.module2' ), 'error', 'Expected "error" state for test.module2' );
-       strictEqual( mw.loader.getState( 'test.module3' ), 'error', 'Expected "error" state for test.module3' );
+       mw.loader.implement( 'test.module1', function () { throw new Error( 'expected' ); }, {}, {} );
+       assert.strictEqual( mw.loader.getState( 'test.module1' ), 'error', 'Expected "error" state for test.module1' );
+       assert.strictEqual( mw.loader.getState( 'test.module2' ), 'error', 'Expected "error" state for test.module2' );
+       assert.strictEqual( mw.loader.getState( 'test.module3' ), 'error', 'Expected "error" state for test.module3' );
 } );
 
-test( 'mw.loader out-of-order implementation', function() {
-       expect( 9 );
+QUnit.test( 'mw.loader out-of-order implementation', 9, function ( assert ) {
        mw.loader.register( [
                ['test.module4', '0'],
                ['test.module5', '0', ['test.module4']],
                ['test.module6', '0', ['test.module5']]
        ] );
-       mw.loader.implement( 'test.module4', function() {}, {}, {} );
-       strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'Expected "ready" state for test.module4' );
-       strictEqual( mw.loader.getState( 'test.module5' ), 'registered', 'Expected "registered" state for test.module5' );
-       strictEqual( mw.loader.getState( 'test.module6' ), 'registered', 'Expected "registered" state for test.module6' );
-       mw.loader.implement( 'test.module6', function() {}, {}, {} );
-       strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'Expected "ready" state for test.module4' );
-       strictEqual( mw.loader.getState( 'test.module5' ), 'registered', 'Expected "registered" state for test.module5' );
-       strictEqual( mw.loader.getState( 'test.module6' ), 'loaded', 'Expected "loaded" state for test.module6' );
+       mw.loader.implement( 'test.module4', function () {}, {}, {} );
+       assert.strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'Expected "ready" state for test.module4' );
+       assert.strictEqual( mw.loader.getState( 'test.module5' ), 'registered', 'Expected "registered" state for test.module5' );
+       assert.strictEqual( mw.loader.getState( 'test.module6' ), 'registered', 'Expected "registered" state for test.module6' );
+       mw.loader.implement( 'test.module6', function () {}, {}, {} );
+       assert.strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'Expected "ready" state for test.module4' );
+       assert.strictEqual( mw.loader.getState( 'test.module5' ), 'registered', 'Expected "registered" state for test.module5' );
+       assert.strictEqual( mw.loader.getState( 'test.module6' ), 'loaded', 'Expected "loaded" state for test.module6' );
        mw.loader.implement( 'test.module5', function() {}, {}, {} );
-       strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'Expected "ready" state for test.module4' );
-       strictEqual( mw.loader.getState( 'test.module5' ), 'ready', 'Expected "ready" state for test.module5' );
-       strictEqual( mw.loader.getState( 'test.module6' ), 'ready', 'Expected "ready" state for test.module6' );
+       assert.strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'Expected "ready" state for test.module4' );
+       assert.strictEqual( mw.loader.getState( 'test.module5' ), 'ready', 'Expected "ready" state for test.module5' );
+       assert.strictEqual( mw.loader.getState( 'test.module6' ), 'ready', 'Expected "ready" state for test.module6' );
 } );
 
-test( 'mw.loader missing dependency', function() {
-       expect( 13 );
+QUnit.test( 'mw.loader missing dependency', 13, function ( assert ) {
        mw.loader.register( [
                ['test.module7', '0'],
                ['test.module8', '0', ['test.module7']],
                ['test.module9', '0', ['test.module8']]
        ] );
-       mw.loader.implement( 'test.module8', function() {}, {}, {} );
-       strictEqual( mw.loader.getState( 'test.module7' ), 'registered', 'Expected "registered" state for test.module7' );
-       strictEqual( mw.loader.getState( 'test.module8' ), 'loaded', 'Expected "loaded" state for test.module8' );
-       strictEqual( mw.loader.getState( 'test.module9' ), 'registered', 'Expected "registered" state for test.module9' );
+       mw.loader.implement( 'test.module8', function () {}, {}, {} );
+       assert.strictEqual( mw.loader.getState( 'test.module7' ), 'registered', 'Expected "registered" state for test.module7' );
+       assert.strictEqual( mw.loader.getState( 'test.module8' ), 'loaded', 'Expected "loaded" state for test.module8' );
+       assert.strictEqual( mw.loader.getState( 'test.module9' ), 'registered', 'Expected "registered" state for test.module9' );
        mw.loader.state( 'test.module7', 'missing' );
-       strictEqual( mw.loader.getState( 'test.module7' ), 'missing', 'Expected "missing" state for test.module7' );
-       strictEqual( mw.loader.getState( 'test.module8' ), 'error', 'Expected "error" state for test.module8' );
-       strictEqual( mw.loader.getState( 'test.module9' ), 'error', 'Expected "error" state for test.module9' );
-       mw.loader.implement( 'test.module9', function() {}, {}, {} );
-       strictEqual( mw.loader.getState( 'test.module7' ), 'missing', 'Expected "missing" state for test.module7' );
-       strictEqual( mw.loader.getState( 'test.module8' ), 'error', 'Expected "error" state for test.module8' );
-       strictEqual( mw.loader.getState( 'test.module9' ), 'error', 'Expected "error" state for test.module9' );
+       assert.strictEqual( mw.loader.getState( 'test.module7' ), 'missing', 'Expected "missing" state for test.module7' );
+       assert.strictEqual( mw.loader.getState( 'test.module8' ), 'error', 'Expected "error" state for test.module8' );
+       assert.strictEqual( mw.loader.getState( 'test.module9' ), 'error', 'Expected "error" state for test.module9' );
+       mw.loader.implement( 'test.module9', function () {}, {}, {} );
+       assert.strictEqual( mw.loader.getState( 'test.module7' ), 'missing', 'Expected "missing" state for test.module7' );
+       assert.strictEqual( mw.loader.getState( 'test.module8' ), 'error', 'Expected "error" state for test.module8' );
+       assert.strictEqual( mw.loader.getState( 'test.module9' ), 'error', 'Expected "error" state for test.module9' );
        mw.loader.using(
                ['test.module7'],
-               function() {
-                       ok( false, "Success fired despite missing dependency" );
-                       ok( true , "QUnit expected() count dummy" );
+               function () {
+                       assert.ok( false, "Success fired despite missing dependency" );
+                       assert.ok( true , "QUnit expected() count dummy" );
                },
-               function( e, dependencies ) {
-                       strictEqual( $.isArray( dependencies ), true, 'Expected array of dependencies' );
-                       deepEqual( dependencies, ['test.module7'], 'Error callback called with module test.module7' );
+               function ( e, dependencies ) {
+                       assert.strictEqual( $.isArray( dependencies ), true, 'Expected array of dependencies' );
+                       assert.deepEqual( dependencies, ['test.module7'], 'Error callback called with module test.module7' );
                }
        );
        mw.loader.using(
                ['test.module9'],
-               function() {
-                       ok( false, "Success fired despite missing dependency" );
-                       ok( true , "QUnit expected() count dummy" );
+               function () {
+                       assert.ok( false, "Success fired despite missing dependency" );
+                       assert.ok( true , "QUnit expected() count dummy" );
                },
-               function( e, dependencies ) {
-                       strictEqual( $.isArray( dependencies ), true, 'Expected array of dependencies' );
+               function ( e, dependencies ) {
+                       assert.strictEqual( $.isArray( dependencies ), true, 'Expected array of dependencies' );
                        dependencies.sort();
-                       deepEqual(
+                       assert.deepEqual(
                                dependencies,
                                ['test.module7', 'test.module8', 'test.module9'],
                                'Error callback called with all three modules as dependencies'
@@ -343,9 +324,7 @@ test( 'mw.loader missing dependency', function() {
        );
 } );
 
-test( 'mw.loader dependency handling', function () {
-       expect( 5 );
-
+QUnit.asyncTest( 'mw.loader dependency handling', 5, function ( assert ) {
        mw.loader.addSource(
                'testloader',
                {
@@ -361,62 +340,52 @@ test( 'mw.loader dependency handling', function () {
        ] );
 
        function verifyModuleStates() {
-               equal( mw.loader.getState( 'testMissing' ), 'missing', 'Module not known to server must have state "missing"' );
-               equal( mw.loader.getState( 'testUsesMissing' ), 'error', 'Module with missing dependency must have state "error"' );
-               equal( mw.loader.getState( 'testUsesNestedMissing' ), 'error', 'Module with indirect missing dependency must have state "error"' );
+               assert.equal( mw.loader.getState( 'testMissing' ), 'missing', 'Module not known to server must have state "missing"' );
+               assert.equal( mw.loader.getState( 'testUsesMissing' ), 'error', 'Module with missing dependency must have state "error"' );
+               assert.equal( mw.loader.getState( 'testUsesNestedMissing' ), 'error', 'Module with indirect missing dependency must have state "error"' );
        }
 
-       stop();
-
        mw.loader.using( ['testUsesNestedMissing'],
                function () {
-                       ok( false, 'Error handler should be invoked.' );
-                       ok( true ); // Dummy to reach QUnit expect()
+                       assert.ok( false, 'Error handler should be invoked.' );
+                       assert.ok( true ); // Dummy to reach QUnit expect()
 
                        verifyModuleStates();
 
-                       start();
+                       QUnit.start();
                },
                function ( e, badmodules ) {
-                       ok( true, 'Error handler should be invoked.' );
+                       assert.ok( true, 'Error handler should be invoked.' );
                        // As soon as server spits out state('testMissing', 'missing');
                        // it will bubble up and trigger the error callback.
                        // Therefor the badmodules array is not testUsesMissing or testUsesNestedMissing.
-                       deepEqual( badmodules, ['testMissing'], 'Bad modules as expected.' );
+                       assert.deepEqual( badmodules, ['testMissing'], 'Bad modules as expected.' );
 
                        verifyModuleStates();
 
-                       start();
+                       QUnit.start();
                }
        );
 } );
 
-test( 'mw.loader bug29107' , function () {
-       expect(2);
-
+QUnit.asyncTest( 'mw.loader bug29107' , 2, function ( assert ) {
        // Message doesn't exist already
-       ok( !mw.messages.exists( 'bug29107' ) );
-
-       // Async! Failure in this test may lead to neither the success nor error callbacks getting called.
-       // Due to QUnit's timeout feauture we won't hang here forever if this happends.
-       stop();
+       assert.ok( !mw.messages.exists( 'bug29107' ) );
 
        mw.loader.implement( 'bug29107.messages-only', [], {}, {'bug29107': 'loaded'} );
        mw.loader.using( 'bug29107.messages-only', function() {
-               start();
-               ok( mw.messages.exists( 'bug29107' ), 'Bug 29107: messages-only module should implement ok' );
+               QUnit.start();
+               assert.ok( mw.messages.exists( 'bug29107' ), 'Bug 29107: messages-only module should implement ok' );
        }, function() {
-               start();
-               ok( false, 'Error callback fired while implementing "bug29107.messages-only" module' );
+               QUnit.start();
+               assert.ok( false, 'Error callback fired while implementing "bug29107.messages-only" module' );
        });
 });
 
-test( 'mw.loader.bug30825', function() {
+QUnit.asyncTest( 'mw.loader.bug30825', 2, function ( assert ) {
        // This bug was actually already fixed in 1.18 and later when discovered in 1.17.
        // Test is for regressions!
 
-       expect(2);
-
        // Forge an URL to the test callback script
        var target = QUnit.fixurl(
                mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/qunitOkCall.js'
@@ -425,33 +394,31 @@ test( 'mw.loader.bug30825', function() {
        // Confirm that mw.loader.load() works with protocol-relative URLs
        target = target.replace( /https?:/, '' );
 
-       equal( target.substr( 0, 2 ), '//',
+       assert.equal( target.substr( 0, 2 ), '//',
                'URL must be relative to test relative URLs!'
        );
 
        // Async!
-       stop();
+       // The target calls QUnit.start
        mw.loader.load( target );
 });
 
-test( 'mw.html', function () {
-       expect(13);
-
-       raises( function () {
+QUnit.test( 'mw.html', 13, function ( assert ) {
+       assert.throws( function () {
                mw.html.escape();
        }, TypeError, 'html.escape throws a TypeError if argument given is not a string' );
 
-       equal( mw.html.escape( '<mw awesome="awesome" value=\'test\' />' ),
+       assert.equal( mw.html.escape( '<mw awesome="awesome" value=\'test\' />' ),
                '&lt;mw awesome=&quot;awesome&quot; value=&#039;test&#039; /&gt;', 'escape() escapes special characters to html entities' );
 
-       equal( mw.html.element(),
+       assert.equal( mw.html.element(),
                '<undefined/>', 'element() always returns a valid html string (even without arguments)' );
 
-       equal( mw.html.element( 'div' ), '<div/>', 'element() Plain DIV (simple)' );
+       assert.equal( mw.html.element( 'div' ), '<div/>', 'element() Plain DIV (simple)' );
 
-       equal( mw.html.element( 'div', {}, '' ), '<div></div>', 'element() Basic DIV (simple)' );
+       assert.equal( mw.html.element( 'div', {}, '' ), '<div></div>', 'element() Basic DIV (simple)' );
 
-       equal(
+       assert.equal(
                mw.html.element(
                        'div', {
                                id: 'foobar'
@@ -460,12 +427,12 @@ test( 'mw.html', function () {
                '<div id="foobar"/>',
                'html.element DIV (attribs)' );
 
-       equal( mw.html.element( 'p', null, 12 ), '<p>12</p>', 'Numbers are valid content and should be casted to a string' );
+       assert.equal( mw.html.element( 'p', null, 12 ), '<p>12</p>', 'Numbers are valid content and should be casted to a string' );
 
-       equal( mw.html.element( 'p', { title: 12 }, '' ), '<p title="12"></p>', 'Numbers are valid attribute values' );
+       assert.equal( mw.html.element( 'p', { title: 12 }, '' ), '<p title="12"></p>', 'Numbers are valid attribute values' );
 
        // Example from https://www.mediawiki.org/wiki/ResourceLoader/Default_modules#mediaWiki.html
-       equal(
+       assert.equal(
                mw.html.element(
                        'div',
                        {},
@@ -477,7 +444,7 @@ test( 'mw.html', function () {
                'Raw inclusion of another element'
        );
 
-       equal(
+       assert.equal(
                mw.html.element(
                        'option', {
                                selected: true
@@ -487,7 +454,7 @@ test( 'mw.html', function () {
                'Attributes may have boolean values. True copies the attribute name to the value.'
        );
 
-       equal(
+       assert.equal(
                mw.html.element(
                        'option', {
                                value: 'foo',
@@ -498,12 +465,12 @@ test( 'mw.html', function () {
                'Attributes may have boolean values. False keeps the attribute from output.'
        );
 
-       equal( mw.html.element( 'div',
+       assert.equal( mw.html.element( 'div',
                        null, 'a' ),
                '<div>a</div>',
                'html.element DIV (content)' );
 
-       equal( mw.html.element( 'a',
+       assert.equal( mw.html.element( 'a',
                        { href: 'http://mediawiki.org/w/index.php?title=RL&action=history' }, 'a' ),
                '<a href="http://mediawiki.org/w/index.php?title=RL&amp;action=history">a</a>',
                'html.element DIV (attribs + content)' );
index 15265db..79768da 100644 (file)
@@ -1,21 +1,12 @@
-module( 'mediawiki.user', QUnit.newMwEnvironment() );
+( function ( mw ) {
 
-test( '-- Initial check', function() {
-       expect(1);
+QUnit.module( 'mediawiki.user', QUnit.newMwEnvironment() );
 
-       ok( mw.user, 'mw.user defined' );
+QUnit.test( 'options', 1, function ( assert ) {
+       assert.ok( mw.user.options instanceof mw.Map, 'options instance of mw.Map' );
 });
 
-
-test( 'options', function() {
-       expect(1);
-
-       ok( mw.user.options instanceof mw.Map, 'options instance of mw.Map' );
-});
-
-test( 'User login status', function() {
-       expect(5);
-
+QUnit.test( 'User login status', 5, function ( assert ) {
        /**
         * Tests can be run under three different conditions:
         *   1) From tests/qunit/index.html, user will be anonymous.
@@ -26,14 +17,16 @@ test( 'User login status', function() {
        // Forge an anonymous user:
        mw.config.set( 'wgUserName', null);
 
-       strictEqual( mw.user.name(), null, 'user.name should return null when anonymous' );
-       ok( mw.user.anonymous(), 'user.anonymous should reutrn true when anonymous' );
+       assert.strictEqual( mw.user.name(), null, 'user.name should return null when anonymous' );
+       assert.ok( mw.user.anonymous(), 'user.anonymous should reutrn true when anonymous' );
 
        // Not part of startUp module
        mw.config.set( 'wgUserName', 'John' );
 
-       equal( mw.user.name(), 'John', 'user.name returns username when logged-in' );
-       ok( !mw.user.anonymous(), 'user.anonymous returns false when logged-in' );
+       assert.equal( mw.user.name(), 'John', 'user.name returns username when logged-in' );
+       assert.ok( !mw.user.anonymous(), 'user.anonymous returns false when logged-in' );
 
-       equal( mw.user.id(), 'John', 'user.id Returns username when logged-in' );
+       assert.equal( mw.user.id(), 'John', 'user.id Returns username when logged-in' );
 });
+
+}( mediaWiki ) );
index 0e700ef..d9b2055 100644 (file)
@@ -1,73 +1,55 @@
-module( 'mediawiki.util', QUnit.newMwEnvironment() );
+QUnit.module( 'mediawiki.util', QUnit.newMwEnvironment() );
 
-test( '-- Initial check', function() {
-       expect(1);
-
-       ok( mw.util, 'mw.util defined' );
+QUnit.test( 'rawurlencode', 1, function ( assert ) {
+       assert.equal( mw.util.rawurlencode( 'Test:A & B/Here' ), 'Test%3AA%20%26%20B%2FHere' );
 });
 
-test( 'rawurlencode', function() {
-       expect(1);
-
-       equal( mw.util.rawurlencode( 'Test:A & B/Here' ), 'Test%3AA%20%26%20B%2FHere' );
-});
-
-test( 'wikiUrlencode', function() {
-       expect(1);
-
-       equal( mw.util.wikiUrlencode( 'Test:A & B/Here' ), 'Test:A_%26_B/Here' );
+QUnit.test( 'wikiUrlencode', 1, function ( assert ) {
+       assert.equal( mw.util.wikiUrlencode( 'Test:A & B/Here' ), 'Test:A_%26_B/Here' );
 });
 
-test( 'wikiGetlink', function() {
-       expect(3);
-
+QUnit.test( 'wikiGetlink', 3, function ( assert ) {
        // Not part of startUp module
        mw.config.set( 'wgArticlePath', '/wiki/$1' );
        mw.config.set( 'wgPageName', 'Foobar' );
 
        var hrefA = mw.util.wikiGetlink( 'Sandbox' );
-       equal( hrefA, '/wiki/Sandbox', 'Simple title; Get link for "Sandbox"' );
+       assert.equal( hrefA, '/wiki/Sandbox', 'Simple title; Get link for "Sandbox"' );
 
        var hrefB = mw.util.wikiGetlink( 'Foo:Sandbox ? 5+5=10 ! (test)/subpage' );
-       equal( hrefB, '/wiki/Foo:Sandbox_%3F_5%2B5%3D10_%21_%28test%29/subpage',
+       assert.equal( hrefB, '/wiki/Foo:Sandbox_%3F_5%2B5%3D10_%21_%28test%29/subpage',
                'Advanced title; Get link for "Foo:Sandbox ? 5+5=10 ! (test)/subpage"' );
 
        var hrefC = mw.util.wikiGetlink();
-       equal( hrefC, '/wiki/Foobar', 'Default title; Get link for current page ("Foobar")' );
+       assert.equal( hrefC, '/wiki/Foobar', 'Default title; Get link for current page ("Foobar")' );
 });
 
-test( 'wikiScript', function() {
-       expect(2);
-
+QUnit.test( 'wikiScript', 2, function ( assert ) {
        mw.config.set({
                'wgScript': '/w/index.php',
                'wgScriptPath': '/w',
                'wgScriptExtension': '.php'
        });
 
-       equal( mw.util.wikiScript(), mw.config.get( 'wgScript' ), 'Defaults to index.php and is equal to wgScript' );
-       equal( mw.util.wikiScript( 'api' ), '/w/api.php', 'API path' );
+       assert.equal( mw.util.wikiScript(), mw.config.get( 'wgScript' ), 'Defaults to index.php and is equal to wgScript' );
+       assert.equal( mw.util.wikiScript( 'api' ), '/w/api.php', 'API path' );
 });
 
-test( 'addCSS', function() {
-       expect(3);
-
+QUnit.test( 'addCSS', 3, function ( assert ) {
        var $testEl = $( '<div>' ).attr( 'id', 'mw-addcsstest' ).appendTo( '#qunit-fixture' );
 
        var style = mw.util.addCSS( '#mw-addcsstest { visibility: hidden; }' );
-       equal( typeof style, 'object', 'addCSS returned an object' );
-       strictEqual( style.disabled, false, 'property "disabled" is available and set to false' );
+       assert.equal( typeof style, 'object', 'addCSS returned an object' );
+       assert.strictEqual( style.disabled, false, 'property "disabled" is available and set to false' );
 
-       equal( $testEl.css( 'visibility' ), 'hidden', 'Added style properties are in effect' );
+       assert.equal( $testEl.css( 'visibility' ), 'hidden', 'Added style properties are in effect' );
 
        // Clean up
        $( style.ownerNode ).remove();
 });
 
-test( 'toggleToc', function() {
-       expect(4);
-
-       strictEqual( mw.util.toggleToc(), null, 'Return null if there is no table of contents on the page.' );
+QUnit.asyncTest( 'toggleToc', 4, function ( assert ) {
+       assert.strictEqual( mw.util.toggleToc(), null, 'Return null if there is no table of contents on the page.' );
 
        var     tocHtml =
        '<table id="toc" class="toc"><tr><td>' +
@@ -80,57 +62,46 @@ test( 'toggleToc', function() {
                $toc = $(tocHtml).appendTo( '#qunit-fixture' ),
                $toggleLink = $( '#togglelink' );
 
-       strictEqual( $toggleLink.length, 1, 'Toggle link is appended to the page.' );
-
-       // Toggle animation is asynchronous
-       // QUnit should not finish this test() untill they are all done
-       stop();
+       assert.strictEqual( $toggleLink.length, 1, 'Toggle link is appended to the page.' );
 
        var actionC = function() {
-               start();
+               QUnit.start();
        };
        var actionB = function() {
-               start(); stop();
-               strictEqual( mw.util.toggleToc( $toggleLink, actionC ), true, 'Return boolean true if the TOC is now visible.' );
+               assert.strictEqual( mw.util.toggleToc( $toggleLink, actionC ), true, 'Return boolean true if the TOC is now visible.' );
        };
        var actionA = function() {
-               strictEqual( mw.util.toggleToc( $toggleLink, actionB ), false, 'Return boolean false if the TOC is now hidden.' );
+               assert.strictEqual( mw.util.toggleToc( $toggleLink, actionB ), false, 'Return boolean false if the TOC is now hidden.' );
        };
 
        actionA();
 });
 
-test( 'getParamValue', function() {
-       expect(5);
-
+QUnit.test( 'getParamValue', 5, function ( assert ) {
        var     url1 = 'http://example.org/?foo=wrong&foo=right#&foo=bad';
 
-       equal( mw.util.getParamValue( 'foo', url1 ), 'right', 'Use latest one, ignore hash' );
-       strictEqual( mw.util.getParamValue( 'bar', url1 ), null, 'Return null when not found' );
+       assert.equal( mw.util.getParamValue( 'foo', url1 ), 'right', 'Use latest one, ignore hash' );
+       assert.strictEqual( mw.util.getParamValue( 'bar', url1 ), null, 'Return null when not found' );
 
        var url2 = 'http://example.org/#&foo=bad';
-       strictEqual( mw.util.getParamValue( 'foo', url2 ), null, 'Ignore hash if param is not in querystring but in hash (bug 27427)' );
+       assert.strictEqual( mw.util.getParamValue( 'foo', url2 ), null, 'Ignore hash if param is not in querystring but in hash (bug 27427)' );
 
        var url3 = 'example.org?' + $.param({ 'TEST': 'a b+c' });
-       strictEqual( mw.util.getParamValue( 'TEST', url3 ), 'a b+c', 'Bug 30441: getParamValue must understand "+" encoding of space' );
+       assert.strictEqual( mw.util.getParamValue( 'TEST', url3 ), 'a b+c', 'Bug 30441: getParamValue must understand "+" encoding of space' );
 
        var url4 = 'example.org?' + $.param({ 'TEST': 'a b+c d' }); // check for sloppy code from r95332 :)
-       strictEqual( mw.util.getParamValue( 'TEST', url4 ), 'a b+c d', 'Bug 30441: getParamValue must understand "+" encoding of space (multiple spaces)' );
+       assert.strictEqual( mw.util.getParamValue( 'TEST', url4 ), 'a b+c d', 'Bug 30441: getParamValue must understand "+" encoding of space (multiple spaces)' );
 });
 
-test( 'tooltipAccessKey', function() {
-       expect(3);
-
-       equal( typeof mw.util.tooltipAccessKeyPrefix, 'string', 'mw.util.tooltipAccessKeyPrefix must be a string' );
-       ok( mw.util.tooltipAccessKeyRegexp instanceof RegExp, 'mw.util.tooltipAccessKeyRegexp instance of RegExp' );
-       ok( mw.util.updateTooltipAccessKeys, 'mw.util.updateTooltipAccessKeys' );
+QUnit.test( 'tooltipAccessKey', 3, function ( assert ) {
+       assert.equal( typeof mw.util.tooltipAccessKeyPrefix, 'string', 'mw.util.tooltipAccessKeyPrefix must be a string' );
+       assert.ok( mw.util.tooltipAccessKeyRegexp instanceof RegExp, 'mw.util.tooltipAccessKeyRegexp instance of RegExp' );
+       assert.ok( mw.util.updateTooltipAccessKeys, 'mw.util.updateTooltipAccessKeys' );
 });
 
-test( '$content', function() {
-       expect(2);
-
-       ok( mw.util.$content instanceof jQuery, 'mw.util.$content instance of jQuery' );
-       strictEqual( mw.util.$content.length, 1, 'mw.util.$content must have length of 1' );
+QUnit.test( '$content', 2, function ( assert ) {
+       assert.ok( mw.util.$content instanceof jQuery, 'mw.util.$content instance of jQuery' );
+       assert.strictEqual( mw.util.$content.length, 1, 'mw.util.$content must have length of 1' );
 });
 
 
@@ -138,12 +109,10 @@ test( '$content', function() {
  * Portlet names are prefixed with 'p-test' to avoid conflict with core
  * when running the test suite under a wiki page.
  * Previously, test elements where invisible to the selector since only
- * one element can have a given id. 
+ * one element can have a given id.
  */
-test( 'addPortletLink', function () {
+QUnit.test( 'addPortletLink', 8, function ( assert ) {
        var pTestTb, pCustom, vectorTabs, tbRL, cuQuux, $cuQuux, tbMW, $tbMW, tbRLDM, caFoo;
-       expect( 8 );
-
        pTestTb = '\
        <div class="portlet" id="p-test-tb">\
                <h5>Toolbox</h5>\
@@ -172,21 +141,21 @@ test( 'addPortletLink', function () {
        tbRL = mw.util.addPortletLink( 'p-test-tb', '//mediawiki.org/wiki/ResourceLoader',
                'ResourceLoader', 't-rl', 'More info about ResourceLoader on MediaWiki.org ', 'l' );
 
-       ok( $.isDomElement( tbRL ), 'addPortletLink returns a valid DOM Element according to $.isDomElement' );
+       assert.ok( $.isDomElement( tbRL ), 'addPortletLink returns a valid DOM Element according to $.isDomElement' );
 
        tbMW = mw.util.addPortletLink( 'p-test-tb', '//mediawiki.org/',
                'MediaWiki.org', 't-mworg', 'Go to MediaWiki.org ', 'm', tbRL );
        $tbMW = $( tbMW );
 
 
-       equal( $tbMW.attr( 'id' ), 't-mworg', 'Link has correct ID set' );
-       equal( $tbMW.closest( '.portlet' ).attr( 'id' ), 'p-test-tb', 'Link was inserted within correct portlet' );
-       equal( $tbMW.next().attr( 'id' ), 't-rl', 'Link is in the correct position (by passing nextnode)' );
+       assert.equal( $tbMW.attr( 'id' ), 't-mworg', 'Link has correct ID set' );
+       assert.equal( $tbMW.closest( '.portlet' ).attr( 'id' ), 'p-test-tb', 'Link was inserted within correct portlet' );
+       assert.equal( $tbMW.next().attr( 'id' ), 't-rl', 'Link is in the correct position (by passing nextnode)' );
 
        cuQuux = mw.util.addPortletLink( 'p-test-custom', '#', 'Quux' );
        $cuQuux = $(cuQuux);
 
-       equal(
+       assert.equal(
                $( '#p-test-custom #c-barmenu ul li' ).length,
                1,
                'addPortletLink did not add the item to all <ul> elements in the portlet (bug 35082)'
@@ -195,49 +164,43 @@ test( 'addPortletLink', function () {
        tbRLDM = mw.util.addPortletLink( 'p-test-tb', '//mediawiki.org/wiki/RL/DM',
                'Default modules', 't-rldm', 'List of all default modules ', 'd', '#t-rl' );
 
-       equal( $( tbRLDM ).next().attr( 'id' ), 't-rl', 'Link is in the correct position (by passing CSS selector)' );
+       assert.equal( $( tbRLDM ).next().attr( 'id' ), 't-rl', 'Link is in the correct position (by passing CSS selector)' );
 
        caFoo = mw.util.addPortletLink( 'p-test-views', '#', 'Foo' );
 
-       strictEqual( $tbMW.find( 'span').length, 0, 'No <span> element should be added for porlets without vectorTabs class.' );
-       strictEqual( $( caFoo ).find( 'span').length, 1, 'A <span> element should be added for porlets with vectorTabs class.' );
+       assert.strictEqual( $tbMW.find( 'span').length, 0, 'No <span> element should be added for porlets without vectorTabs class.' );
+       assert.strictEqual( $( caFoo ).find( 'span').length, 1, 'A <span> element should be added for porlets with vectorTabs class.' );
 });
 
-test( 'jsMessage', function() {
-       expect(1);
-
+QUnit.test( 'jsMessage', 1, function ( assert ) {
        var a = mw.util.jsMessage( "MediaWiki is <b>Awesome</b>." );
-       ok( a, 'Basic checking of return value' );
+       assert.ok( a, 'Basic checking of return value' );
 
        // Clean up
        $( '#mw-js-message' ).remove();
 });
 
-test( 'validateEmail', function() {
-       expect(6);
-
-       strictEqual( mw.util.validateEmail( "" ), null, 'Should return null for empty string ' );
-       strictEqual( mw.util.validateEmail( "user@localhost" ), true, 'Return true for a valid e-mail address' );
+QUnit.test( 'validateEmail', 6, function ( assert ) {
+       assert.strictEqual( mw.util.validateEmail( "" ), null, 'Should return null for empty string ' );
+       assert.strictEqual( mw.util.validateEmail( "user@localhost" ), true, 'Return true for a valid e-mail address' );
 
        // testEmailWithCommasAreInvalids
-       strictEqual( mw.util.validateEmail( "user,foo@example.org" ), false, 'Emails with commas are invalid' );
-       strictEqual( mw.util.validateEmail( "userfoo@ex,ample.org" ), false, 'Emails with commas are invalid' );
+       assert.strictEqual( mw.util.validateEmail( "user,foo@example.org" ), false, 'Emails with commas are invalid' );
+       assert.strictEqual( mw.util.validateEmail( "userfoo@ex,ample.org" ), false, 'Emails with commas are invalid' );
 
        // testEmailWithHyphens
-       strictEqual( mw.util.validateEmail( "user-foo@example.org" ), true, 'Emails may contain a hyphen' );
-       strictEqual( mw.util.validateEmail( "userfoo@ex-ample.org" ), true, 'Emails may contain a hyphen' );
+       assert.strictEqual( mw.util.validateEmail( "user-foo@example.org" ), true, 'Emails may contain a hyphen' );
+       assert.strictEqual( mw.util.validateEmail( "userfoo@ex-ample.org" ), true, 'Emails may contain a hyphen' );
 });
 
-test( 'isIPv6Address', function() {
-       expect(40);
-
+QUnit.test( 'isIPv6Address', 40, function ( assert ) {
        // Shortcuts
-       var     assertFalseIPv6 = function( addy, summary ) {
-                       return strictEqual( mw.util.isIPv6Address( addy ), false, summary );
-               },
-               assertTrueIPv6 = function( addy, summary ) {
-                       return strictEqual( mw.util.isIPv6Address( addy ), true, summary );
-               };
+       function assertFalseIPv6( addy, summary ) {
+               return assert.strictEqual( mw.util.isIPv6Address( addy ), false, summary );
+       }
+       function assertTrueIPv6( addy, summary ) {
+               return assert.strictEqual( mw.util.isIPv6Address( addy ), true, summary );
+       }
 
        // Based on IPTest.php > testisIPv6
        assertFalseIPv6( ':fc:100::', 'IPv6 starting with lone ":"' );
@@ -251,7 +214,7 @@ test( 'isIPv6Address', function() {
        'fc:100:a:d::',
        'fc:100:a:d:1::',
        'fc:100:a:d:1:e::',
-       'fc:100:a:d:1:e:ac::'], function( i, addy ){
+       'fc:100:a:d:1:e:ac::'], function ( i, addy ){
                assertTrueIPv6( addy, addy + ' is a valid IP' );
        });
 
@@ -272,7 +235,7 @@ test( 'isIPv6Address', function() {
        '::fc:100:a:d:1:e',
        '::fc:100:a:d:1:e:ac',
 
-       'fc:100:a:d:1:e:ac:0'], function( i, addy ){
+       'fc:100:a:d:1:e:ac:0'], function ( i, addy ){
                assertTrueIPv6( addy, addy + ' is a valid IP' );
        });
 
@@ -297,16 +260,14 @@ test( 'isIPv6Address', function() {
        assertFalseIPv6( 'fc::100:a:d:1:e:ac:0:1', 'IPv6 with 9 words' );
 });
 
-test( 'isIPv4Address', function() {
-       expect(11);
-
+QUnit.test( 'isIPv4Address', 11, function ( assert ) {
        // Shortcuts
-       var     assertFalseIPv4 = function( addy, summary ) {
-                       return strictEqual( mw.util.isIPv4Address( addy ), false, summary );
-               },
-               assertTrueIPv4 = function( addy, summary ) {
-                       return strictEqual( mw.util.isIPv4Address( addy ), true, summary );
-               };
+       function assertFalseIPv4( addy, summary ) {
+               assert.strictEqual( mw.util.isIPv4Address( addy ), false, summary );
+       }
+       function assertTrueIPv4( addy, summary ) {
+               assert.strictEqual( mw.util.isIPv4Address( addy ), true, summary );
+       }
 
        // Based on IPTest.php > testisIPv4
        assertFalseIPv4( false, 'Boolean false is not an IP' );