added suite functionality and tests on function scope

This commit is contained in:
pivotal 2008-12-02 10:27:09 -08:00
parent be33f1e6d4
commit f43ba0a51c
3 changed files with 250 additions and 211 deletions

View File

@ -79,20 +79,20 @@
<leaf> <leaf>
<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 editor-type-id="HtmlPreview">
<state />
</provider>
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="15" column="26" selection-start="541" selection-end="541" vertical-scroll-proportion="0.2926078"> <state line="15" column="26" selection-start="541" selection-end="541" vertical-scroll-proportion="0.29533678">
<folding /> <folding />
</state> </state>
</provider> </provider>
<provider editor-type-id="HtmlPreview">
<state />
</provider>
</entry> </entry>
</file> </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"> <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="295" column="2" selection-start="8248" selection-end="8248" vertical-scroll-proportion="0.4717162"> <state line="411" column="0" selection-start="11018" selection-end="11018" vertical-scroll-proportion="0.7427466">
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -101,16 +101,16 @@
<file leaf-file-name="test.css" pinned="false" current="false" current-in-tab="false"> <file leaf-file-name="test.css" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/test.css"> <entry file="file://$PROJECT_DIR$/test/test.css">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="5" column="0" selection-start="118" selection-end="118" vertical-scroll-proportion="0.091083415"> <state line="5" column="0" selection-start="118" selection-end="118" vertical-scroll-proportion="0.09187621">
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </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"> <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="131" column="32" selection-start="2951" selection-end="2951" vertical-scroll-proportion="0.29766536"> <state line="199" column="0" selection-start="4076" selection-end="4076" vertical-scroll-proportion="1.8949951">
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -156,118 +156,6 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" /> <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
</PATH_ELEMENT> </PATH_ELEMENT>
</PATH> </PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="PsiDirectory:/Users/pivotal/Desktop/jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<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/Desktop/jasmine/test" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<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/Desktop/jasmine/lib" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<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/Desktop/jasmine/jspec" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<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/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/Desktop/jasmine/jspec/test" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<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/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/Desktop/jasmine/jspec/lib" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane> </subPane>
</component> </component>
<component name="ProjectReloadState"> <component name="ProjectReloadState">
@ -301,6 +189,52 @@
<RUBY_DOC NAME="NUMBER" VALUE="0" /> <RUBY_DOC NAME="NUMBER" VALUE="0" />
</component> </component>
<component name="RunManager"> <component name="RunManager">
<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="" />
<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">
<module name="" />
<option name="MAIN_CLASS_NAME" />
<option name="HTML_FILE_NAME" />
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
<option name="HEIGHT" value="300" />
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<option name="VM_PARAMETERS" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
</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="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" />
@ -320,52 +254,6 @@
</option> </option>
<envs /> <envs />
</configuration> </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="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="Applet" factoryName="Applet">
<module name="" />
<option name="MAIN_CLASS_NAME" />
<option name="HTML_FILE_NAME" />
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
<option name="HEIGHT" value="300" />
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<option name="VM_PARAMETERS" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
</configuration>
<list size="0" /> <list size="0" />
<configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false"> <configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
<Host>localhost</Host> <Host>localhost</Host>
@ -417,7 +305,7 @@
</todo-panel> </todo-panel>
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="80" y="22" width="1661" height="1187" extended-state="0" /> <frame x="80" y="22" width="1661" height="1178" extended-state="0" />
<editor active="true" /> <editor active="true" />
<layout> <layout>
<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="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" />
@ -504,24 +392,24 @@
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/jspec/test/test.html"> <entry file="file://$PROJECT_DIR$/jspec/test/test.html">
<provider editor-type-id="HtmlPreview">
<state />
</provider>
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="14" column="0" selection-start="14" selection-end="491" vertical-scroll-proportion="0.278826"> <state line="14" column="0" selection-start="14" selection-end="491" vertical-scroll-proportion="0.278826">
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/test.html">
<provider editor-type-id="HtmlPreview"> <provider editor-type-id="HtmlPreview">
<state /> <state />
</provider> </provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/test.html">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="12" column="4" selection-start="492" selection-end="492" vertical-scroll-proportion="0.2389937"> <state line="12" column="4" selection-start="492" selection-end="492" vertical-scroll-proportion="0.2389937">
<folding /> <folding />
</state> </state>
</provider> </provider>
<provider editor-type-id="HtmlPreview">
<state />
</provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/test/test.js"> <entry file="file://$PROJECT_DIR$/test/test.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
@ -537,23 +425,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/test/test.css">
<provider selected="true" editor-type-id="text-editor">
<state line="5" column="0" selection-start="118" selection-end="118" vertical-scroll-proportion="0.091083415">
<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="15" column="26" selection-start="541" selection-end="541" vertical-scroll-proportion="0.2926078">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/jspec/test/test.js"> <entry file="file://$PROJECT_DIR$/jspec/test/test.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0"> <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
@ -561,16 +432,33 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/test/bootstrap.js"> <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="295" column="2" selection-start="8248" selection-end="8248" vertical-scroll-proportion="0.4717162"> <state line="15" column="26" selection-start="541" selection-end="541" vertical-scroll-proportion="0.29533678">
<folding />
</state>
</provider>
<provider editor-type-id="HtmlPreview">
<state />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/test.css">
<provider selected="true" editor-type-id="text-editor">
<state line="5" column="0" selection-start="118" selection-end="118" vertical-scroll-proportion="0.09187621">
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<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="131" column="32" selection-start="2951" selection-end="2951" vertical-scroll-proportion="0.29766536"> <state line="199" column="0" selection-start="4076" selection-end="4076" vertical-scroll-proportion="1.8949951">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<provider selected="true" editor-type-id="text-editor">
<state line="411" column="0" selection-start="11018" selection-end="11018" vertical-scroll-proportion="0.7427466">
<folding /> <folding />
</state> </state>
</provider> </provider>

