From 735ebd6c66874b2b8863abe36b5c8d6375832e49 Mon Sep 17 00:00:00 2001 From: pivotal Date: Thu, 4 Dec 2008 09:37:36 -0800 Subject: [PATCH] dwf/rva: actionColllection now has an optional finishCallback --- jasmine.iws | 116 +++++++++++++++++++++++----------------------- lib/jasmine.js | 9 +++- test/bootstrap.js | 29 ++++++++++++ 3 files changed, 95 insertions(+), 59 deletions(-) diff --git a/jasmine.iws b/jasmine.iws index 38cdd56..abf9ed5 100644 --- a/jasmine.iws +++ b/jasmine.iws @@ -79,44 +79,44 @@ + + + - - - - + - + - + - + + + + - - - @@ -296,6 +296,19 @@ + + - - - - - - - @@ -361,6 +342,25 @@ + + + + + localhost @@ -412,7 +412,7 @@ - + @@ -499,14 +499,14 @@ + + + - - - @@ -522,30 +522,30 @@ + + + + + + + + + + - + - + - - - - - - - - - - diff --git a/lib/jasmine.js b/lib/jasmine.js index 798e253..74b0d3f 100755 --- a/lib/jasmine.js +++ b/lib/jasmine.js @@ -64,6 +64,13 @@ var actionCollection = function () { finished: false, results: nestedResults(), + finish: function () { + if (that.finishCallback) { + that.finishCallback(); + } + that.finished = true; + }, + report: function (result) { that.results.push(result); }, @@ -80,7 +87,7 @@ var actionCollection = function () { next: function() { if (that.index >= that.actions.length) { - that.finished = true; + that.finish(); return; } diff --git a/test/bootstrap.js b/test/bootstrap.js index d0248da..d2f8d13 100755 --- a/test/bootstrap.js +++ b/test/bootstrap.js @@ -541,6 +541,34 @@ var testRunner = function() { }, 1000); } +var testRunnerFinishCallback = function () { + var runner = Runner(); + var foo = 0; + + runner.finish(); + + reporter.test((runner.finishCallback === undefined), + "Runner finish callback was defined"); + reporter.test((runner.finished === true), + "Runner finished flag was not set."); + + + runner.finishCallback = function () { + foo++; + } + + runner.finish(); + + reporter.test((runner.finished === true), + "Runner finished flag was not set."); + reporter.test((runner.finishCallback !== undefined), + "Runner finish callback was not defined"); + reporter.test((foo === 1), + "Runner finish callback was not called"); +} + + + var testNestedResults = function () { // Leaf case @@ -636,6 +664,7 @@ var runTests = function () { testBeforeAndAfterCallbacks(); testSpecScope(); testRunner(); + testRunnerFinishCallback(); testNestedResults(); testReporting();