dwf/rva: minor Jasmine cleanup
This commit is contained in:
parent
10b613c97d
commit
0f3685aca3
20
README
20
README
@ -1,20 +0,0 @@
|
|||||||
Jasmine
|
|
||||||
=======
|
|
||||||
**yet another JavaScript testing framework**
|
|
||||||
|
|
||||||
The Problem
|
|
||||||
-----------
|
|
||||||
|
|
||||||
There are some situations when you want to test-drive JavaScript, but you don't want to be bothered with or even have an explicit document. You have no DOM to work with and so don't have HTML elements on which to hang events handlers. You may need to make asynchronous calls (say, to an AJAX API) and cannot mock/stub them.
|
|
||||||
|
|
||||||
But you still need to write tests.
|
|
||||||
|
|
||||||
What's an Agile Engineer to do?
|
|
||||||
|
|
||||||
The Solution
|
|
||||||
------------
|
|
||||||
|
|
||||||
Enter Jasmine.
|
|
||||||
|
|
||||||
Jasmine is yet another JavaScript testing framework. It's *heavily* influenced by [RSpec]() & [JSpec](http://github.com/visionmedia/jspec/tree/master),
|
|
||||||
|
|
169
README.markdown
169
README.markdown
@ -1,11 +1,11 @@
|
|||||||
Jasmine
|
Jasmine
|
||||||
=======
|
=======
|
||||||
**yet another JavaScript testing framework**
|
**YET ANOTHER JavaScript testing framework**
|
||||||
|
|
||||||
Why another frickin' JS tdd/bdd framework?
|
Why Another Frickin' JS TDD/BDD Framework?
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
There are some situations when you want to test-drive JavaScript, but you don't want to be bothered with or even have an explicit document. You have no DOM to work with and so don't have HTML elements on which to hang events handlers. You may need to make asynchronous calls (say, to an AJAX API) and cannot mock/stub them.
|
There are some situations when you want to test-drive JavaScript, but you don't want to be bothered with or even have an explicit document. You have no DOM to work with and thus lack HTML elements on which to hang event handlers. You may need to make asynchronous calls (say, to an AJAX API) and cannot mock/stub them.
|
||||||
|
|
||||||
But you still need to write tests.
|
But you still need to write tests.
|
||||||
|
|
||||||
@ -14,56 +14,173 @@ What's an Agile Engineer to do?
|
|||||||
Enter Jasmine
|
Enter Jasmine
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Jasmine is yet another JavaScript testing framework. It's *heavily* influenced by JSSpec, ScrewUnit & [JSpec](http://github.com/visionmedia/jspec/tree/master), which are all influenced by RSpec. But each of those was lacking in some way: JSSpec & ScrewUnit required a DOM. JSpec's DOM-less assumption was a great start, but it needed asynchronous support.
|
Jasmine is yet another JavaScript testing framework. It's *heavily* influenced by JSSpec, ScrewUnit & [JSpec](http://github.com/visionmedia/jspec/tree/master), which are all influenced by RSpec. But each of those was lacking in some way: JSSpec & ScrewUnit require a DOM. JSpec's DOM-less assumption was a great start, but it needed asynchronous support.
|
||||||
|
|
||||||
So we started over. And TDD'd a whole new framework. Enjoy.
|
So we started over. And TDD'd a whole new framework. Enjoy.
|
||||||
|
|
||||||
How To
|
How To
|
||||||
------
|
------
|
||||||
|
|
||||||
### Runner
|
There is a nice example of how to use Jasmine in the /example directory. But here's more information.
|
||||||
|
|
||||||
Jasmine()
|
|
||||||
|
|
||||||
You don't need a DOM, but you do need a page on which to load & execute your JS.
|
|
||||||
|
|
||||||
### Suites
|
|
||||||
|
|
||||||
Group your specs via describe
|
|
||||||
|
|
||||||
### Specs
|
### Specs
|
||||||
|
|
||||||
call it() and provide a desc & a function
|
Each spec is, naturally, a JavaScript function. You tell Jasmine about this spec with a call to `it()` with a name and the function. The string is a description that will be helpful to you when reading a report.
|
||||||
|
|
||||||
call runs
|
Your spec needs to call `runs()` with another function that is the actual spec. More on why in a moment. Here's an example:
|
||||||
|
|
||||||
alias of runs to then
|
it('should be a test', function () {
|
||||||
|
runs(function () {
|
||||||
|
var foo = 0
|
||||||
|
foo++;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
#### Asynchronous support
|
### Expectations
|
||||||
|
|
||||||
call waits
|
Within your spec you will want/need to make expectations. These are made like this:
|
||||||
|
|
||||||
### Custom Matchers
|
it('should be a test', function () {
|
||||||
|
runs(function () {
|
||||||
|
var foo = 0
|
||||||
|
foo++;
|
||||||
|
|
||||||
|
this.expects_that(foo).should_equal(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
use Matchers.method('name', function ()). Write TESTS!
|
Results of the expectations are logged for later for reporting.
|
||||||
|
|
||||||
|
### Multiple Calls to `runs()` & Scope in Your Spec
|
||||||
|
|
||||||
|
Your spec can call `runs()` multiple times if you need to break your spec up for any reason. Say, for async support (see next section). To allow you to share variables across your `runs()` functions, `this` is set to the spec itself. For example:
|
||||||
|
|
||||||
|
it('should be a test', function () {
|
||||||
|
runs(function () {
|
||||||
|
this.foo = 0
|
||||||
|
this.foo++;
|
||||||
|
|
||||||
|
this.expects_that(this.foo).should_equal(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
runs(function () {
|
||||||
|
this.foo++;
|
||||||
|
|
||||||
|
this.expects_that(this.foo).should_equal(2);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
Functions defined with `runs()` are called in the order in which they are defined.
|
||||||
|
|
||||||
|
### Asynchronous Specs
|
||||||
|
|
||||||
|
You may be asking yourself, "Self, why would I ever need to break up my tests into pieces like this?" The answer is when dealing with asynchronous function calls.
|
||||||
|
|
||||||
|
Say you need to make a call that is asynchronous - an AJAX API, or some other JavaScript library. That is, the call returns immediately, yet you want to make expectations 'at some point in the future' after some magic happens in the background.
|
||||||
|
|
||||||
|
Jasmine allows you to do this by chaining calls to `runs()` with calls to `waits()`. You supply a time to wait before the next `runs()` function is executed. Such as:
|
||||||
|
|
||||||
|
it('should be a test', function () {
|
||||||
|
runs(function () {
|
||||||
|
this.foo = 0;
|
||||||
|
var that = this;
|
||||||
|
setTimeout(function () {}
|
||||||
|
that.foo++;
|
||||||
|
}, 250);
|
||||||
|
});
|
||||||
|
|
||||||
|
runs(function () {
|
||||||
|
this.expects_that(this.foo).should_equal(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
waits(500);
|
||||||
|
|
||||||
|
runs(function () {
|
||||||
|
this.expects_that(this.foo).should_equal(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
What's happening here?
|
||||||
|
|
||||||
|
* The first call to `runs()` sets call for 1/4 of a second in the future that increments `this.foo`.
|
||||||
|
* The second `runs()` is executed immediately and then verifies that `this.foo` was indeed initialized to zero in the previous `runs()`.
|
||||||
|
* Then we wait for half a second.
|
||||||
|
* Then the last call to `runs()` expects that `this.foo` was incremented by the `setTimeout`.
|
||||||
|
|
||||||
|
### Suites
|
||||||
|
|
||||||
|
Specs are grouped in Suites. Suites are defined using the global `describe()` function:
|
||||||
|
|
||||||
|
describe('One suite', function () {
|
||||||
|
it('has a test', function () {
|
||||||
|
...
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has another test', function () {
|
||||||
|
...
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
The name is so that reporting is more descriptive.
|
||||||
|
|
||||||
|
Suites are executed in the order in which `describe()` calls are made, usually in the order in which their script files are included.
|
||||||
|
|
||||||
|
### Runner
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
### Reports
|
### Reports
|
||||||
|
|
||||||
no reporting yet other than Runner.results, which is walkable
|
no reporting yet other than Runner.results, which is walkable
|
||||||
|
|
||||||
### Tests
|
#### JSON Reporter
|
||||||
|
Coming soon.
|
||||||
|
|
||||||
There is a VERY simple test reporter - it's not even a framework at all - that allows you to write tests.
|
#### HTML Reporter
|
||||||
|
Coming soon.
|
||||||
|
|
||||||
Contributing
|
#### In-line HTML Reporter
|
||||||
-----------
|
Coming soon.
|
||||||
|
|
||||||
Contributions are welcome. Please submit tests with your pull request.
|
### Custom Matchers
|
||||||
|
|
||||||
|
Jasmine has a simple set of matchers - currently just should\_equal and should\_not\_equal. But Matchers can be extended simply to add new expectations. We use Douglas Crockford's Function.method() helper to define new Matchers.
|
||||||
|
|
||||||
|
A Matcher has a method name, takes an expected value as it's only parameter, has access to the actual value in this, and then makes a call to this.report with true/false with a failure message. Here's the definition of should\_equal():
|
||||||
|
|
||||||
|
Matchers.method('should_equal', function (expected) {
|
||||||
|
return this.report((this.actual === expected),
|
||||||
|
'Expected ' + expected + ' but got ' + this.actual + '.');
|
||||||
|
});
|
||||||
|
|
||||||
|
Feel free to define your own matcher as needed in your code. If you'd like to add Matchers to Jasmine, please write tests.
|
||||||
|
|
||||||
|
Contributing and Tests
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Sometimes it's hard to test a framework with the framework itself. Either the framework isn't mature enough or it just hurts your head. Jasmine is affected by both.
|
||||||
|
|
||||||
|
So we made a little bootstrappy test reporter that lets us test Jasmine's pieces in isolation. See test/bootstrap.js. Feel free to use the bootstrap test suite to test your custom Matchers or extensions/changes to Jasmine.
|
||||||
|
|
||||||
|
Your contributions are welcome. Please submit tests with your pull request.
|
||||||
|
|
||||||
|
## Maintainers
|
||||||
|
|
||||||
|
* [Davis W. Frank](dwfrank@pivotallabs.com), Pivotal Labs
|
||||||
|
* [Rajan Akasgar](rajan@pivotallabs.com), Pivotal Labs
|
||||||
|
|
||||||
|
## TODO List
|
||||||
|
|
||||||
|
In no particular order:
|
||||||
|
|
||||||
### TODO
|
|
||||||
* protect the global-ness of some variables & functions
|
* protect the global-ness of some variables & functions
|
||||||
|
* Suite beforeAll and afterAll functions
|
||||||
|
* add a description to runs()
|
||||||
* suite.beforeAll and suite.afterAll
|
* suite.beforeAll and suite.afterAll
|
||||||
* JSON reporter
|
* JSON reporter
|
||||||
|
* HTML reporter
|
||||||
* HTML reporter (callback driven)
|
* HTML reporter (callback driven)
|
||||||
|
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
243
jasmine.iws
243
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="15" column="26" selection-start="541" selection-end="541" vertical-scroll-proportion="0.47342193">
|
<state line="15" column="26" selection-start="541" selection-end="541" vertical-scroll-proportion="0.29533678">
|
||||||
<folding />
|
<folding />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
@ -89,10 +89,10 @@
|
|||||||
</provider>
|
</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="361" column="6" selection-start="10010" selection-end="10010" vertical-scroll-proportion="0.14728682">
|
<state line="642" column="7" selection-start="18504" selection-end="18504" vertical-scroll-proportion="0.81150794">
|
||||||
<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.14157973">
|
<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="296" column="0" selection-start="6528" selection-end="6528" vertical-scroll-proportion="0.76829267">
|
<state line="284" column="31" selection-start="5933" selection-end="5933" vertical-scroll-proportion="0.85083413">
|
||||||
<folding />
|
<folding />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
@ -156,6 +156,74 @@
|
|||||||
<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/workspace/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/workspace/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="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/workspace/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="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/workspace/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/images" />
|
||||||
|
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
||||||
|
</PATH_ELEMENT>
|
||||||
|
</PATH>
|
||||||
</subPane>
|
</subPane>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectReloadState">
|
<component name="ProjectReloadState">
|
||||||
@ -189,52 +257,6 @@
|
|||||||
<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" />
|
||||||
@ -254,6 +276,52 @@
|
|||||||
</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="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="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>
|
||||||
<list size="0" />
|
<list size="0" />
|
||||||
<configuration name="<template>" type="WebApp" default="true" selected="false">
|
<configuration name="<template>" type="WebApp" default="true" selected="false">
|
||||||
<Host>localhost</Host>
|
<Host>localhost</Host>
|
||||||
@ -305,16 +373,16 @@
|
|||||||
</todo-panel>
|
</todo-panel>
|
||||||
</component>
|
</component>
|
||||||
<component name="ToolWindowManager">
|
<component name="ToolWindowManager">
|
||||||
<frame x="1" y="22" width="1661" height="1178" 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" />
|
||||||
<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="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="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="false" weight="0.21091811" order="0" />
|
<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="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="true" weight="0.32841328" order="1" />
|
<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="true" weight="0.25" 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="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="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="Module Dependencies" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" />
|
||||||
@ -391,9 +459,9 @@
|
|||||||
</GetOptions>
|
</GetOptions>
|
||||||
</component>
|
</component>
|
||||||
<component name="editorHistoryManager">
|
<component name="editorHistoryManager">
|
||||||
<entry file="file://$PROJECT_DIR$/jspec/test/test.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="14" column="0" selection-start="14" selection-end="491" vertical-scroll-proportion="0.278826">
|
<state line="15" column="26" selection-start="541" selection-end="541" vertical-scroll-proportion="0.29533678">
|
||||||
<folding />
|
<folding />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
@ -401,64 +469,23 @@
|
|||||||
<state />
|
<state />
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/test/test.html">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state line="12" column="4" selection-start="492" selection-end="492" vertical-scroll-proportion="0.2389937">
|
|
||||||
<folding />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
<provider editor-type-id="HtmlPreview">
|
|
||||||
<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="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$/jspec/test/test.js">
|
|
||||||
<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/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.14157973">
|
<state line="5" column="0" selection-start="118" selection-end="118" vertical-scroll-proportion="0.09187621">
|
||||||
<folding />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state line="15" column="26" selection-start="541" selection-end="541" vertical-scroll-proportion="0.47342193">
|
|
||||||
<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="361" column="6" selection-start="10010" selection-end="10010" vertical-scroll-proportion="0.14728682">
|
|
||||||
<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="296" column="0" selection-start="6528" selection-end="6528" vertical-scroll-proportion="0.76829267">
|
<state line="284" column="31" selection-start="5933" selection-end="5933" vertical-scroll-proportion="0.85083413">
|
||||||
|
<folding />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state line="642" column="7" selection-start="18504" selection-end="18504" vertical-scroll-proportion="0.81150794">
|
||||||
<folding />
|
<folding />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
|
1
jspec
1
jspec
@ -1 +0,0 @@
|
|||||||
Subproject commit d1c67d1f23fc186b86d1a4472039e13a389c903b
|
|
@ -18,6 +18,45 @@ if (typeof Function.method !== 'function') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* object for holding results; allows for the results array to hold another nestedResults()
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
var nestedResults = function() {
|
||||||
|
var that = {
|
||||||
|
totalCount: 0,
|
||||||
|
passedCount: 0,
|
||||||
|
failedCount: 0,
|
||||||
|
results: [],
|
||||||
|
|
||||||
|
rollupCounts: function (result) {
|
||||||
|
that.totalCount += result.totalCount;
|
||||||
|
that.passedCount += result.passedCount;
|
||||||
|
that.failedCount += result.failedCount;
|
||||||
|
},
|
||||||
|
|
||||||
|
push: function (result) {
|
||||||
|
if (result.results) {
|
||||||
|
that.rollupCounts(result);
|
||||||
|
} else {
|
||||||
|
that.totalCount++;
|
||||||
|
result.passed ? that.passedCount++ : that.failedCount++;
|
||||||
|
}
|
||||||
|
that.results.push(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return that;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* base for Runner & Suite: allows for a queue of functions to get executed, allowing for
|
||||||
|
* any one action to complete, including asynchronous calls, before going to the next
|
||||||
|
* action.
|
||||||
|
*
|
||||||
|
**/
|
||||||
var actionCollection = function () {
|
var actionCollection = function () {
|
||||||
var that = {
|
var that = {
|
||||||
actions: [],
|
actions: [],
|
||||||
@ -82,6 +121,7 @@ var actionCollection = function () {
|
|||||||
/*
|
/*
|
||||||
* Matchers methods; add your own with Matchers.method()
|
* Matchers methods; add your own with Matchers.method()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Matchers = function (actual, results) {
|
Matchers = function (actual, results) {
|
||||||
this.actual = actual;
|
this.actual = actual;
|
||||||
this.passing_message = 'Passed.'
|
this.passing_message = 'Passed.'
|
||||||
@ -101,7 +141,6 @@ Matchers.method('report', function (result, failing_message) {
|
|||||||
Matchers.method('should_equal', function (expected) {
|
Matchers.method('should_equal', function (expected) {
|
||||||
return this.report((this.actual === expected),
|
return this.report((this.actual === expected),
|
||||||
'Expected ' + expected + ' but got ' + this.actual + '.');
|
'Expected ' + expected + ' but got ' + this.actual + '.');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Matchers.method('should_not_equal', function (expected) {
|
Matchers.method('should_not_equal', function (expected) {
|
||||||
@ -134,34 +173,6 @@ var queuedFunction = function(func, timeout, spec) {
|
|||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
var nestedResults = function() {
|
|
||||||
var that = {
|
|
||||||
totalCount: 0,
|
|
||||||
passedCount: 0,
|
|
||||||
failedCount: 0,
|
|
||||||
results: [],
|
|
||||||
|
|
||||||
push: function(result) {
|
|
||||||
if (result.results) {
|
|
||||||
that.totalCount += result.totalCount;
|
|
||||||
that.passedCount += result.passedCount;
|
|
||||||
that.failedCount += result.failedCount;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
that.totalCount++;
|
|
||||||
if (result.passed) {
|
|
||||||
that.passedCount++;
|
|
||||||
} else {
|
|
||||||
that.failedCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
that.results.push(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return that;
|
|
||||||
}
|
|
||||||
|
|
||||||
var it = function (description, func) {
|
var it = function (description, func) {
|
||||||
var that = {
|
var that = {
|
||||||
description: description,
|
description: description,
|
||||||
@ -211,7 +222,6 @@ var it = function (description, func) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
that.runs = addToQueue;
|
that.runs = addToQueue;
|
||||||
that.then = addToQueue;
|
|
||||||
|
|
||||||
currentSuite.specs.push(that);
|
currentSuite.specs.push(that);
|
||||||
currentSpec = that;
|
currentSpec = that;
|
||||||
@ -228,8 +238,6 @@ var runs = function (func) {
|
|||||||
currentSpec.runs(func);
|
currentSpec.runs(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
var then = runs;
|
|
||||||
|
|
||||||
var waits = function (timeout) {
|
var waits = function (timeout) {
|
||||||
currentSpec.waits(timeout);
|
currentSpec.waits(timeout);
|
||||||
}
|
}
|
||||||
@ -249,7 +257,7 @@ var describe = function (description, spec_definitions) {
|
|||||||
that.specs = that.actions;
|
that.specs = that.actions;
|
||||||
|
|
||||||
currentSuite = that;
|
currentSuite = that;
|
||||||
currentRunner.suites.push(that);
|
Jasmine.suites.push(that);
|
||||||
|
|
||||||
spec_definitions();
|
spec_definitions();
|
||||||
|
|
||||||
@ -258,19 +266,18 @@ var describe = function (description, spec_definitions) {
|
|||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
var Jasmine = function () {
|
var Runner = function () {
|
||||||
var that = actionCollection();
|
var that = actionCollection();
|
||||||
|
|
||||||
that.suites = that.actions;
|
that.suites = that.actions;
|
||||||
that.results.description = 'All Jasmine Suites';
|
that.results.description = 'All Jasmine Suites';
|
||||||
|
|
||||||
currentRunner = that;
|
Jasmine = that;
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentRunner = Jasmine();
|
var Jasmine = Runner();
|
||||||
var currentSuite = describe('default current suite', function() {});
|
var currentSuite = describe('default current suite', function() {});
|
||||||
|
|
||||||
var currentSpec;
|
var currentSpec;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
</h1>
|
</h1>
|
||||||
<div id="icon_wrapper">
|
<div id="icon_wrapper">
|
||||||
<span id="icons"></span>
|
<span id="icons"></span>
|
||||||
<img id="spinner" src="spinner.gif" alt="" />
|
<img id="spinner" src="../images/spinner.gif" alt="" />
|
||||||
</div>
|
</div>
|
||||||
<div id="report">
|
<div id="report">
|
||||||
<div id="results_summary" style="display:none;">
|
<div id="results_summary" style="display:none;">
|
||||||
|
136
test/bootstrap.js
vendored
136
test/bootstrap.js
vendored
@ -136,22 +136,26 @@ var testSpecs = function () {
|
|||||||
var testAsyncSpecs = function () {
|
var testAsyncSpecs = function () {
|
||||||
var foo = 0;
|
var foo = 0;
|
||||||
|
|
||||||
var a_spec = it('simple queue test').
|
var a_spec = it('simple queue test', function () {
|
||||||
runs(function () {
|
runs(function () {
|
||||||
foo++;
|
foo++;
|
||||||
}).then(function() {
|
});
|
||||||
this.expects_that(foo).should_equal(1)
|
runs(function () {
|
||||||
|
this.expects_that(foo).should_equal(1)
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.test(a_spec.queue.length === 2,
|
reporter.test(a_spec.queue.length === 2,
|
||||||
'Spec queue length is not 2');
|
'Spec queue length is not 2');
|
||||||
|
|
||||||
foo = 0;
|
foo = 0;
|
||||||
a_spec = it('spec w/ queued statments').
|
a_spec = it('spec w/ queued statments', function () {
|
||||||
runs(function () {
|
runs(function () {
|
||||||
foo++;
|
foo++;
|
||||||
}).then(function() {
|
});
|
||||||
this.expects_that(foo).should_equal(1);
|
runs(function () {
|
||||||
|
this.expects_that(foo).should_equal(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
a_spec.execute();
|
a_spec.execute();
|
||||||
@ -162,14 +166,16 @@ var testAsyncSpecs = function () {
|
|||||||
'No call to waits(): Queued expectation failed');
|
'No call to waits(): Queued expectation failed');
|
||||||
|
|
||||||
foo = 0;
|
foo = 0;
|
||||||
a_spec = it('spec w/ queued statments').
|
a_spec = it('spec w/ queued statments', function () {
|
||||||
runs(function () {
|
runs(function () {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
foo++
|
foo++
|
||||||
}, 500);
|
}, 500);
|
||||||
}).waits(1000).
|
});
|
||||||
then(function() {
|
waits(1000);
|
||||||
this.expects_that(foo).should_equal(1);
|
runs(function() {
|
||||||
|
this.expects_that(foo).should_equal(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var mockSuite = {
|
var mockSuite = {
|
||||||
@ -185,22 +191,25 @@ var testAsyncSpecs = function () {
|
|||||||
waitForDone(a_spec, mockSuite);
|
waitForDone(a_spec, mockSuite);
|
||||||
|
|
||||||
var bar = 0;
|
var bar = 0;
|
||||||
var another_spec = it('spec w/ queued statments').
|
var another_spec = it('spec w/ queued statments', function () {
|
||||||
runs(function () {
|
runs(function () {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
bar++;
|
bar++;
|
||||||
}, 250);
|
}, 250);
|
||||||
}).
|
|
||||||
waits(500).
|
});
|
||||||
then(function () {
|
waits(500);
|
||||||
setTimeout(function() {
|
runs(function () {
|
||||||
bar++;
|
setTimeout(function() {
|
||||||
}, 250);
|
bar++;
|
||||||
}).
|
}, 250);
|
||||||
waits(1500).
|
});
|
||||||
then(function() {
|
waits(500);
|
||||||
this.expects_that(bar).should_equal(2);
|
runs(function () {
|
||||||
|
this.expects_that(bar).should_equal(2);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
mockSuite = {
|
mockSuite = {
|
||||||
next: function() {
|
next: function() {
|
||||||
reporter.test((another_spec.queue.length === 3),
|
reporter.test((another_spec.queue.length === 3),
|
||||||
@ -215,17 +224,19 @@ var testAsyncSpecs = function () {
|
|||||||
waitForDone(another_spec, mockSuite);
|
waitForDone(another_spec, mockSuite);
|
||||||
|
|
||||||
var baz = 0;
|
var baz = 0;
|
||||||
var yet_another_spec = it('spec w/ async fail').
|
var yet_another_spec = it('spec w/ async fail', function () {
|
||||||
runs(function () {
|
runs(function () {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
baz++;
|
baz++;
|
||||||
}, 250);
|
}, 250);
|
||||||
}).
|
});
|
||||||
waits(100).
|
waits(100);
|
||||||
then(function() {
|
runs(function() {
|
||||||
this.expects_that(baz).should_equal(1);
|
this.expects_that(baz).should_equal(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
mockSuite = {
|
mockSuite = {
|
||||||
next: function() {
|
next: function() {
|
||||||
|
|
||||||
@ -244,21 +255,22 @@ var testAsyncSpecs = function () {
|
|||||||
|
|
||||||
var testAsyncSpecsWithMockSuite = function () {
|
var testAsyncSpecsWithMockSuite = function () {
|
||||||
var bar = 0;
|
var bar = 0;
|
||||||
var another_spec = it('spec w/ queued statments').
|
var another_spec = it('spec w/ queued statments', function () {
|
||||||
runs(function () {
|
runs(function () {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
bar++;
|
bar++;
|
||||||
}, 250);
|
}, 250);
|
||||||
}).
|
});
|
||||||
waits(500).
|
waits(500);
|
||||||
then(function () {
|
runs(function () {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
bar++;
|
bar++;
|
||||||
}, 250);
|
}, 250);
|
||||||
}).
|
});
|
||||||
waits(1500).
|
waits(1500)
|
||||||
then(function() {
|
runs(function() {
|
||||||
this.expects_that(bar).should_equal(2);
|
this.expects_that(bar).should_equal(2);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var mockSuite = {
|
var mockSuite = {
|
||||||
@ -481,14 +493,14 @@ var testSpecScope = function () {
|
|||||||
|
|
||||||
var testRunner = function() {
|
var testRunner = function() {
|
||||||
|
|
||||||
var runner = Jasmine();
|
var runner = Runner();
|
||||||
describe('one suite description', function () {
|
describe('one suite description', function () {
|
||||||
it('should be a test');
|
it('should be a test');
|
||||||
});
|
});
|
||||||
reporter.test((runner.suites.length === 1),
|
reporter.test((runner.suites.length === 1),
|
||||||
"Runner expected one suite");
|
"Runner expected one suite");
|
||||||
|
|
||||||
runner = Jasmine();
|
runner = Runner();
|
||||||
describe('one suite description', function () {
|
describe('one suite description', function () {
|
||||||
it('should be a test');
|
it('should be a test');
|
||||||
});
|
});
|
||||||
@ -498,7 +510,7 @@ var testRunner = function() {
|
|||||||
reporter.test((runner.suites.length === 2),
|
reporter.test((runner.suites.length === 2),
|
||||||
"Runner expected two suites");
|
"Runner expected two suites");
|
||||||
|
|
||||||
runner = Jasmine();
|
runner = Runner();
|
||||||
describe('one suite description', function () {
|
describe('one suite description', function () {
|
||||||
it('should be a test', function() {
|
it('should be a test', function() {
|
||||||
runs(function () {
|
runs(function () {
|
||||||
@ -578,7 +590,7 @@ var testNestedResults = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var testReporting = function () {
|
var testReporting = function () {
|
||||||
var runner = Jasmine();
|
var runner = Runner();
|
||||||
describe('one suite description', function () {
|
describe('one suite description', function () {
|
||||||
it('should be a test', function() {
|
it('should be a test', function() {
|
||||||
runs(function () {
|
runs(function () {
|
||||||
@ -628,7 +640,7 @@ var runTests = function () {
|
|||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$('spinner').hide();
|
$('spinner').hide();
|
||||||
reporter.summary();
|
reporter.summary();
|
||||||
}, 4500);
|
}, 3500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Jasmine Tests</title>
|
|
||||||
<link type="text/css" rel="stylesheet" href="../jspec/lib/jspec.css"/>
|
|
||||||
<script type="text/javascript" src="../jspec/lib/jspec.js"></script>
|
|
||||||
|
|
||||||
<script type="text/javascript" src="../lib/jasmine.js"></script>
|
|
||||||
<link type="text/css" rel="stylesheet" href="test.css"/>
|
|
||||||
<script type="text/javascript" src="test.js"></script>
|
|
||||||
</head>
|
|
||||||
<body onLoad="JSpecManager.run(htmlReporter);">
|
|
||||||
<h1>
|
|
||||||
Running all Jasmine Test Suites
|
|
||||||
</h1>
|
|
||||||
<div id="jspec">
|
|
||||||
<img src="spinner.gif" alt=""/>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
|
|
126
test/test.js
126
test/test.js
@ -1,126 +0,0 @@
|
|||||||
// NOTE: we're using JSpec to test-drive Jasmine. Any syntax
|
|
||||||
// similarities should be ignored. THIS FILE uses JSpec
|
|
||||||
|
|
||||||
with(JSpec('Jasmine expectation results')) {
|
|
||||||
|
|
||||||
it('should compare actual and expected values that are equal', function () {
|
|
||||||
var jasmine_result = expects(true).should_equal(true);
|
|
||||||
|
|
||||||
expects_that(jasmine_result).should_equal(true).and_finish();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should compare actual and expected values that are NOT equal', function () {
|
|
||||||
var jasmine_result = expects(false).should_equal(true);
|
|
||||||
|
|
||||||
expects_that(jasmine_result).should_equal(false).and_finish();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be able to store the results of assertions', function () {
|
|
||||||
Jasmine = jasmine_init(); // re-clears out Jasmine
|
|
||||||
|
|
||||||
expects(true).should_equal(true);
|
|
||||||
expects(false).should_equal(true);
|
|
||||||
|
|
||||||
expects_that(Jasmine.results.length).should_equal(2);
|
|
||||||
expects_that(Jasmine.results[0].passed).should_equal(true);
|
|
||||||
expects_that(Jasmine.results[1].passed).should_equal(false).and_finish();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should store a message with a failed expectation', function () {
|
|
||||||
Jasmine = jasmine_init(); // re-clears out Jasmine
|
|
||||||
|
|
||||||
expects(false).should_equal(true);
|
|
||||||
|
|
||||||
var expected_message = 'Expected true but got false.';
|
|
||||||
expects_that(Jasmine.results[0].message).should_equal(expected_message).and_finish();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should store a default message with a passed expectation', function () {
|
|
||||||
Jasmine = jasmine_init();
|
|
||||||
|
|
||||||
expects(true).should_equal(true);
|
|
||||||
|
|
||||||
var expected_message = 'Passed.';
|
|
||||||
expects_that(Jasmine.results[0].message).should_equal(expected_message).and_finish();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support should_not_equal() passing', function () {
|
|
||||||
Jasmine = jasmine_init();
|
|
||||||
|
|
||||||
expects(true).should_not_equal(false);
|
|
||||||
|
|
||||||
var expected_message = 'Passed.';
|
|
||||||
expects_that(Jasmine.results[0].message).should_equal(expected_message).and_finish();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support should_not_equal() message', function () {
|
|
||||||
Jasmine = jasmine_init();
|
|
||||||
|
|
||||||
expects(true).should_not_equal(true);
|
|
||||||
|
|
||||||
var expected_message = 'Expected true to not equal true, but it does.';
|
|
||||||
expects_that(Jasmine.results[0].message).should_equal(expected_message).and_finish();
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
with(JSpec('Jasmine specs')){
|
|
||||||
|
|
||||||
it('can have a description', function () {
|
|
||||||
Jasmine = jasmine_init();
|
|
||||||
|
|
||||||
var a_spec = spec('new spec');
|
|
||||||
expects_that(a_spec.description).should_equal('new spec').and_finish();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can execute some statements & expectations', function () {
|
|
||||||
Jasmine = jasmine_init();
|
|
||||||
|
|
||||||
var a_spec = spec('new spec', function () {
|
|
||||||
var foo = 'bar';
|
|
||||||
expects(foo).should_equal('bar');
|
|
||||||
});
|
|
||||||
|
|
||||||
a_spec.execute();
|
|
||||||
|
|
||||||
expects_that(Jasmine.results.length).should_equal(1)
|
|
||||||
expects_that(Jasmine.results[0].passed).should_equal(true).and_finish();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can have multiple assertions', function () {
|
|
||||||
Jasmine = jasmine_init();
|
|
||||||
|
|
||||||
var a_spec = spec('new spec', function () {
|
|
||||||
var foo = 'bar';
|
|
||||||
var baz = 'quux'
|
|
||||||
|
|
||||||
expects(foo).should_equal('bar');
|
|
||||||
expects(baz).should_equal('quux');
|
|
||||||
});
|
|
||||||
|
|
||||||
a_spec.execute();
|
|
||||||
|
|
||||||
expects_that(Jasmine.results.length).should_equal(2).and_finish();
|
|
||||||
});
|
|
||||||
|
|
||||||
// it('can evaluate expectations after an asynchronous set of execution steps', function () {
|
|
||||||
// });
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// should be able to run multiple specs in a suite in order
|
|
||||||
|
|
||||||
//with(JSpec('Test runner')) {
|
|
||||||
//
|
|
||||||
// it('should run a test and collect a result', function () {
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// expects_that(actual).should_equal(expected)u;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//}
|
|
Loading…
Reference in New Issue
Block a user