Added statement chaining to specs

This commit is contained in:
pivotal 2008-12-01 12:26:12 -08:00
parent 9f2d3e0540
commit a4979fe851
16 changed files with 249 additions and 123 deletions

0
images/accept.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 781 B

After

Width:  |  Height:  |  Size: 781 B

0
images/exclamation.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 701 B

After

Width:  |  Height:  |  Size: 701 B

0
jasmine.iml Normal file → Executable file
View File

0
jasmine.ipr Normal file → Executable file
View File

View File

@ -77,13 +77,31 @@
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="test.html" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/test/test.html">
<file leaf-file-name="bootstrap.html" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
<provider editor-type-id="HtmlPreview">
<state />
</provider>
<provider selected="true" editor-type-id="text-editor">
<state line="12" column="4" selection-start="481" selection-end="481" vertical-scroll-proportion="0.2389937">
<state line="19" column="20" selection-start="652" selection-end="652" vertical-scroll-proportion="0.37063655">
<folding />
</state>
</provider>
</entry>
</file>
<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="171" column="38" selection-start="4839" selection-end="4839" vertical-scroll-proportion="0.7267498">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="test.css" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/test.css">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@ -92,25 +110,7 @@
<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="7" column="10" selection-start="95" selection-end="95" vertical-scroll-proportion="0.13000977">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="test.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/test.js">
<provider selected="true" editor-type-id="text-editor">
<state line="66" column="6" selection-start="2025" selection-end="2025" vertical-scroll-proportion="0.69742066">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="jspec.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/jspec/lib/jspec.js">
<provider selected="true" editor-type-id="text-editor">
<state line="265" column="0" selection-start="6520" selection-end="6520" vertical-scroll-proportion="-0.8293651">
<state line="80" column="6" selection-start="1900" selection-end="1900" vertical-scroll-proportion="0.27918288">
<folding />
</state>
</provider>
@ -166,7 +166,7 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="PsiDirectory:/Users/pivotal/workspace/jasmine" />
<option name="myItemId" value="PsiDirectory:/Users/pivotal/Desktop/jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
@ -180,11 +180,11 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="PsiDirectory:/Users/pivotal/workspace/jasmine" />
<option name="myItemId" value="PsiDirectory:/Users/pivotal/Desktop/jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="PsiDirectory:/Users/pivotal/workspace/jasmine/test" />
<option name="myItemId" value="PsiDirectory:/Users/pivotal/Desktop/jasmine/test" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
@ -198,11 +198,11 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="PsiDirectory:/Users/pivotal/workspace/jasmine" />
<option name="myItemId" value="PsiDirectory:/Users/pivotal/Desktop/jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="PsiDirectory:/Users/pivotal/workspace/jasmine/lib" />
<option name="myItemId" value="PsiDirectory:/Users/pivotal/Desktop/jasmine/lib" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
@ -216,11 +216,11 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="PsiDirectory:/Users/pivotal/workspace/jasmine" />
<option name="myItemId" value="PsiDirectory:/Users/pivotal/Desktop/jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="PsiDirectory:/Users/pivotal/workspace/jasmine/jspec" />
<option name="myItemId" value="PsiDirectory:/Users/pivotal/Desktop/jasmine/jspec" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
@ -234,15 +234,15 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="PsiDirectory:/Users/pivotal/workspace/jasmine" />
<option name="myItemId" value="PsiDirectory:/Users/pivotal/Desktop/jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="PsiDirectory:/Users/pivotal/workspace/jasmine/jspec" />
<option name="myItemId" value="PsiDirectory:/Users/pivotal/Desktop/jasmine/jspec" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="PsiDirectory:/Users/pivotal/workspace/jasmine/jspec/lib" />
<option name="myItemId" value="PsiDirectory:/Users/pivotal/Desktop/jasmine/jspec/lib" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
@ -266,6 +266,7 @@
</navigator>
</component>
<component name="PropertiesComponent">
<property name="GoToClass.includeJavaFiles" value="false" />
<property name="MemberChooser.copyJavadoc" value="false" />
<property name="GoToClass.includeLibraries" value="false" />
<property name="MemberChooser.showClasses" value="true" />
@ -297,19 +298,6 @@
</option>
<envs />
</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="RubyRunConfigurationType" factoryName="Ruby test">
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
@ -331,6 +319,19 @@
<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="Applet" factoryName="Applet">
<module name="" />
<option name="MAIN_CLASS_NAME" />
@ -394,33 +395,33 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="39" y="22" width="1412" height="1167" extended-state="0" />
<frame x="80" y="22" width="1661" height="1187" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
<window_info id="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" />
<window_info id="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="7" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.25" order="0" />
<window_info id="RDoc" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" 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.33" 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="-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="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="-1" />
<window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
<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="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="-1" />
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" 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="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="-1" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
<window_info id="Duplicates" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
<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="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="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" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="5" />
</layout>
@ -490,33 +491,57 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/jspec/lib/jspec.js">
<entry file="file://$PROJECT_DIR$/test/test.html">
<provider editor-type-id="HtmlPreview">
<state />
</provider>
<provider selected="true" editor-type-id="text-editor">
<state line="265" column="0" selection-start="6520" selection-end="6520" vertical-scroll-proportion="-0.8293651">
<state line="12" column="4" selection-start="492" selection-end="492" vertical-scroll-proportion="0.2389937">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/test.js">
<provider selected="true" editor-type-id="text-editor">
<state line="66" column="6" selection-start="2025" selection-end="2025" vertical-scroll-proportion="0.69742066">
<state line="66" column="6" selection-start="2216" selection-end="2216" vertical-scroll-proportion="0.018849207">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/jspec/lib/jspec.js">
<provider selected="true" editor-type-id="text-editor">
<state line="265" column="0" selection-start="6520" selection-end="6520" vertical-scroll-proportion="0.018849207">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/test.css">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
<provider editor-type-id="HtmlPreview">
<state />
</provider>
<provider selected="true" editor-type-id="text-editor">
<state line="19" column="20" selection-start="652" selection-end="652" vertical-scroll-proportion="0.37063655">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
<provider selected="true" editor-type-id="text-editor">
<state line="7" column="10" selection-start="95" selection-end="95" vertical-scroll-proportion="0.13000977">
<state line="80" column="6" selection-start="1900" selection-end="1900" vertical-scroll-proportion="0.27918288">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/test.html">
<provider editor-type-id="HtmlPreview">
<state />
</provider>
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<provider selected="true" editor-type-id="text-editor">
<state line="12" column="4" selection-start="481" selection-end="481" vertical-scroll-proportion="0.2389937">
<state line="171" column="38" selection-start="4839" selection-end="4839" vertical-scroll-proportion="0.7267498">
<folding />
</state>
</provider>

