From: Aleksey Bekh-Ivanov (WMDE) Date: Thu, 1 Jun 2017 22:14:56 +0000 (+0200) Subject: Ability to create tests with nested modules X-Git-Tag: 1.31.0-rc.0~2928^2 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=0a208911a257;p=lhc%2Fweb%2Fwiklou.git Ability to create tests with nested modules Change-Id: Ie0bf2dcfb63e7dc53cd5afe411e2fbb8d1bbfd73 --- diff --git a/tests/qunit/data/testrunner.js b/tests/qunit/data/testrunner.js index a947484727..39baf17013 100644 --- a/tests/qunit/data/testrunner.js +++ b/tests/qunit/data/testrunner.js @@ -63,7 +63,12 @@ ( 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 () { @@ -80,9 +85,11 @@ localEnv.teardown.call( this ); } - this.sandbox.verifyAndRestore(); + if ( this.sandbox ) { + this.sandbox.verifyAndRestore(); + } } - } ); + }, executeNow ); }; }() ); @@ -90,8 +97,14 @@ ( 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 () { @@ -110,7 +123,7 @@ fixture.parentNode.removeChild( fixture ); } - } ); + }, executeNow ); }; }() );