From 8ee209585d651b205962742776602f1f06c7c173 Mon Sep 17 00:00:00 2001 From: pivotal Date: Thu, 4 Dec 2008 11:45:30 -0800 Subject: [PATCH] dwf/rva: ensured JSON reporter works if no DOM element specified --- jasmine.iws | 20 ++++++++++---------- test/bootstrap.js | 24 ++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/jasmine.iws b/jasmine.iws index f4c7c96..d1ede82 100644 --- a/jasmine.iws +++ b/jasmine.iws @@ -89,7 +89,7 @@ - + @@ -98,10 +98,10 @@ - + - + @@ -548,13 +548,6 @@ - - - - - - - @@ -562,6 +555,13 @@ + + + + + + + diff --git a/test/bootstrap.js b/test/bootstrap.js index b22e70f..024c4f2 100755 --- a/test/bootstrap.js +++ b/test/bootstrap.js @@ -658,7 +658,7 @@ var testJSONReporter = function () { }); }); - runner.reporter = JasmineReporters.JSON('json_reporter_results'); + runner.reporter = JasmineReporters.JSON(); reporter.test((runner.reporter !== undefined), "Runner's reporter is undefined"); @@ -671,8 +671,27 @@ var testJSONReporter = function () { setTimeout(function() { reporter.test((runner.reporter.report() === expectedJSONString), 'Jasmine Reporter does not have the expected report, has: ' + runner.reporter.report()); + }, 500); +} + +var testJSONReporterWithDOM = function () { + var runner = Runner(); + describe('one suite description', function () { + it('should be a test', function() { + runs(function () { + this.expects_that(true).should_equal(true); + }); + }); + }); + + runner.reporter = JasmineReporters.JSON('json_reporter_results'); + + runner.execute(); + + expectedJSONString = '{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"passed": true, "message": "Passed."}], "description": "should be a test"}], "description": "one suite description"}], "description": "All Jasmine Suites"}'; + setTimeout(function() { reporter.test((document.getElementById('json_reporter_results').innerHTML === expectedJSONString), - 'Jasmine Reporter did not output the string to the DOM'); + 'Jasmine Reporter did not output the string to the DOM'); }, 500); } @@ -693,6 +712,7 @@ var runTests = function () { testNestedResults(); testResults(); testJSONReporter(); + testJSONReporterWithDOM(); setTimeout(function() { $('spinner').hide();