Merge "Ability to create tests with nested modules"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 22 Jun 2017 14:11:21 +0000 (14:11 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 22 Jun 2017 14:11:21 +0000 (14:11 +0000)
tests/qunit/data/testrunner.js

index a947484..39baf17 100644 (file)
        ( function () {
                var orgModule = QUnit.module;
 
-               QUnit.module = function ( name, localEnv ) {
+               QUnit.module = function ( name, localEnv, executeNow ) {
+                       if ( arguments.length === 2 && typeof localEnv === 'function' ) {
+                               executeNow = localEnv;
+                               localEnv = undefined;
+                       }
+
                        localEnv = localEnv || {};
                        orgModule( name, {
                                setup: function () {
                                                localEnv.teardown.call( this );
                                        }
 
-                                       this.sandbox.verifyAndRestore();
+                                       if ( this.sandbox ) {
+                                               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 );
                };
        }() );