From 0a208911a257554e59d4664e82f66827e9ed7c43 Mon Sep 17 00:00:00 2001 From: "Aleksey Bekh-Ivanov (WMDE)" Date: Fri, 2 Jun 2017 00:14:56 +0200 Subject: [PATCH] Ability to create tests with nested modules Change-Id: Ie0bf2dcfb63e7dc53cd5afe411e2fbb8d1bbfd73 --- tests/qunit/data/testrunner.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) 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 ); }; }() ); -- 2.20.1