dwf: refactoring how reporters work to add callbacks at all levels, separating how/when DOM writing works;
This commit is contained in:
parent
1450eb5b65
commit
b8a8dc4562
@ -2,7 +2,7 @@
|
|||||||
"http://www.w3.org/TR/html4/loose.dtd">
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Jasmine Tests</title>
|
<title>Jasmine Example</title>
|
||||||
<script type="text/javascript" src="../lib/jasmine.js"></script>
|
<script type="text/javascript" src="../lib/jasmine.js"></script>
|
||||||
<script type="text/javascript" src="example.js"></script>
|
<script type="text/javascript" src="example.js"></script>
|
||||||
<link type="text/css" rel="stylesheet" href="../lib/jasmine.css"/>
|
<link type="text/css" rel="stylesheet" href="../lib/jasmine.css"/>
|
||||||
|
164
jasmine.iws
164
jasmine.iws
@ -80,7 +80,7 @@
|
|||||||
<file leaf-file-name="bootstrap.html" pinned="false" current="false" current-in-tab="false">
|
<file leaf-file-name="bootstrap.html" pinned="false" current="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
|
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state line="29" column="63" selection-start="1054" selection-end="1054" vertical-scroll-proportion="0.5709845">
|
<state line="10" column="7" selection-start="500" selection-end="500" vertical-scroll-proportion="0.19689119">
|
||||||
<folding />
|
<folding />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
@ -92,7 +92,7 @@
|
|||||||
<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="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/lib/json_reporter.js">
|
<entry file="file://$PROJECT_DIR$/lib/json_reporter.js">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state line="22" column="3" selection-start="581" selection-end="581" vertical-scroll-proportion="0.40425533">
|
<state line="6" column="36" selection-start="284" selection-end="284" vertical-scroll-proportion="0.11025145">
|
||||||
<folding />
|
<folding />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
@ -101,16 +101,16 @@
|
|||||||
<file leaf-file-name="bootstrap.js" pinned="false" current="false" current-in-tab="false">
|
<file leaf-file-name="bootstrap.js" pinned="false" current="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
|
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state line="693" column="63" selection-start="20819" selection-end="20819" vertical-scroll-proportion="0.55937195">
|
<state line="53" column="39" selection-start="1542" selection-end="1542" vertical-scroll-proportion="0.5166163">
|
||||||
<folding />
|
<folding />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
</file>
|
</file>
|
||||||
<file leaf-file-name="jasmine.js" pinned="false" current="false" current-in-tab="false">
|
<file leaf-file-name="jasmine.js" pinned="false" current="true" current-in-tab="true">
|
||||||
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
|
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state line="320" column="0" selection-start="6758" selection-end="6758" vertical-scroll-proportion="0.58531743">
|
<state line="198" column="17" selection-start="4329" selection-end="4329" vertical-scroll-proportion="0.7901354">
|
||||||
<folding />
|
<folding />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
@ -119,7 +119,7 @@
|
|||||||
<file leaf-file-name="example.html" pinned="false" current="false" current-in-tab="false">
|
<file leaf-file-name="example.html" pinned="false" current="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/example/example.html">
|
<entry file="file://$PROJECT_DIR$/example/example.html">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state line="8" column="7" selection-start="355" selection-end="355" vertical-scroll-proportion="0.15751295">
|
<state line="4" column="24" selection-start="145" selection-end="145" vertical-scroll-proportion="0.078756474">
|
||||||
<folding />
|
<folding />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
@ -137,7 +137,7 @@
|
|||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
</file>
|
</file>
|
||||||
<file leaf-file-name="example.js" pinned="false" current="true" current-in-tab="true">
|
<file leaf-file-name="example.js" pinned="false" current="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/example/example.js">
|
<entry file="file://$PROJECT_DIR$/example/example.js">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state line="6" column="0" selection-start="183" selection-end="183" vertical-scroll-proportion="0.11025145">
|
<state line="6" column="0" selection-start="183" selection-end="183" vertical-scroll-proportion="0.11025145">
|
||||||
@ -305,6 +305,40 @@
|
|||||||
<RUBY_DOC NAME="NUMBER" VALUE="0" />
|
<RUBY_DOC NAME="NUMBER" VALUE="0" />
|
||||||
</component>
|
</component>
|
||||||
<component name="RunManager">
|
<component name="RunManager">
|
||||||
|
<configuration default="true" type="RubyRunConfigurationType" factoryName="Ruby test">
|
||||||
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
|
||||||
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
|
||||||
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_CLASS_NAME" VALUE="" />
|
||||||
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="" />
|
||||||
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_METHOD_NAME" VALUE="" />
|
||||||
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
|
||||||
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift)" />
|
||||||
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="" />
|
||||||
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="MODULE_NAME" VALUE="" />
|
||||||
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
||||||
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
||||||
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="INHERITANCE_CHECK_DISABLED" VALUE="false" />
|
||||||
|
</configuration>
|
||||||
|
<configuration default="true" type="Remote" factoryName="Remote">
|
||||||
|
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
||||||
|
<option name="SERVER_MODE" value="false" />
|
||||||
|
<option name="SHMEM_ADDRESS" value="javadebug" />
|
||||||
|
<option name="HOST" value="localhost" />
|
||||||
|
<option name="PORT" value="5005" />
|
||||||
|
</configuration>
|
||||||
|
<configuration default="true" type="Application" factoryName="Application" enabled="false" merge="false">
|
||||||
|
<option name="MAIN_CLASS_NAME" />
|
||||||
|
<option name="VM_PARAMETERS" />
|
||||||
|
<option name="PROGRAM_PARAMETERS" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||||
|
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||||
|
<option name="ALTERNATIVE_JRE_PATH" />
|
||||||
|
<option name="ENABLE_SWING_INSPECTOR" value="false" />
|
||||||
|
<option name="ENV_VARIABLES" />
|
||||||
|
<option name="PASS_PARENT_ENVS" value="true" />
|
||||||
|
<module name="" />
|
||||||
|
<envs />
|
||||||
|
</configuration>
|
||||||
<configuration default="true" type="JUnit" factoryName="JUnit" enabled="false" merge="false">
|
<configuration default="true" type="JUnit" factoryName="JUnit" enabled="false" merge="false">
|
||||||
<module name="" />
|
<module name="" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||||
@ -324,40 +358,6 @@
|
|||||||
</option>
|
</option>
|
||||||
<envs />
|
<envs />
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration default="true" type="Application" factoryName="Application" enabled="false" merge="false">
|
|
||||||
<option name="MAIN_CLASS_NAME" />
|
|
||||||
<option name="VM_PARAMETERS" />
|
|
||||||
<option name="PROGRAM_PARAMETERS" />
|
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH" />
|
|
||||||
<option name="ENABLE_SWING_INSPECTOR" value="false" />
|
|
||||||
<option name="ENV_VARIABLES" />
|
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
|
||||||
<module name="" />
|
|
||||||
<envs />
|
|
||||||
</configuration>
|
|
||||||
<configuration default="true" type="Remote" factoryName="Remote">
|
|
||||||
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
|
||||||
<option name="SERVER_MODE" value="false" />
|
|
||||||
<option name="SHMEM_ADDRESS" value="javadebug" />
|
|
||||||
<option name="HOST" value="localhost" />
|
|
||||||
<option name="PORT" value="5005" />
|
|
||||||
</configuration>
|
|
||||||
<configuration default="true" type="RubyRunConfigurationType" factoryName="Ruby test">
|
|
||||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
|
|
||||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
|
|
||||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_CLASS_NAME" VALUE="" />
|
|
||||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="" />
|
|
||||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_METHOD_NAME" VALUE="" />
|
|
||||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
|
|
||||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift)" />
|
|
||||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="" />
|
|
||||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="MODULE_NAME" VALUE="" />
|
|
||||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
|
||||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
|
||||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="INHERITANCE_CHECK_DISABLED" VALUE="false" />
|
|
||||||
</configuration>
|
|
||||||
<configuration default="true" type="Applet" factoryName="Applet">
|
<configuration default="true" type="Applet" factoryName="Applet">
|
||||||
<module name="" />
|
<module name="" />
|
||||||
<option name="MAIN_CLASS_NAME" />
|
<option name="MAIN_CLASS_NAME" />
|
||||||
@ -507,26 +507,6 @@
|
|||||||
</GetOptions>
|
</GetOptions>
|
||||||
</component>
|
</component>
|
||||||
<component name="editorHistoryManager">
|
<component name="editorHistoryManager">
|
||||||
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state line="29" column="63" selection-start="1054" selection-end="1054" vertical-scroll-proportion="0.5709845">
|
|
||||||
<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="8" column="7" selection-start="355" selection-end="355" vertical-scroll-proportion="0.15751295">
|
|
||||||
<folding />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
<provider editor-type-id="HtmlPreview">
|
|
||||||
<state />
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/lib/jasmine.css">
|
<entry file="file://$PROJECT_DIR$/lib/jasmine.css">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state line="16" column="8" selection-start="315" selection-end="315" vertical-scroll-proportion="0.29400387">
|
<state line="16" column="8" selection-start="315" selection-end="315" vertical-scroll-proportion="0.29400387">
|
||||||
@ -534,27 +514,6 @@
|
|||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state line="320" column="0" selection-start="6758" selection-end="6758" vertical-scroll-proportion="0.58531743">
|
|
||||||
<folding />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/lib/json_reporter.js">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state line="22" column="3" selection-start="581" selection-end="581" vertical-scroll-proportion="0.40425533">
|
|
||||||
<folding />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state line="693" column="63" selection-start="20819" selection-end="20819" vertical-scroll-proportion="0.55937195">
|
|
||||||
<folding />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/example/example.js">
|
<entry file="file://$PROJECT_DIR$/example/example.js">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state line="6" column="0" selection-start="183" selection-end="183" vertical-scroll-proportion="0.11025145">
|
<state line="6" column="0" selection-start="183" selection-end="183" vertical-scroll-proportion="0.11025145">
|
||||||
@ -562,6 +521,47 @@
|
|||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
|
<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$/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">
|
||||||
|
<folding />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
<provider editor-type-id="HtmlPreview">
|
||||||
|
<state />
|
||||||
|
</provider>
|
||||||
|
</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">
|
||||||
|
<folding />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
@ -18,11 +18,14 @@ if (typeof Function.method !== 'function') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Jasmine internal classes & objects
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* object for holding results; allows for the results array to hold another nestedResults()
|
* object for holding results; allows for the results array to hold another nestedResults()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var nestedResults = function() {
|
var nestedResults = function() {
|
||||||
var that = {
|
var that = {
|
||||||
totalCount: 0,
|
totalCount: 0,
|
||||||
@ -121,6 +124,30 @@ var actionCollection = function () {
|
|||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* queuedFunction is how actionCollection's actions are implemented
|
||||||
|
*/
|
||||||
|
var queuedFunction = function(func, timeout, spec) {
|
||||||
|
var that = {
|
||||||
|
func: func,
|
||||||
|
next: function () {
|
||||||
|
spec.finish(); // default value is to be done after one function
|
||||||
|
},
|
||||||
|
execute: function () {
|
||||||
|
if (timeout > 0) {
|
||||||
|
setTimeout(function () {
|
||||||
|
that.func.apply(spec);
|
||||||
|
that.next();
|
||||||
|
}, timeout);
|
||||||
|
} else {
|
||||||
|
that.func.apply(spec);
|
||||||
|
that.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return that;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Jasmine
|
* Jasmine
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
@ -159,27 +186,6 @@ Matchers.method('should_not_equal', function (expected) {
|
|||||||
* Jasmine spec constructor
|
* Jasmine spec constructor
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var queuedFunction = function(func, timeout, spec) {
|
|
||||||
var that = {
|
|
||||||
func: func,
|
|
||||||
next: function () {
|
|
||||||
spec.finish(); // default value is to be done after one function
|
|
||||||
},
|
|
||||||
execute: function () {
|
|
||||||
if (timeout > 0) {
|
|
||||||
setTimeout(function () {
|
|
||||||
that.func.apply(spec);
|
|
||||||
that.next();
|
|
||||||
}, timeout);
|
|
||||||
} else {
|
|
||||||
that.func.apply(spec);
|
|
||||||
that.next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return that;
|
|
||||||
}
|
|
||||||
|
|
||||||
var it = function (description, func) {
|
var it = function (description, func) {
|
||||||
var that = {
|
var that = {
|
||||||
description: description,
|
description: description,
|
||||||
@ -302,39 +308,28 @@ var Runner = function () {
|
|||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
var JasmineReporters = {};
|
|
||||||
|
|
||||||
var Jasmine = Runner();
|
var Jasmine = Runner();
|
||||||
var currentSuite;
|
var currentSuite;
|
||||||
var currentSpec;
|
var currentSpec;
|
||||||
|
|
||||||
JasmineReporters.reporter = function (elementId) {
|
/* 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 = {};
|
||||||
|
|
||||||
|
JasmineReporters.reporter = function (callbacks) {
|
||||||
var that = {
|
var that = {
|
||||||
element: document.getElementById(elementId),
|
callbacks: callbacks || {},
|
||||||
output: '',
|
|
||||||
|
|
||||||
reportRunnerResults: function (results) { that.output += ''; },
|
doCallback: function (callback, results) {
|
||||||
|
if (callback) { callback(results); }
|
||||||
|
},
|
||||||
|
|
||||||
reportSuiteResults: function (results) { that.output += ''; },
|
reportRunnerResults: function (results) { that.doCallback(that.callbacks.runnerCallback, results); },
|
||||||
|
reportSuiteResults: function (results) { that.doCallback(that.callbacks.suiteCallback, results); },
|
||||||
reportSpecResults: function (results) { that.output += ''; },
|
reportSpecResults: function (results) { that.doCallback(that.callbacks.specCallback, results);}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: throw if no element?
|
|
||||||
if (that.element) {
|
|
||||||
that.element.innerHTML = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO:
|
|
||||||
* - HTML reporter
|
|
||||||
* - Shows pass/fail progress (just like bootstrap reporter)
|
|
||||||
* - Lists a Summary: total # specs, # of passed, # of failed
|
|
||||||
* - Failed reports lists all specs that failed and what the failure was
|
|
||||||
* - Failed output is styled with red
|
|
||||||
*/
|
|
||||||
|
|
@ -1,27 +1,73 @@
|
|||||||
JasmineReporters.JSON = function (elementId) {
|
/*
|
||||||
var that = JasmineReporters.reporter(elementId);
|
* JasmineReporters.JSON --
|
||||||
|
* 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();
|
||||||
|
that.specJSON = '';
|
||||||
|
that.suiteJSON = '';
|
||||||
|
that.runnerJSON = '';
|
||||||
|
|
||||||
that.reportRunnerResults = function (results) {
|
var saveSpecResults = function (results) {
|
||||||
that.output = Object.toJSON(results);
|
that.specJSON = Object.toJSON(results);
|
||||||
|
}
|
||||||
|
that.reportSpecResults = saveSpecResults;
|
||||||
|
|
||||||
if (that.element) {
|
var saveSuiteResults = function (results) {
|
||||||
that.element.innerHTML += that.output;
|
that.suiteJSON = Object.toJSON(results);
|
||||||
}
|
}
|
||||||
}
|
that.reportSuiteResults = saveSuiteResults;
|
||||||
|
|
||||||
|
var saveRunnerResults = function (results) {
|
||||||
|
that.runnerJSON = Object.toJSON(results);
|
||||||
|
}
|
||||||
|
that.reportRunnerResults = saveRunnerResults;
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
JasmineReporters.IncrementalJSON = function (elementId) {
|
var domWriter = function (elementId) {
|
||||||
var that = JasmineReporters.reporter(elementId);
|
var that = {
|
||||||
|
element: document.getElementById(elementId),
|
||||||
|
|
||||||
that.reportSpecResults = function (results) {
|
write: function (text) {
|
||||||
that.output = Object.toJSON(results);
|
if (that.element) {
|
||||||
if (that.element) {
|
that.element.innerHTML += text;
|
||||||
that.element.innerHTML += that.output;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
that.element.innerHTML = '';
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JasmineReporters.JSONtoDOM = function (elementId) {
|
||||||
|
var that = JasmineReporters.JSON();
|
||||||
|
|
||||||
|
that.domWriter = domWriter(elementId);
|
||||||
|
|
||||||
|
var writeRunnerResults = function (results) {
|
||||||
|
that.domWriter.write(Object.toJSON(results));
|
||||||
|
};
|
||||||
|
|
||||||
|
that.reportRunnerResults = writeRunnerResults;
|
||||||
|
|
||||||
|
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;
|
||||||
|
//}
|
||||||
|
|
||||||
|
156
test/bootstrap.js
vendored
156
test/bootstrap.js
vendored
@ -19,7 +19,7 @@ var reporter = function () {
|
|||||||
var fails_report = $('fails');
|
var fails_report = $('fails');
|
||||||
fails_report.show();
|
fails_report.show();
|
||||||
|
|
||||||
iconElement = $('icons');
|
var iconElement = $('icons');
|
||||||
iconElement.appendChild(new Element('img', {src: '../images/exclamation.png'}));
|
iconElement.appendChild(new Element('img', {src: '../images/exclamation.png'}));
|
||||||
|
|
||||||
var failMessages = $('fail_messages');
|
var failMessages = $('fail_messages');
|
||||||
@ -30,11 +30,11 @@ var reporter = function () {
|
|||||||
},
|
},
|
||||||
|
|
||||||
summary: function () {
|
summary: function () {
|
||||||
summary = new Element('p', {'class': ((fails > 0) ? 'fail_in_summary' : '') });
|
var el = new Element('p', {'class': ((fails > 0) ? 'fail_in_summary' : '') });
|
||||||
summary.innerHTML = total + ' expectations, ' + passes + ' passing, ' + fails + ' failed.';
|
el.innerHTML = total + ' expectations, ' + passes + ' passing, ' + fails + ' failed.';
|
||||||
|
|
||||||
var summaryElement = $('results_summary');
|
var summaryElement = $('results_summary');
|
||||||
summaryElement.appendChild(summary);
|
summaryElement.appendChild(el);
|
||||||
summaryElement.show();
|
summaryElement.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,6 +190,7 @@ var testAsyncSpecs = function () {
|
|||||||
'Calling waits(): Queued expectation failed');
|
'Calling waits(): Queued expectation failed');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
a_spec.execute();
|
a_spec.execute();
|
||||||
waitForDone(a_spec, mockSuite);
|
waitForDone(a_spec, mockSuite);
|
||||||
|
|
||||||
@ -450,7 +451,7 @@ var testBeforeAndAfterCallbacks = function () {
|
|||||||
|
|
||||||
var testSpecScope = function () {
|
var testSpecScope = function () {
|
||||||
|
|
||||||
suite = describe('one suite description', function () {
|
var suite = describe('one suite description', function () {
|
||||||
it('should be a test with queuedFunctions', function() {
|
it('should be a test with queuedFunctions', function() {
|
||||||
runs(function() {
|
runs(function() {
|
||||||
this.foo = 0;
|
this.foo = 0;
|
||||||
@ -545,7 +546,6 @@ var testRunner = function() {
|
|||||||
var testRunnerFinishCallback = function () {
|
var testRunnerFinishCallback = function () {
|
||||||
var runner = Runner();
|
var runner = Runner();
|
||||||
var foo = 0;
|
var foo = 0;
|
||||||
var s
|
|
||||||
|
|
||||||
runner.finish();
|
runner.finish();
|
||||||
|
|
||||||
@ -644,10 +644,70 @@ var testResults = function () {
|
|||||||
'Expectation Failed count should be 1, but was ' + runner.results.failedCount);
|
'Expectation Failed count should be 1, but was ' + runner.results.failedCount);
|
||||||
reporter.test((runner.results.description === 'All Jasmine Suites'),
|
reporter.test((runner.results.description === 'All Jasmine Suites'),
|
||||||
'Jasmine Runner does not have the expected description, has: ' + runner.results.description);
|
'Jasmine Runner does not have the expected description, has: ' + runner.results.description);
|
||||||
}, 1000);
|
}, 500);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var testReporterWithCallbacks = function () {
|
||||||
|
var foo = 0;
|
||||||
|
var bar = 0;
|
||||||
|
var baz = 0;
|
||||||
|
|
||||||
|
var runner = Runner();
|
||||||
|
describe('Suite for JSON Reporter with Callbacks', function () {
|
||||||
|
it('should be a test', function() {
|
||||||
|
runs(function () {
|
||||||
|
this.expects_that(true).should_equal(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('should be a failing test', function() {
|
||||||
|
runs(function () {
|
||||||
|
this.expects_that(false).should_equal(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('Suite for JSON Reporter with Callbacks 2', function () {
|
||||||
|
it('should be a test', function() {
|
||||||
|
runs(function () {
|
||||||
|
this.expects_that(true).should_equal(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var specCallback = function (results) {
|
||||||
|
foo++;
|
||||||
|
}
|
||||||
|
|
||||||
|
var suiteCallback = function (results) {
|
||||||
|
bar++;
|
||||||
|
}
|
||||||
|
|
||||||
|
var runnerCallback = function (results) {
|
||||||
|
baz++;
|
||||||
|
}
|
||||||
|
|
||||||
|
callbackFunctions = {
|
||||||
|
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);
|
||||||
|
reporter.test((bar === 2),
|
||||||
|
'bar was expected to be 2, was ' + bar);
|
||||||
|
reporter.test((baz === 1),
|
||||||
|
'baz was expected to be 1, was ' + baz);
|
||||||
|
|
||||||
|
}, 750);
|
||||||
|
}
|
||||||
|
|
||||||
var testJSONReporter = function () {
|
var testJSONReporter = function () {
|
||||||
var runner = Runner();
|
var runner = Runner();
|
||||||
describe('Suite for JSON Reporter, NO DOM', function () {
|
describe('Suite for JSON Reporter, NO DOM', function () {
|
||||||
@ -660,17 +720,27 @@ var testJSONReporter = function () {
|
|||||||
|
|
||||||
runner.reporter = JasmineReporters.JSON();
|
runner.reporter = JasmineReporters.JSON();
|
||||||
|
|
||||||
reporter.test((runner.reporter !== undefined),
|
|
||||||
"Runner's reporter is undefined");
|
|
||||||
reporter.test((runner.finishCallback !== undefined),
|
|
||||||
"Runner's finishCallback is undefined");
|
|
||||||
|
|
||||||
runner.execute();
|
runner.execute();
|
||||||
|
|
||||||
var 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": "Suite for JSON Reporter, NO DOM"}], "description": "All Jasmine Suites"}';
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
reporter.test((runner.reporter.output === expectedJSONString),
|
var expectedSpecJSON = '{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"passed": true, "message": "Passed."}], "description": "should be a test"}';
|
||||||
'Jasmine Reporter with No DOM does not have the expected report.<br /> <b>Expected:</b><br /> ' + expectedJSONString + '<br /><b>Got:</b><br /> ' + runner.reporter.output);
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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);
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -684,47 +754,17 @@ var testJSONReporterWithDOM = function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
runner.reporter = JasmineReporters.JSON('json_reporter_results');
|
runner.reporter = JasmineReporters.JSONtoDOM('json_reporter_results');
|
||||||
|
|
||||||
runner.execute();
|
runner.execute();
|
||||||
|
|
||||||
var 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": "Suite for JSON Reporter/DOM"}], "description": "All Jasmine Suites"}';
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
var 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": "Suite for JSON Reporter/DOM"}], "description": "All Jasmine Suites"}';
|
||||||
|
|
||||||
reporter.test((document.getElementById('json_reporter_results').innerHTML === expectedJSONString),
|
reporter.test((document.getElementById('json_reporter_results').innerHTML === expectedJSONString),
|
||||||
'Jasmine Reporter did not output the string to the DOM, got:' + document.getElementById('json_reporter_results').innerHTML);
|
'JSON Reporter with DOM did not write the expected report to the DOM, got:' + document.getElementById('json_reporter_results').innerHTML);
|
||||||
}, 500);
|
}, 250);
|
||||||
}
|
}
|
||||||
|
|
||||||
var testJSONReporterWithIncrementalSpecReports = function() {
|
|
||||||
setTimeout( function () {
|
|
||||||
var runner = Runner();
|
|
||||||
describe('Suite for Incremental JSON Reporter/DOM', function () {
|
|
||||||
it('should be a test', function() {
|
|
||||||
runs(function () {
|
|
||||||
this.expects_that(true).should_equal(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it('should be a failing test', function() {
|
|
||||||
runs(function () {
|
|
||||||
this.expects_that(false).should_equal(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
runner.reporter = JasmineReporters.IncrementalJSON('json_reporter_results_incremental');
|
|
||||||
runner.execute();
|
|
||||||
var expectedJSONString = '{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"passed": true, "message": "Passed."}], "description": "should be a test"}{"totalCount": 1, "passedCount": 0, "failedCount": 1, "results": [{"passed": false, "message": "Expected true but got false."}], "description": "should be a failing test"}'
|
|
||||||
|
|
||||||
setTimeout(function() {
|
|
||||||
reporter.test((document.getElementById('json_reporter_results_incremental').innerHTML === expectedJSONString),
|
|
||||||
'Jasmine Incremental Reporter did not output the correct string to the DOM, got ' + document.getElementById('json_reporter_results_incremental').innerHTML);
|
|
||||||
|
|
||||||
}, 500);
|
|
||||||
}, 2500);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var runTests = function () {
|
var runTests = function () {
|
||||||
$('spinner').show();
|
$('spinner').show();
|
||||||
|
|
||||||
@ -740,14 +780,22 @@ var runTests = function () {
|
|||||||
testRunnerFinishCallback();
|
testRunnerFinishCallback();
|
||||||
testNestedResults();
|
testNestedResults();
|
||||||
testResults();
|
testResults();
|
||||||
testJSONReporter();
|
|
||||||
testJSONReporterWithDOM();
|
// Timing starts to matter with these tests; ALWAYS use setTimeout()
|
||||||
testJSONReporterWithIncrementalSpecReports();
|
setTimeout(function () {
|
||||||
|
testReporterWithCallbacks();
|
||||||
|
}, 2000);
|
||||||
|
setTimeout(function () {
|
||||||
|
testJSONReporter();
|
||||||
|
}, 2750);
|
||||||
|
setTimeout(function () {
|
||||||
|
testJSONReporterWithDOM();
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$('spinner').hide();
|
$('spinner').hide();
|
||||||
reporter.summary();
|
reporter.summary();
|
||||||
}, 3500);
|
}, 4500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user