From e6262d9ca4ffddf49b16965d342de44233ae3fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rn=20Zaefferer?= Date: Fri, 10 Oct 2014 13:37:08 +0200 Subject: [PATCH] Core: Remove the newly introduced global hooks until we have consensus Between locating the hooks in `QUnit` or `QUnit.config` and making them simple setters and callback lists (like QUnit.done et al) and upcoming plans for nested suites, we decided not to release this feature, for now. I'm keeping the abstractions for hooks in place, so it should be trivial to bring this back in whatever form we decide on later. Effectively reverts 5ee31a083af3b17187f90cde54885bcc46d3dd8f and follow-up commits. Fixes #665 Ref #633 Ref #635 Ref #647 --- src/test.js | 4 +--- test/modules.js | 59 ------------------------------------------------- 2 files changed, 1 insertion(+), 62 deletions(-) diff --git a/src/test.js b/src/test.js index 33799fb2e..ab0b72511 100644 --- a/src/test.js +++ b/src/test.js @@ -125,6 +125,7 @@ Test.prototype = { }; }, + // Currently only used for module-level hooks, can be used to add global level ones hooks: function( handler ) { var hooks = []; @@ -133,9 +134,6 @@ Test.prototype = { return hooks; } - if ( QUnit.objectType( config[ handler ] ) === "function" ) { - hooks.push( this.queueHook( config[ handler ], handler ) ); - } if ( this.moduleTestEnvironment && QUnit.objectType( this.moduleTestEnvironment[ handler ] ) === "function" ) { hooks.push( this.queueHook( this.moduleTestEnvironment[ handler ], handler ) ); } diff --git a/test/modules.js b/test/modules.js index e8027cefb..5f3a5efca 100644 --- a/test/modules.js +++ b/test/modules.js @@ -1,62 +1,3 @@ -// Before and after each tests -QUnit.config.beforeEach = function() { - this.lastHook = "global-beforeEach"; -}; - -QUnit.config.afterEach = function( assert ) { - if ( this.hooksTest ) { - assert.strictEqual( this.lastHook, "module-afterEach", "Global afterEach runs after module's afterEach" ); - this.hooksTest = false; - } - - if ( this.contextTest ) { - assert.ok( true ); - this.contextTest = false; - } -}; - -QUnit.module( "beforeEach/afterEach", { - beforeEach: function( assert ) { - assert.strictEqual( this.lastHook, "global-beforeEach", "Global beforeEach runs before module's beforeEach" ); - this.lastHook = "module-beforeEach"; - }, - afterEach: function( assert ) { - if ( this.hooksTest ) { - assert.strictEqual( this.lastHook, "test-block", "Module's afterEach runs after current test block" ); - this.lastHook = "module-afterEach"; - } - } -}); - -QUnit.test( "hooks order", function( assert ) { - assert.expect( 4 ); - - // This will trigger an assertion on the global and one on the module's afterEach - this.hooksTest = true; - - assert.strictEqual( this.lastHook, "module-beforeEach", "Module's beforeEach runs before current test block" ); - this.lastHook = "test-block"; -}); - -QUnit.module( "Test context object", { - beforeEach: function( assert ) { - var key, - keys = []; - - for ( key in this ) { - keys.push( key ); - } - assert.deepEqual( keys, [ "helper", "lastHook" ] ); - }, - afterEach: function() {}, - helper: function() {} -}); - -QUnit.test( "keys", function( assert ) { - assert.expect( 2 ); - this.contextTest = true; -}); - QUnit.module( "afterEach and QUnit.stop", { beforeEach: function() { this.state = false;