From 72ba4ea90a3637664f2c81c45b8e233fbe20302c Mon Sep 17 00:00:00 2001 From: pivotal Date: Wed, 10 Dec 2008 10:30:01 -0800 Subject: [PATCH] dwf/rva: better aliasing for getting to results at each level --- jasmine.iws | 137 ++++++++++++++++++++++------------------------ lib/jasmine.js | 4 ++ test/bootstrap.js | 91 +++++++++++++++++++++++++++++- 3 files changed, 158 insertions(+), 74 deletions(-) diff --git a/jasmine.iws b/jasmine.iws index 0ee516f..43d69e1 100644 --- a/jasmine.iws +++ b/jasmine.iws @@ -83,7 +83,7 @@ - + @@ -92,16 +92,16 @@ - + - + - + @@ -110,16 +110,7 @@ - - - - - - - - - - + @@ -314,32 +305,12 @@ - - - - - - - - - - - - - - - - - - - + @@ -516,39 +507,32 @@ + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + @@ -564,16 +548,23 @@ - + - + - + - + + + + + + + + diff --git a/lib/jasmine.js b/lib/jasmine.js index 6c7294b..6200c3e 100755 --- a/lib/jasmine.js +++ b/lib/jasmine.js @@ -259,6 +259,7 @@ var it = function (description, func) { return that; } + that.expectationResults = that.results.results; that.runs = addToQueue; jasmine.currentSuite.specs.push(that); @@ -300,6 +301,7 @@ var describe = function (description, spec_definitions) { spec_definitions(); that.results.description = description; + that.specResults = that.results.results; that.finishCallback = function () { if (jasmine.reporter) { @@ -322,6 +324,8 @@ var Runner = function () { } } + that.suiteResults = that.results.results; + jasmine.currentRunner = that; return that; } diff --git a/test/bootstrap.js b/test/bootstrap.js index 60c5dee..34069ac 100755 --- a/test/bootstrap.js +++ b/test/bootstrap.js @@ -760,6 +760,93 @@ var testJSONReporterWithDOM = function () { }, 250); } +var testHandlesBlankSpecs = function () { + jasmine = Jasmine.init(); + var runner = Runner(); + + describe('Suite for handles blank specs', function () { + it('should be a test with a blank runs block', function() { + runs(function () { + }); + }); + it('should be a blank (empty function) test', function() { + + }); + + }); + runner.execute(); + + setTimeout(function() { + reporter.test((runner.results.results[0].results.results.length === 2), + 'Should have found 2 spec results, got ' + runner.results.results[0].results.results.length ); + reporter.test((runner.results.results[0].results.passedCount === 2), + 'Should have found 2 passing specs, got ' + runner.results.results[0].results.passedCount); + }, 250); +} + +var testResultsAliasing = function () { + jasmine = Jasmine.init(); + var runner = Runner(); + + describe('Suite for result aliasing test', function () { + + it('should be a test', function() { + runs(function () { + this.expects_that(true).should_equal(true); + }); + }); + + }); + + describe('Suite number two for result aliasing test', function () { + it('should be a passing test', function() { + runs(function () { + this.expects_that(true).should_equal(true); + }); + }); + + it('should be a passing test', function() { + runs(function () { + this.expects_that(true).should_equal(true); + }); + }); + + }); + + + runner.execute(); + + setTimeout(function() { + + reporter.test((runner.suiteResults !== undefined), + 'runner.suiteResults was not defined'); + + reporter.test((runner.suiteResults == runner.results.results), + 'runner.suiteResults should have been ' + Object.toJSON(runner.results.results) + + ', but was ' + Object.toJSON(runner.suiteResults)); + + reporter.test((runner.suiteResults[1] == runner.results.results[1]), + 'runner.suiteResults should have been ' + Object.toJSON(runner.results.results[1]) + + ', but was ' + Object.toJSON(runner.suiteResults[1])); + + reporter.test((runner.suites[0].specResults !== undefined), + 'runner.suites[0].specResults was not defined'); + + reporter.test((runner.suites[0].specResults == runner.results.results[0].results), + 'runner.suites[0].specResults should have been ' + Object.toJSON(runner.results.results[0].results) + + ', but was ' + Object.toJSON(runner.suites[0].specResults)); + + reporter.test((runner.suites[0].specs[0].expectationResults !== undefined), + 'runner.suites[0].specs[0].expectationResults was not defined'); + + reporter.test((runner.suites[0].specs[0].expectationResults == runner.results.results[0].results[0].results), + 'runner.suites[0].specs[0].expectationResults should have been ' + Object.toJSON(runner.results.results[0].results[0].results) + + ', but was ' + Object.toJSON(runner.suites[0].specs[0].expectationResults)); + + }, 250); +} + + var runTests = function () { $('spinner').show(); @@ -775,11 +862,12 @@ var runTests = function () { testRunnerFinishCallback(); testNestedResults(); testResults(); +// testHandlesBlankSpecs(); // Timing starts to matter with these tests; ALWAYS use setTimeout() setTimeout(function () { testReporterWithCallbacks(); - }, 2000); + }, 2500); setTimeout(function () { testJSONReporter(); }, 3500); @@ -787,6 +875,7 @@ var runTests = function () { testJSONReporterWithDOM(); }, 5000); + testResultsAliasing(); setTimeout(function() { $('spinner').hide(); reporter.summary();