View File

@ -78,13 +78,14 @@ var queuedFunction = function(func, timeout, spec) {
} }
var it = function (description) { var it = function (description, func) {
var that = { var that = {
description: description, description: description,
queue: [], queue: [],
currentTimeout: 0, currentTimeout: 0,
finished: false, finished: false,
suite: {next:function() {}}, suite: {next:function() {
}},
results: [], results: [],
expects_that: function (actual) { expects_that: function (actual) {
@ -129,25 +130,74 @@ var it = function (description) {
that.runs = addToQueue; that.runs = addToQueue;
that.then = addToQueue; that.then = addToQueue;
currentSuite.tests.push(that); currentSuite.specs.push(that);
currentSpec = that;
if (func) {
func();
}
return that; return that;
} }
var runs = function (func) {
currentSpec.runs(func);
}
var currentSuite; var waits = function (timeout) {
currentSpec.waits(timeout);
}
var describe = function (description, tests) { var then = runs;
var describe = function (description, spec_definitions) {
var that = { var that = {
description: description, description: description,
tests: [] specs: [],
specIndex: 0,
execute: function () {
if (that.specs.length > 0) {
that.next();
}
},
getCurrentSpec: function () {
return that.specs[that.specIndex];
},
next: function() {
if (that.specIndex < that.specs.length) {
var currentSpec = that.getCurrentSpec();
currentSpec.execute();
that.waitForDone(currentSpec);
}
},
waitForDone: function(spec) {
var id = setInterval(function () {
if (spec.finished) {
clearInterval(id);
that.specIndex++;
that.next();
}
}, 150);
}
} }
currentSuite = that; currentSuite = that;
tests(); spec_definitions();
return that; return that;
} }
var currentSuite = describe('default current suite', function() {});
var currentSpec;
/* /*
* Jasmine constructor * Jasmine constructor
*/ */

123
test/bootstrap.js vendored
View File

@ -285,34 +285,135 @@ var waitForDone = function(spec, mockSuite) {
var testSuites = function () { var testSuites = function () {
// suite has a description // suite has a description
var suite = describe('one suite description', function() {}); var suite = describe('one suite description', function() {
});
reporter.test((suite.description == 'one suite description'), reporter.test((suite.description == 'one suite description'),
'Suite did not get a description'); 'Suite did not get a description');
// suite can have a test // suite can have a test
suite = describe('one suite description', function () { suite = describe('one suite description', function () {
it('should be a test'); it('should be a test');
}); });
reporter.test((suite.tests[0].queue.length === 1), reporter.test((suite.specs.length === 1),
'Suite did not get a test pushed'); 'Suite did not get a spec pushed');
reporter.test((suite.specs[0].queue.length === 0),
"Suite's Spec should not have queuedFunctions");
suite = describe('one suite description', function () {
it('should be a test with queuedFunctions', function() {
runs(function() {
var foo = 0;
foo++;
});
});
});
reporter.test((suite.specs[0].queue.length === 1),
"Suite's spec did not get a function pushed");
suite = describe('one suite description', function () {
it('should be a test with queuedFunctions', function() {
runs(function() {
var foo = 0;
foo++;
});
waits(100);
runs(function() {
var bar = 0;
bar++;
});
});
});
reporter.test((suite.specs[0].queue.length === 2),
"Suite's spec did not get 2 functions pushed");
var foo = 0;
suite = describe('one suite description', function () {
it('should be a test with queuedFunctions', function() {
runs(function() {
foo++;
});
});
it('should be a another spec with queuedFunctions', function() {
runs(function() {
foo++;
});
});
});
suite.execute();
setTimeout(function () {
reporter.test((suite.specs.length === 2),
"Suite doesn't have two specs");
reporter.test((foo === 2),
"Suite didn't execute both specs");
}, 500);
} }
var testSpecScope = function () {
suite = describe('one suite description', function () {
it('should be a test with queuedFunctions', function() {
runs(function() {
this.foo = 0;
this.foo++;
});
runs(function() {
var that = this;
setTimeout(function() {
that.foo++;
}, 250);
});
runs(function() {
this.expects_that(this.foo).should_equal(2);
});
waits(300);
runs(function() {
this.expects_that(this.foo).should_equal(2);
});
});
});
suite.execute();
setTimeout(function () {
reporter.test((suite.specs[0].foo === 2),
"Spec does not maintain scope in between functions");
reporter.test((suite.specs[0].results.length === 2),
"Spec did not get results for all expectations");
reporter.test((suite.specs[0].results[0].passed === false),
"Spec did not return false for a failed expectation");
reporter.test((suite.specs[0].results[1].passed === true),
"Spec did not return true for a passing expectation");
}, 1000);
}
var runTests = function () { var runTests = function () {
$('spinner').show(); $('spinner').show();
// testMatchersComparisons(); testMatchersComparisons();
// testMatchersReporting(); testMatchersReporting();
// testSpecs(); testSpecs();
// testAsyncSpecs(); testAsyncSpecs();
// testAsyncSpecsWithMockSuite(); testAsyncSpecsWithMockSuite();
testSuites(); testSuites();
testSpecScope();
setTimeout(function() { setTimeout(function() {
$('spinner').hide(); $('spinner').hide();
reporter.summary(); reporter.summary();
}, 100); }, 10000);
} }