dwf/rva: ensured JSON reporter works if no DOM element specified

This commit is contained in:
pivotal 2008-12-04 11:45:30 -08:00
parent e1cafe7881
commit 8ee209585d
2 changed files with 32 additions and 12 deletions

View File

@ -89,7 +89,7 @@
</provider>
</entry>
</file>
<file leaf-file-name="json_reporter.js" pinned="false" current="true" current-in-tab="true">
<file leaf-file-name="json_reporter.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/json_reporter.js">
<provider selected="true" editor-type-id="text-editor">
<state line="2" column="25" selection-start="87" selection-end="87" vertical-scroll-proportion="0.036750484">
@ -98,10 +98,10 @@
</provider>
</entry>
</file>
<file leaf-file-name="bootstrap.js" pinned="false" current="false" current-in-tab="false">
<file leaf-file-name="bootstrap.js" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<provider selected="true" editor-type-id="text-editor">
<state line="674" column="65" selection-start="20000" selection-end="20000" vertical-scroll-proportion="0.5947007">
<state line="714" column="25" selection-start="21145" selection-end="21145" vertical-scroll-proportion="0.85083413">
<folding />
</state>
</provider>
@ -548,13 +548,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<provider selected="true" editor-type-id="text-editor">
<state line="674" column="65" selection-start="20000" selection-end="20000" vertical-scroll-proportion="0.5947007">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/json_reporter.js">
<provider selected="true" editor-type-id="text-editor">
<state line="2" column="25" selection-start="87" selection-end="87" vertical-scroll-proportion="0.036750484">
@ -562,6 +555,13 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<provider selected="true" editor-type-id="text-editor">
<state line="714" column="25" selection-start="21145" selection-end="21145" vertical-scroll-proportion="0.85083413">
<folding />
</state>
</provider>
</entry>
</component>
</project>

24
test/bootstrap.js vendored
View File

@ -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();