From: Aleksey Bekh-Ivanov (WMDE) Date: Wed, 2 Aug 2017 14:21:56 +0000 (+0200) Subject: qunit: Test `before` and `after` hooks in QUnit testrunner X-Git-Tag: 1.31.0-rc.0~736^2 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=27fb62af34f1c04a7fdb49122a79049fbd6301b3;p=lhc%2Fweb%2Fwiklou.git qunit: Test `before` and `after` hooks in QUnit testrunner Change-Id: Ib5b5d29e860d37dbec675e5d24c31b57c5e64102 --- diff --git a/tests/qunit/data/testrunner.js b/tests/qunit/data/testrunner.js index eef6703c3f..06c146c298 100644 --- a/tests/qunit/data/testrunner.js +++ b/tests/qunit/data/testrunner.js @@ -622,4 +622,31 @@ } ); } ); + QUnit.module( 'testrunner-hooks-outer', function () { + var beforeHookWasExecuted = false, + afterHookWasExecuted = false; + QUnit.module( 'testrunner-hooks', { + before: function () { + beforeHookWasExecuted = true; + + // This way we can be sure that module `testrunner-hook-after` will always + // be executed after module `testrunner-hooks` + QUnit.module( 'testrunner-hooks-after' ); + QUnit.test( + '`after` hook for module `testrunner-hooks` was executed', + function ( assert ) { + assert.ok( afterHookWasExecuted ); + } + ); + }, + after: function () { + afterHookWasExecuted = true; + } + } ); + + QUnit.test( '`before` hook was executed', function ( assert ) { + assert.ok( beforeHookWasExecuted ); + } ); + } ); + }( jQuery, mediaWiki, QUnit ) );