dwf: made Jasmine & Jasmine.Reporters namespaces; the instance of Jasmine is now just jasmine.

This commit is contained in:
pivotal 2008-12-08 13:01:06 -08:00
parent b8a8dc4562
commit 821fb54934
9 changed files with 157 additions and 158 deletions

View File

@ -129,20 +129,37 @@ Suites are executed in the order in which `describe()` calls are made, usually i
You don't need a DOM to run your tests, but you do need a page on which to load & execute your JS. Include the `jasmine.js` file in a script tag as well as the JS file with your specs. You can also use this page for reporting. More on that in a moment.
// include example.html
Here's the example HTML file (in `jasmine/example`):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Example</title>
<script type="text/javascript" src="../lib/jasmine.js"></script>
<script type="text/javascript" src="example.js"></script>
<link type="text/css" rel="stylesheet" href="../lib/jasmine.css"/>
</head>
<body>
<h1>
Running Jasmine Example Specs
</h1>
<div id="results"></div>
<script type="text/javascript">
jasmine.execute();
setTimeout(function () {
document.getElementById('results').innerHTML = 'It\'s alive! :' +
(jasmine.currentRunner.results.passedCount === 1);
}, 250);
</script>
</body>
</html>
### Reports
no reporting yet other than Runner.results, which is walkable
If a reporter exists on the Jasmine instance (named `jasmine`), it will be called when each spec, suite and the overall runner complete. If you're at the single-spec result level, you'll get a spec description, whether it passed or failed, and what the failure message was. At the suite & runner report level, you'll get the total specs run so far, the passed counts, failed counts, and a description (of the suite or runner).
#### JSON Reporter
Coming soon.
#### HTML Reporter
Coming soon.
#### In-line HTML Reporter
Coming soon.
There is a `Jasmine.Reporters` namespace for you to see how to handle reporting. See the file `json_reporter.js`, which takes the results objects and turns them into JSON strings, for two examples of how to make the results callbacks work for you.
### Custom Matchers
@ -157,6 +174,13 @@ A Matcher has a method name, takes an expected value as it's only parameter, has
Feel free to define your own matcher as needed in your code. If you'd like to add Matchers to Jasmine, please write tests.
### Limitations
You can only have one instance of Jasmine (which is a container for a runner) running at any given time. As you can see from `bootstrap.js`, this means you have to wait until a runner is done before defining suites & specs for another runner.
This is a bit sloppy and will be fixed at some point - but it allows for a nicer syntax when defining your specs. For now we expect this to be fine as most of the time having multiple suites is sufficient for isolating application-level code.
Contributing and Tests
----------------------
@ -171,17 +195,13 @@ Your contributions are welcome. Please submit tests with your pull request.
* [Davis W. Frank](dwfrank@pivotallabs.com), Pivotal Labs
* [Rajan Agaskar](rajan@pivotallabs.com), Pivotal Labs
## Acknowledgments
A big shout out to the various JavaScript test framework authors, especially TJ for [JSpec](http://github.com/visionmedia/jspec/tree/master) - we played with it a bit before deciding that we really needed to roll our own.
## TODO List
In no particular order:
* protect the global-ness of some variables & functions
* Suite beforeAll and afterAll functions
* add a description to runs()
* suite.beforeAll and suite.afterAll
* JSON reporter
* HTML reporter
* HTML reporter (callback driven)

View File

@ -13,9 +13,10 @@
</h1>
<div id="results"></div>
<script type="text/javascript">
Jasmine.execute();
jasmine.execute();
setTimeout(function () {
document.getElementById('results').innerHTML = 'It\'s alive! :' + (Jasmine.results.passedCount ==1);
document.getElementById('results').innerHTML = 'It\'s alive! :' +
(jasmine.currentRunner.results.passedCount === 1);
}, 250);
</script>
</body>

View File

@ -89,10 +89,10 @@
</provider>
</entry>
</file>
<file leaf-file-name="json_reporter.js" pinned="false" current="false" current-in-tab="false">
<file leaf-file-name="json_reporter.js" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/json_reporter.js">
<provider selected="true" editor-type-id="text-editor">
<state line="6" column="36" selection-start="284" selection-end="284" vertical-scroll-proportion="0.11025145">
<state line="36" column="7" selection-start="1033" selection-end="1033" vertical-scroll-proportion="0.6615087">
<folding />
</state>
</provider>
@ -101,16 +101,16 @@
<file leaf-file-name="bootstrap.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<provider selected="true" editor-type-id="text-editor">
<state line="53" column="39" selection-start="1542" selection-end="1542" vertical-scroll-proportion="0.5166163">
<state line="751" column="29" selection-start="22512" selection-end="22512" vertical-scroll-proportion="0.44749755">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="jasmine.js" pinned="false" current="true" current-in-tab="true">
<file leaf-file-name="jasmine.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
<provider selected="true" editor-type-id="text-editor">
<state line="198" column="17" selection-start="4329" selection-end="4329" vertical-scroll-proportion="0.7901354">
<state line="155" column="4" selection-start="3291" selection-end="3291" vertical-scroll-proportion="-2.7886906">
<folding />
</state>
</provider>
@ -119,7 +119,7 @@
<file leaf-file-name="example.html" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/example.html">
<provider selected="true" editor-type-id="text-editor">
<state line="4" column="24" selection-start="145" selection-end="145" vertical-scroll-proportion="0.078756474">
<state line="0" column="0" selection-start="0" selection-end="721" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@ -430,22 +430,22 @@
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.21091811" order="0" />
<window_info id="RDoc" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32841328" order="1" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="1" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.25" order="1" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="14" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" order="6" />
<window_info id="Module Dependencies" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" />
<window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" />
<window_info id="Module Dependencies" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="6" />
<window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="11" />
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="4" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="1" />
<window_info id="Maven projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" />
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
<window_info id="Maven projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="5" />
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="12" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="2" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="2" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" order="0" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" order="4" />
<window_info id="IDEtalk Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
<window_info id="Duplicates" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
<window_info id="IDEtalk Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="13" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="9" />
<window_info id="Duplicates" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="10" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="0" />
<window_info id="Web" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="2" />
<window_info id="EJB" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="3" />
@ -507,6 +507,23 @@
</GetOptions>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
<provider selected="true" editor-type-id="text-editor">
<state line="10" column="7" selection-start="500" selection-end="500" vertical-scroll-proportion="0.19689119">
<folding />
</state>
</provider>
<provider editor-type-id="HtmlPreview">
<state />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<provider selected="true" editor-type-id="text-editor">
<state line="751" column="29" selection-start="22512" selection-end="22512" vertical-scroll-proportion="0.44749755">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/jasmine.css">
<provider selected="true" editor-type-id="text-editor">
<state line="16" column="8" selection-start="315" selection-end="315" vertical-scroll-proportion="0.29400387">
@ -521,19 +538,16 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
<provider selected="true" editor-type-id="text-editor">
<state line="10" column="7" selection-start="500" selection-end="500" vertical-scroll-proportion="0.19689119">
<state line="155" column="4" selection-start="3291" selection-end="3291" vertical-scroll-proportion="-2.7886906">
<folding />
</state>
</provider>
<provider editor-type-id="HtmlPreview">
<state />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/example.html">
<provider selected="true" editor-type-id="text-editor">
<state line="4" column="24" selection-start="145" selection-end="145" vertical-scroll-proportion="0.078756474">
<state line="0" column="0" selection-start="0" selection-end="721" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@ -543,21 +557,7 @@
</entry>
<entry file="file://$PROJECT_DIR$/lib/json_reporter.js">
<provider selected="true" editor-type-id="text-editor">
<state line="6" column="36" selection-start="284" selection-end="284" vertical-scroll-proportion="0.11025145">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<provider selected="true" editor-type-id="text-editor">
<state line="53" column="39" selection-start="1542" selection-end="1542" vertical-scroll-proportion="0.5166163">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
<provider selected="true" editor-type-id="text-editor">
<state line="198" column="17" selection-start="4329" selection-end="4329" vertical-scroll-proportion="0.7901354">
<state line="36" column="7" selection-start="1033" selection-end="1033" vertical-scroll-proportion="0.6615087">
<folding />
</state>
</provider>

View File

@ -152,17 +152,35 @@ var queuedFunction = function(func, timeout, spec) {
* Jasmine
******************************************************************************/
var Jasmine = {}
Jasmine.init = function () {
var that = {
currentSpec: null,
currentSuite: null,
currentRunner: null,
execute: function () {
that.currentRunner.execute();
}
}
return that;
}
var jasmine = Jasmine.init();
/*
* Matchers methods; add your own with Matchers.method()
* Jasmine.Matchers methods; add your own with Jasmine.Matchers.method() - don't forget to write a test
*
*/
Matchers = function (actual, results) {
Jasmine.Matchers = function (actual, results) {
this.actual = actual;
this.passing_message = 'Passed.'
this.results = results || nestedResults();
}
Matchers.method('report', function (result, failing_message) {
Jasmine.Matchers.method('report', function (result, failing_message) {
this.results.push({
passed: result,
@ -172,12 +190,12 @@ Matchers.method('report', function (result, failing_message) {
return result;
});
Matchers.method('should_equal', function (expected) {
Jasmine.Matchers.method('should_equal', function (expected) {
return this.report((this.actual === expected),
'Expected ' + expected + ' but got ' + this.actual + '.');
});
Matchers.method('should_not_equal', function (expected) {
Jasmine.Matchers.method('should_not_equal', function (expected) {
return this.report((this.actual !== expected),
'Expected ' + expected + ' to not equal ' + this.actual + ', but it does.');
});
@ -196,7 +214,7 @@ var it = function (description, func) {
results: nestedResults(),
expects_that: function (actual) {
return new Matchers(actual, that.results);
return new Jasmine.Matchers(actual, that.results);
},
waits: function (timeout) {
@ -209,8 +227,8 @@ var it = function (description, func) {
},
finishCallback: function () {
if (Jasmine.reporter) {
Jasmine.reporter.reportSpecResults(that.results);
if (jasmine.reporter) {
jasmine.reporter.reportSpecResults(that.results);
}
},
@ -243,8 +261,8 @@ var it = function (description, func) {
that.runs = addToQueue;
currentSuite.specs.push(that);
currentSpec = that;
jasmine.currentSuite.specs.push(that);
jasmine.currentSpec = that;
if (func) {
func();
@ -255,19 +273,19 @@ var it = function (description, func) {
}
var runs = function (func) {
currentSpec.runs(func);
jasmine.currentSpec.runs(func);
}
var waits = function (timeout) {
currentSpec.waits(timeout);
jasmine.currentSpec.waits(timeout);
}
var beforeEach = function (beforeEach) {
currentSuite.beforeEach = beforeEach;
jasmine.currentSuite.beforeEach = beforeEach;
}
var afterEach = function (afterEach) {
currentSuite.afterEach = afterEach;
jasmine.currentSuite.afterEach = afterEach;
}
var describe = function (description, spec_definitions) {
@ -276,16 +294,16 @@ var describe = function (description, spec_definitions) {
that.description = description;
that.specs = that.actions;
currentSuite = that;
Jasmine.suites.push(that);
jasmine.currentSuite = that;
jasmine.currentRunner.suites.push(that);
spec_definitions();
that.results.description = description;
that.finishCallback = function () {
if (Jasmine.reporter) {
Jasmine.reporter.reportSuiteResults(that.results);
if (jasmine.reporter) {
jasmine.reporter.reportSuiteResults(that.results);
}
}
@ -299,26 +317,24 @@ var Runner = function () {
that.results.description = 'All Jasmine Suites';
that.finishCallback = function () {
if (that.reporter) {
that.reporter.reportRunnerResults(that.results);
if (jasmine.reporter) {
jasmine.reporter.reportRunnerResults(that.results);
}
}
Jasmine = that;
jasmine.currentRunner = that;
return that;
}
var Jasmine = Runner();
var currentSuite;
var currentSpec;
jasmine.currentRunner = Runner();
/* JasmineReporters.reporter
* Base object that will get called whenever a Spec, Suite, or Runner is done. It is up to
* descendants of this object to do something with the results (see json_reporter.js)
*/
var JasmineReporters = {};
Jasmine.Reporters = {};
JasmineReporters.reporter = function (callbacks) {
Jasmine.Reporters.reporter = function (callbacks) {
var that = {
callbacks: callbacks || {},

View File

@ -3,8 +3,8 @@
* Basic reporter that keeps a JSON string of the most recent Spec, Suite or Runner
* result. Calling application can then do whatever it wants/needs with the string;
*/
JasmineReporters.JSON = function () {
var that = JasmineReporters.reporter();
Jasmine.Reporters.JSON = function () {
var that = Jasmine.Reporters.reporter();
that.specJSON = '';
that.suiteJSON = '';
that.runnerJSON = '';
@ -27,7 +27,7 @@ JasmineReporters.JSON = function () {
return that;
}
var domWriter = function (elementId) {
Jasmine.Reporters.domWriter = function (elementId) {
var that = {
element: document.getElementById(elementId),
@ -43,10 +43,10 @@ var domWriter = function (elementId) {
return that;
}
JasmineReporters.JSONtoDOM = function (elementId) {
var that = JasmineReporters.JSON();
Jasmine.Reporters.JSONtoDOM = function (elementId) {
var that = Jasmine.Reporters.JSON();
that.domWriter = domWriter(elementId);
that.domWriter = Jasmine.Reporters.domWriter(elementId);
var writeRunnerResults = function (results) {
that.domWriter.write(Object.toJSON(results));
@ -56,18 +56,3 @@ JasmineReporters.JSONtoDOM = function (elementId) {
return that;
}
//JasmineReporters.IncrementalJSON = function (elementId) {
// var that = JasmineReporters.reporter(elementId);
//
// that.reportSpecResults = function (results) {
// that.output = Object.toJSON(results);
// if (that.element) {
// that.element.innerHTML += that.output;
// }
// }
//
// return that;
//}

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
</project-private>

View File

@ -1,3 +0,0 @@
main.file=
platform.active=Ruby
source.encoding=UTF-8

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.ruby.rubyproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/ruby-project/1">
<name>jasmine</name>
<source-roots/>
<test-roots/>
</data>
</configuration>
</project>

69
test/bootstrap.js vendored
View File

@ -42,19 +42,19 @@ var reporter = function () {
}();
var testMatchersComparisons = function () {
var expected = new Matchers(true);
var expected = new Jasmine.Matchers(true);
reporter.test(expected.should_equal(true),
'expects_that(true).should_equal(true) returned false');
expected = new Matchers(false);
expected = new Jasmine.Matchers(false);
reporter.test(!(expected.should_equal(true)),
'expects_that(true).should_equal(true) returned true');
expected = new Matchers(true);
expected = new Jasmine.Matchers(true);
reporter.test(expected.should_not_equal(false),
'expects_that(true).should_not_equal(false) retruned false');
expected = new Matchers(true);
expected = new Jasmine.Matchers(true);
reporter.test(!(expected.should_not_equal(true)),
'expects_that(true).should_not_equal(false) retruned true');
}
@ -62,7 +62,7 @@ var testMatchersComparisons = function () {
var testMatchersReporting = function () {
var results = [];
var expected = new Matchers(true, results);
var expected = new Jasmine.Matchers(true, results);
expected.should_equal(true);
expected.should_equal(false);
@ -76,14 +76,14 @@ var testMatchersReporting = function () {
"Second spec did pass");
results = [];
expected = new Matchers(false, results);
expected = new Jasmine.Matchers(false, results);
expected.should_equal(true);
reporter.test((results[0].message == 'Expected true but got false.'),
"Failed expectation didn't test the failure message");
results = [];
expected = new Matchers(true, results);
expected = new Jasmine.Matchers(true, results);
expected.should_equal(true);
reporter.test((results[0].message == 'Passed.'),
@ -502,7 +502,7 @@ var testRunner = function() {
it('should be a test');
});
reporter.test((runner.suites.length === 1),
"Runner expected one suite");
"Runner expected one suite, got " + runner.suites.length);
runner = Runner();
describe('one suite description', function () {
@ -535,7 +535,7 @@ var testRunner = function() {
setTimeout(function () {
reporter.test((runner.suites.length === 2),
"Runner expected two suites");
"Runner expected two suites, got " + runner.suites.length);
reporter.test((runner.suites[0].specs[0].results.results[0].passed === true),
"Runner should have run specs in first suite");
reporter.test((runner.suites[1].specs[0].results.results[0].passed === false),
@ -649,11 +649,9 @@ var testResults = function () {
}
var testReporterWithCallbacks = function () {
var foo = 0;
var bar = 0;
var baz = 0;
jasmine = Jasmine.init();
var runner = Runner();
describe('Suite for JSON Reporter with Callbacks', function () {
it('should be a test', function() {
runs(function () {
@ -675,31 +673,24 @@ var testReporterWithCallbacks = function () {
});
var foo = 0;
var bar = 0;
var baz = 0;
var specCallback = function (results) {
foo++;
}
var specCallback = function (results) { foo++; }
var suiteCallback = function (results) { bar++; }
var runnerCallback = function (results) { baz++; }
var suiteCallback = function (results) {
bar++;
}
var runnerCallback = function (results) {
baz++;
}
callbackFunctions = {
jasmine.reporter = Jasmine.Reporters.reporter({
specCallback: specCallback,
suiteCallback: suiteCallback,
runnerCallback: runnerCallback
}
runner.reporter = JasmineReporters.reporter(callbackFunctions);
});
runner.execute();
setTimeout(function() {
reporter.test((foo === 3),
'foo was expected to be 1, was ' + foo);
'foo was expected to be 3, was ' + foo);
reporter.test((bar === 2),
'bar was expected to be 2, was ' + bar);
reporter.test((baz === 1),
@ -709,7 +700,9 @@ var testReporterWithCallbacks = function () {
}
var testJSONReporter = function () {
jasmine = Jasmine.init();
var runner = Runner();
describe('Suite for JSON Reporter, NO DOM', function () {
it('should be a test', function() {
runs(function () {
@ -718,7 +711,7 @@ var testJSONReporter = function () {
});
});
runner.reporter = JasmineReporters.JSON();
jasmine.reporter = Jasmine.Reporters.JSON();
runner.execute();
@ -727,17 +720,17 @@ var testJSONReporter = function () {
var expectedSuiteJSON = '{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"passed": true, "message": "Passed."}], "description": "should be a test"}], "description": "Suite for JSON Reporter, NO DOM"}';
var expectedRunnerJSON = '{"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": "Suite for JSON Reporter, NO DOM"}], "description": "All Jasmine Suites"}';
specJSON = runner.reporter.specJSON;
specJSON = jasmine.reporter.specJSON;
reporter.test((specJSON === expectedSpecJSON),
'JSON Reporter does not have the expected Spec results report.<br /> <b>Expected:</b><br /> ' + expectedSpecJSON +
'<br /><b>Got:</b><br /> ' + specJSON);
suiteJSON = runner.reporter.suiteJSON;
suiteJSON = jasmine.reporter.suiteJSON;
reporter.test((suiteJSON === expectedSuiteJSON),
'JSON Reporter does not have the expected Suite results report.<br /> <b>Expected:</b><br /> ' + expectedSuiteJSON +
'<br /><b>Got:</b><br /> ' + suiteJSON);
runnerJSON = runner.reporter.runnerJSON;
runnerJSON = jasmine.reporter.runnerJSON;
reporter.test((runnerJSON === expectedRunnerJSON),
'JSON Reporter does not have the expected Runner results report.<br /> <b>Expected:</b><br /> ' + expectedRunnerJSON +
'<br /><b>Got:</b><br /> ' + runnerJSON);
@ -745,7 +738,9 @@ var testJSONReporter = function () {
}
var testJSONReporterWithDOM = function () {
jasmine = Jasmine.init();
var runner = Runner();
describe('Suite for JSON Reporter/DOM', function () {
it('should be a test', function() {
runs(function () {
@ -754,7 +749,7 @@ var testJSONReporterWithDOM = function () {
});
});
runner.reporter = JasmineReporters.JSONtoDOM('json_reporter_results');
jasmine.reporter = Jasmine.Reporters.JSONtoDOM('json_reporter_results');
runner.execute();
setTimeout(function() {
@ -787,15 +782,15 @@ var runTests = function () {
}, 2000);
setTimeout(function () {
testJSONReporter();
}, 2750);
}, 3500);
setTimeout(function () {
testJSONReporterWithDOM();
}, 3000);
}, 5000);
setTimeout(function() {
$('spinner').hide();
reporter.summary();
}, 4500);
}, 6000);
}