83
lib/jasmine.js Normal file → Executable file
View File

@ -10,10 +10,12 @@ if (typeof Object.create !== 'function') {
}
// Klass.method instead of Klass.prototype.name = function
if (typeof Function.method !== 'function') {
Function.prototype.method = function (name, func) {
this.prototype[name] = func;
return this;
}
}
/******************************************************************************
* Jasmine
@ -49,7 +51,7 @@ Matchers.method('should_not_equal', function (expected) {
});
/*
* expects helper method that allows for chaining Matcher
* expects_hat helper method that allows for chaining Matcher
*/
var expects_that = function (actual) {
return new Matchers(actual);
@ -59,11 +61,44 @@ var expects_that = function (actual) {
* Jasmine spec constructor
*/
var it = function (description, func) {
return {
var that = {
description: description,
execute: func
func: func,
done: false,
execute: function() {
that.func.apply(that);
}
}
return that;
}
var it_async = function (description) {
var that = {
description: description,
queue: [],
waits: function (timeout) {
return that;
},
done: false,
execute: function () {
for(i = 0; i < that.queue.length; i++) {
that.queue[i]();
}
}
};
var addToQueue = function(func) {
that.queue.push(func);
return that;
}
that.runs = addToQueue;
that.then = addToQueue;
return that;
}
/*
* Jasmine constructor
@ -79,21 +114,27 @@ var jasmine_init = function () {
*/
var Jasmine = jasmine_init();
// spec: {
// description: description,
// func: func,
// execute: function() {with(jasmine) {func();}}
// },
//
// expects_that: function(actual) {
//
// this.actual = actual;
// return this;
// },
//
// }
//}
//
//var JasmineSpec = function(description, func) {
//
//}
/*
* TODO:
* - add spec or description to results
* - spec.execute needs to wait until the spec is done
* - an async test will be killed after X ms if not done and then listed as failed with an "async fail" message of some sort
* - Suite to run tests in order, constructed with a function called describe
* - Suite supports before
* - Suite supports after
* - Suite supports before_each
* - Suite supports after_each
* - Suite supports asynch
* - Runner that runs suites in order
* - Runner supports async
* - 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
* - JSON reporter
* - Lists full results as a JSON object/string
* - Luna reporter
* - each result calls back into widgets for rendering to Luna views
*/

0
nbproject/private/private.xml Normal file → Executable file
View File

0
nbproject/project.properties Normal file → Executable file
View File

0
nbproject/project.xml Normal file → Executable file
View File

4
test/bootstrap.html Normal file → Executable file
View File

@ -19,8 +19,8 @@
<div id="results_summary" style="display:none;">
<h2>Summary</h2>
</div>
<div id="fails">
<h2 id="fails_header" style="display:none;">Failure Messages</h2>
<div id="fails" style="display:none;">
<h2 id="fails_header">Failure Messages</h2>
<div id="fail_messages"></div>
</div>
</div>

78
test/bootstrap.js vendored Normal file → Executable file
View File

@ -16,22 +16,23 @@ var reporter = function () {
}
else {
fails++;
var failsHeader = $('fails_header');
failsHeader.show();
var fails_report = $('fails');
fails_report.show();
iconElement = $('icons');
iconElement.appendChild(new Element('img', {src: '../images/exclamation.png'}));
var failMessages = $('fail_messages');
var newFail = new Element('p', {class: 'fail'});
var newFail = new Element('p', {'class': 'fail'});
newFail.innerHTML = message;
failMessages.appendChild(newFail);
}
},
summary: function () {
summary = new Element('p', {class: ((fails > 0) ? 'fail_in_summary' : '') });
summary = new Element('p', {'class': ((fails > 0) ? 'fail_in_summary' : '') });
summary.innerHTML = total + ' tests, ' + passes + ' passing, ' + fails + ' failed.';
var summaryElement = $('results_summary');
summaryElement.appendChild(summary);
summaryElement.show();
@ -42,7 +43,6 @@ var reporter = function () {
var testMatchersComparisons = function () {
Jasmine = jasmine_init();
reporter.test(expects_that(true).should_equal(true),
'expects_that(true).should_equal(true) returned false');
@ -93,11 +93,12 @@ var testSpecs = function () {
"Spec did not have a description");
Jasmine = jasmine_init();
var another_spec = it('another spec', function () {
var another_spec = it('spec with an expectation', function () {
var foo = 'bar';
expects_that(foo).should_equal('bar');
});
another_spec.execute();
another_spec.done = true;
reporter.test((Jasmine.results.length == 1),
"Results aren't there after a spec was executed");
@ -110,6 +111,7 @@ var testSpecs = function () {
expects_that(foo).should_equal('baz');
});
yet_another_spec.execute();
another_spec.done = true;
reporter.test((Jasmine.results[0].passed == false),
"Expectation that failed, passed");
@ -123,18 +125,76 @@ var testSpecs = function () {
expects_that(baz).should_equal('quux');
});
yet_yet_another_spec.execute();
another_spec.done = true;
reporter.test((Jasmine.results.length == 2),
"Spec doesn't support multiple expectations");
}
var testAsyncSpecs = function () {
Jasmine = jasmine_init();
var foo = 0;
var a_spec = it_async('simple queue test').
runs(function () {
foo++;
}).then(function() {
expects_that(foo).should_equal(1)
});
reporter.test(a_spec.queue.length === 2,
'Spec queue length is not 2');
Jasmine = jasmine_init();
foo = 0;
a_spec = it_async('spec w/ queued statments').
runs(function () {
foo++;
}).then(function() {
expects_that(foo).should_equal(1)
});
a_spec.execute();
reporter.test((Jasmine.results.length === 1),
'Spec queue did not run all functions');
reporter.test((Jasmine.results[0].passed === true),
'Queued expectation failed');
Jasmine = jasmine_init();
foo = 0;
a_spec = it_async('spec w/ queued statments').
runs(function () {
setTimeout(function() {
foo++
}, 500);
}).waits(1000).then(function() {
expects_that(foo).should_equal(1);
});
a_spec.execute();
reporter.test((Jasmine.results.length === 1),
'Spec queue did not run all functions');
reporter.test((Jasmine.results[0].passed === true),
'Queued expectation failed');
}
var runTests = function () {
$('spinner').show();
testMatchersComparisons();
testMatchersReporting();
testSpecs();
// testMatchersComparisons();
// testMatchersReporting();
// testSpecs();
testAsyncSpecs();
$('spinner').hide();
reporter.summary();
}
//it('should be an async test') {
// run(function() {setup}).and.wait(2000).then.expects_that(true).should_equal(true).and.expects_that
//}

0
test/prototype-1.6.0.3.js vendored Normal file → Executable file
View File

0
test/spinner.gif Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

0
test/test.css Normal file → Executable file
View File

0
test/test.html Normal file → Executable file
View File

0
test/test.js Normal file → Executable file
View File