Merge "HTMLSelectAndOtherField/HTMLSelectOrOtherField: Add OOUI implementation"
[lhc/web/wiklou.git] / tests / qunit / data / testrunner.js
index 55bd276..f023ddd 100644 (file)
        ( function () {
                var orgModule = QUnit.module;
 
-               QUnit.module = function ( name, localEnv ) {
+               QUnit.module = function ( name, localEnv, executeNow ) {
+                       if ( QUnit.config.moduleStack.length ) {
+                               // When inside a nested module, don't add our Sinon
+                               // setup/teardown a second time.
+                               return orgModule.apply( this, arguments );
+                       }
+
+                       if ( arguments.length === 2 && typeof localEnv === 'function' ) {
+                               executeNow = localEnv;
+                               localEnv = undefined;
+                       }
+
                        localEnv = localEnv || {};
                        orgModule( name, {
                                setup: function () {
@@ -82,7 +93,7 @@
 
                                        this.sandbox.verifyAndRestore();
                                }
-                       } );
+                       }, executeNow );
                };
        }() );
 
        ( function () {
                var orgModule = QUnit.module;
 
-               QUnit.module = function ( name, localEnv ) {
+               QUnit.module = function ( name, localEnv, executeNow ) {
                        var fixture;
+
+                       if ( arguments.length === 2 && typeof localEnv === 'function' ) {
+                               executeNow = localEnv;
+                               localEnv = undefined;
+                       }
+
                        localEnv = localEnv || {};
                        orgModule( name, {
                                setup: function () {
 
                                        fixture.parentNode.removeChild( fixture );
                                }
-                       } );
+                       }, executeNow );
                };
        }() );
 
 
                        return {
                                setup: function () {
-
                                        // Greetings, mock environment!
                                        mw.config = new MwMap();
                                        mw.config.set( freshConfigCopy( localEnv.config ) );
                                                        );
                                                } );
                                                // Force animations to stop to give the next test a clean start
+                                               $.timers = [];
                                                $.fx.stop();
 
                                                throw new Error( 'Unfinished animations: ' + timers );