From 7ad261837a6e3de586ef1e8de09425bdbbb42e6e Mon Sep 17 00:00:00 2001 From: Javen Wang Date: Sat, 12 Apr 2014 00:35:47 +0800 Subject: [PATCH] disabled suite should still call onStart callback --- spec/core/SuiteSpec.js | 12 ++++++++++-- src/core/Suite.js | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/spec/core/SuiteSpec.js b/spec/core/SuiteSpec.js index be884a20..65d7c9f0 100644 --- a/spec/core/SuiteSpec.js +++ b/spec/core/SuiteSpec.js @@ -67,12 +67,17 @@ describe("Suite", function() { expect(suite.afterFns).toEqual([innerAfter, outerAfter]); }); - it("can be disabled", function() { + it("can be disabled, but still calls callbacks", function() { var env = new j$.Env(), fakeQueueRunner = jasmine.createSpy('fake queue runner'), + onStart = jasmine.createSpy('onStart'), + resultCallback = jasmine.createSpy('resultCallback'), + onComplete = jasmine.createSpy('onComplete'), suite = new j$.Suite({ env: env, description: "with a child suite", + onStart: onStart, + resultCallback: resultCallback, queueRunner: fakeQueueRunner }); @@ -80,9 +85,12 @@ describe("Suite", function() { expect(suite.disabled).toBe(true); - suite.execute(); + suite.execute(onComplete); expect(fakeQueueRunner).not.toHaveBeenCalled(); + expect(onStart).toHaveBeenCalled(); + expect(resultCallback).toHaveBeenCalled(); + expect(onComplete).toHaveBeenCalled(); }); it("delegates execution of its specs and suites", function() { diff --git a/src/core/Suite.js b/src/core/Suite.js index 4b5e573d..60d29d81 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -51,6 +51,9 @@ getJasmineRequireObj().Suite = function() { Suite.prototype.execute = function(onComplete) { var self = this; + + this.onStart(this); + if (this.disabled) { complete(); return; @@ -62,8 +65,6 @@ getJasmineRequireObj().Suite = function() { allFns.push(wrapChildAsAsync(this.children[i])); } - this.onStart(this); - this.queueRunner({ fns: allFns, onComplete: complete