Compare commits
257 Commits
0.8.0-rele
...
0.11.1-rel
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6d1f7d871 | ||
|
|
5e843e087b | ||
|
|
51c0563608 | ||
|
|
9e3036fbf7 | ||
|
|
dcc8b460d1 | ||
|
|
c533b67aa5 | ||
|
|
7a69d64669 | ||
|
|
ed80a0cad7 | ||
|
|
85351f2c1c | ||
|
|
1057596665 | ||
|
|
22065fafad | ||
|
|
2939aff80c | ||
|
|
6a0e452788 | ||
|
|
00296b02e0 | ||
|
|
8f5f6a6d27 | ||
|
|
ed47ececa9 | ||
|
|
9c8180d8d0 | ||
|
|
6a9f74e849 | ||
|
|
3be2455d8c | ||
|
|
40b0c49d25 | ||
|
|
82e04c327a | ||
|
|
2a3376d11e | ||
|
|
413be6b4ca | ||
|
|
0539251fe6 | ||
|
|
1154fcaf3b | ||
|
|
01d842fdfd | ||
|
|
e60f22a2e5 | ||
|
|
e7cd6a473a | ||
|
|
3bdc96c00a | ||
|
|
b9bf42c6b5 | ||
|
|
2d138f1cfa | ||
|
|
e30b99e7b3 | ||
|
|
40272cd563 | ||
|
|
c187adc096 | ||
|
|
5aa306cf66 | ||
|
|
462b50e84e | ||
|
|
46249bf515 | ||
|
|
03d7bfb7d4 | ||
|
|
11292ff83c | ||
|
|
ab7678e713 | ||
|
|
6431431dfc | ||
|
|
a2041e90a6 | ||
|
|
ed49104fad | ||
|
|
803a2fb2ba | ||
|
|
bb1928a75c | ||
|
|
7d5ff6985f | ||
|
|
841e93fc09 | ||
|
|
5cfb019b6b | ||
|
|
9f8d18b6b7 | ||
|
|
f0574086de | ||
|
|
2212d755c3 | ||
|
|
5f10b2e623 | ||
|
|
d8ed4156c7 | ||
|
|
1469f83262 | ||
|
|
d6353a3db2 | ||
|
|
9a5b46fd99 | ||
|
|
bf938ffc50 | ||
|
|
c85079e9d0 | ||
|
|
dec92322f1 | ||
|
|
72ea614d5e | ||
|
|
184ff6fb2d | ||
|
|
9830952461 | ||
|
|
e9a2b0dcdb | ||
|
|
23d5c7180b | ||
|
|
a661e77345 | ||
|
|
564b9a0c3e | ||
|
|
2ab6af1e48 | ||
|
|
22e9434a50 | ||
|
|
581d948c93 | ||
|
|
7721f47f59 | ||
|
|
49f295690a | ||
|
|
4b80a10969 | ||
|
|
6574dcc728 | ||
|
|
99bcfdcd0d | ||
|
|
fcfe23d516 | ||
|
|
e1b3ca4066 | ||
|
|
5a7eea53b1 | ||
|
|
f9426a008e | ||
|
|
0bb7f4bd6a | ||
|
|
da49a0ce40 | ||
|
|
80d67d49a0 | ||
|
|
6ca766d5ea | ||
|
|
5e3eb884ca | ||
|
|
aef78b1ef1 | ||
|
|
f1f5d8de7d | ||
|
|
535d9abce0 | ||
|
|
8679090bf3 | ||
|
|
b12605274d | ||
|
|
db1c6e659d | ||
|
|
d72b18c47b | ||
|
|
81c2779731 | ||
|
|
163f5977a5 | ||
|
|
99ab1f0e81 | ||
|
|
02db3338fb | ||
|
|
ca841c9248 | ||
|
|
c78460289a | ||
|
|
a16cbe7e5b | ||
|
|
e986b024bc | ||
|
|
bef9867b61 | ||
|
|
d16e2b7992 | ||
|
|
20a00d517e | ||
|
|
9f247eb278 | ||
|
|
b99bd08df9 | ||
|
|
72b5ede0da | ||
|
|
21998dcb9d | ||
|
|
ba8c16acd7 | ||
|
|
dd5e97bf14 | ||
|
|
d90852336f | ||
|
|
849a4efda8 | ||
|
|
40ff1cb4c8 | ||
|
|
23c5289b7e | ||
|
|
7653107f0c | ||
|
|
2cb5bf146c | ||
|
|
4ebc3b5964 | ||
|
|
701ee719e6 | ||
|
|
f99a5ff577 | ||
|
|
1a53838d97 | ||
|
|
2fc78a0fe2 | ||
|
|
60ea562560 | ||
|
|
b0326d3078 | ||
|
|
752b91f118 | ||
|
|
b0ae461139 | ||
|
|
ee5905d237 | ||
|
|
5a8a050c46 | ||
|
|
7be8247b2f | ||
|
|
2881a645a5 | ||
|
|
98e86817bf | ||
|
|
3b92b9bb79 | ||
|
|
1b3545c82a | ||
|
|
2a5754600a | ||
|
|
ff8b9d8375 | ||
|
|
1982fb51c9 | ||
|
|
0810e4a01c | ||
|
|
0f610b03d2 | ||
|
|
8feb285ca8 | ||
|
|
c21431415b | ||
|
|
f9d73761bb | ||
|
|
4c600311df | ||
|
|
827fd1da0e | ||
|
|
328cc89980 | ||
|
|
cf6d26d25f | ||
|
|
b67d2a265d | ||
|
|
8b23698852 | ||
|
|
6a467fc00e | ||
|
|
fa2d36c5dc | ||
|
|
a0cac54492 | ||
|
|
2059422955 | ||
|
|
b35a2acfc8 | ||
|
|
e77162f308 | ||
|
|
1c3b3b89be | ||
|
|
970ef0cec2 | ||
|
|
97ce2070d1 | ||
|
|
b6e408aab8 | ||
|
|
6b3bf1b3ba | ||
|
|
5dd9c53176 | ||
|
|
5f82bdbf1b | ||
|
|
3109e7a4bb | ||
|
|
397d202f54 | ||
|
|
2597c235d9 | ||
|
|
d222855cc8 | ||
|
|
308d02f72f | ||
|
|
35171c9222 | ||
|
|
e9e74f1800 | ||
|
|
85d3b2d14b | ||
|
|
706b180a2c | ||
|
|
beddbaf5c7 | ||
|
|
a907301dcb | ||
|
|
1b1c2b1998 | ||
|
|
e7865295dd | ||
|
|
6d8557608c | ||
|
|
fd37be4dff | ||
|
|
92ffcb47e2 | ||
|
|
c164d58a1a | ||
|
|
3459697cb4 | ||
|
|
31bb686fd5 | ||
|
|
5659a1e79e | ||
|
|
b7549196da | ||
|
|
a3ed49a5ed | ||
|
|
e1ebc1e692 | ||
|
|
d27684d280 | ||
|
|
f9b3eff5ab | ||
|
|
34b479a1a4 | ||
|
|
6ee8ed02a9 | ||
|
|
73c0d57c94 | ||
|
|
cbc15d733d | ||
|
|
61241140e8 | ||
|
|
250c483a6b | ||
|
|
a394b564f4 | ||
|
|
2588368231 | ||
|
|
d09cacebc7 | ||
|
|
ddaab50b75 | ||
|
|
e33ecf3665 | ||
|
|
26fdc7cc91 | ||
|
|
724f1772b7 | ||
|
|
2a29bb3ad9 | ||
|
|
3e7f870965 | ||
|
|
11f356e375 | ||
|
|
65cec7a2b9 | ||
|
|
4620ea6a44 | ||
|
|
3b702bd992 | ||
|
|
bed9e118b6 | ||
|
|
8ba804e299 | ||
|
|
17b513eafb | ||
|
|
ca6b23684e | ||
|
|
268cb0c6c5 | ||
|
|
5e8b52debf | ||
|
|
43f819e9e2 | ||
|
|
4533d6a7cd | ||
|
|
50134eb1ac | ||
|
|
4138fd3626 | ||
|
|
b9ee6a9119 | ||
|
|
d7a47264ef | ||
|
|
187bde37ca | ||
|
|
7edeb13be8 | ||
|
|
e8d582600c | ||
|
|
7a446d53c0 | ||
|
|
ba5b4ab166 | ||
|
|
985d08885e | ||
|
|
368756e4d5 | ||
|
|
a1bc4dc2e4 | ||
|
|
f9d61108ee | ||
|
|
3993969c41 | ||
|
|
9b9a4b6835 | ||
|
|
96bcde80af | ||
|
|
bc790d6b87 | ||
|
|
2a4241323d | ||
|
|
0a3358f249 | ||
|
|
1573bf58c5 | ||
|
|
1c9607ec33 | ||
|
|
e9126fdd9b | ||
|
|
ab65914233 | ||
|
|
027b28ecb0 | ||
|
|
8870f907e8 | ||
|
|
ca077342f3 | ||
|
|
454d453207 | ||
|
|
7b63960db0 | ||
|
|
3e68a2c2bc | ||
|
|
4410c7cd94 | ||
|
|
93c7b092b3 | ||
|
|
624a6dd85c | ||
|
|
8f12dbf3b4 | ||
|
|
2ef71580ad | ||
|
|
4b244612c1 | ||
|
|
b1a007dfb5 | ||
|
|
e476f2375a | ||
|
|
0061054aaa | ||
|
|
56c26c5b55 | ||
|
|
8b998749f3 | ||
|
|
b55399bd4b | ||
|
|
0d6c6c2a35 | ||
|
|
9475de28b3 | ||
|
|
b6a41c85e1 | ||
|
|
f73fd8ae95 | ||
|
|
d5489a3e0d | ||
|
|
60f513cbff | ||
|
|
f84c67b98a | ||
|
|
a1a278ee69 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
.idea/
|
||||
.idea/inspectionProfiles/
|
||||
.svn/
|
||||
.DS_Store
|
||||
|
||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "pages"]
|
||||
path = pages
|
||||
url = git@github.com:pivotal/jasmine.git
|
||||
6
.idea/inspectionProfiles/Project_Default.xml
generated
6
.idea/inspectionProfiles/Project_Default.xml
generated
@@ -1,6 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0" is_locked="false">
|
||||
<option name="myName" value="Project Default" />
|
||||
<option name="myLocal" value="false" />
|
||||
</profile>
|
||||
</component>
|
||||
8
.idea/inspectionProfiles/profiles_settings.xml
generated
8
.idea/inspectionProfiles/profiles_settings.xml
generated
@@ -1,8 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="PROJECT_PROFILE" value="Project Default" />
|
||||
<option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
|
||||
<scopes />
|
||||
<list size="0" />
|
||||
</settings>
|
||||
</component>
|
||||
659
README.markdown
659
README.markdown
@@ -1,48 +1,73 @@
|
||||
Jasmine
|
||||
[Jasmine](http://pivotal.github.com/jasmine)
|
||||
=======
|
||||
**YET ANOTHER JavaScript testing framework**
|
||||
**A JavaScript Testing Framework**
|
||||
|
||||
Why Another Frickin' JS TDD/BDD Framework?
|
||||
Quick Start
|
||||
----------
|
||||
|
||||
1. Get the latest release from the [downloads page](http://github.com/pivotal/jasmine/downloads).
|
||||
2. Open `SpecRunner.html` in your favorite browser.
|
||||
|
||||
For running within a Ruby environment, including automated execution with Selenium, please use
|
||||
the [jasmine gem](http://github.com/pivotal/jasmine-gem).
|
||||
|
||||
### Which Release Should I Use?
|
||||
|
||||
Please use the latest version unless you have a good reason not to. Some of this documentation may not be applicable to older versions. Please see [[Release Notes]](http://wiki.github.com/pivotal/jasmine/release-notes) for change information.
|
||||
|
||||
Why Another JavaScript 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 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.
|
||||
There are some great JavaScript testing frameworks out there already, so why did we write another?
|
||||
|
||||
But you still need to write tests.
|
||||
None of the existing frameworks quite worked the way we wanted. Many only work from within a browser. Most don't support testing asynchronous code like event callbacks. Some have syntax that's hard for JS developers or IDEs to understand.
|
||||
|
||||
What's an Agile Engineer to do?
|
||||
So we decided to start from scratch.
|
||||
|
||||
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 require a DOM. JSpec's DOM-less assumption was a great start, but it needed asynchronous support.
|
||||
Jasmine is our dream JavaScript testing framework. It's heavily influenced by, and borrows the best parts of, ScrewUnit, JSSpec, [JSpec](http://github.com/visionmedia/jspec/tree/master), and of course RSpec.
|
||||
|
||||
So we started over. And TDD'd a whole new framework. Enjoy.
|
||||
Jasmine was designed with a few principles in mind. We believe that a good JavaScript testing framework:
|
||||
|
||||
* should not be tied to any browser, framework, platform, or host language.
|
||||
* should have idiomatic and unsurprising syntax.
|
||||
* should work anywhere JavaScript can run, including browsers, servers, phones, etc.
|
||||
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).
|
||||
* should play well with IDEs (e.g. test code should pass static analysis).
|
||||
|
||||
Some of our goals while writing Jasmine:
|
||||
|
||||
* it should encourage good testing practices.
|
||||
* it should integrate easily with continuous build systems.
|
||||
* it should be simple to get started with.
|
||||
|
||||
The result is Jasmine, and we love test-driving our code with it. Enjoy.
|
||||
|
||||
How To
|
||||
------
|
||||
|
||||
There is a nice example of how to use Jasmine in the /example directory. But here's more information.
|
||||
|
||||
Exciting changes are afoot and many syntax changes have been made to make Jasmine more usable. Please read the examples below for updates.
|
||||
There is a simple example of how to use Jasmine in the /example directory. But here's more information.
|
||||
|
||||
### Specs
|
||||
|
||||
Each spec is, naturally, a JavaScript function. You tell Jasmine about this spec with a call to `it()` with a string and the function. The string is a description that will be helpful to you when reading a report.
|
||||
|
||||
it('should be a test', function () {
|
||||
var foo = 0
|
||||
var foo = 0;
|
||||
foo++;
|
||||
});
|
||||
|
||||
### Expectations
|
||||
|
||||
Within your spec you will want/need to make expectations. These are made with the `expect()` funciton and expectation matchers. like this:
|
||||
Within your spec you will want to express expectations about the behavior of your application code. These are made with the `expect()` function and expectation matchers, like this:
|
||||
|
||||
it('should be a test', function () {
|
||||
var foo = 0
|
||||
foo++;
|
||||
var foo = 0; // set up the world
|
||||
foo++; // call your application code
|
||||
|
||||
expect(foo).toEqual(1);
|
||||
expect(foo).toEqual(1); // passes because foo == 1
|
||||
});
|
||||
|
||||
Results of the expectations are logged for later for reporting.
|
||||
@@ -51,42 +76,297 @@ Results of the expectations are logged for later for reporting.
|
||||
|
||||
Jasmine has several built-in matchers. Here are a few:
|
||||
|
||||
`toEqual()` compares objects or primitives and returns true if they are equal
|
||||
>`expect(x).toEqual(y);` compares objects or primitives `x` and `y` and passes if they are equivalent
|
||||
>
|
||||
>`expect(x).toMatch(pattern);` compares `x` to string or regular expression `pattern` and passes if they match
|
||||
>
|
||||
>`expect(x).toBeDefined();` passes if `x` is not `undefined`
|
||||
>
|
||||
>`expect(x).toBeNull();` passes if `x` is `null`
|
||||
>
|
||||
>`expect(x).toBeTruthy();` passes if `x` evaluates to true
|
||||
>
|
||||
>`expect(x).toBeFalsy();` passes if `x` evaluates to false
|
||||
>
|
||||
>`expect(x).toContain(y);` passes if array or string `x` contains `y`
|
||||
|
||||
`toNotEqual()` compares objects or primitives and returns true if they are not equal
|
||||
Every matcher's criteria can be inverted by prepending `.not`:
|
||||
|
||||
`toMatch()` takes a regex or a string and returns true if it matches
|
||||
|
||||
`toNotMatch()` takes a regex or a string and returns true if it does not match
|
||||
|
||||
`toBeDefined()` returns true if the object or primitive is not `undefined`
|
||||
|
||||
`toBeNull()` returns true if the object or primitive is not `null`
|
||||
|
||||
`toBeTruthy()` returns true if the object or primitive evaluates to true
|
||||
|
||||
`toBeFalsy()` returns true if the object or primitive evaluates to false
|
||||
|
||||
`toContain()` returns true if an array or string contains the passed variable.
|
||||
|
||||
`toNotContain()` returns true if an array or string does not contain the passed variable.
|
||||
>`expect(x).not.toEqual(y);` compares objects or primitives `x` and `y` and passes if they are *not* equivalent
|
||||
|
||||
#### Writing 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 `toEqual()`:
|
||||
We've provided a small set of matchers that cover many common situations. However, we recommend that you write custom matchers when you want to assert a more specific sort of expectation. Custom matchers help to document the intent of your specs, and can help to remove code duplication in your specs.
|
||||
|
||||
Jasmine.Matchers.prototype.toEqual = function (expected) {
|
||||
return this.report((this.actual === expected),
|
||||
'Expected ' + expected + ' but got ' + this.actual + '.');
|
||||
});
|
||||
It's extremely easy to create new matchers for your app. A matcher function receives the actual value as `this.actual`, and zero or more arguments may be passed in the function call. The function should return `true` if the actual value passes the matcher's requirements, and `false` if it does not.
|
||||
|
||||
Feel free to define your own matcher as needed in your code. If you'd like to add Matchers to Jasmine, please write tests.
|
||||
Here's the definition of `toBeLessThan()`:
|
||||
|
||||
toBeLessThan: function(expected) {
|
||||
return this.actual < expected;
|
||||
};
|
||||
|
||||
To add the matcher to your suite, call `this.addMatchers()` from within a `before` or `it` block. Call it with an object mapping matcher name to function:
|
||||
|
||||
beforeEach(function() {
|
||||
this.addMatchers({
|
||||
toBeVisible: function() { return this.actual.isVisible(); }
|
||||
});
|
||||
});
|
||||
|
||||
### 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 Suite 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. Additionally, specs within a suite share a functional scope. So you may declare variables inside a describe block and they are accessible from within your specs. For example:
|
||||
|
||||
describe('A suite with some variables', function () {
|
||||
var bar = 0
|
||||
|
||||
it('has a test', function () {
|
||||
bar++;
|
||||
expect(bar).toEqual(1);
|
||||
});
|
||||
|
||||
it('has another test', function () {
|
||||
bar++;
|
||||
expect(bar).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
#### beforeEach
|
||||
|
||||
A suite can have a beforeEach declaration. It takes a function that is run before each spec. For example:
|
||||
|
||||
describe('some suite', function () {
|
||||
|
||||
var suiteWideFoo;
|
||||
|
||||
beforeEach(function () {
|
||||
suiteWideFoo = 1;
|
||||
});
|
||||
|
||||
it('should equal bar', function () {
|
||||
expect(suiteWideFoo).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
A runner can also have beforeEach declarations. Runner beforeEach functions are executed before every spec in all suites, and execute BEFORE suite beforeEach functions. For example:
|
||||
|
||||
var runnerWideFoo = [];
|
||||
|
||||
beforeEach(function () {
|
||||
runnerWideFoo.push('runner');
|
||||
});
|
||||
|
||||
describe('some suite', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
runnerWideFoo.push('suite');
|
||||
});
|
||||
|
||||
it('should equal bar', function () {
|
||||
expect(runnerWideFoo).toEqual(['runner', 'suite']);
|
||||
});
|
||||
});
|
||||
|
||||
#### afterEach
|
||||
|
||||
Similarly, there is an afterEach declaration. It takes a function that is run after each spec. For example:
|
||||
|
||||
describe('some suite', function () {
|
||||
|
||||
var suiteWideFoo;
|
||||
afterEach(function () {
|
||||
suiteWideFoo = 0;
|
||||
});
|
||||
|
||||
it('should equal 1', function () {
|
||||
expect(suiteWideFoo).toEqual(1);
|
||||
});
|
||||
|
||||
it('should equal 0 after', function () {
|
||||
expect(suiteWideFoo).toEqual(0);
|
||||
};
|
||||
});
|
||||
|
||||
A runner can also have an afterEach declarations. Runner afterEach functions are executed after every spec in all suites, and execute AFTER suite afterEach functions. For example:
|
||||
|
||||
var runnerWideFoo = [];
|
||||
|
||||
afterEach(function () {
|
||||
runnerWideFoo.push('runner');
|
||||
});
|
||||
|
||||
describe('some suite', function () {
|
||||
|
||||
afterEach(function () {
|
||||
runnerWideFoo.push('suite');
|
||||
});
|
||||
|
||||
it('should be empty', function () {
|
||||
expect(runnerWideFoo).toEqual([]);
|
||||
});
|
||||
|
||||
it('should be populated after', function () {
|
||||
expect(runnerWideFoo).toEqual(['suite', 'runner']);
|
||||
};
|
||||
});
|
||||
|
||||
### Single-spec After functions
|
||||
|
||||
A spec may ask Jasmine to execute some code after the spec has finished running; the code will run whether the spec finishes successfully or not. Multiple after functions may be given.
|
||||
|
||||
describe('some suite', function () {
|
||||
it(function () {
|
||||
var originalTitle = window.title;
|
||||
this.after(function() { window.title = originalTitle; });
|
||||
MyWindow.setTitle("new value");
|
||||
expect(window.title).toEqual("new value");
|
||||
});
|
||||
|
||||
|
||||
### Nested Describes
|
||||
Jasmine supports nested describes. An example:
|
||||
|
||||
describe('some suite', function () {
|
||||
|
||||
var suiteWideFoo;
|
||||
|
||||
beforeEach(function () {
|
||||
suiteWideFoo = 0;
|
||||
});
|
||||
|
||||
describe('some nested suite', function() {
|
||||
var nestedSuiteBar;
|
||||
beforeEach(function() {
|
||||
nestedSuiteBar=1;
|
||||
});
|
||||
|
||||
it('nested expectation', function () {
|
||||
expect(suiteWideFoo).toEqual(0);
|
||||
expect(nestedSuiteBar).toEqual(1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('top-level describe', function () {
|
||||
expect(suiteWideFoo).toEqual(0);
|
||||
expect(nestedSuiteBar).toEqual(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
### Spies
|
||||
|
||||
Jasmine integrates 'spies' that permit many spying, mocking, and faking behaviors.
|
||||
|
||||
Here are a few examples:
|
||||
|
||||
var Klass = function () {
|
||||
};
|
||||
|
||||
var Klass.prototype.method = function (arg) {
|
||||
return arg;
|
||||
};
|
||||
|
||||
var Klass.prototype.methodWithCallback = function (callback) {
|
||||
return callback('foo');
|
||||
};
|
||||
|
||||
...
|
||||
|
||||
it('should spy on Klass#method') {
|
||||
spyOn(Klass, 'method');
|
||||
Klass.method('foo argument');
|
||||
|
||||
expect(Klass.method).toHaveBeenCalledWith('foo argument');
|
||||
});
|
||||
|
||||
it('should spy on Klass#methodWithCallback') {
|
||||
var callback = Jasmine.createSpy();
|
||||
Klass.methodWithCallback(callback);
|
||||
|
||||
expect(callback).toHaveBeenCalledWith('foo');
|
||||
});
|
||||
|
||||
|
||||
Spies can be very useful for testing AJAX or other asynchronous behaviors that take callbacks by faking the method firing an async call.
|
||||
|
||||
var Klass = function () {
|
||||
};
|
||||
|
||||
var Klass.prototype.asyncMethod = function (callback) {
|
||||
someAsyncCall(callback);
|
||||
};
|
||||
|
||||
...
|
||||
|
||||
it('should test async call') {
|
||||
spyOn(Klass, 'asyncMethod');
|
||||
var callback = Jasmine.createSpy();
|
||||
|
||||
Klass.asyncMethod(callback);
|
||||
expect(callback).not.toHaveBeenCalled();
|
||||
|
||||
var someResponseData = 'foo';
|
||||
Klass.asyncMethod.mostRecentCall.args[0](someResponseData);
|
||||
expect(callback).toHaveBeenCalledWith(someResponseData);
|
||||
|
||||
});
|
||||
|
||||
There are spy-specfic matchers that are very handy.
|
||||
|
||||
`expect(x).toHaveBeenCalled()` passes if `x` is a spy and was called
|
||||
|
||||
`expect(x).toHaveBeenCalledWith(arguments)` passes if `x` is a spy and was called with the specified arguments
|
||||
|
||||
`expect(x).not.toHaveBeenCalled()` passes if `x` is a spy and was not called
|
||||
|
||||
`expect(x).not.toHaveBeenCalledWith(arguments)` passes if `x` is a spy and was not called with the specified arguments
|
||||
|
||||
The old matchers `wasCalled`, `wasNotCalled`, `wasCalledWith`, and `wasNotCalledWith` have been deprecated and will be removed in a future release. Please change your specs to use `toHaveBeenCalled`, `not.toHaveBeenCalled`, `toHaveBeenCalledWith`, and `not.toHaveBeenCalledWith` respectively.
|
||||
|
||||
Spies can be trained to respond in a variety of ways when invoked:
|
||||
|
||||
`spyOn(x, 'method').andCallThrough()`: spies on AND calls the original function spied on
|
||||
|
||||
`spyOn(x, 'method').andReturn(arguments)`: returns passed arguments when spy is called
|
||||
|
||||
`spyOn(x, 'method').andThrow(exception)`: throws passed exception when spy is called
|
||||
|
||||
`spyOn(x, 'method').andCallFake(function)`: calls passed function when spy is called
|
||||
|
||||
Spies have some useful properties:
|
||||
|
||||
`callCount`: returns number of times spy was called
|
||||
|
||||
`mostRecentCall.args`: returns argument array from last call to spy.
|
||||
|
||||
`argsForCall[i]` returns arguments array for call `i` to spy.
|
||||
|
||||
Spies are automatically removed after each spec. They may be set in the beforeEach function.
|
||||
|
||||
### Disabling Tests & Suites
|
||||
|
||||
Specs may be disabled by calling `xit()` instead of `it()`. Suites may be disabled by calling `xdescribe()` instead of `describe()`. A simple find/replace in your editor of choice will allow you to run a subset of your specs.
|
||||
|
||||
### Asynchronous Specs
|
||||
|
||||
You may be thinking, "That's all well and good, but you mentioned something about asynchronous tests."
|
||||
You may be thinking, "That's all very nice, but what's this about asynchronous tests?"
|
||||
|
||||
Well, 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.
|
||||
Well, say you need to make a call that is asynchronous - an AJAX API, event callback, 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 with `runs()` and `waits()` blocks.
|
||||
|
||||
@@ -129,7 +409,7 @@ multiple `runs()` blocks in a spec will run serially. For example,
|
||||
|
||||
`runs()` blocks share functional scope -- `this` properties will be common to all blocks, but declared `var`'s will not!
|
||||
|
||||
it('should be a test', function () {
|
||||
it('should be a test', function () {
|
||||
runs( function () {
|
||||
this.foo = 0
|
||||
this.foo++;
|
||||
@@ -152,26 +432,26 @@ multiple `runs()` blocks in a spec will run serially. For example,
|
||||
`runs()` blocks exist so you can test asynchronous processes. The function `waits()` works with `runs()` to provide a naive
|
||||
timeout before the next block is run. You supply a time to wait before the next `runs()` function is executed. For example:
|
||||
|
||||
it('should be a test', function () {
|
||||
runs(function () {
|
||||
this.foo = 0;
|
||||
var that = this;
|
||||
setTimeout(function () {
|
||||
that.foo++;
|
||||
}, 250);
|
||||
it('should be a test', function () {
|
||||
runs(function () {
|
||||
this.foo = 0;
|
||||
var that = this;
|
||||
setTimeout(function () {
|
||||
that.foo++;
|
||||
}, 250);
|
||||
});
|
||||
|
||||
runs(function () {
|
||||
this.expects(this.foo).toEqual(0);
|
||||
});
|
||||
|
||||
waits(500);
|
||||
|
||||
runs(function () {
|
||||
this.expects(this.foo).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
runs(function () {
|
||||
this.expects(this.foo).toEqual(0);
|
||||
});
|
||||
|
||||
waits(500);
|
||||
|
||||
runs(function () {
|
||||
this.expects(this.foo).toEqual(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`.
|
||||
@@ -179,263 +459,24 @@ What's happening here?
|
||||
* 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 Suite 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. Additionally, specs within a suite share a functional scope. So you may declare variables inside a describe block and they are accessible from within your specs. For example:
|
||||
|
||||
describe('A suite with some variables', function () {
|
||||
var bar = 0
|
||||
|
||||
it('has a test', function () {
|
||||
bar++;
|
||||
expect(bar).toEqual(1);
|
||||
});
|
||||
|
||||
it('has another test', function () {
|
||||
bar++;
|
||||
expect(bar).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
#### beforeEach
|
||||
|
||||
A suite can have a beforeEach declaration. It takes a function that is run before each spec. For example:
|
||||
|
||||
describe('some suite', function () {
|
||||
|
||||
var suiteWideFoo;
|
||||
|
||||
beforeEach(function () {
|
||||
suiteWideFoo = 1;
|
||||
}
|
||||
|
||||
it('should equal bar', function () {
|
||||
expect(suiteWideFoo).toEqual(1);
|
||||
};
|
||||
});
|
||||
|
||||
#### afterEach
|
||||
|
||||
Similarly, there is an afterEach declaration. It takes a function that is run after each spec. For example:
|
||||
|
||||
describe('some suite', function () {
|
||||
|
||||
var suiteWideFoo;
|
||||
afterEach(function () {
|
||||
suiteWideFoo = 0;
|
||||
}
|
||||
|
||||
it('should equal 1', function () {
|
||||
expect(suiteWideFoo).toEqual(1);
|
||||
};
|
||||
|
||||
it('should equal 0 after', function () {
|
||||
expect(suiteWideFoo).toEqual(0);
|
||||
};
|
||||
});
|
||||
|
||||
### Nested Describes
|
||||
Jasmine supports nested describes. An example:
|
||||
|
||||
describe('some suite', function () {
|
||||
|
||||
var suiteWideFoo;
|
||||
|
||||
beforeEach(function () {
|
||||
suiteWideFoo = 0;
|
||||
});
|
||||
|
||||
describe('some nested suite', function() {
|
||||
var nestedSuiteBar;
|
||||
beforeEach(function() {
|
||||
nestedSuiteBar=1;
|
||||
});
|
||||
|
||||
it('nested expectation', function () {
|
||||
expect(suiteWideFoo).toEqual(0);
|
||||
expect(nestedSuiteBar).toEqual(1);
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
it('top-level describe', function () {
|
||||
expect(suiteWideFoo).toEqual(0);
|
||||
expect(nestedSuiteBar).toEqual(undefined);
|
||||
};
|
||||
});
|
||||
|
||||
### Spies
|
||||
|
||||
Jasmine integrates 'spies' that permit many spying, mocking, and faking behaviors.
|
||||
|
||||
Here are a few examples:
|
||||
|
||||
var Klass = function () {
|
||||
}
|
||||
|
||||
var Klass.prototype.method = function (arg) {
|
||||
return arg;
|
||||
}
|
||||
|
||||
var Klass.prototype.methodWithCallback = function (callback) {
|
||||
return callback('foo');
|
||||
}
|
||||
|
||||
...
|
||||
|
||||
it('should spy on Klass#method') {
|
||||
spyOn(Klass, 'method');
|
||||
Klass.method('foo argument');
|
||||
|
||||
expect(Klass.method).wasCalledWith('foo argument');
|
||||
});
|
||||
|
||||
it('should spy on Klass#methodWithCallback') {
|
||||
var callback = Jasmine.createSpy();
|
||||
Klass.method(callback);
|
||||
|
||||
expect(callback).wasCalledWith('foo');
|
||||
});
|
||||
|
||||
|
||||
Spies can be very useful for testing AJAX or other asynchronous behaviors that take callbacks by faking the method firing an async call.
|
||||
|
||||
var Klass = function () {
|
||||
};
|
||||
|
||||
var Klass.prototype.asyncMethod = function (callback) {
|
||||
someAsyncCall(callback);
|
||||
};
|
||||
|
||||
...
|
||||
|
||||
it('should test async call') {
|
||||
spyOn(Klass, 'asyncMethod');
|
||||
var callback = Jasmine.createSpy();
|
||||
|
||||
Klass.asyncMethod(callback);
|
||||
expect(callback).wasNotCalled();
|
||||
|
||||
var someResponseData = 'foo';
|
||||
Klass.asyncMethod.mostRecentCall.args[0](someResponseData);
|
||||
expect(callback).wasCalledWith(someResponseData);
|
||||
|
||||
});
|
||||
|
||||
There are spy-specfic matchers that are very handy.
|
||||
|
||||
`wasCalled()` returns true if the object is a spy and was called
|
||||
|
||||
`wasCalledWith(arguments)` returns true if the object is a spy and was called with the passed arguments
|
||||
|
||||
`wasNotCalled()` returns true if the object is a spy and was not called
|
||||
|
||||
`wasNotCalledWith(arguments)` returns true if the object is a spy and was not called with the passed arguments
|
||||
|
||||
Spies can be trained to respond in a variety of ways when invoked:
|
||||
|
||||
`andCallThrough()`: spies on AND calls the original function spied on
|
||||
|
||||
`andReturn(arguments)`: returns passed arguments when spy is called
|
||||
|
||||
`andThrow(exception)`: throws passed exception when spy is called
|
||||
|
||||
`andCallFake(function)`: calls passed function when spy is called
|
||||
|
||||
Spies have some useful properties:
|
||||
|
||||
`callCount`: returns number of times spy was called
|
||||
|
||||
`mostRecentCall.args`: returns argument array from last call to spy.
|
||||
|
||||
`argsForCall[i]` returns arguments array for call `i` to spy.
|
||||
|
||||
Spies are automatically removed after each spec. They may be set in the beforeEach function.
|
||||
|
||||
### 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.
|
||||
|
||||
Here's the example HTML file (in `jasmine/example`):
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Example</title>
|
||||
<script type="text/javascript" src="../lib/jasmine.js"></script>
|
||||
<script type="text/javascript" src="example.js"></script>
|
||||
<link type="text/css" rel="stylesheet" href="../lib/jasmine.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<h1>
|
||||
Running Jasmine Example Specs
|
||||
</h1>
|
||||
<div id="results"></div>
|
||||
<script type="text/javascript">
|
||||
jasmine.execute();
|
||||
setTimeout(function () {
|
||||
document.getElementById('results').innerHTML = 'It\'s alive! :' +
|
||||
(jasmine.currentRunner.results.passedCount === 1);
|
||||
}, 250);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
It's the call to `jasmine.execute()` that runs all of the defined specs, gathering reports of each expectation.
|
||||
|
||||
### Reports
|
||||
|
||||
If a reporter exists on the Jasmine instance (named `jasmine`), it will be called when each spec, suite and the overall runner complete. If you're at the single-spec result level, you'll get a spec description, whether it passed or failed, and what the failure message was. At the suite & runner report level, you'll get the total specs run so far, the passed counts, failed counts, and a description (of the suite or runner).
|
||||
|
||||
There is a `Jasmine.Reporters` namespace for you to see how to handle reporting. See the file `json_reporter.js`, which takes the results objects and turns them into JSON strings, for two examples of how to make the results callbacks work for you.
|
||||
|
||||
|
||||
### Disabling Tests & Suites
|
||||
|
||||
Specs may be disabled by calling `xit()` instead of `it()`. Suites may be disabled by calling `xdescribe()` instead of `describe()`. A simple find/replace in your editor of choice will allow you to run a subset of your specs.
|
||||
|
||||
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.
|
||||
|
||||
## Support
|
||||
We now have a Google Group for support & discussion.
|
||||
|
||||
* Homepage: [http://groups.google.com/group/jasmine-js](http://groups.google.com/group/jasmine-js)
|
||||
* Discussion: [http://groups.google.com/group/jasmine-js](http://groups.google.com/group/jasmine-js)
|
||||
* Group email: [jasmine-js@googlegroups.com](jasmine-js@googlegroups.com)
|
||||
* Current build status of Jasmine is visible at [ci.pivotallabs.com](http://ci.pivotallabs.com)
|
||||
* Pivotal Tracker project: [http://www.pivotaltracker.com/projects/10606](http://www.pivotaltracker.com/projects/10606)
|
||||
* Twitter: [@JasmineBDD](http://twitter.com/JasmineBDD)
|
||||
|
||||
## Maintainers
|
||||
* [Davis W. Frank](mailto:dwfrank@pivotallabs.com), Pivotal Labs
|
||||
* [Rajan Agaskar](mailto:rajan@pivotallabs.com), Pivotal Labs
|
||||
* [Christian Williams](mailto:xian@pivotallabs.com), Pivotal Labs
|
||||
|
||||
* [Davis W. Frank](dwfrank@pivotallabs.com), Pivotal Labs
|
||||
* [Rajan Agaskar](rajan@pivotallabs.com), Pivotal Labs
|
||||
## Developers
|
||||
We welcome your contributions! Jasmine is currently maintained by Davis Frank ([infews](http://github.com/infews)), Rajan Agaskar ([ragaskar](http://github.com/ragaskar)), and Christian Williams ([Xian](http://github.com/Xian)). You can help us by removing all other recipients from your pull request.
|
||||
|
||||
## Acknowledgments
|
||||
* A big shout out to the various JavaScript test framework authors, especially TJ for [JSpec](http://github.com/visionmedia/jspec/tree/master) - we played with it a bit before deciding that we really needed to roll our own.
|
||||
* Thanks to Pivot [Jessica Miller](http://www.jessicamillerworks.com/) for our fancy pass/fail/pending icons
|
||||
* Huge contributions have been made by [Christian Williams](xian@pivotallabs.com) (the master "spy" coder), [Erik Hanson](erik@pivotallabs.com), [Adam Abrons](adam@pivotallabs.com) and [Carl Jackson](carl@pivotallabs.com), and many other Pivots.
|
||||
|
||||
## TODO List
|
||||
|
||||
* Pending & Disabled counts should be included in results
|
||||
* BUG: describe blocks can't be empty - specs will stall
|
||||
* Huge contributions have been made by [Adam Abrons](mailto:adam@pivotallabs.com), [Lee Byrd](mailto:lee@pivotallabs.com), [Erik Hanson](mailto:erik@pivotallabs.com), [Carl Jackson](mailto:carl@pivotallabs.com), and many other Pivots.
|
||||
|
||||
178
Rakefile
178
Rakefile
@@ -1,14 +1,176 @@
|
||||
desc 'Builds lib/jasmine from source'
|
||||
task :build do
|
||||
def jasmine_sources
|
||||
sources = ["src/base.js", "src/util.js", "src/Env.js", "src/Reporter.js", "src/Block.js"]
|
||||
sources += Dir.glob('src/*.js').reject { |f| f == 'src/base.js' || sources.include?(f) }.sort
|
||||
sources
|
||||
end
|
||||
|
||||
# these files must be better
|
||||
sources = ["src/base.js", "src/util.js", "src/Env.js", "src/ActionCollection.js", "src/Reporter.js"]
|
||||
def jasmine_html_sources
|
||||
["src/html/TrivialReporter.js"]
|
||||
end
|
||||
|
||||
sources += Dir.glob('src/*.js').reject{|f| sources.include?(f)}
|
||||
def jasmine_version
|
||||
"#{version_hash['major']}.#{version_hash['minor']}.#{version_hash['build']}"
|
||||
end
|
||||
|
||||
jasmine = File.new('lib/jasmine.js', 'w')
|
||||
sources.each do |source_filename|
|
||||
jasmine.puts(File.read(source_filename))
|
||||
def version_hash
|
||||
require 'json'
|
||||
@version ||= JSON.parse(File.new("src/version.json").read);
|
||||
end
|
||||
|
||||
task :default => 'jasmine:dist'
|
||||
|
||||
def substitute_jasmine_version(filename)
|
||||
contents = File.read(filename)
|
||||
contents = contents.gsub(/##JASMINE_VERSION##/, (jasmine_version))
|
||||
File.open(filename, 'w') { |f| f.write(contents) }
|
||||
end
|
||||
|
||||
namespace :jasmine do
|
||||
|
||||
desc 'Prepares for distribution'
|
||||
task :dist => ['jasmine:build', 'jasmine:doc', 'jasmine:build_example_project', 'jasmine:fill_index_downloads']
|
||||
|
||||
desc 'Check jasmine sources for coding problems'
|
||||
task :lint do
|
||||
passed = true
|
||||
jasmine_sources.each do |src|
|
||||
lines = File.read(src).split(/\n/)
|
||||
lines.each_index do |i|
|
||||
line = lines[i]
|
||||
undefineds = line.scan(/.?undefined/)
|
||||
if undefineds.include?(" undefined") || undefineds.include?("\tundefined")
|
||||
puts "Dangerous undefined at #{src}:#{i}:\n > #{line}"
|
||||
passed = false
|
||||
end
|
||||
|
||||
if line.scan(/window/).length > 0
|
||||
puts "Dangerous window at #{src}:#{i}:\n > #{line}"
|
||||
passed = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless passed
|
||||
puts "Lint failed!"
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Builds lib/jasmine from source'
|
||||
task :build => :lint do
|
||||
puts 'Building Jasmine from source'
|
||||
|
||||
sources = jasmine_sources
|
||||
version = version_hash
|
||||
|
||||
old_jasmine_files = Dir.glob('lib/jasmine*.js')
|
||||
old_jasmine_files.each { |file| File.delete(file) }
|
||||
|
||||
File.open("lib/jasmine.js", 'w') do |jasmine|
|
||||
sources.each do |source_filename|
|
||||
jasmine.puts(File.read(source_filename))
|
||||
end
|
||||
|
||||
jasmine.puts %{
|
||||
jasmine.version_= {
|
||||
"major": #{version['major']},
|
||||
"minor": #{version['minor']},
|
||||
"build": #{version['build']},
|
||||
"revision": #{Time.now.to_i}
|
||||
};
|
||||
}
|
||||
end
|
||||
|
||||
File.open("lib/jasmine-html.js", 'w') do |jasmine_html|
|
||||
jasmine_html_sources.each do |source_filename|
|
||||
jasmine_html.puts(File.read(source_filename))
|
||||
end
|
||||
end
|
||||
|
||||
FileUtils.cp("src/html/jasmine.css", "lib/jasmine.css")
|
||||
end
|
||||
|
||||
task :need_pages_submodule do
|
||||
unless File.exists?('pages/index.html')
|
||||
raise "Jasmine pages submodule isn't present. Run git submodule update --init"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Build jasmine documentation"
|
||||
task :doc => :need_pages_submodule do
|
||||
puts 'Creating Jasmine Documentation'
|
||||
require 'rubygems'
|
||||
#sudo gem install ragaskar-jsdoc_helper
|
||||
require 'jsdoc_helper'
|
||||
|
||||
FileUtils.rm_r "pages/jsdoc", :force => true
|
||||
|
||||
JsdocHelper::Rake::Task.new(:lambda_jsdoc) do |t|
|
||||
t[:files] = jasmine_sources << jasmine_html_sources
|
||||
t[:options] = "-a"
|
||||
t[:out] = "pages/jsdoc"
|
||||
end
|
||||
Rake::Task[:lambda_jsdoc].invoke
|
||||
end
|
||||
|
||||
desc "Build example project"
|
||||
task :build_example_project => :need_pages_submodule do
|
||||
require 'tmpdir'
|
||||
|
||||
temp_dir = File.join(Dir.tmpdir, 'jasmine-standalone-project')
|
||||
puts "Building Example Project in #{temp_dir}"
|
||||
FileUtils.rm_r temp_dir if File.exists?(temp_dir)
|
||||
Dir.mkdir(temp_dir)
|
||||
|
||||
root = File.expand_path(File.dirname(__FILE__))
|
||||
FileUtils.cp_r File.join(root, 'example/.'), File.join(temp_dir)
|
||||
substitute_jasmine_version(File.join(temp_dir, "SpecRunner.html"))
|
||||
|
||||
lib_dir = File.join(temp_dir, "lib/jasmine-#{jasmine_version}")
|
||||
FileUtils.mkdir_p(lib_dir)
|
||||
{
|
||||
"lib/jasmine.js" => "jasmine.js",
|
||||
"lib/jasmine-html.js" => "jasmine-html.js",
|
||||
"src/html/jasmine.css" => "jasmine.css"
|
||||
}.each_pair do |src, dest|
|
||||
FileUtils.cp(File.join(root, src), File.join(lib_dir, dest))
|
||||
end
|
||||
|
||||
dist_dir = File.join(root, 'pages/downloads')
|
||||
zip_file_name = File.join(dist_dir, "jasmine-standalone-#{jasmine_version}.zip")
|
||||
puts "Zipping Example Project and moving to #{zip_file_name}"
|
||||
FileUtils.mkdir(dist_dir) unless File.exist?(dist_dir)
|
||||
if File.exist?(zip_file_name)
|
||||
puts "WARNING!!! #{zip_file_name} already exists!"
|
||||
FileUtils.rm(zip_file_name)
|
||||
end
|
||||
exec "cd #{temp_dir} && zip -r #{zip_file_name} . -x .[a-zA-Z0-9]*"
|
||||
end
|
||||
|
||||
task :fill_index_downloads do
|
||||
require 'digest/sha1'
|
||||
|
||||
download_html = "<!-- START_DOWNLOADS -->\n"
|
||||
download_html += "<table>\n<tr><th/><th>Version</th><th>Size</th><th>Date</th><th>SHA1</th></tr>\n"
|
||||
Dir.glob('pages/downloads/*.zip').sort.reverse.each do |f|
|
||||
sha1 = Digest::SHA1.hexdigest File.read(f)
|
||||
|
||||
fn = f.sub(/^pages\//, '')
|
||||
version = /jasmine-standalone-(.*).zip/.match(f)[1]
|
||||
download_html += "<td><a href='#{fn}'>#{fn.sub(/downloads\//, '')}</a></td>"
|
||||
download_html += "<td>#{version}</td>\n"
|
||||
download_html += "<td>#{File.size(f) / 1024}k</td>\n"
|
||||
download_html += "<td>#{File.mtime(f).strftime("%Y/%m/%d %H:%M:%S")}</td>\n"
|
||||
download_html += "<td>#{sha1}</td>\n"
|
||||
end
|
||||
download_html += "</table>\n<!-- END_DOWNLOADS -->"
|
||||
|
||||
index_page = File.read('pages/index.html')
|
||||
matcher = /<!-- START_DOWNLOADS -->.*<!-- END_DOWNLOADS -->/m
|
||||
index_page = index_page.sub(matcher, download_html)
|
||||
File.open('pages/index.html', 'w') {|f| f.write(index_page)}
|
||||
puts "rewrote that file"
|
||||
end
|
||||
end
|
||||
|
||||
task :jasmine => ['jasmine:dist']
|
||||
|
||||
@@ -1,187 +0,0 @@
|
||||
require 'socket'
|
||||
require 'erb'
|
||||
|
||||
module Jasmine
|
||||
# this seemingly-over-complex method is necessary to get an open port on at least some of our Macs
|
||||
def self.open_socket_on_unused_port
|
||||
infos = Socket::getaddrinfo("localhost", nil, Socket::AF_UNSPEC, Socket::SOCK_STREAM, 0, Socket::AI_PASSIVE)
|
||||
families = Hash[*infos.collect { |af, *_| af }.uniq.zip([]).flatten]
|
||||
|
||||
return TCPServer.open('0.0.0.0', 0) if families.has_key?('AF_INET')
|
||||
return TCPServer.open('::', 0) if families.has_key?('AF_INET6')
|
||||
return TCPServer.open(0)
|
||||
end
|
||||
|
||||
def self.find_unused_port
|
||||
socket = open_socket_on_unused_port
|
||||
port = socket.addr[1]
|
||||
socket.close
|
||||
port
|
||||
end
|
||||
|
||||
def self.server_is_listening_on(hostname, port)
|
||||
require 'socket'
|
||||
begin
|
||||
socket = TCPSocket.open(hostname, port)
|
||||
rescue Errno::ECONNREFUSED
|
||||
return false
|
||||
end
|
||||
socket.close
|
||||
true
|
||||
end
|
||||
|
||||
def self.wait_for_listener(port, name = "required process", seconds_to_wait = 10)
|
||||
time_out_at = Time.now + seconds_to_wait
|
||||
until server_is_listening_on "localhost", port
|
||||
sleep 0.1
|
||||
puts "Waiting for #{name} on #{port}..."
|
||||
raise "#{name} didn't show up on port #{port} after #{seconds_to_wait} seconds." if Time.now > time_out_at
|
||||
end
|
||||
end
|
||||
|
||||
def self.kill_process_group(process_group_id, signal="TERM")
|
||||
Process.kill signal, -process_group_id # negative pid means kill process group. (see man 2 kill)
|
||||
end
|
||||
|
||||
class RunAdapter
|
||||
def initialize(spec_files_or_proc)
|
||||
@spec_files_or_proc = spec_files_or_proc
|
||||
end
|
||||
|
||||
def call(env)
|
||||
spec_files = @spec_files_or_proc
|
||||
spec_files = spec_files.call if spec_files.respond_to?(:call)
|
||||
|
||||
body = ERB.new(File.read(File.join(File.dirname(__FILE__), "run.html"))).result(binding)
|
||||
[
|
||||
200,
|
||||
{ 'Content-Type' => 'text/html' },
|
||||
body
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
class SimpleServer
|
||||
def self.start(port, spec_files_or_proc, mappings)
|
||||
require 'thin'
|
||||
|
||||
config = {
|
||||
'/run.html' => Jasmine::RunAdapter.new(spec_files_or_proc)
|
||||
}
|
||||
mappings.each do |from, to|
|
||||
config[from] = Rack::File.new(to)
|
||||
end
|
||||
|
||||
app = Rack::URLMap.new(config)
|
||||
|
||||
Thin::Server.start('0.0.0.0', port, app)
|
||||
end
|
||||
end
|
||||
|
||||
class SimpleClient
|
||||
def initialize(selenium_host, selenium_port, selenium_browser_start_command, http_address)
|
||||
require 'selenium'
|
||||
@driver = Selenium::Client::Driver.new(
|
||||
selenium_host,
|
||||
selenium_port,
|
||||
selenium_browser_start_command,
|
||||
http_address
|
||||
)
|
||||
@http_address = http_address
|
||||
end
|
||||
|
||||
def tests_have_finished?
|
||||
@driver.get_eval("window.jasmine.getEnv().currentRunner.finished") == "true"
|
||||
end
|
||||
|
||||
def connect
|
||||
@driver.start
|
||||
@driver.open("/run.html")
|
||||
end
|
||||
|
||||
def disconnect
|
||||
@driver.stop
|
||||
end
|
||||
|
||||
def run
|
||||
until tests_have_finished? do
|
||||
sleep 0.1
|
||||
end
|
||||
|
||||
puts @driver.get_eval("window.getResults()")
|
||||
failed_count = @driver.get_eval("window.jasmine.getEnv().currentRunner.getResults().failedCount").to_i
|
||||
failed_count == 0
|
||||
end
|
||||
|
||||
def eval_js(script)
|
||||
escaped_script = "'" + script.gsub(/(['\\])/) { '\\' + $1 } + "'"
|
||||
|
||||
result = @driver.get_eval("window.eval(#{escaped_script})")
|
||||
JSON.parse("[#{result}]")[0]
|
||||
end
|
||||
end
|
||||
|
||||
class Runner
|
||||
def initialize(selenium_jar_path, spec_files, dir_mappings)
|
||||
@selenium_jar_path = selenium_jar_path
|
||||
@spec_files = spec_files
|
||||
@dir_mappings = dir_mappings
|
||||
|
||||
@selenium_pid = nil
|
||||
@jasmine_server_pid = nil
|
||||
end
|
||||
|
||||
def start
|
||||
start_servers
|
||||
@client = Jasmine::SimpleClient.new("localhost", @selenium_server_port, "*firefox", "http://localhost:#{@jasmine_server_port}/")
|
||||
@client.connect
|
||||
end
|
||||
|
||||
def stop
|
||||
@client.disconnect
|
||||
stop_servers
|
||||
end
|
||||
|
||||
def start_servers
|
||||
@jasmine_server_port = Jasmine::find_unused_port
|
||||
@selenium_server_port = Jasmine::find_unused_port
|
||||
|
||||
@selenium_pid = fork do
|
||||
Process.setpgrp
|
||||
exec "java -jar #{@selenium_jar_path} -port #{@selenium_server_port} > /dev/null 2>&1"
|
||||
end
|
||||
puts "selenium started. pid is #{@selenium_pid}"
|
||||
|
||||
@jasmine_server_pid = fork do
|
||||
Process.setpgrp
|
||||
Jasmine::SimpleServer.start(@jasmine_server_port, @spec_files, @dir_mappings)
|
||||
exit! 0
|
||||
end
|
||||
puts "jasmine server started. pid is #{@jasmine_server_pid}"
|
||||
|
||||
Jasmine::wait_for_listener(@selenium_server_port, "selenium server")
|
||||
Jasmine::wait_for_listener(@jasmine_server_port, "jasmine server")
|
||||
end
|
||||
|
||||
def stop_servers
|
||||
puts "shutting down the servers..."
|
||||
Jasmine::kill_process_group(@selenium_pid) if @selenium_pid
|
||||
Jasmine::kill_process_group(@jasmine_server_pid) if @jasmine_server_pid
|
||||
end
|
||||
|
||||
def run
|
||||
begin
|
||||
start
|
||||
puts "servers are listening on their ports -- running the test script..."
|
||||
tests_passed = @client.run
|
||||
ensure
|
||||
stop
|
||||
end
|
||||
return tests_passed
|
||||
end
|
||||
|
||||
def eval_js(script)
|
||||
@client.eval_js(script)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,51 +0,0 @@
|
||||
require 'spec'
|
||||
require 'open-uri'
|
||||
require File.dirname(__FILE__) + '/jasmine_runner'
|
||||
|
||||
describe Jasmine::SimpleServer do
|
||||
before do
|
||||
@port = Jasmine::find_unused_port
|
||||
end
|
||||
|
||||
after do
|
||||
Jasmine::kill_process_group(@jasmine_server_pid) if @jasmine_server_pid
|
||||
end
|
||||
|
||||
it "should start and print script tags" do
|
||||
@jasmine_server_pid = fork do
|
||||
Process.setpgrp
|
||||
Jasmine::SimpleServer.start(@port, ["file1", "file2"], {})
|
||||
exit! 0
|
||||
end
|
||||
|
||||
Jasmine::wait_for_listener(@port)
|
||||
|
||||
run_html = open("http://localhost:#{@port}/run.html").read
|
||||
run_html.should =~ /<script src="file1"/
|
||||
run_html.should =~ /<script src="file2"/
|
||||
end
|
||||
|
||||
it "should take a proc that returns a list of spec files" do
|
||||
spec_fileses = [["file1", "file2"], ["file1", "file2", "file3"]]
|
||||
spec_files_proc = lambda do
|
||||
spec_fileses.shift
|
||||
end
|
||||
|
||||
@jasmine_server_pid = fork do
|
||||
Process.setpgrp
|
||||
Jasmine::SimpleServer.start(@port, spec_files_proc, {})
|
||||
exit! 0
|
||||
end
|
||||
|
||||
Jasmine::wait_for_listener(@port)
|
||||
|
||||
run_html = open("http://localhost:#{@port}/run.html").read
|
||||
run_html.should =~ /<script src="file1"/
|
||||
run_html.should =~ /<script src="file2"/
|
||||
|
||||
run_html = open("http://localhost:#{@port}/run.html").read
|
||||
run_html.should =~ /<script src="file1"/
|
||||
run_html.should =~ /<script src="file2"/
|
||||
run_html.should =~ /<script src="file3"/
|
||||
end
|
||||
end
|
||||
@@ -1,142 +0,0 @@
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), "jasmine_runner.rb"))
|
||||
|
||||
module Jasmine
|
||||
|
||||
class SpecBuilder
|
||||
attr_accessor :suites
|
||||
|
||||
def initialize(spec_files, runner)
|
||||
@spec_files = spec_files
|
||||
@runner = runner
|
||||
end
|
||||
|
||||
def start
|
||||
guess_example_locations
|
||||
|
||||
@runner.start
|
||||
load_suite_info
|
||||
@spec_results = {}
|
||||
end
|
||||
|
||||
def stop
|
||||
@runner.stop
|
||||
end
|
||||
|
||||
def script_path
|
||||
File.expand_path(__FILE__)
|
||||
end
|
||||
|
||||
def guess_example_locations
|
||||
@example_locations = {}
|
||||
|
||||
example_name_parts = []
|
||||
previous_indent_level = 0
|
||||
@spec_files.each do |filename|
|
||||
line_number = 1
|
||||
File.open(filename, "r") do |file|
|
||||
file.readlines.each do |line|
|
||||
match = /^(\s*)(describe|it)\s*\(\s*["'](.*)["']\s*,\s*function/.match(line)
|
||||
if (match)
|
||||
indent_level = match[1].length / 2
|
||||
example_name = match[3]
|
||||
example_name_parts[indent_level] = example_name
|
||||
|
||||
full_example_name = example_name_parts.slice(0, indent_level + 1).join(" ")
|
||||
@example_locations[full_example_name] = "#{filename}:#{line_number}: in `it'"
|
||||
end
|
||||
line_number += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def load_suite_info
|
||||
while !eval_js('jsApiReporter.started') do
|
||||
sleep 0.1
|
||||
end
|
||||
|
||||
@suites = eval_js('JSON.stringify(jsApiReporter.suites)')
|
||||
end
|
||||
|
||||
def results_for(spec_id)
|
||||
spec_id = spec_id.to_s
|
||||
return @spec_results[spec_id] if @spec_results[spec_id]
|
||||
|
||||
@spec_results[spec_id] = eval_js("JSON.stringify(jsApiReporter.results[#{spec_id}])")
|
||||
while @spec_results[spec_id].nil? do
|
||||
sleep 0.1
|
||||
@spec_results[spec_id] = eval_js("JSON.stringify(jsApiReporter.results[#{spec_id}])")
|
||||
end
|
||||
|
||||
@spec_results[spec_id]
|
||||
end
|
||||
|
||||
def declare_suites
|
||||
me = self
|
||||
suites.each do |suite|
|
||||
declare_suite(self, suite)
|
||||
end
|
||||
end
|
||||
|
||||
def declare_suite(parent, suite)
|
||||
me = self
|
||||
parent.describe suite["name"] do
|
||||
suite["children"].each do |suite_or_spec|
|
||||
type = suite_or_spec["type"]
|
||||
if type == "suite"
|
||||
me.declare_suite(self, suite_or_spec)
|
||||
elsif type == "spec"
|
||||
me.declare_spec(self, suite_or_spec)
|
||||
else
|
||||
raise "unknown type #{type} for #{suite_or_spec.inspect}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def declare_spec(parent, spec)
|
||||
me = self
|
||||
example_name = spec["name"]
|
||||
|
||||
backtrace = @example_locations[parent.description + " " + example_name]
|
||||
parent.it example_name, {}, backtrace do
|
||||
me.report_spec(spec["id"])
|
||||
end
|
||||
end
|
||||
|
||||
def report_spec(spec_id)
|
||||
spec_results = results_for(spec_id)
|
||||
|
||||
out = ""
|
||||
messages = spec_results['messages'].each do |message|
|
||||
case
|
||||
when message["type"] == "MessageResult"
|
||||
puts message["text"]
|
||||
puts "\n"
|
||||
else
|
||||
STDERR << message["message"]
|
||||
STDERR << "\n"
|
||||
|
||||
out << message["message"]
|
||||
out << "\n"
|
||||
|
||||
unless message["passed"]
|
||||
stack_trace = message["trace"]["stack"].gsub(/<br \/>/, "\n").gsub(/<\/?b>/, " ")
|
||||
STDERR << stack_trace.gsub(/\(.*\)@http:\/\/localhost:[0-9]+\/specs\//, "/spec/")
|
||||
STDERR << "\n"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
fail out unless spec_results['result'] == 'passed'
|
||||
puts out
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def eval_js(js)
|
||||
@runner.eval_js(js)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type"/>
|
||||
<title>Jasmine suite</title>
|
||||
<script src="/jasmine/lib/jasmine.js"></script>
|
||||
<script src="/jasmine/lib/json2.js"></script><!-- todo: don't load JSON in the test runner! [20090710 xw] -->
|
||||
<script src="/jasmine/lib/TrivialReporter.js"></script>
|
||||
<script src="/specs/javascripts/screw-jasmine-compat.js"></script>
|
||||
<script type="text/javascript"></script>
|
||||
<link href="/jasmine/lib/jasmine.css" rel="stylesheet"/>
|
||||
<script type="text/javascript">
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
var jsApiReporter = new jasmine.JsApiReporter();
|
||||
jasmineEnv.addReporter(jsApiReporter);
|
||||
jasmineEnv.addReporter(new jasmine.TrivialReporter());
|
||||
window.onload = function() {
|
||||
jasmineEnv.execute();
|
||||
};
|
||||
</script>
|
||||
|
||||
<% spec_files.each do |spec_file| %>
|
||||
<script src="<%= spec_file %>" type="text/javascript"></script>
|
||||
<% end %>
|
||||
</head>
|
||||
<body>
|
||||
<div id="jasmine_content"></div>
|
||||
</body>
|
||||
</html>
|
||||
21
cruise_config.rb
Normal file
21
cruise_config.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
# Project-specific configuration for CruiseControl.rb
|
||||
Project.configure do |project|
|
||||
|
||||
# Send email notifications about broken and fixed builds to email1@your.site, email2@your.site (default: send to nobody)
|
||||
# project.email_notifier.emails = ['email1@your.site', 'email2@your.site']
|
||||
|
||||
# Set email 'from' field to john@doe.com:
|
||||
# project.email_notifier.from = 'john@doe.com'
|
||||
|
||||
# Build the project by invoking rake task 'custom'
|
||||
project.rake_task = 'jasmine:test:ci:saucelabs'
|
||||
|
||||
# Build the project by invoking shell script "build_my_app.sh". Keep in mind that when the script is invoked,
|
||||
# current working directory is <em>[cruise data]</em>/projects/your_project/work, so if you do not keep build_my_app.sh
|
||||
# in version control, it should be '../build_my_app.sh' instead
|
||||
#project.build_command = 'cp ../saucelabs.yml .'
|
||||
|
||||
# Ping Subversion for new revisions every 5 minutes (default: 30 seconds)
|
||||
# project.scheduler.polling_interval = 5.minutes
|
||||
|
||||
end
|
||||
240
doc/files.html
240
doc/files.html
@@ -1,240 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8"" />
|
||||
|
||||
<title>JsDoc Reference - File Index</title>
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
|
||||
<style type="text/css">
|
||||
/* default.css */
|
||||
body
|
||||
{
|
||||
font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.header
|
||||
{
|
||||
clear: both;
|
||||
background-color: #ccc;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 1em 0 0 .3em;
|
||||
}
|
||||
|
||||
hr
|
||||
{
|
||||
border: none 0;
|
||||
border-top: 1px solid #7F8FB1;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
pre.code
|
||||
{
|
||||
display: block;
|
||||
padding: 8px;
|
||||
border: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
#index
|
||||
{
|
||||
margin-top: 24px;
|
||||
float: left;
|
||||
width: 160px;
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
background-color: #F3F3F3;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
margin-left: 190px;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.classList
|
||||
{
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0 0 0 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 1em;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.classList li
|
||||
{
|
||||
padding: 0;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.summaryTable { width: 100%; }
|
||||
|
||||
h1.classTitle
|
||||
{
|
||||
font-size:170%;
|
||||
line-height:130%;
|
||||
}
|
||||
|
||||
h2 { font-size: 110%; }
|
||||
caption, div.sectionTitle
|
||||
{
|
||||
background-color: #7F8FB1;
|
||||
color: #fff;
|
||||
font-size:130%;
|
||||
text-align: left;
|
||||
padding: 2px 6px 2px 6px;
|
||||
border: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
div.sectionTitle { margin-bottom: 8px; }
|
||||
.summaryTable thead { display: none; }
|
||||
|
||||
.summaryTable td
|
||||
{
|
||||
vertical-align: top;
|
||||
padding: 4px;
|
||||
border-bottom: 1px #7F8FB1 solid;
|
||||
border-right: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
/*col#summaryAttributes {}*/
|
||||
.summaryTable td.attributes
|
||||
{
|
||||
border-left: 1px #7F8FB1 solid;
|
||||
width: 140px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.attributes, .fixedFont
|
||||
{
|
||||
line-height: 15px;
|
||||
color: #002EBE;
|
||||
font-family: "Courier New",Courier,monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription
|
||||
{
|
||||
text-align: left;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription, .description
|
||||
{
|
||||
line-height: 15px;
|
||||
padding: 4px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.summaryTable { margin-bottom: 8px; }
|
||||
|
||||
ul.inheritsList
|
||||
{
|
||||
list-style: square;
|
||||
margin-left: 20px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.detailList {
|
||||
margin-left: 20px;
|
||||
line-height: 15px;
|
||||
}
|
||||
.detailList dt { margin-left: 20px; }
|
||||
|
||||
.detailList .heading
|
||||
{
|
||||
font-weight: bold;
|
||||
padding-bottom: 6px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.light, td.attributes, .light a:link, .light a:visited
|
||||
{
|
||||
color: #777;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.fineprint
|
||||
{
|
||||
text-align: right;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="header">
|
||||
</div>
|
||||
|
||||
<div id="index">
|
||||
<div align="center"><a href="index.html">Class Index</a>
|
||||
| <a href="files.html">File Index</a></div>
|
||||
<hr />
|
||||
<h2>Classes</h2>
|
||||
<ul class="classList">
|
||||
|
||||
<li><i><a href="symbols/_global_.html">_global_</a></i></li>
|
||||
|
||||
<li><a href="symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Spec.html">jasmine.Spec</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Spy.html">jasmine.Spy</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Suite.html">jasmine.Suite</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.util.html">jasmine.util</a></li>
|
||||
|
||||
</ul>
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<h1 class="classTitle">File Index</h1>
|
||||
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/src/lib_jasmine.js.html">lib/jasmine.js</a></h2>
|
||||
|
||||
<dl>
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
|
||||
</div>
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
306
doc/index.html
306
doc/index.html
@@ -1,306 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
|
||||
<title>JsDoc Reference - Index</title>
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
|
||||
<style type="text/css">
|
||||
/* default.css */
|
||||
body
|
||||
{
|
||||
font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.header
|
||||
{
|
||||
clear: both;
|
||||
background-color: #ccc;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 1em 0 0 .3em;
|
||||
}
|
||||
|
||||
hr
|
||||
{
|
||||
border: none 0;
|
||||
border-top: 1px solid #7F8FB1;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
pre.code
|
||||
{
|
||||
display: block;
|
||||
padding: 8px;
|
||||
border: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
#index
|
||||
{
|
||||
margin-top: 24px;
|
||||
float: left;
|
||||
width: 160px;
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
background-color: #F3F3F3;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
margin-left: 190px;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.classList
|
||||
{
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0 0 0 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 1em;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.classList li
|
||||
{
|
||||
padding: 0;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.summaryTable { width: 100%; }
|
||||
|
||||
h1.classTitle
|
||||
{
|
||||
font-size:170%;
|
||||
line-height:130%;
|
||||
}
|
||||
|
||||
h2 { font-size: 110%; }
|
||||
caption, div.sectionTitle
|
||||
{
|
||||
background-color: #7F8FB1;
|
||||
color: #fff;
|
||||
font-size:130%;
|
||||
text-align: left;
|
||||
padding: 2px 6px 2px 6px;
|
||||
border: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
div.sectionTitle { margin-bottom: 8px; }
|
||||
.summaryTable thead { display: none; }
|
||||
|
||||
.summaryTable td
|
||||
{
|
||||
vertical-align: top;
|
||||
padding: 4px;
|
||||
border-bottom: 1px #7F8FB1 solid;
|
||||
border-right: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
/*col#summaryAttributes {}*/
|
||||
.summaryTable td.attributes
|
||||
{
|
||||
border-left: 1px #7F8FB1 solid;
|
||||
width: 140px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.attributes, .fixedFont
|
||||
{
|
||||
line-height: 15px;
|
||||
color: #002EBE;
|
||||
font-family: "Courier New",Courier,monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription
|
||||
{
|
||||
text-align: left;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription, .description
|
||||
{
|
||||
line-height: 15px;
|
||||
padding: 4px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.summaryTable { margin-bottom: 8px; }
|
||||
|
||||
ul.inheritsList
|
||||
{
|
||||
list-style: square;
|
||||
margin-left: 20px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.detailList {
|
||||
margin-left: 20px;
|
||||
line-height: 15px;
|
||||
}
|
||||
.detailList dt { margin-left: 20px; }
|
||||
|
||||
.detailList .heading
|
||||
{
|
||||
font-weight: bold;
|
||||
padding-bottom: 6px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.light, td.attributes, .light a:link, .light a:visited
|
||||
{
|
||||
color: #777;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.fineprint
|
||||
{
|
||||
text-align: right;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="header">
|
||||
</div>
|
||||
|
||||
<div id="index">
|
||||
<div align="center"><a href="index.html">Class Index</a>
|
||||
| <a href="files.html">File Index</a></div>
|
||||
<hr />
|
||||
<h2>Classes</h2>
|
||||
<ul class="classList">
|
||||
|
||||
<li><i><a href="symbols/_global_.html">_global_</a></i></li>
|
||||
|
||||
<li><a href="symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Spec.html">jasmine.Spec</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Spy.html">jasmine.Spy</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Suite.html">jasmine.Suite</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.util.html">jasmine.util</a></li>
|
||||
|
||||
</ul>
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<h1 class="classTitle">Class Index</h1>
|
||||
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/_global_.html">_global_</a></h2>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/jasmine.html">jasmine</a></h2>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></h2>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/jasmine.Env.html">jasmine.Env</a></h2>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></h2>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></h2>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></h2>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/jasmine.Reporter.html">jasmine.Reporter</a></h2>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/jasmine.Runner.html">jasmine.Runner</a></h2>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/jasmine.Spec.html">jasmine.Spec</a></h2>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/jasmine.Spy.html">jasmine.Spy</a></h2>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/jasmine.Suite.html">jasmine.Suite</a></h2>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/jasmine.util.html">jasmine.util</a></h2>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
|
||||
</div>
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,914 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
|
||||
<title>JsDoc Reference - _global_</title>
|
||||
|
||||
<style type="text/css">
|
||||
/* default.css */
|
||||
body
|
||||
{
|
||||
font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.header
|
||||
{
|
||||
clear: both;
|
||||
background-color: #ccc;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 1em 0 0 .3em;
|
||||
}
|
||||
|
||||
hr
|
||||
{
|
||||
border: none 0;
|
||||
border-top: 1px solid #7F8FB1;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
pre.code
|
||||
{
|
||||
display: block;
|
||||
padding: 8px;
|
||||
border: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
#index
|
||||
{
|
||||
margin-top: 24px;
|
||||
float: left;
|
||||
width: 160px;
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
background-color: #F3F3F3;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
margin-left: 190px;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.classList
|
||||
{
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0 0 0 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 1em;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.classList li
|
||||
{
|
||||
padding: 0;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.summaryTable { width: 100%; }
|
||||
|
||||
h1.classTitle
|
||||
{
|
||||
font-size:170%;
|
||||
line-height:130%;
|
||||
}
|
||||
|
||||
h2 { font-size: 110%; }
|
||||
caption, div.sectionTitle
|
||||
{
|
||||
background-color: #7F8FB1;
|
||||
color: #fff;
|
||||
font-size:130%;
|
||||
text-align: left;
|
||||
padding: 2px 6px 2px 6px;
|
||||
border: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
div.sectionTitle { margin-bottom: 8px; }
|
||||
.summaryTable thead { display: none; }
|
||||
|
||||
.summaryTable td
|
||||
{
|
||||
vertical-align: top;
|
||||
padding: 4px;
|
||||
border-bottom: 1px #7F8FB1 solid;
|
||||
border-right: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
/*col#summaryAttributes {}*/
|
||||
.summaryTable td.attributes
|
||||
{
|
||||
border-left: 1px #7F8FB1 solid;
|
||||
width: 140px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.attributes, .fixedFont
|
||||
{
|
||||
line-height: 15px;
|
||||
color: #002EBE;
|
||||
font-family: "Courier New",Courier,monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription
|
||||
{
|
||||
text-align: left;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription, .description
|
||||
{
|
||||
line-height: 15px;
|
||||
padding: 4px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.summaryTable { margin-bottom: 8px; }
|
||||
|
||||
ul.inheritsList
|
||||
{
|
||||
list-style: square;
|
||||
margin-left: 20px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.detailList {
|
||||
margin-left: 20px;
|
||||
line-height: 15px;
|
||||
}
|
||||
.detailList dt { margin-left: 20px; }
|
||||
|
||||
.detailList .heading
|
||||
{
|
||||
font-weight: bold;
|
||||
padding-bottom: 6px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.light, td.attributes, .light a:link, .light a:visited
|
||||
{
|
||||
color: #777;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.fineprint
|
||||
{
|
||||
text-align: right;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- ============================== header ================================= -->
|
||||
<!-- begin static/header.html -->
|
||||
<div id="header">
|
||||
</div>
|
||||
<!-- end static/header.html -->
|
||||
|
||||
<!-- ============================== classes index ============================ -->
|
||||
<div id="index">
|
||||
<!-- begin publish.classesIndex -->
|
||||
<div align="center"><a href="../index.html">Class Index</a>
|
||||
| <a href="../files.html">File Index</a></div>
|
||||
<hr />
|
||||
<h2>Classes</h2>
|
||||
<ul class="classList">
|
||||
|
||||
<li><i><a href="../symbols/_global_.html">_global_</a></i></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spec.html">jasmine.Spec</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spy.html">jasmine.Spy</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Suite.html">jasmine.Suite</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.util.html">jasmine.util</a></li>
|
||||
|
||||
</ul>
|
||||
<hr />
|
||||
<!-- end publish.classesIndex -->
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<!-- ============================== class title ============================ -->
|
||||
<h1 class="classTitle">
|
||||
|
||||
Built-In Namespace _global_
|
||||
</h1>
|
||||
|
||||
<!-- ============================== class summary ========================== -->
|
||||
<p class="description">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</p>
|
||||
|
||||
<!-- ============================== constructor summary ==================== -->
|
||||
|
||||
|
||||
<!-- ============================== properties summary ===================== -->
|
||||
|
||||
|
||||
<!-- ============================== methods summary ======================== -->
|
||||
|
||||
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the methods documented in the class _global_.">
|
||||
<caption>Method Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Method Attributes</th>
|
||||
<th scope="col">Method Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/_global_.html#afterEach">afterEach</a></b>(afterEachFunction)
|
||||
</div>
|
||||
<div class="description">A function that is called after each spec in a suite.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/_global_.html#beforeEach">beforeEach</a></b>(beforeEachFunction)
|
||||
</div>
|
||||
<div class="description">A function that is called before each spec in a suite.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/_global_.html#describe">describe</a></b>(description, specDefinitions)
|
||||
</div>
|
||||
<div class="description">Defines a suite of specifications.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/_global_.html#expect">expect</a></b>(actual)
|
||||
</div>
|
||||
<div class="description">Starts a chain for a Jasmine expectation.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/_global_.html#it">it</a></b>(desc, func)
|
||||
</div>
|
||||
<div class="description">Creates a Jasmine spec that will be added to the current suite.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/_global_.html#runs">runs</a></b>(func)
|
||||
</div>
|
||||
<div class="description">Defines part of a jasmine spec.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/_global_.html#spyOn">spyOn</a></b>(obj, methodName)
|
||||
</div>
|
||||
<div class="description">Function that installs a spy on an existing object's method name.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/_global_.html#waits">waits</a></b>(timeout)
|
||||
</div>
|
||||
<div class="description">Waits for a timeout before moving to the next runs()-defined block.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/_global_.html#waitsFor">waitsFor</a></b>(timeout, latchFunction, message)
|
||||
</div>
|
||||
<div class="description">Waits for the latchFunction to return true before proceeding to the next runs()-defined block.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/_global_.html#xdescribe">xdescribe</a></b>(description, specDefinitions)
|
||||
</div>
|
||||
<div class="description">Disables a suite of specifications.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/_global_.html#xit">xit</a></b>(desc, func)
|
||||
</div>
|
||||
<div class="description">Creates a <em>disabled</em> Jasmine spec.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== events summary ======================== -->
|
||||
|
||||
|
||||
<!-- ============================== constructor details ==================== -->
|
||||
|
||||
|
||||
<!-- ============================== field details ========================== -->
|
||||
|
||||
|
||||
<!-- ============================== method details ========================= -->
|
||||
|
||||
<div class="sectionTitle">
|
||||
Method Detail
|
||||
</div>
|
||||
|
||||
<a name="afterEach"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>afterEach</b>(afterEachFunction)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
A function that is called after each spec in a suite.
|
||||
|
||||
Used for restoring any state that is hijacked during spec execution.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Function}</span> <b>afterEachFunction</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="beforeEach"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>beforeEach</b>(beforeEachFunction)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
A function that is called before each spec in a suite.
|
||||
|
||||
Used for spec setup, including validating assumptions.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Function}</span> <b>beforeEachFunction</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="describe"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>describe</b>(description, specDefinitions)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Defines a suite of specifications.
|
||||
|
||||
Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared
|
||||
are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization
|
||||
of setup in some tests.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<pre class="code">// TODO: a simple suite
|
||||
|
||||
// TODO: a simple suite with a nested describe block</pre>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{String}</span> <b>description</b>
|
||||
|
||||
</dt>
|
||||
<dd>A string, usually the class under test.</dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Function}</span> <b>specDefinitions</b>
|
||||
|
||||
</dt>
|
||||
<dd>function that defines several specs.</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="expect"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>expect</b>(actual)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Starts a chain for a Jasmine expectation.
|
||||
|
||||
It is passed an Object that is the actual value and should chain to one of the many
|
||||
jasmine.Matchers functions.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Object}</span> <b>actual</b>
|
||||
|
||||
</dt>
|
||||
<dd>Actual value to test against and expected value</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="it"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>it</b>(desc, func)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Creates a Jasmine spec that will be added to the current suite.
|
||||
|
||||
// TODO: pending tests
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<pre class="code">it('should be true', function() {
|
||||
expect(true).toEqual(true);
|
||||
});</pre>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{String}</span> <b>desc</b>
|
||||
|
||||
</dt>
|
||||
<dd>description of this specification</dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Function}</span> <b>func</b>
|
||||
|
||||
</dt>
|
||||
<dd>defines the preconditions and expectations of the spec</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="runs"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>runs</b>(func)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Function}</span> <b>func</b>
|
||||
|
||||
</dt>
|
||||
<dd>Function that defines part of a jasmine spec.</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="spyOn"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>spyOn</b>(obj, methodName)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Function that installs a spy on an existing object's method name. Used within a Spec to create a spy.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<pre class="code">// spy example
|
||||
var foo = {
|
||||
not: function(bool) { return !bool; }
|
||||
}
|
||||
spyOn(foo, 'not'); // actual foo.not will not be called, execution stops</pre>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<b>obj</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt>
|
||||
<b>methodName</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Returns:</dt>
|
||||
|
||||
<dd>a Jasmine spy that can be chained with all spy methods</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">See:</dt>
|
||||
|
||||
<dd>jasmine.createSpy</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="waits"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>waits</b>(timeout)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Waits for a timeout before moving to the next runs()-defined block.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Number}</span> <b>timeout</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="waitsFor"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>waitsFor</b>(timeout, latchFunction, message)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Waits for the latchFunction to return true before proceeding to the next runs()-defined block.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Number}</span> <b>timeout</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Function}</span> <b>latchFunction</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{String}</span> <b>message</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="xdescribe"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>xdescribe</b>(description, specDefinitions)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{String}</span> <b>description</b>
|
||||
|
||||
</dt>
|
||||
<dd>A string, usually the class under test.</dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Function}</span> <b>specDefinitions</b>
|
||||
|
||||
</dt>
|
||||
<dd>function that defines several specs.</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="xit"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>xit</b>(desc, func)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Creates a <em>disabled</em> Jasmine spec.
|
||||
|
||||
A convenience method that allows existing specs to be disabled temporarily during development.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{String}</span> <b>desc</b>
|
||||
|
||||
</dt>
|
||||
<dd>description of this specification</dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Function}</span> <b>func</b>
|
||||
|
||||
</dt>
|
||||
<dd>defines the preconditions and expectations of the spec</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== event details ========================= -->
|
||||
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:18 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,496 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
|
||||
<title>JsDoc Reference - jasmine.ActionCollection</title>
|
||||
|
||||
<style type="text/css">
|
||||
/* default.css */
|
||||
body
|
||||
{
|
||||
font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.header
|
||||
{
|
||||
clear: both;
|
||||
background-color: #ccc;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 1em 0 0 .3em;
|
||||
}
|
||||
|
||||
hr
|
||||
{
|
||||
border: none 0;
|
||||
border-top: 1px solid #7F8FB1;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
pre.code
|
||||
{
|
||||
display: block;
|
||||
padding: 8px;
|
||||
border: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
#index
|
||||
{
|
||||
margin-top: 24px;
|
||||
float: left;
|
||||
width: 160px;
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
background-color: #F3F3F3;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
margin-left: 190px;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.classList
|
||||
{
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0 0 0 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 1em;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.classList li
|
||||
{
|
||||
padding: 0;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.summaryTable { width: 100%; }
|
||||
|
||||
h1.classTitle
|
||||
{
|
||||
font-size:170%;
|
||||
line-height:130%;
|
||||
}
|
||||
|
||||
h2 { font-size: 110%; }
|
||||
caption, div.sectionTitle
|
||||
{
|
||||
background-color: #7F8FB1;
|
||||
color: #fff;
|
||||
font-size:130%;
|
||||
text-align: left;
|
||||
padding: 2px 6px 2px 6px;
|
||||
border: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
div.sectionTitle { margin-bottom: 8px; }
|
||||
.summaryTable thead { display: none; }
|
||||
|
||||
.summaryTable td
|
||||
{
|
||||
vertical-align: top;
|
||||
padding: 4px;
|
||||
border-bottom: 1px #7F8FB1 solid;
|
||||
border-right: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
/*col#summaryAttributes {}*/
|
||||
.summaryTable td.attributes
|
||||
{
|
||||
border-left: 1px #7F8FB1 solid;
|
||||
width: 140px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.attributes, .fixedFont
|
||||
{
|
||||
line-height: 15px;
|
||||
color: #002EBE;
|
||||
font-family: "Courier New",Courier,monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription
|
||||
{
|
||||
text-align: left;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription, .description
|
||||
{
|
||||
line-height: 15px;
|
||||
padding: 4px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.summaryTable { margin-bottom: 8px; }
|
||||
|
||||
ul.inheritsList
|
||||
{
|
||||
list-style: square;
|
||||
margin-left: 20px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.detailList {
|
||||
margin-left: 20px;
|
||||
line-height: 15px;
|
||||
}
|
||||
.detailList dt { margin-left: 20px; }
|
||||
|
||||
.detailList .heading
|
||||
{
|
||||
font-weight: bold;
|
||||
padding-bottom: 6px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.light, td.attributes, .light a:link, .light a:visited
|
||||
{
|
||||
color: #777;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.fineprint
|
||||
{
|
||||
text-align: right;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- ============================== header ================================= -->
|
||||
<!-- begin static/header.html -->
|
||||
<div id="header">
|
||||
</div>
|
||||
<!-- end static/header.html -->
|
||||
|
||||
<!-- ============================== classes index ============================ -->
|
||||
<div id="index">
|
||||
<!-- begin publish.classesIndex -->
|
||||
<div align="center"><a href="../index.html">Class Index</a>
|
||||
| <a href="../files.html">File Index</a></div>
|
||||
<hr />
|
||||
<h2>Classes</h2>
|
||||
<ul class="classList">
|
||||
|
||||
<li><i><a href="../symbols/_global_.html">_global_</a></i></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spec.html">jasmine.Spec</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spy.html">jasmine.Spy</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Suite.html">jasmine.Suite</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.util.html">jasmine.util</a></li>
|
||||
|
||||
</ul>
|
||||
<hr />
|
||||
<!-- end publish.classesIndex -->
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<!-- ============================== class title ============================ -->
|
||||
<h1 class="classTitle">
|
||||
|
||||
Class jasmine.ActionCollection
|
||||
</h1>
|
||||
|
||||
<!-- ============================== class summary ========================== -->
|
||||
<p class="description">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
<!-- ============================== constructor summary ==================== -->
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the constructor documented in the class jasmine.ActionCollection.">
|
||||
<caption>Class Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Constructor Attributes</th>
|
||||
<th scope="col">Constructor Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.ActionCollection.html#constructor">jasmine.ActionCollection</a></b>(env)
|
||||
</div>
|
||||
<div class="description">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.</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<!-- ============================== properties summary ===================== -->
|
||||
|
||||
|
||||
<!-- ============================== methods summary ======================== -->
|
||||
|
||||
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the methods documented in the class jasmine.ActionCollection.">
|
||||
<caption>Method Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Method Attributes</th>
|
||||
<th scope="col">Method Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.ActionCollection.html#execute">execute</a></b>()
|
||||
</div>
|
||||
<div class="description">Starts executing the queue of functions/actions.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.ActionCollection.html#finish">finish</a></b>()
|
||||
</div>
|
||||
<div class="description">Marks the collection as done & calls the finish callback, if there is one</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.ActionCollection.html#getCurrentAction">getCurrentAction</a></b>()
|
||||
</div>
|
||||
<div class="description">Gets the current action.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.ActionCollection.html#next">next</a></b>()
|
||||
</div>
|
||||
<div class="description">Executes the next queued function/action.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== events summary ======================== -->
|
||||
|
||||
|
||||
<!-- ============================== constructor details ==================== -->
|
||||
|
||||
<div class="details"><a name="constructor"> </a>
|
||||
<div class="sectionTitle">
|
||||
Class Detail
|
||||
</div>
|
||||
|
||||
<div class="fixedFont">
|
||||
<b>jasmine.ActionCollection</b>(env)
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
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.
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{<a href="../symbols/jasmine.Env.html">jasmine.Env</a>}</span> <b>env</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== field details ========================== -->
|
||||
|
||||
|
||||
<!-- ============================== method details ========================= -->
|
||||
|
||||
<div class="sectionTitle">
|
||||
Method Detail
|
||||
</div>
|
||||
|
||||
<a name="execute"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>execute</b>()
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Starts executing the queue of functions/actions.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="finish"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>finish</b>()
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Marks the collection as done & calls the finish callback, if there is one
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="getCurrentAction"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>getCurrentAction</b>()
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Gets the current action.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="next"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>next</b>()
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Executes the next queued function/action. If there are no more in the queue, calls #finish.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== event details ========================= -->
|
||||
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:18 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,390 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
|
||||
<title>JsDoc Reference - jasmine.Env</title>
|
||||
|
||||
<style type="text/css">
|
||||
/* default.css */
|
||||
body
|
||||
{
|
||||
font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.header
|
||||
{
|
||||
clear: both;
|
||||
background-color: #ccc;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 1em 0 0 .3em;
|
||||
}
|
||||
|
||||
hr
|
||||
{
|
||||
border: none 0;
|
||||
border-top: 1px solid #7F8FB1;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
pre.code
|
||||
{
|
||||
display: block;
|
||||
padding: 8px;
|
||||
border: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
#index
|
||||
{
|
||||
margin-top: 24px;
|
||||
float: left;
|
||||
width: 160px;
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
background-color: #F3F3F3;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
margin-left: 190px;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.classList
|
||||
{
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0 0 0 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 1em;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.classList li
|
||||
{
|
||||
padding: 0;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.summaryTable { width: 100%; }
|
||||
|
||||
h1.classTitle
|
||||
{
|
||||
font-size:170%;
|
||||
line-height:130%;
|
||||
}
|
||||
|
||||
h2 { font-size: 110%; }
|
||||
caption, div.sectionTitle
|
||||
{
|
||||
background-color: #7F8FB1;
|
||||
color: #fff;
|
||||
font-size:130%;
|
||||
text-align: left;
|
||||
padding: 2px 6px 2px 6px;
|
||||
border: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
div.sectionTitle { margin-bottom: 8px; }
|
||||
.summaryTable thead { display: none; }
|
||||
|
||||
.summaryTable td
|
||||
{
|
||||
vertical-align: top;
|
||||
padding: 4px;
|
||||
border-bottom: 1px #7F8FB1 solid;
|
||||
border-right: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
/*col#summaryAttributes {}*/
|
||||
.summaryTable td.attributes
|
||||
{
|
||||
border-left: 1px #7F8FB1 solid;
|
||||
width: 140px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.attributes, .fixedFont
|
||||
{
|
||||
line-height: 15px;
|
||||
color: #002EBE;
|
||||
font-family: "Courier New",Courier,monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription
|
||||
{
|
||||
text-align: left;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription, .description
|
||||
{
|
||||
line-height: 15px;
|
||||
padding: 4px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.summaryTable { margin-bottom: 8px; }
|
||||
|
||||
ul.inheritsList
|
||||
{
|
||||
list-style: square;
|
||||
margin-left: 20px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.detailList {
|
||||
margin-left: 20px;
|
||||
line-height: 15px;
|
||||
}
|
||||
.detailList dt { margin-left: 20px; }
|
||||
|
||||
.detailList .heading
|
||||
{
|
||||
font-weight: bold;
|
||||
padding-bottom: 6px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.light, td.attributes, .light a:link, .light a:visited
|
||||
{
|
||||
color: #777;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.fineprint
|
||||
{
|
||||
text-align: right;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- ============================== header ================================= -->
|
||||
<!-- begin static/header.html -->
|
||||
<div id="header">
|
||||
</div>
|
||||
<!-- end static/header.html -->
|
||||
|
||||
<!-- ============================== classes index ============================ -->
|
||||
<div id="index">
|
||||
<!-- begin publish.classesIndex -->
|
||||
<div align="center"><a href="../index.html">Class Index</a>
|
||||
| <a href="../files.html">File Index</a></div>
|
||||
<hr />
|
||||
<h2>Classes</h2>
|
||||
<ul class="classList">
|
||||
|
||||
<li><i><a href="../symbols/_global_.html">_global_</a></i></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spec.html">jasmine.Spec</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spy.html">jasmine.Spy</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Suite.html">jasmine.Suite</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.util.html">jasmine.util</a></li>
|
||||
|
||||
</ul>
|
||||
<hr />
|
||||
<!-- end publish.classesIndex -->
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<!-- ============================== class title ============================ -->
|
||||
<h1 class="classTitle">
|
||||
|
||||
Class jasmine.Env
|
||||
</h1>
|
||||
|
||||
<!-- ============================== class summary ========================== -->
|
||||
<p class="description">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
<!-- ============================== constructor summary ==================== -->
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the constructor documented in the class jasmine.Env.">
|
||||
<caption>Class Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Constructor Attributes</th>
|
||||
<th scope="col">Constructor Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.Env.html#constructor">jasmine.Env</a></b>()
|
||||
</div>
|
||||
<div class="description">Environment for Jasmine</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<!-- ============================== properties summary ===================== -->
|
||||
|
||||
|
||||
<!-- ============================== methods summary ======================== -->
|
||||
|
||||
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the methods documented in the class jasmine.Env.">
|
||||
<caption>Method Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Method Attributes</th>
|
||||
<th scope="col">Method Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.Env.html#addReporter">addReporter</a></b>(reporter)
|
||||
</div>
|
||||
<div class="description">Register a reporter to receive status updates from Jasmine.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== events summary ======================== -->
|
||||
|
||||
|
||||
<!-- ============================== constructor details ==================== -->
|
||||
|
||||
<div class="details"><a name="constructor"> </a>
|
||||
<div class="sectionTitle">
|
||||
Class Detail
|
||||
</div>
|
||||
|
||||
<div class="fixedFont">
|
||||
<b>jasmine.Env</b>()
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
Environment for Jasmine
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== field details ========================== -->
|
||||
|
||||
|
||||
<!-- ============================== method details ========================= -->
|
||||
|
||||
<div class="sectionTitle">
|
||||
Method Detail
|
||||
</div>
|
||||
|
||||
<a name="addReporter"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>addReporter</b>(reporter)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Register a reporter to receive status updates from Jasmine.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{<a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a>}</span> <b>reporter</b>
|
||||
|
||||
</dt>
|
||||
<dd>An object which will receive status updates.</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== event details ========================= -->
|
||||
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,322 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
|
||||
<title>JsDoc Reference - jasmine.MultiReporter</title>
|
||||
|
||||
<style type="text/css">
|
||||
/* default.css */
|
||||
body
|
||||
{
|
||||
font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.header
|
||||
{
|
||||
clear: both;
|
||||
background-color: #ccc;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 1em 0 0 .3em;
|
||||
}
|
||||
|
||||
hr
|
||||
{
|
||||
border: none 0;
|
||||
border-top: 1px solid #7F8FB1;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
pre.code
|
||||
{
|
||||
display: block;
|
||||
padding: 8px;
|
||||
border: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
#index
|
||||
{
|
||||
margin-top: 24px;
|
||||
float: left;
|
||||
width: 160px;
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
background-color: #F3F3F3;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
margin-left: 190px;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.classList
|
||||
{
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0 0 0 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 1em;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.classList li
|
||||
{
|
||||
padding: 0;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.summaryTable { width: 100%; }
|
||||
|
||||
h1.classTitle
|
||||
{
|
||||
font-size:170%;
|
||||
line-height:130%;
|
||||
}
|
||||
|
||||
h2 { font-size: 110%; }
|
||||
caption, div.sectionTitle
|
||||
{
|
||||
background-color: #7F8FB1;
|
||||
color: #fff;
|
||||
font-size:130%;
|
||||
text-align: left;
|
||||
padding: 2px 6px 2px 6px;
|
||||
border: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
div.sectionTitle { margin-bottom: 8px; }
|
||||
.summaryTable thead { display: none; }
|
||||
|
||||
.summaryTable td
|
||||
{
|
||||
vertical-align: top;
|
||||
padding: 4px;
|
||||
border-bottom: 1px #7F8FB1 solid;
|
||||
border-right: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
/*col#summaryAttributes {}*/
|
||||
.summaryTable td.attributes
|
||||
{
|
||||
border-left: 1px #7F8FB1 solid;
|
||||
width: 140px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.attributes, .fixedFont
|
||||
{
|
||||
line-height: 15px;
|
||||
color: #002EBE;
|
||||
font-family: "Courier New",Courier,monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription
|
||||
{
|
||||
text-align: left;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription, .description
|
||||
{
|
||||
line-height: 15px;
|
||||
padding: 4px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.summaryTable { margin-bottom: 8px; }
|
||||
|
||||
ul.inheritsList
|
||||
{
|
||||
list-style: square;
|
||||
margin-left: 20px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.detailList {
|
||||
margin-left: 20px;
|
||||
line-height: 15px;
|
||||
}
|
||||
.detailList dt { margin-left: 20px; }
|
||||
|
||||
.detailList .heading
|
||||
{
|
||||
font-weight: bold;
|
||||
padding-bottom: 6px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.light, td.attributes, .light a:link, .light a:visited
|
||||
{
|
||||
color: #777;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.fineprint
|
||||
{
|
||||
text-align: right;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- ============================== header ================================= -->
|
||||
<!-- begin static/header.html -->
|
||||
<div id="header">
|
||||
</div>
|
||||
<!-- end static/header.html -->
|
||||
|
||||
<!-- ============================== classes index ============================ -->
|
||||
<div id="index">
|
||||
<!-- begin publish.classesIndex -->
|
||||
<div align="center"><a href="../index.html">Class Index</a>
|
||||
| <a href="../files.html">File Index</a></div>
|
||||
<hr />
|
||||
<h2>Classes</h2>
|
||||
<ul class="classList">
|
||||
|
||||
<li><i><a href="../symbols/_global_.html">_global_</a></i></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spec.html">jasmine.Spec</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spy.html">jasmine.Spy</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Suite.html">jasmine.Suite</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.util.html">jasmine.util</a></li>
|
||||
|
||||
</ul>
|
||||
<hr />
|
||||
<!-- end publish.classesIndex -->
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<!-- ============================== class title ============================ -->
|
||||
<h1 class="classTitle">
|
||||
|
||||
Class jasmine.MultiReporter
|
||||
</h1>
|
||||
|
||||
<!-- ============================== class summary ========================== -->
|
||||
<p class="description">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
<!-- ============================== constructor summary ==================== -->
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the constructor documented in the class jasmine.MultiReporter.">
|
||||
<caption>Class Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Constructor Attributes</th>
|
||||
<th scope="col">Constructor Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.MultiReporter.html#constructor">jasmine.MultiReporter</a></b>()
|
||||
</div>
|
||||
<div class="description"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<!-- ============================== properties summary ===================== -->
|
||||
|
||||
|
||||
<!-- ============================== methods summary ======================== -->
|
||||
|
||||
<!-- ============================== events summary ======================== -->
|
||||
|
||||
|
||||
<!-- ============================== constructor details ==================== -->
|
||||
|
||||
<div class="details"><a name="constructor"> </a>
|
||||
<div class="sectionTitle">
|
||||
Class Detail
|
||||
</div>
|
||||
|
||||
<div class="fixedFont">
|
||||
<b>jasmine.MultiReporter</b>()
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== field details ========================== -->
|
||||
|
||||
|
||||
<!-- ============================== method details ========================= -->
|
||||
|
||||
|
||||
<!-- ============================== event details ========================= -->
|
||||
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,706 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
|
||||
<title>JsDoc Reference - jasmine.NestedResults</title>
|
||||
|
||||
<style type="text/css">
|
||||
/* default.css */
|
||||
body
|
||||
{
|
||||
font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.header
|
||||
{
|
||||
clear: both;
|
||||
background-color: #ccc;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 1em 0 0 .3em;
|
||||
}
|
||||
|
||||
hr
|
||||
{
|
||||
border: none 0;
|
||||
border-top: 1px solid #7F8FB1;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
pre.code
|
||||
{
|
||||
display: block;
|
||||
padding: 8px;
|
||||
border: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
#index
|
||||
{
|
||||
margin-top: 24px;
|
||||
float: left;
|
||||
width: 160px;
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
background-color: #F3F3F3;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
margin-left: 190px;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.classList
|
||||
{
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0 0 0 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 1em;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.classList li
|
||||
{
|
||||
padding: 0;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.summaryTable { width: 100%; }
|
||||
|
||||
h1.classTitle
|
||||
{
|
||||
font-size:170%;
|
||||
line-height:130%;
|
||||
}
|
||||
|
||||
h2 { font-size: 110%; }
|
||||
caption, div.sectionTitle
|
||||
{
|
||||
background-color: #7F8FB1;
|
||||
color: #fff;
|
||||
font-size:130%;
|
||||
text-align: left;
|
||||
padding: 2px 6px 2px 6px;
|
||||
border: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
div.sectionTitle { margin-bottom: 8px; }
|
||||
.summaryTable thead { display: none; }
|
||||
|
||||
.summaryTable td
|
||||
{
|
||||
vertical-align: top;
|
||||
padding: 4px;
|
||||
border-bottom: 1px #7F8FB1 solid;
|
||||
border-right: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
/*col#summaryAttributes {}*/
|
||||
.summaryTable td.attributes
|
||||
{
|
||||
border-left: 1px #7F8FB1 solid;
|
||||
width: 140px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.attributes, .fixedFont
|
||||
{
|
||||
line-height: 15px;
|
||||
color: #002EBE;
|
||||
font-family: "Courier New",Courier,monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription
|
||||
{
|
||||
text-align: left;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription, .description
|
||||
{
|
||||
line-height: 15px;
|
||||
padding: 4px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.summaryTable { margin-bottom: 8px; }
|
||||
|
||||
ul.inheritsList
|
||||
{
|
||||
list-style: square;
|
||||
margin-left: 20px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.detailList {
|
||||
margin-left: 20px;
|
||||
line-height: 15px;
|
||||
}
|
||||
.detailList dt { margin-left: 20px; }
|
||||
|
||||
.detailList .heading
|
||||
{
|
||||
font-weight: bold;
|
||||
padding-bottom: 6px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.light, td.attributes, .light a:link, .light a:visited
|
||||
{
|
||||
color: #777;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.fineprint
|
||||
{
|
||||
text-align: right;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- ============================== header ================================= -->
|
||||
<!-- begin static/header.html -->
|
||||
<div id="header">
|
||||
</div>
|
||||
<!-- end static/header.html -->
|
||||
|
||||
<!-- ============================== classes index ============================ -->
|
||||
<div id="index">
|
||||
<!-- begin publish.classesIndex -->
|
||||
<div align="center"><a href="../index.html">Class Index</a>
|
||||
| <a href="../files.html">File Index</a></div>
|
||||
<hr />
|
||||
<h2>Classes</h2>
|
||||
<ul class="classList">
|
||||
|
||||
<li><i><a href="../symbols/_global_.html">_global_</a></i></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spec.html">jasmine.Spec</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spy.html">jasmine.Spy</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Suite.html">jasmine.Suite</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.util.html">jasmine.util</a></li>
|
||||
|
||||
</ul>
|
||||
<hr />
|
||||
<!-- end publish.classesIndex -->
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<!-- ============================== class title ============================ -->
|
||||
<h1 class="classTitle">
|
||||
|
||||
Class jasmine.NestedResults
|
||||
</h1>
|
||||
|
||||
<!-- ============================== class summary ========================== -->
|
||||
<p class="description">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
<!-- ============================== constructor summary ==================== -->
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the constructor documented in the class jasmine.NestedResults.">
|
||||
<caption>Class Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Constructor Attributes</th>
|
||||
<th scope="col">Constructor Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.NestedResults.html#constructor">jasmine.NestedResults</a></b>()
|
||||
</div>
|
||||
<div class="description">Holds results for a set of Jasmine spec.</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<!-- ============================== properties summary ===================== -->
|
||||
|
||||
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the fields documented in the class jasmine.NestedResults.">
|
||||
<caption>Field Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Field Attributes</th>
|
||||
<th scope="col">Field Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.NestedResults.html#failedCount">failedCount</a></b>
|
||||
</div>
|
||||
<div class="description">Number of failed results</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.NestedResults.html#passedCount">passedCount</a></b>
|
||||
</div>
|
||||
<div class="description">Number of passed results</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.NestedResults.html#skipped">skipped</a></b>
|
||||
</div>
|
||||
<div class="description">Was this suite/spec skipped?</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.NestedResults.html#totalCount">totalCount</a></b>
|
||||
</div>
|
||||
<div class="description">The total count of results</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== methods summary ======================== -->
|
||||
|
||||
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the methods documented in the class jasmine.NestedResults.">
|
||||
<caption>Method Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Method Attributes</th>
|
||||
<th scope="col">Method Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.NestedResults.html#addResult">addResult</a></b>(result)
|
||||
</div>
|
||||
<div class="description">Adds a result, tracking counts (total, passed, & failed)</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.NestedResults.html#getItems">getItems</a></b>()
|
||||
</div>
|
||||
<div class="description">Getter for the results: message & results.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.NestedResults.html#log">log</a></b>(message)
|
||||
</div>
|
||||
<div class="description">Tracks a result's message.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.NestedResults.html#passed">passed</a></b>()
|
||||
</div>
|
||||
<div class="description"></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.NestedResults.html#rollupCounts">rollupCounts</a></b>(result)
|
||||
</div>
|
||||
<div class="description">Roll up the result counts.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== events summary ======================== -->
|
||||
|
||||
|
||||
<!-- ============================== constructor details ==================== -->
|
||||
|
||||
<div class="details"><a name="constructor"> </a>
|
||||
<div class="sectionTitle">
|
||||
Class Detail
|
||||
</div>
|
||||
|
||||
<div class="fixedFont">
|
||||
<b>jasmine.NestedResults</b>()
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== field details ========================== -->
|
||||
|
||||
<div class="sectionTitle">
|
||||
Field Detail
|
||||
</div>
|
||||
|
||||
<a name="failedCount"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>failedCount</b>
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Number of failed results
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="passedCount"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>passedCount</b>
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Number of passed results
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="skipped"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>skipped</b>
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Was this suite/spec skipped?
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="totalCount"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>totalCount</b>
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
The total count of results
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== method details ========================= -->
|
||||
|
||||
<div class="sectionTitle">
|
||||
Method Detail
|
||||
</div>
|
||||
|
||||
<a name="addResult"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>addResult</b>(result)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Adds a result, tracking counts (total, passed, & failed)
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{jasmine.ExpectationResult|<a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a>}</span> <b>result</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="getItems"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>getItems</b>()
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Getter for the results: message & results.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="log"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>log</b>(message)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Tracks a result's message.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<b>message</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="passed"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
<span class="light">{Boolean}</span>
|
||||
<b>passed</b>()
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Returns:</dt>
|
||||
|
||||
<dd><span class="light fixedFont">{Boolean}</span> True if <b>everything</b> below passed</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="rollupCounts"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>rollupCounts</b>(result)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Roll up the result counts.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<b>result</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== event details ========================= -->
|
||||
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,357 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
|
||||
<title>JsDoc Reference - jasmine.QueuedFunction</title>
|
||||
|
||||
<style type="text/css">
|
||||
/* default.css */
|
||||
body
|
||||
{
|
||||
font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.header
|
||||
{
|
||||
clear: both;
|
||||
background-color: #ccc;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 1em 0 0 .3em;
|
||||
}
|
||||
|
||||
hr
|
||||
{
|
||||
border: none 0;
|
||||
border-top: 1px solid #7F8FB1;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
pre.code
|
||||
{
|
||||
display: block;
|
||||
padding: 8px;
|
||||
border: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
#index
|
||||
{
|
||||
margin-top: 24px;
|
||||
float: left;
|
||||
width: 160px;
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
background-color: #F3F3F3;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
margin-left: 190px;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.classList
|
||||
{
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0 0 0 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 1em;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.classList li
|
||||
{
|
||||
padding: 0;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.summaryTable { width: 100%; }
|
||||
|
||||
h1.classTitle
|
||||
{
|
||||
font-size:170%;
|
||||
line-height:130%;
|
||||
}
|
||||
|
||||
h2 { font-size: 110%; }
|
||||
caption, div.sectionTitle
|
||||
{
|
||||
background-color: #7F8FB1;
|
||||
color: #fff;
|
||||
font-size:130%;
|
||||
text-align: left;
|
||||
padding: 2px 6px 2px 6px;
|
||||
border: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
div.sectionTitle { margin-bottom: 8px; }
|
||||
.summaryTable thead { display: none; }
|
||||
|
||||
.summaryTable td
|
||||
{
|
||||
vertical-align: top;
|
||||
padding: 4px;
|
||||
border-bottom: 1px #7F8FB1 solid;
|
||||
border-right: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
/*col#summaryAttributes {}*/
|
||||
.summaryTable td.attributes
|
||||
{
|
||||
border-left: 1px #7F8FB1 solid;
|
||||
width: 140px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.attributes, .fixedFont
|
||||
{
|
||||
line-height: 15px;
|
||||
color: #002EBE;
|
||||
font-family: "Courier New",Courier,monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription
|
||||
{
|
||||
text-align: left;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription, .description
|
||||
{
|
||||
line-height: 15px;
|
||||
padding: 4px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.summaryTable { margin-bottom: 8px; }
|
||||
|
||||
ul.inheritsList
|
||||
{
|
||||
list-style: square;
|
||||
margin-left: 20px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.detailList {
|
||||
margin-left: 20px;
|
||||
line-height: 15px;
|
||||
}
|
||||
.detailList dt { margin-left: 20px; }
|
||||
|
||||
.detailList .heading
|
||||
{
|
||||
font-weight: bold;
|
||||
padding-bottom: 6px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.light, td.attributes, .light a:link, .light a:visited
|
||||
{
|
||||
color: #777;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.fineprint
|
||||
{
|
||||
text-align: right;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- ============================== header ================================= -->
|
||||
<!-- begin static/header.html -->
|
||||
<div id="header">
|
||||
</div>
|
||||
<!-- end static/header.html -->
|
||||
|
||||
<!-- ============================== classes index ============================ -->
|
||||
<div id="index">
|
||||
<!-- begin publish.classesIndex -->
|
||||
<div align="center"><a href="../index.html">Class Index</a>
|
||||
| <a href="../files.html">File Index</a></div>
|
||||
<hr />
|
||||
<h2>Classes</h2>
|
||||
<ul class="classList">
|
||||
|
||||
<li><i><a href="../symbols/_global_.html">_global_</a></i></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spec.html">jasmine.Spec</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spy.html">jasmine.Spy</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Suite.html">jasmine.Suite</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.util.html">jasmine.util</a></li>
|
||||
|
||||
</ul>
|
||||
<hr />
|
||||
<!-- end publish.classesIndex -->
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<!-- ============================== class title ============================ -->
|
||||
<h1 class="classTitle">
|
||||
|
||||
Class jasmine.QueuedFunction
|
||||
</h1>
|
||||
|
||||
<!-- ============================== class summary ========================== -->
|
||||
<p class="description">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
<!-- ============================== constructor summary ==================== -->
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the constructor documented in the class jasmine.QueuedFunction.">
|
||||
<caption>Class Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Constructor Attributes</th>
|
||||
<th scope="col">Constructor Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.QueuedFunction.html#constructor">jasmine.QueuedFunction</a></b>(env, func, timeout, latchFunction, spec)
|
||||
</div>
|
||||
<div class="description">QueuedFunction is how ActionCollections' actions are implemented</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<!-- ============================== properties summary ===================== -->
|
||||
|
||||
|
||||
<!-- ============================== methods summary ======================== -->
|
||||
|
||||
<!-- ============================== events summary ======================== -->
|
||||
|
||||
|
||||
<!-- ============================== constructor details ==================== -->
|
||||
|
||||
<div class="details"><a name="constructor"> </a>
|
||||
<div class="sectionTitle">
|
||||
Class Detail
|
||||
</div>
|
||||
|
||||
<div class="fixedFont">
|
||||
<b>jasmine.QueuedFunction</b>(env, func, timeout, latchFunction, spec)
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
QueuedFunction is how ActionCollections' actions are implemented
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{<a href="../symbols/jasmine.Env.html">jasmine.Env</a>}</span> <b>env</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Function}</span> <b>func</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Number}</span> <b>timeout</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Function}</span> <b>latchFunction</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{<a href="../symbols/jasmine.Spec.html">jasmine.Spec</a>}</span> <b>spec</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== field details ========================== -->
|
||||
|
||||
|
||||
<!-- ============================== method details ========================= -->
|
||||
|
||||
|
||||
<!-- ============================== event details ========================= -->
|
||||
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,322 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
|
||||
<title>JsDoc Reference - jasmine.Reporter</title>
|
||||
|
||||
<style type="text/css">
|
||||
/* default.css */
|
||||
body
|
||||
{
|
||||
font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.header
|
||||
{
|
||||
clear: both;
|
||||
background-color: #ccc;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 1em 0 0 .3em;
|
||||
}
|
||||
|
||||
hr
|
||||
{
|
||||
border: none 0;
|
||||
border-top: 1px solid #7F8FB1;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
pre.code
|
||||
{
|
||||
display: block;
|
||||
padding: 8px;
|
||||
border: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
#index
|
||||
{
|
||||
margin-top: 24px;
|
||||
float: left;
|
||||
width: 160px;
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
background-color: #F3F3F3;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
margin-left: 190px;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.classList
|
||||
{
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0 0 0 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 1em;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.classList li
|
||||
{
|
||||
padding: 0;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.summaryTable { width: 100%; }
|
||||
|
||||
h1.classTitle
|
||||
{
|
||||
font-size:170%;
|
||||
line-height:130%;
|
||||
}
|
||||
|
||||
h2 { font-size: 110%; }
|
||||
caption, div.sectionTitle
|
||||
{
|
||||
background-color: #7F8FB1;
|
||||
color: #fff;
|
||||
font-size:130%;
|
||||
text-align: left;
|
||||
padding: 2px 6px 2px 6px;
|
||||
border: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
div.sectionTitle { margin-bottom: 8px; }
|
||||
.summaryTable thead { display: none; }
|
||||
|
||||
.summaryTable td
|
||||
{
|
||||
vertical-align: top;
|
||||
padding: 4px;
|
||||
border-bottom: 1px #7F8FB1 solid;
|
||||
border-right: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
/*col#summaryAttributes {}*/
|
||||
.summaryTable td.attributes
|
||||
{
|
||||
border-left: 1px #7F8FB1 solid;
|
||||
width: 140px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.attributes, .fixedFont
|
||||
{
|
||||
line-height: 15px;
|
||||
color: #002EBE;
|
||||
font-family: "Courier New",Courier,monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription
|
||||
{
|
||||
text-align: left;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription, .description
|
||||
{
|
||||
line-height: 15px;
|
||||
padding: 4px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.summaryTable { margin-bottom: 8px; }
|
||||
|
||||
ul.inheritsList
|
||||
{
|
||||
list-style: square;
|
||||
margin-left: 20px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.detailList {
|
||||
margin-left: 20px;
|
||||
line-height: 15px;
|
||||
}
|
||||
.detailList dt { margin-left: 20px; }
|
||||
|
||||
.detailList .heading
|
||||
{
|
||||
font-weight: bold;
|
||||
padding-bottom: 6px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.light, td.attributes, .light a:link, .light a:visited
|
||||
{
|
||||
color: #777;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.fineprint
|
||||
{
|
||||
text-align: right;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- ============================== header ================================= -->
|
||||
<!-- begin static/header.html -->
|
||||
<div id="header">
|
||||
</div>
|
||||
<!-- end static/header.html -->
|
||||
|
||||
<!-- ============================== classes index ============================ -->
|
||||
<div id="index">
|
||||
<!-- begin publish.classesIndex -->
|
||||
<div align="center"><a href="../index.html">Class Index</a>
|
||||
| <a href="../files.html">File Index</a></div>
|
||||
<hr />
|
||||
<h2>Classes</h2>
|
||||
<ul class="classList">
|
||||
|
||||
<li><i><a href="../symbols/_global_.html">_global_</a></i></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spec.html">jasmine.Spec</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spy.html">jasmine.Spy</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Suite.html">jasmine.Suite</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.util.html">jasmine.util</a></li>
|
||||
|
||||
</ul>
|
||||
<hr />
|
||||
<!-- end publish.classesIndex -->
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<!-- ============================== class title ============================ -->
|
||||
<h1 class="classTitle">
|
||||
|
||||
Class jasmine.Reporter
|
||||
</h1>
|
||||
|
||||
<!-- ============================== class summary ========================== -->
|
||||
<p class="description">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
<!-- ============================== constructor summary ==================== -->
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the constructor documented in the class jasmine.Reporter.">
|
||||
<caption>Class Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Constructor Attributes</th>
|
||||
<th scope="col">Constructor Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.Reporter.html#constructor">jasmine.Reporter</a></b>()
|
||||
</div>
|
||||
<div class="description">No-op base class for Jasmine reporters.</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<!-- ============================== properties summary ===================== -->
|
||||
|
||||
|
||||
<!-- ============================== methods summary ======================== -->
|
||||
|
||||
<!-- ============================== events summary ======================== -->
|
||||
|
||||
|
||||
<!-- ============================== constructor details ==================== -->
|
||||
|
||||
<div class="details"><a name="constructor"> </a>
|
||||
<div class="sectionTitle">
|
||||
Class Detail
|
||||
</div>
|
||||
|
||||
<div class="fixedFont">
|
||||
<b>jasmine.Reporter</b>()
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
No-op base class for Jasmine reporters.
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== field details ========================== -->
|
||||
|
||||
|
||||
<!-- ============================== method details ========================= -->
|
||||
|
||||
|
||||
<!-- ============================== event details ========================= -->
|
||||
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,333 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
|
||||
<title>JsDoc Reference - jasmine.Runner</title>
|
||||
|
||||
<style type="text/css">
|
||||
/* default.css */
|
||||
body
|
||||
{
|
||||
font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.header
|
||||
{
|
||||
clear: both;
|
||||
background-color: #ccc;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 1em 0 0 .3em;
|
||||
}
|
||||
|
||||
hr
|
||||
{
|
||||
border: none 0;
|
||||
border-top: 1px solid #7F8FB1;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
pre.code
|
||||
{
|
||||
display: block;
|
||||
padding: 8px;
|
||||
border: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
#index
|
||||
{
|
||||
margin-top: 24px;
|
||||
float: left;
|
||||
width: 160px;
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
background-color: #F3F3F3;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
margin-left: 190px;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.classList
|
||||
{
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0 0 0 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 1em;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.classList li
|
||||
{
|
||||
padding: 0;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.summaryTable { width: 100%; }
|
||||
|
||||
h1.classTitle
|
||||
{
|
||||
font-size:170%;
|
||||
line-height:130%;
|
||||
}
|
||||
|
||||
h2 { font-size: 110%; }
|
||||
caption, div.sectionTitle
|
||||
{
|
||||
background-color: #7F8FB1;
|
||||
color: #fff;
|
||||
font-size:130%;
|
||||
text-align: left;
|
||||
padding: 2px 6px 2px 6px;
|
||||
border: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
div.sectionTitle { margin-bottom: 8px; }
|
||||
.summaryTable thead { display: none; }
|
||||
|
||||
.summaryTable td
|
||||
{
|
||||
vertical-align: top;
|
||||
padding: 4px;
|
||||
border-bottom: 1px #7F8FB1 solid;
|
||||
border-right: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
/*col#summaryAttributes {}*/
|
||||
.summaryTable td.attributes
|
||||
{
|
||||
border-left: 1px #7F8FB1 solid;
|
||||
width: 140px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.attributes, .fixedFont
|
||||
{
|
||||
line-height: 15px;
|
||||
color: #002EBE;
|
||||
font-family: "Courier New",Courier,monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription
|
||||
{
|
||||
text-align: left;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription, .description
|
||||
{
|
||||
line-height: 15px;
|
||||
padding: 4px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.summaryTable { margin-bottom: 8px; }
|
||||
|
||||
ul.inheritsList
|
||||
{
|
||||
list-style: square;
|
||||
margin-left: 20px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.detailList {
|
||||
margin-left: 20px;
|
||||
line-height: 15px;
|
||||
}
|
||||
.detailList dt { margin-left: 20px; }
|
||||
|
||||
.detailList .heading
|
||||
{
|
||||
font-weight: bold;
|
||||
padding-bottom: 6px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.light, td.attributes, .light a:link, .light a:visited
|
||||
{
|
||||
color: #777;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.fineprint
|
||||
{
|
||||
text-align: right;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- ============================== header ================================= -->
|
||||
<!-- begin static/header.html -->
|
||||
<div id="header">
|
||||
</div>
|
||||
<!-- end static/header.html -->
|
||||
|
||||
<!-- ============================== classes index ============================ -->
|
||||
<div id="index">
|
||||
<!-- begin publish.classesIndex -->
|
||||
<div align="center"><a href="../index.html">Class Index</a>
|
||||
| <a href="../files.html">File Index</a></div>
|
||||
<hr />
|
||||
<h2>Classes</h2>
|
||||
<ul class="classList">
|
||||
|
||||
<li><i><a href="../symbols/_global_.html">_global_</a></i></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spec.html">jasmine.Spec</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spy.html">jasmine.Spy</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Suite.html">jasmine.Suite</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.util.html">jasmine.util</a></li>
|
||||
|
||||
</ul>
|
||||
<hr />
|
||||
<!-- end publish.classesIndex -->
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<!-- ============================== class title ============================ -->
|
||||
<h1 class="classTitle">
|
||||
|
||||
Class jasmine.Runner
|
||||
</h1>
|
||||
|
||||
<!-- ============================== class summary ========================== -->
|
||||
<p class="description">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
<!-- ============================== constructor summary ==================== -->
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the constructor documented in the class jasmine.Runner.">
|
||||
<caption>Class Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Constructor Attributes</th>
|
||||
<th scope="col">Constructor Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.Runner.html#constructor">jasmine.Runner</a></b>(env)
|
||||
</div>
|
||||
<div class="description">Runner</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<!-- ============================== properties summary ===================== -->
|
||||
|
||||
|
||||
<!-- ============================== methods summary ======================== -->
|
||||
|
||||
<!-- ============================== events summary ======================== -->
|
||||
|
||||
|
||||
<!-- ============================== constructor details ==================== -->
|
||||
|
||||
<div class="details"><a name="constructor"> </a>
|
||||
<div class="sectionTitle">
|
||||
Class Detail
|
||||
</div>
|
||||
|
||||
<div class="fixedFont">
|
||||
<b>jasmine.Runner</b>(env)
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
Runner
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{<a href="../symbols/jasmine.Env.html">jasmine.Env</a>}</span> <b>env</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== field details ========================== -->
|
||||
|
||||
|
||||
<!-- ============================== method details ========================= -->
|
||||
|
||||
|
||||
<!-- ============================== event details ========================= -->
|
||||
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,345 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
|
||||
<title>JsDoc Reference - jasmine.Spec</title>
|
||||
|
||||
<style type="text/css">
|
||||
/* default.css */
|
||||
body
|
||||
{
|
||||
font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.header
|
||||
{
|
||||
clear: both;
|
||||
background-color: #ccc;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 1em 0 0 .3em;
|
||||
}
|
||||
|
||||
hr
|
||||
{
|
||||
border: none 0;
|
||||
border-top: 1px solid #7F8FB1;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
pre.code
|
||||
{
|
||||
display: block;
|
||||
padding: 8px;
|
||||
border: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
#index
|
||||
{
|
||||
margin-top: 24px;
|
||||
float: left;
|
||||
width: 160px;
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
background-color: #F3F3F3;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
margin-left: 190px;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.classList
|
||||
{
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0 0 0 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 1em;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.classList li
|
||||
{
|
||||
padding: 0;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.summaryTable { width: 100%; }
|
||||
|
||||
h1.classTitle
|
||||
{
|
||||
font-size:170%;
|
||||
line-height:130%;
|
||||
}
|
||||
|
||||
h2 { font-size: 110%; }
|
||||
caption, div.sectionTitle
|
||||
{
|
||||
background-color: #7F8FB1;
|
||||
color: #fff;
|
||||
font-size:130%;
|
||||
text-align: left;
|
||||
padding: 2px 6px 2px 6px;
|
||||
border: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
div.sectionTitle { margin-bottom: 8px; }
|
||||
.summaryTable thead { display: none; }
|
||||
|
||||
.summaryTable td
|
||||
{
|
||||
vertical-align: top;
|
||||
padding: 4px;
|
||||
border-bottom: 1px #7F8FB1 solid;
|
||||
border-right: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
/*col#summaryAttributes {}*/
|
||||
.summaryTable td.attributes
|
||||
{
|
||||
border-left: 1px #7F8FB1 solid;
|
||||
width: 140px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.attributes, .fixedFont
|
||||
{
|
||||
line-height: 15px;
|
||||
color: #002EBE;
|
||||
font-family: "Courier New",Courier,monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription
|
||||
{
|
||||
text-align: left;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription, .description
|
||||
{
|
||||
line-height: 15px;
|
||||
padding: 4px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.summaryTable { margin-bottom: 8px; }
|
||||
|
||||
ul.inheritsList
|
||||
{
|
||||
list-style: square;
|
||||
margin-left: 20px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.detailList {
|
||||
margin-left: 20px;
|
||||
line-height: 15px;
|
||||
}
|
||||
.detailList dt { margin-left: 20px; }
|
||||
|
||||
.detailList .heading
|
||||
{
|
||||
font-weight: bold;
|
||||
padding-bottom: 6px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.light, td.attributes, .light a:link, .light a:visited
|
||||
{
|
||||
color: #777;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.fineprint
|
||||
{
|
||||
text-align: right;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- ============================== header ================================= -->
|
||||
<!-- begin static/header.html -->
|
||||
<div id="header">
|
||||
</div>
|
||||
<!-- end static/header.html -->
|
||||
|
||||
<!-- ============================== classes index ============================ -->
|
||||
<div id="index">
|
||||
<!-- begin publish.classesIndex -->
|
||||
<div align="center"><a href="../index.html">Class Index</a>
|
||||
| <a href="../files.html">File Index</a></div>
|
||||
<hr />
|
||||
<h2>Classes</h2>
|
||||
<ul class="classList">
|
||||
|
||||
<li><i><a href="../symbols/_global_.html">_global_</a></i></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spec.html">jasmine.Spec</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spy.html">jasmine.Spy</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Suite.html">jasmine.Suite</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.util.html">jasmine.util</a></li>
|
||||
|
||||
</ul>
|
||||
<hr />
|
||||
<!-- end publish.classesIndex -->
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<!-- ============================== class title ============================ -->
|
||||
<h1 class="classTitle">
|
||||
|
||||
Class jasmine.Spec
|
||||
</h1>
|
||||
|
||||
<!-- ============================== class summary ========================== -->
|
||||
<p class="description">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
<!-- ============================== constructor summary ==================== -->
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the constructor documented in the class jasmine.Spec.">
|
||||
<caption>Class Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Constructor Attributes</th>
|
||||
<th scope="col">Constructor Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.Spec.html#constructor">jasmine.Spec</a></b>(env, suite, description)
|
||||
</div>
|
||||
<div class="description">Internal representation of a Jasmine specification, or test.</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<!-- ============================== properties summary ===================== -->
|
||||
|
||||
|
||||
<!-- ============================== methods summary ======================== -->
|
||||
|
||||
<!-- ============================== events summary ======================== -->
|
||||
|
||||
|
||||
<!-- ============================== constructor details ==================== -->
|
||||
|
||||
<div class="details"><a name="constructor"> </a>
|
||||
<div class="sectionTitle">
|
||||
Class Detail
|
||||
</div>
|
||||
|
||||
<div class="fixedFont">
|
||||
<b>jasmine.Spec</b>(env, suite, description)
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
Internal representation of a Jasmine specification, or test.
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{<a href="../symbols/jasmine.Env.html">jasmine.Env</a>}</span> <b>env</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{<a href="../symbols/jasmine.Suite.html">jasmine.Suite</a>}</span> <b>suite</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{String}</span> <b>description</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== field details ========================== -->
|
||||
|
||||
|
||||
<!-- ============================== method details ========================= -->
|
||||
|
||||
|
||||
<!-- ============================== event details ========================= -->
|
||||
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,851 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
|
||||
<title>JsDoc Reference - jasmine.Spy</title>
|
||||
|
||||
<style type="text/css">
|
||||
/* default.css */
|
||||
body
|
||||
{
|
||||
font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.header
|
||||
{
|
||||
clear: both;
|
||||
background-color: #ccc;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 1em 0 0 .3em;
|
||||
}
|
||||
|
||||
hr
|
||||
{
|
||||
border: none 0;
|
||||
border-top: 1px solid #7F8FB1;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
pre.code
|
||||
{
|
||||
display: block;
|
||||
padding: 8px;
|
||||
border: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
#index
|
||||
{
|
||||
margin-top: 24px;
|
||||
float: left;
|
||||
width: 160px;
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
background-color: #F3F3F3;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
margin-left: 190px;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.classList
|
||||
{
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0 0 0 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 1em;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.classList li
|
||||
{
|
||||
padding: 0;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.summaryTable { width: 100%; }
|
||||
|
||||
h1.classTitle
|
||||
{
|
||||
font-size:170%;
|
||||
line-height:130%;
|
||||
}
|
||||
|
||||
h2 { font-size: 110%; }
|
||||
caption, div.sectionTitle
|
||||
{
|
||||
background-color: #7F8FB1;
|
||||
color: #fff;
|
||||
font-size:130%;
|
||||
text-align: left;
|
||||
padding: 2px 6px 2px 6px;
|
||||
border: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
div.sectionTitle { margin-bottom: 8px; }
|
||||
.summaryTable thead { display: none; }
|
||||
|
||||
.summaryTable td
|
||||
{
|
||||
vertical-align: top;
|
||||
padding: 4px;
|
||||
border-bottom: 1px #7F8FB1 solid;
|
||||
border-right: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
/*col#summaryAttributes {}*/
|
||||
.summaryTable td.attributes
|
||||
{
|
||||
border-left: 1px #7F8FB1 solid;
|
||||
width: 140px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.attributes, .fixedFont
|
||||
{
|
||||
line-height: 15px;
|
||||
color: #002EBE;
|
||||
font-family: "Courier New",Courier,monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription
|
||||
{
|
||||
text-align: left;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription, .description
|
||||
{
|
||||
line-height: 15px;
|
||||
padding: 4px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.summaryTable { margin-bottom: 8px; }
|
||||
|
||||
ul.inheritsList
|
||||
{
|
||||
list-style: square;
|
||||
margin-left: 20px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.detailList {
|
||||
margin-left: 20px;
|
||||
line-height: 15px;
|
||||
}
|
||||
.detailList dt { margin-left: 20px; }
|
||||
|
||||
.detailList .heading
|
||||
{
|
||||
font-weight: bold;
|
||||
padding-bottom: 6px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.light, td.attributes, .light a:link, .light a:visited
|
||||
{
|
||||
color: #777;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.fineprint
|
||||
{
|
||||
text-align: right;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- ============================== header ================================= -->
|
||||
<!-- begin static/header.html -->
|
||||
<div id="header">
|
||||
</div>
|
||||
<!-- end static/header.html -->
|
||||
|
||||
<!-- ============================== classes index ============================ -->
|
||||
<div id="index">
|
||||
<!-- begin publish.classesIndex -->
|
||||
<div align="center"><a href="../index.html">Class Index</a>
|
||||
| <a href="../files.html">File Index</a></div>
|
||||
<hr />
|
||||
<h2>Classes</h2>
|
||||
<ul class="classList">
|
||||
|
||||
<li><i><a href="../symbols/_global_.html">_global_</a></i></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spec.html">jasmine.Spec</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spy.html">jasmine.Spy</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Suite.html">jasmine.Suite</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.util.html">jasmine.util</a></li>
|
||||
|
||||
</ul>
|
||||
<hr />
|
||||
<!-- end publish.classesIndex -->
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<!-- ============================== class title ============================ -->
|
||||
<h1 class="classTitle">
|
||||
|
||||
Class jasmine.Spy
|
||||
</h1>
|
||||
|
||||
<!-- ============================== class summary ========================== -->
|
||||
<p class="description">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
<!-- ============================== constructor summary ==================== -->
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the constructor documented in the class jasmine.Spy.">
|
||||
<caption>Class Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Constructor Attributes</th>
|
||||
<th scope="col">Constructor Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.Spy.html#constructor">jasmine.Spy</a></b>(name)
|
||||
</div>
|
||||
<div class="description">Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks.</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<!-- ============================== properties summary ===================== -->
|
||||
|
||||
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the fields documented in the class jasmine.Spy.">
|
||||
<caption>Field Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Field Attributes</th>
|
||||
<th scope="col">Field Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.Spy.html#argsForCall">argsForCall</a></b>
|
||||
</div>
|
||||
<div class="description">Holds arguments for each call to the spy, indexed by call count</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.Spy.html#identity">identity</a></b>
|
||||
</div>
|
||||
<div class="description">The name of the spy, if provided.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.Spy.html#isSpy">isSpy</a></b>
|
||||
</div>
|
||||
<div class="description">Is this Object a spy?</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.Spy.html#mostRecentCall">mostRecentCall</a></b>
|
||||
</div>
|
||||
<div class="description">Tracking of the most recent call to the spy.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== methods summary ======================== -->
|
||||
|
||||
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the methods documented in the class jasmine.Spy.">
|
||||
<caption>Method Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Method Attributes</th>
|
||||
<th scope="col">Method Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.Spy.html#andCallFake">andCallFake</a></b>(fakeFunc)
|
||||
</div>
|
||||
<div class="description">Calls an alternate implementation when a spy is called.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.Spy.html#andCallThrough">andCallThrough</a></b>()
|
||||
</div>
|
||||
<div class="description">Tells a spy to call through to the actual implemenatation.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.Spy.html#andReturn">andReturn</a></b>(value)
|
||||
</div>
|
||||
<div class="description">For setting the return value of a spy.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.Spy.html#andThrow">andThrow</a></b>(exceptionMsg)
|
||||
</div>
|
||||
<div class="description">For throwing an exception when a spy is called.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.Spy.html#plan">plan</a></b>()
|
||||
</div>
|
||||
<div class="description">The acutal function this spy stubs.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.Spy.html#reset">reset</a></b>()
|
||||
</div>
|
||||
<div class="description">Resets all of a spy's the tracking variables so that it can be used again.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== events summary ======================== -->
|
||||
|
||||
|
||||
<!-- ============================== constructor details ==================== -->
|
||||
|
||||
<div class="details"><a name="constructor"> </a>
|
||||
<div class="sectionTitle">
|
||||
Class Detail
|
||||
</div>
|
||||
|
||||
<div class="fixedFont">
|
||||
<b>jasmine.Spy</b>(name)
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks.
|
||||
|
||||
Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine
|
||||
expectation syntax. Spies can be checked if they were called or not and what the calling params were.
|
||||
|
||||
A Spy has the following mehtod: wasCalled, callCount, mostRecentCall, and argsForCall (see docs)
|
||||
Spies are torn down at the end of every spec.
|
||||
|
||||
Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj.
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<pre class="code">// a stub
|
||||
var myStub = jasmine.createSpy('myStub'); // can be used anywhere
|
||||
|
||||
// spy example
|
||||
var foo = {
|
||||
not: function(bool) { return !bool; }
|
||||
}
|
||||
|
||||
// actual foo.not will not be called, execution stops
|
||||
spyOn(foo, 'not');
|
||||
|
||||
// foo.not spied upon, execution will continue to implementation
|
||||
spyOn(foo, 'not').andCallThrough();
|
||||
|
||||
// fake example
|
||||
var foo = {
|
||||
not: function(bool) { return !bool; }
|
||||
}
|
||||
|
||||
// foo.not(val) will return val
|
||||
spyOn(foo, 'not').andCallFake(function(value) {return value;});
|
||||
|
||||
// mock example
|
||||
foo.not(7 == 7);
|
||||
expect(foo.not).wasCalled();
|
||||
expect(foo.not).wasCalledWith(true);</pre>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{String}</span> <b>name</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">See:</dt>
|
||||
|
||||
<dd><a href="../symbols/_global_.html#spyOn">spyOn</a>, jasmine.createSpy, jasmine.createSpyObj</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== field details ========================== -->
|
||||
|
||||
<div class="sectionTitle">
|
||||
Field Detail
|
||||
</div>
|
||||
|
||||
<a name="argsForCall"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>argsForCall</b>
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Holds arguments for each call to the spy, indexed by call count
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<pre class="code">var mySpy = jasmine.createSpy('foo');
|
||||
mySpy(1, 2);
|
||||
mySpy(7, 8);
|
||||
mySpy.mostRecentCall.args = [7, 8];
|
||||
mySpy.argsForCall[0] = [1, 2];
|
||||
mySpy.argsForCall[1] = [7, 8];</pre>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="identity"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>identity</b>
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
The name of the spy, if provided.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="isSpy"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>isSpy</b>
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Is this Object a spy?
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="mostRecentCall"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>mostRecentCall</b>
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Tracking of the most recent call to the spy.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<pre class="code">var mySpy = jasmine.createSpy('foo');
|
||||
mySpy(1, 2);
|
||||
mySpy.mostRecentCall.args = [1, 2];</pre>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== method details ========================= -->
|
||||
|
||||
<div class="sectionTitle">
|
||||
Method Detail
|
||||
</div>
|
||||
|
||||
<a name="andCallFake"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>andCallFake</b>(fakeFunc)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Calls an alternate implementation when a spy is called.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<pre class="code">var baz = function() {
|
||||
// do some stuff, return something
|
||||
}
|
||||
// defining a spy from scratch: foo() calls the function baz
|
||||
var foo = jasmine.createSpy('spy on foo').andCall(baz);
|
||||
|
||||
// defining a spy on an existing property: foo.bar() calls an anonymnous function
|
||||
spyOn(foo, 'bar').andCall(function() { return 'baz';} );</pre>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Function}</span> <b>fakeFunc</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="andCallThrough"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>andCallThrough</b>()
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Tells a spy to call through to the actual implemenatation.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<pre class="code">var foo = {
|
||||
bar: function() { // do some stuff }
|
||||
}
|
||||
|
||||
// defining a spy on an existing property: foo.bar
|
||||
spyOn(foo, 'bar').andCallThrough();</pre>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="andReturn"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>andReturn</b>(value)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
For setting the return value of a spy.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<pre class="code">// defining a spy from scratch: foo() returns 'baz'
|
||||
var foo = jasmine.createSpy('spy on foo').andReturn('baz');
|
||||
|
||||
// defining a spy on an existing property: foo.bar() returns 'baz'
|
||||
spyOn(foo, 'bar').andReturn('baz');</pre>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Object}</span> <b>value</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="andThrow"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>andThrow</b>(exceptionMsg)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
For throwing an exception when a spy is called.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<pre class="code">// defining a spy from scratch: foo() throws an exception w/ message 'ouch'
|
||||
var foo = jasmine.createSpy('spy on foo').andThrow('baz');
|
||||
|
||||
// defining a spy on an existing property: foo.bar() throws an exception w/ message 'ouch'
|
||||
spyOn(foo, 'bar').andThrow('baz');</pre>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{String}</span> <b>exceptionMsg</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="plan"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>plan</b>()
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
The acutal function this spy stubs.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="reset"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>reset</b>()
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Resets all of a spy's the tracking variables so that it can be used again.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<pre class="code">spyOn(foo, 'bar');
|
||||
|
||||
foo.bar();
|
||||
|
||||
expect(foo.bar.callCount).toEqual(1);
|
||||
|
||||
foo.bar.reset();
|
||||
|
||||
expect(foo.bar.callCount).toEqual(0);</pre>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== event details ========================= -->
|
||||
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,351 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
|
||||
<title>JsDoc Reference - jasmine.Suite</title>
|
||||
|
||||
<style type="text/css">
|
||||
/* default.css */
|
||||
body
|
||||
{
|
||||
font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.header
|
||||
{
|
||||
clear: both;
|
||||
background-color: #ccc;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 1em 0 0 .3em;
|
||||
}
|
||||
|
||||
hr
|
||||
{
|
||||
border: none 0;
|
||||
border-top: 1px solid #7F8FB1;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
pre.code
|
||||
{
|
||||
display: block;
|
||||
padding: 8px;
|
||||
border: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
#index
|
||||
{
|
||||
margin-top: 24px;
|
||||
float: left;
|
||||
width: 160px;
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
background-color: #F3F3F3;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
margin-left: 190px;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.classList
|
||||
{
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0 0 0 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 1em;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.classList li
|
||||
{
|
||||
padding: 0;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.summaryTable { width: 100%; }
|
||||
|
||||
h1.classTitle
|
||||
{
|
||||
font-size:170%;
|
||||
line-height:130%;
|
||||
}
|
||||
|
||||
h2 { font-size: 110%; }
|
||||
caption, div.sectionTitle
|
||||
{
|
||||
background-color: #7F8FB1;
|
||||
color: #fff;
|
||||
font-size:130%;
|
||||
text-align: left;
|
||||
padding: 2px 6px 2px 6px;
|
||||
border: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
div.sectionTitle { margin-bottom: 8px; }
|
||||
.summaryTable thead { display: none; }
|
||||
|
||||
.summaryTable td
|
||||
{
|
||||
vertical-align: top;
|
||||
padding: 4px;
|
||||
border-bottom: 1px #7F8FB1 solid;
|
||||
border-right: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
/*col#summaryAttributes {}*/
|
||||
.summaryTable td.attributes
|
||||
{
|
||||
border-left: 1px #7F8FB1 solid;
|
||||
width: 140px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.attributes, .fixedFont
|
||||
{
|
||||
line-height: 15px;
|
||||
color: #002EBE;
|
||||
font-family: "Courier New",Courier,monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription
|
||||
{
|
||||
text-align: left;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription, .description
|
||||
{
|
||||
line-height: 15px;
|
||||
padding: 4px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.summaryTable { margin-bottom: 8px; }
|
||||
|
||||
ul.inheritsList
|
||||
{
|
||||
list-style: square;
|
||||
margin-left: 20px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.detailList {
|
||||
margin-left: 20px;
|
||||
line-height: 15px;
|
||||
}
|
||||
.detailList dt { margin-left: 20px; }
|
||||
|
||||
.detailList .heading
|
||||
{
|
||||
font-weight: bold;
|
||||
padding-bottom: 6px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.light, td.attributes, .light a:link, .light a:visited
|
||||
{
|
||||
color: #777;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.fineprint
|
||||
{
|
||||
text-align: right;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- ============================== header ================================= -->
|
||||
<!-- begin static/header.html -->
|
||||
<div id="header">
|
||||
</div>
|
||||
<!-- end static/header.html -->
|
||||
|
||||
<!-- ============================== classes index ============================ -->
|
||||
<div id="index">
|
||||
<!-- begin publish.classesIndex -->
|
||||
<div align="center"><a href="../index.html">Class Index</a>
|
||||
| <a href="../files.html">File Index</a></div>
|
||||
<hr />
|
||||
<h2>Classes</h2>
|
||||
<ul class="classList">
|
||||
|
||||
<li><i><a href="../symbols/_global_.html">_global_</a></i></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spec.html">jasmine.Spec</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spy.html">jasmine.Spy</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Suite.html">jasmine.Suite</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.util.html">jasmine.util</a></li>
|
||||
|
||||
</ul>
|
||||
<hr />
|
||||
<!-- end publish.classesIndex -->
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<!-- ============================== class title ============================ -->
|
||||
<h1 class="classTitle">
|
||||
|
||||
Class jasmine.Suite
|
||||
</h1>
|
||||
|
||||
<!-- ============================== class summary ========================== -->
|
||||
<p class="description">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
<!-- ============================== constructor summary ==================== -->
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the constructor documented in the class jasmine.Suite.">
|
||||
<caption>Class Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Constructor Attributes</th>
|
||||
<th scope="col">Constructor Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.Suite.html#constructor">jasmine.Suite</a></b>(env, description, specDefinitions, parentSuite)
|
||||
</div>
|
||||
<div class="description">Internal representation of a Jasmine suite.</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<!-- ============================== properties summary ===================== -->
|
||||
|
||||
|
||||
<!-- ============================== methods summary ======================== -->
|
||||
|
||||
<!-- ============================== events summary ======================== -->
|
||||
|
||||
|
||||
<!-- ============================== constructor details ==================== -->
|
||||
|
||||
<div class="details"><a name="constructor"> </a>
|
||||
<div class="sectionTitle">
|
||||
Class Detail
|
||||
</div>
|
||||
|
||||
<div class="fixedFont">
|
||||
<b>jasmine.Suite</b>(env, description, specDefinitions, parentSuite)
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
Internal representation of a Jasmine suite.
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{<a href="../symbols/jasmine.Env.html">jasmine.Env</a>}</span> <b>env</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{String}</span> <b>description</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Function}</span> <b>specDefinitions</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{<a href="../symbols/jasmine.Suite.html">jasmine.Suite</a>}</span> <b>parentSuite</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== field details ========================== -->
|
||||
|
||||
|
||||
<!-- ============================== method details ========================= -->
|
||||
|
||||
|
||||
<!-- ============================== event details ========================= -->
|
||||
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,684 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
|
||||
<title>JsDoc Reference - jasmine</title>
|
||||
|
||||
<style type="text/css">
|
||||
/* default.css */
|
||||
body
|
||||
{
|
||||
font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.header
|
||||
{
|
||||
clear: both;
|
||||
background-color: #ccc;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 1em 0 0 .3em;
|
||||
}
|
||||
|
||||
hr
|
||||
{
|
||||
border: none 0;
|
||||
border-top: 1px solid #7F8FB1;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
pre.code
|
||||
{
|
||||
display: block;
|
||||
padding: 8px;
|
||||
border: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
#index
|
||||
{
|
||||
margin-top: 24px;
|
||||
float: left;
|
||||
width: 160px;
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
background-color: #F3F3F3;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
margin-left: 190px;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.classList
|
||||
{
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0 0 0 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 1em;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.classList li
|
||||
{
|
||||
padding: 0;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.summaryTable { width: 100%; }
|
||||
|
||||
h1.classTitle
|
||||
{
|
||||
font-size:170%;
|
||||
line-height:130%;
|
||||
}
|
||||
|
||||
h2 { font-size: 110%; }
|
||||
caption, div.sectionTitle
|
||||
{
|
||||
background-color: #7F8FB1;
|
||||
color: #fff;
|
||||
font-size:130%;
|
||||
text-align: left;
|
||||
padding: 2px 6px 2px 6px;
|
||||
border: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
div.sectionTitle { margin-bottom: 8px; }
|
||||
.summaryTable thead { display: none; }
|
||||
|
||||
.summaryTable td
|
||||
{
|
||||
vertical-align: top;
|
||||
padding: 4px;
|
||||
border-bottom: 1px #7F8FB1 solid;
|
||||
border-right: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
/*col#summaryAttributes {}*/
|
||||
.summaryTable td.attributes
|
||||
{
|
||||
border-left: 1px #7F8FB1 solid;
|
||||
width: 140px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.attributes, .fixedFont
|
||||
{
|
||||
line-height: 15px;
|
||||
color: #002EBE;
|
||||
font-family: "Courier New",Courier,monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription
|
||||
{
|
||||
text-align: left;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription, .description
|
||||
{
|
||||
line-height: 15px;
|
||||
padding: 4px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.summaryTable { margin-bottom: 8px; }
|
||||
|
||||
ul.inheritsList
|
||||
{
|
||||
list-style: square;
|
||||
margin-left: 20px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.detailList {
|
||||
margin-left: 20px;
|
||||
line-height: 15px;
|
||||
}
|
||||
.detailList dt { margin-left: 20px; }
|
||||
|
||||
.detailList .heading
|
||||
{
|
||||
font-weight: bold;
|
||||
padding-bottom: 6px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.light, td.attributes, .light a:link, .light a:visited
|
||||
{
|
||||
color: #777;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.fineprint
|
||||
{
|
||||
text-align: right;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- ============================== header ================================= -->
|
||||
<!-- begin static/header.html -->
|
||||
<div id="header">
|
||||
</div>
|
||||
<!-- end static/header.html -->
|
||||
|
||||
<!-- ============================== classes index ============================ -->
|
||||
<div id="index">
|
||||
<!-- begin publish.classesIndex -->
|
||||
<div align="center"><a href="../index.html">Class Index</a>
|
||||
| <a href="../files.html">File Index</a></div>
|
||||
<hr />
|
||||
<h2>Classes</h2>
|
||||
<ul class="classList">
|
||||
|
||||
<li><i><a href="../symbols/_global_.html">_global_</a></i></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spec.html">jasmine.Spec</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spy.html">jasmine.Spy</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Suite.html">jasmine.Suite</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.util.html">jasmine.util</a></li>
|
||||
|
||||
</ul>
|
||||
<hr />
|
||||
<!-- end publish.classesIndex -->
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<!-- ============================== class title ============================ -->
|
||||
<h1 class="classTitle">
|
||||
|
||||
Namespace jasmine
|
||||
</h1>
|
||||
|
||||
<!-- ============================== class summary ========================== -->
|
||||
<p class="description">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
<!-- ============================== constructor summary ==================== -->
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the constructor documented in the class jasmine.">
|
||||
<caption>Namespace Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Constructor Attributes</th>
|
||||
<th scope="col">Constructor Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.html#constructor">jasmine</a></b>
|
||||
</div>
|
||||
<div class="description">Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<!-- ============================== properties summary ===================== -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== methods summary ======================== -->
|
||||
|
||||
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the methods documented in the class jasmine.">
|
||||
<caption>Method Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Method Attributes</th>
|
||||
<th scope="col">Method Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"><static> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont">jasmine.<b><a href="../symbols/jasmine.html#.any">any</a></b>(clazz)
|
||||
</div>
|
||||
<div class="description">Returns a matchable 'generic' object of the class type.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"><static> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont">jasmine.<b><a href="../symbols/jasmine.html#.createSpyObj">createSpyObj</a></b>(baseName, methodNames)
|
||||
</div>
|
||||
<div class="description">Creates a more complicated spy: an Object that has every property a function that is a spy.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"><static> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont">jasmine.<b><a href="../symbols/jasmine.html#.getEnv">getEnv</a></b>()
|
||||
</div>
|
||||
<div class="description">Getter for the Jasmine environment.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"><static> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont">jasmine.<b><a href="../symbols/jasmine.html#.include">include</a></b>(url, opt_global)
|
||||
</div>
|
||||
<div class="description">Adds suite files to an HTML document so that they are executed, thus adding them to the current
|
||||
Jasmine environment.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"><static> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont">jasmine.<b><a href="../symbols/jasmine.html#.isDomNode">isDomNode</a></b>(obj)
|
||||
</div>
|
||||
<div class="description">Returns true if the object is a DOM Node.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"><static> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont">jasmine.<b><a href="../symbols/jasmine.html#.pp">pp</a></b>(value)
|
||||
</div>
|
||||
<div class="description">Pretty printer for expecations.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"><static> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont">jasmine.<b><a href="../symbols/jasmine.html#.PrettyPrinter">PrettyPrinter</a></b>()
|
||||
</div>
|
||||
<div class="description">Base class for pretty printing for expectation results.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== events summary ======================== -->
|
||||
|
||||
|
||||
<!-- ============================== constructor details ==================== -->
|
||||
|
||||
<div class="details"><a name="constructor"> </a>
|
||||
<div class="sectionTitle">
|
||||
Namespace Detail
|
||||
</div>
|
||||
|
||||
<div class="fixedFont">
|
||||
<b>jasmine</b>
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== field details ========================== -->
|
||||
|
||||
|
||||
<!-- ============================== method details ========================= -->
|
||||
|
||||
<div class="sectionTitle">
|
||||
Method Detail
|
||||
</div>
|
||||
|
||||
<a name=".any"> </a>
|
||||
<div class="fixedFont"><static>
|
||||
|
||||
|
||||
<span class="light">jasmine.</span><b>any</b>(clazz)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Returns a matchable 'generic' object of the class type. For use in expecations of type when values don't matter.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<pre class="code">// don't care about which function is passed in, as long as it's a function
|
||||
expect(mySpy).wasCalledWith(jasmine.any(Function));</pre>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Class}</span> <b>clazz</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Returns:</dt>
|
||||
|
||||
<dd>matchable object of the type clazz</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name=".createSpyObj"> </a>
|
||||
<div class="fixedFont"><static>
|
||||
|
||||
|
||||
<span class="light">jasmine.</span><b>createSpyObj</b>(baseName, methodNames)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something
|
||||
large in one call.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{String}</span> <b>baseName</b>
|
||||
|
||||
</dt>
|
||||
<dd>name of spy class</dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Array}</span> <b>methodNames</b>
|
||||
|
||||
</dt>
|
||||
<dd>array of names of methods to make spies</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name=".getEnv"> </a>
|
||||
<div class="fixedFont"><static>
|
||||
|
||||
|
||||
<span class="light">jasmine.</span><b>getEnv</b>()
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Getter for the Jasmine environment. Ensures one gets created
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name=".include"> </a>
|
||||
<div class="fixedFont"><static>
|
||||
|
||||
|
||||
<span class="light">jasmine.</span><b>include</b>(url, opt_global)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Adds suite files to an HTML document so that they are executed, thus adding them to the current
|
||||
Jasmine environment.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{String}</span> <b>url</b>
|
||||
|
||||
</dt>
|
||||
<dd>path to the file to include</dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Boolean}</span> <b>opt_global</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name=".isDomNode"> </a>
|
||||
<div class="fixedFont"><static>
|
||||
|
||||
<span class="light">{Boolean}</span>
|
||||
<span class="light">jasmine.</span><b>isDomNode</b>(obj)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Returns true if the object is a DOM Node.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Object}</span> <b>obj</b>
|
||||
|
||||
</dt>
|
||||
<dd>object to check</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Returns:</dt>
|
||||
|
||||
<dd><span class="light fixedFont">{Boolean}</span> </dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name=".pp"> </a>
|
||||
<div class="fixedFont"><static>
|
||||
|
||||
<span class="light">{String}</span>
|
||||
<span class="light">jasmine.</span><b>pp</b>(value)
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Pretty printer for expecations. Takes any object and turns it into a human-readable string.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<b>value</b>
|
||||
|
||||
</dt>
|
||||
<dd>{Object} an object to be outputted</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Returns:</dt>
|
||||
|
||||
<dd><span class="light fixedFont">{String}</span> </dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name=".PrettyPrinter"> </a>
|
||||
<div class="fixedFont"><static>
|
||||
|
||||
|
||||
<span class="light">jasmine.</span><b>PrettyPrinter</b>()
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Base class for pretty printing for expectation results.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== event details ========================= -->
|
||||
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:18 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,322 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
|
||||
<title>JsDoc Reference - jasmine.util</title>
|
||||
|
||||
<style type="text/css">
|
||||
/* default.css */
|
||||
body
|
||||
{
|
||||
font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.header
|
||||
{
|
||||
clear: both;
|
||||
background-color: #ccc;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 1em 0 0 .3em;
|
||||
}
|
||||
|
||||
hr
|
||||
{
|
||||
border: none 0;
|
||||
border-top: 1px solid #7F8FB1;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
pre.code
|
||||
{
|
||||
display: block;
|
||||
padding: 8px;
|
||||
border: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
#index
|
||||
{
|
||||
margin-top: 24px;
|
||||
float: left;
|
||||
width: 160px;
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
background-color: #F3F3F3;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
margin-left: 190px;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.classList
|
||||
{
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0 0 0 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 1em;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.classList li
|
||||
{
|
||||
padding: 0;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.summaryTable { width: 100%; }
|
||||
|
||||
h1.classTitle
|
||||
{
|
||||
font-size:170%;
|
||||
line-height:130%;
|
||||
}
|
||||
|
||||
h2 { font-size: 110%; }
|
||||
caption, div.sectionTitle
|
||||
{
|
||||
background-color: #7F8FB1;
|
||||
color: #fff;
|
||||
font-size:130%;
|
||||
text-align: left;
|
||||
padding: 2px 6px 2px 6px;
|
||||
border: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
div.sectionTitle { margin-bottom: 8px; }
|
||||
.summaryTable thead { display: none; }
|
||||
|
||||
.summaryTable td
|
||||
{
|
||||
vertical-align: top;
|
||||
padding: 4px;
|
||||
border-bottom: 1px #7F8FB1 solid;
|
||||
border-right: 1px #7F8FB1 solid;
|
||||
}
|
||||
|
||||
/*col#summaryAttributes {}*/
|
||||
.summaryTable td.attributes
|
||||
{
|
||||
border-left: 1px #7F8FB1 solid;
|
||||
width: 140px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.attributes, .fixedFont
|
||||
{
|
||||
line-height: 15px;
|
||||
color: #002EBE;
|
||||
font-family: "Courier New",Courier,monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription
|
||||
{
|
||||
text-align: left;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
.summaryTable td.nameDescription, .description
|
||||
{
|
||||
line-height: 15px;
|
||||
padding: 4px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.summaryTable { margin-bottom: 8px; }
|
||||
|
||||
ul.inheritsList
|
||||
{
|
||||
list-style: square;
|
||||
margin-left: 20px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.detailList {
|
||||
margin-left: 20px;
|
||||
line-height: 15px;
|
||||
}
|
||||
.detailList dt { margin-left: 20px; }
|
||||
|
||||
.detailList .heading
|
||||
{
|
||||
font-weight: bold;
|
||||
padding-bottom: 6px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.light, td.attributes, .light a:link, .light a:visited
|
||||
{
|
||||
color: #777;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.fineprint
|
||||
{
|
||||
text-align: right;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- ============================== header ================================= -->
|
||||
<!-- begin static/header.html -->
|
||||
<div id="header">
|
||||
</div>
|
||||
<!-- end static/header.html -->
|
||||
|
||||
<!-- ============================== classes index ============================ -->
|
||||
<div id="index">
|
||||
<!-- begin publish.classesIndex -->
|
||||
<div align="center"><a href="../index.html">Class Index</a>
|
||||
| <a href="../files.html">File Index</a></div>
|
||||
<hr />
|
||||
<h2>Classes</h2>
|
||||
<ul class="classList">
|
||||
|
||||
<li><i><a href="../symbols/_global_.html">_global_</a></i></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spec.html">jasmine.Spec</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Spy.html">jasmine.Spy</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Suite.html">jasmine.Suite</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.util.html">jasmine.util</a></li>
|
||||
|
||||
</ul>
|
||||
<hr />
|
||||
<!-- end publish.classesIndex -->
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<!-- ============================== class title ============================ -->
|
||||
<h1 class="classTitle">
|
||||
|
||||
Namespace jasmine.util
|
||||
</h1>
|
||||
|
||||
<!-- ============================== class summary ========================== -->
|
||||
<p class="description">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
<!-- ============================== constructor summary ==================== -->
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the constructor documented in the class jasmine.util.">
|
||||
<caption>Namespace Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Constructor Attributes</th>
|
||||
<th scope="col">Constructor Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.util.html#constructor">jasmine.util</a></b>
|
||||
</div>
|
||||
<div class="description"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<!-- ============================== properties summary ===================== -->
|
||||
|
||||
|
||||
<!-- ============================== methods summary ======================== -->
|
||||
|
||||
<!-- ============================== events summary ======================== -->
|
||||
|
||||
|
||||
<!-- ============================== constructor details ==================== -->
|
||||
|
||||
<div class="details"><a name="constructor"> </a>
|
||||
<div class="sectionTitle">
|
||||
Namespace Detail
|
||||
</div>
|
||||
|
||||
<div class="fixedFont">
|
||||
<b>jasmine.util</b>
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== field details ========================== -->
|
||||
|
||||
|
||||
<!-- ============================== method details ========================= -->
|
||||
|
||||
|
||||
<!-- ============================== event details ========================= -->
|
||||
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
27
example/SpecRunner.html
Normal file
27
example/SpecRunner.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Test Runner</title>
|
||||
<link rel="stylesheet" type="text/css" href="lib/jasmine-##JASMINE_VERSION##/jasmine.css">
|
||||
<script type="text/javascript" src="lib/jasmine-##JASMINE_VERSION##/jasmine.js"></script>
|
||||
<script type="text/javascript" src="lib/jasmine-##JASMINE_VERSION##/jasmine-html.js"></script>
|
||||
|
||||
<!-- include source files here... -->
|
||||
<script type="text/javascript" src="src/Player.js"></script>
|
||||
<script type="text/javascript" src="src/Song.js"></script>
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script type="text/javascript" src="spec/SpecHelper.js"></script>
|
||||
<script type="text/javascript" src="spec/PlayerSpec.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
||||
jasmine.getEnv().execute();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
58
example/spec/PlayerSpec.js
Normal file
58
example/spec/PlayerSpec.js
Normal file
@@ -0,0 +1,58 @@
|
||||
describe("Player", function() {
|
||||
var player;
|
||||
var song;
|
||||
|
||||
beforeEach(function() {
|
||||
player = new Player();
|
||||
song = new Song();
|
||||
});
|
||||
|
||||
it("should be able to play a Song", function() {
|
||||
player.play(song);
|
||||
expect(player.currentlyPlayingSong).toEqual(song);
|
||||
|
||||
//demonstrates use of custom matcher
|
||||
expect(player).toBePlaying(song);
|
||||
});
|
||||
|
||||
describe("when song has been paused", function() {
|
||||
beforeEach(function() {
|
||||
player.play(song);
|
||||
player.pause();
|
||||
});
|
||||
|
||||
it("should indicate that the song is currently paused", function() {
|
||||
expect(player.isPlaying).toBeFalsy();
|
||||
|
||||
// demonstrates use of 'not' with a custom matcher
|
||||
expect(player).not.toBePlaying(song);
|
||||
});
|
||||
|
||||
it("should be possible to resume", function() {
|
||||
player.resume();
|
||||
expect(player.isPlaying).toBeTruthy();
|
||||
expect(player.currentlyPlayingSong).toEqual(song);
|
||||
});
|
||||
});
|
||||
|
||||
// demonstrates use of spies to intercept and test method calls
|
||||
it("tells the current song if the user has made it a favorite", function() {
|
||||
spyOn(song, 'persistFavoriteStatus');
|
||||
|
||||
player.play(song);
|
||||
player.makeFavorite();
|
||||
|
||||
expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);
|
||||
});
|
||||
|
||||
//demonstrates use of expected exceptions
|
||||
describe("#resume", function() {
|
||||
it("should throw an exception if song is already playing", function() {
|
||||
player.play(song);
|
||||
|
||||
expect(function() {
|
||||
player.resume();
|
||||
}).toThrow("song is already playing");
|
||||
});
|
||||
});
|
||||
});
|
||||
9
example/spec/SpecHelper.js
Normal file
9
example/spec/SpecHelper.js
Normal file
@@ -0,0 +1,9 @@
|
||||
beforeEach(function() {
|
||||
this.addMatchers({
|
||||
toBePlaying: function(expectedSong) {
|
||||
var player = this.actual;
|
||||
return player.currentlyPlayingSong === expectedSong
|
||||
&& player.isPlaying;
|
||||
}
|
||||
})
|
||||
});
|
||||
22
example/src/Player.js
Normal file
22
example/src/Player.js
Normal file
@@ -0,0 +1,22 @@
|
||||
function Player() {
|
||||
}
|
||||
Player.prototype.play = function(song) {
|
||||
this.currentlyPlayingSong = song;
|
||||
this.isPlaying = true;
|
||||
};
|
||||
|
||||
Player.prototype.pause = function() {
|
||||
this.isPlaying = false;
|
||||
};
|
||||
|
||||
Player.prototype.resume = function() {
|
||||
if (this.isPlaying) {
|
||||
throw new Error("song is already playing");
|
||||
}
|
||||
|
||||
this.isPlaying = true;
|
||||
};
|
||||
|
||||
Player.prototype.makeFavorite = function() {
|
||||
this.currentlyPlayingSong.persistFavoriteStatus(true);
|
||||
};
|
||||
7
example/src/Song.js
Normal file
7
example/src/Song.js
Normal file
@@ -0,0 +1,7 @@
|
||||
function Song() {
|
||||
}
|
||||
|
||||
Song.prototype.persistFavoriteStatus = function(value) {
|
||||
// something complicated
|
||||
throw new Error("not yet implemented");
|
||||
};
|
||||
@@ -1,67 +0,0 @@
|
||||
jasmine.TrivialReporter = function() {
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
||||
var el = document.createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(document.createTextNode(child));
|
||||
} else {
|
||||
el.appendChild(child);
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == 'className') {
|
||||
el.setAttribute('class', attrs[attr]);
|
||||
} else {
|
||||
el[attr] = attrs[attr];
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
||||
console.log(runner);
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
||||
console.log(suite);
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||
var specDiv = this.createDom('div', {
|
||||
className: spec.getResults().passed ? 'spec passed' : 'spec failed'
|
||||
}, spec.getFullName());
|
||||
|
||||
var resultItems = spec.getResults().getItems();
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
if (!result.passed) {
|
||||
var resultMessageDiv = this.createDom('div', {className: 'resultMessage fail'});
|
||||
resultMessageDiv.innerHTML = result.message; // todo: lame; mend
|
||||
specDiv.appendChild(resultMessageDiv);
|
||||
specDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||
}
|
||||
}
|
||||
|
||||
document.body.appendChild(specDiv);
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.log = function() {
|
||||
console.log.apply(console, arguments);
|
||||
};
|
||||
|
||||
//protect against console.log incidents
|
||||
if (!("console" in window) || !("firebug" in console)) {
|
||||
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
|
||||
window.console = {};
|
||||
for (var i = 0, len = names.length; i < len; ++i) {
|
||||
window.console[names[i]] = function() {
|
||||
};
|
||||
}
|
||||
}
|
||||
28
lib/consolex.js
Normal file
28
lib/consolex.js
Normal file
@@ -0,0 +1,28 @@
|
||||
/** Console X
|
||||
* http://github.com/deadlyicon/consolex.js
|
||||
*
|
||||
* By Jared Grippe <jared@jaredgrippe.com>
|
||||
*
|
||||
* Copyright (c) 2009 Jared Grippe
|
||||
* Licensed under the MIT license.
|
||||
*
|
||||
* consolex avoids ever having to see javascript bugs in browsers that do not implement the entire
|
||||
* firebug console suit
|
||||
*
|
||||
*/
|
||||
(function(window) {
|
||||
window.console || (window.console = {});
|
||||
|
||||
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
|
||||
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
|
||||
|
||||
function emptyFunction(){}
|
||||
|
||||
for (var i = 0; i < names.length; ++i){
|
||||
window.console[names[i]] || (window.console[names[i]] = emptyFunction);
|
||||
if (typeof window.console[names[i]] !== 'function')
|
||||
window.console[names[i]] = (function(method) {
|
||||
return function(){ return Function.prototype.apply.apply(method, [console,arguments]); };
|
||||
})(window.console[names[i]]);
|
||||
}
|
||||
})(this);
|
||||
@@ -1,50 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Test Runner</title>
|
||||
</head>
|
||||
<script type="text/javascript" src="json2.js"></script>
|
||||
<script type="text/javascript" src="jasmine.js"></script>
|
||||
<script type="text/javascript" src="TrivialReporter.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
jasmine.include('example_suite.js', true);
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
.spec {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.passed {
|
||||
background-color: lightgreen;
|
||||
}
|
||||
|
||||
.failed {
|
||||
background-color: pink;
|
||||
}
|
||||
|
||||
.resultMessage {
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.stackTrace {
|
||||
white-space: pre;
|
||||
font-size: .8em;
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.reporter = new jasmine.TrivialReporter();
|
||||
jasmineEnv.execute();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
describe('ExampleSuite', function () {
|
||||
it('should have a passing test', function() {
|
||||
expect(true).toEqual(true);
|
||||
});
|
||||
|
||||
describe('Nested Describe', function () {
|
||||
it('should also have a passing test', function () {
|
||||
expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
182
lib/jasmine-html.js
Normal file
182
lib/jasmine-html.js
Normal file
@@ -0,0 +1,182 @@
|
||||
jasmine.TrivialReporter = function(doc) {
|
||||
this.document = doc || document;
|
||||
this.suiteDivs = {};
|
||||
this.logRunningSpecs = false;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
||||
var el = document.createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(document.createTextNode(child));
|
||||
} else {
|
||||
if (child) { el.appendChild(child); }
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == "className") {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
var showPassed, showSkipped;
|
||||
|
||||
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
|
||||
this.createDom('div', { className: 'banner' },
|
||||
this.createDom('div', { className: 'logo' },
|
||||
"Jasmine",
|
||||
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
||||
this.createDom('div', { className: 'options' },
|
||||
"Show ",
|
||||
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
||||
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
||||
)
|
||||
),
|
||||
|
||||
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
||||
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
||||
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
||||
);
|
||||
|
||||
this.document.body.appendChild(this.outerDiv);
|
||||
|
||||
var suites = runner.suites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
var suiteDiv = this.createDom('div', { className: 'suite' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
||||
this.suiteDivs[suite.id] = suiteDiv;
|
||||
var parentDiv = this.outerDiv;
|
||||
if (suite.parentSuite) {
|
||||
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
||||
}
|
||||
parentDiv.appendChild(suiteDiv);
|
||||
}
|
||||
|
||||
this.startedAt = new Date();
|
||||
|
||||
var self = this;
|
||||
showPassed.onchange = function(evt) {
|
||||
if (evt.target.checked) {
|
||||
self.outerDiv.className += ' show-passed';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
||||
}
|
||||
};
|
||||
|
||||
showSkipped.onchange = function(evt) {
|
||||
if (evt.target.checked) {
|
||||
self.outerDiv.className += ' show-skipped';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
||||
var results = runner.results();
|
||||
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
||||
this.runnerDiv.setAttribute("class", className);
|
||||
//do it twice for IE
|
||||
this.runnerDiv.setAttribute("className", className);
|
||||
var specs = runner.specs();
|
||||
var specCount = 0;
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
if (this.specFilter(specs[i])) {
|
||||
specCount++;
|
||||
}
|
||||
}
|
||||
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
||||
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
||||
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
||||
|
||||
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
||||
var results = suite.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.totalCount == 0) { // todo: change this to check results.skipped
|
||||
status = 'skipped';
|
||||
}
|
||||
this.suiteDivs[suite.id].className += " " + status;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
||||
if (this.logRunningSpecs) {
|
||||
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||
var results = spec.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
||||
title: spec.getFullName()
|
||||
}, spec.description));
|
||||
|
||||
|
||||
var resultItems = results.getItems();
|
||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
|
||||
if (result.type == 'log') {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||
|
||||
if (result.trace.stack) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (messagesDiv.childNodes.length > 0) {
|
||||
specDiv.appendChild(messagesDiv);
|
||||
}
|
||||
|
||||
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.log = function() {
|
||||
var console = jasmine.getGlobal().console;
|
||||
if (console && console.log) console.log.apply(console, arguments);
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.getLocation = function() {
|
||||
return this.document.location;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
||||
var paramMap = {};
|
||||
var params = this.getLocation().search.substring(1).split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||
}
|
||||
|
||||
if (!paramMap["spec"]) return true;
|
||||
return spec.getFullName().indexOf(paramMap["spec"]) == 0;
|
||||
};
|
||||
159
lib/jasmine.css
159
lib/jasmine.css
@@ -1,51 +1,166 @@
|
||||
body {
|
||||
font: 14px "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
|
||||
padding-left: 40px;
|
||||
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
padding-top: 20px;
|
||||
font-weight: bold;
|
||||
font: 24px; /* "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; */
|
||||
|
||||
.jasmine_reporter a:visited, .jasmine_reporter a {
|
||||
color: #303;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 5px;
|
||||
padding-left: 20px;
|
||||
.jasmine_reporter a:hover, .jasmine_reporter a:active {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.fail {
|
||||
background: url( ../images/fail-16.png ) no-repeat;
|
||||
padding-left: 20px;
|
||||
color: red;
|
||||
.run_spec {
|
||||
float:right;
|
||||
padding-right: 5px;
|
||||
font-size: .8em;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.fail_in_summary {
|
||||
color: red;
|
||||
.jasmine_reporter {
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.banner {
|
||||
color: #303;
|
||||
background-color: #fef;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
float: left;
|
||||
font-size: 1.1em;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.logo .version {
|
||||
font-size: .6em;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.runner.running {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
|
||||
.options {
|
||||
text-align: right;
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.suite {
|
||||
border: 1px outset gray;
|
||||
margin: 5px 0;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.suite .suite {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.suite.passed {
|
||||
background-color: #dfd;
|
||||
}
|
||||
|
||||
.suite.failed {
|
||||
background-color: #fdd;
|
||||
}
|
||||
|
||||
.spec {
|
||||
margin: 5px;
|
||||
padding-left: 1em;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.spec.failed, .spec.passed, .spec.skipped {
|
||||
padding-bottom: 5px;
|
||||
border: 1px solid gray;
|
||||
}
|
||||
|
||||
.spec.failed {
|
||||
background-color: #fbb;
|
||||
border-color: red;
|
||||
}
|
||||
|
||||
.spec.passed {
|
||||
background-color: #bfb;
|
||||
border-color: green;
|
||||
}
|
||||
|
||||
.spec.skipped {
|
||||
background-color: #bbb;
|
||||
}
|
||||
|
||||
.messages {
|
||||
border-left: 1px dashed gray;
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
.passed {
|
||||
background-color: lightgreen;
|
||||
background-color: #cfc;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.failed {
|
||||
background-color: pink;
|
||||
background-color: #fbb;
|
||||
}
|
||||
|
||||
.resultMessage {
|
||||
white-space: pre;
|
||||
.skipped {
|
||||
color: #777;
|
||||
background-color: #eee;
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
/*.resultMessage {*/
|
||||
/*white-space: pre;*/
|
||||
/*}*/
|
||||
|
||||
.resultMessage span.result {
|
||||
display: block;
|
||||
line-height: 2em;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.resultMessage .mismatch {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.stackTrace {
|
||||
white-space: pre;
|
||||
font-size: .8em;
|
||||
margin-left: 10px;
|
||||
height: 5em;
|
||||
max-height: 5em;
|
||||
overflow: auto;
|
||||
border-left: 1px solid red;
|
||||
padding-left: 5em;
|
||||
border: 1px inset red;
|
||||
padding: 1em;
|
||||
background: #eef;
|
||||
}
|
||||
|
||||
.finished-at {
|
||||
padding-left: 1em;
|
||||
font-size: .6em;
|
||||
}
|
||||
|
||||
.show-passed .passed,
|
||||
.show-skipped .skipped {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
#jasmine_content {
|
||||
position:fixed;
|
||||
right: 100%;
|
||||
}
|
||||
|
||||
.runner {
|
||||
border: 1px solid gray;
|
||||
display: block;
|
||||
margin: 5px 0;
|
||||
padding: 2px 0 2px 10px;
|
||||
}
|
||||
|
||||
1816
lib/jasmine.js
1816
lib/jasmine.js
File diff suppressed because it is too large
Load Diff
20
lib/json2.js
20
lib/json2.js
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
http://www.JSON.org/json2.js
|
||||
2008-11-19
|
||||
2009-08-17
|
||||
|
||||
Public Domain.
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
value represented by the name/value pair that should be serialized,
|
||||
or undefined if nothing should be serialized. The toJSON method
|
||||
will be passed the key associated with the value, and this will be
|
||||
bound to the object holding the key.
|
||||
bound to the value
|
||||
|
||||
For example, this would serialize Dates as ISO strings.
|
||||
|
||||
@@ -146,8 +146,6 @@
|
||||
|
||||
/*jslint evil: true */
|
||||
|
||||
/*global JSON */
|
||||
|
||||
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
|
||||
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
|
||||
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
|
||||
@@ -155,12 +153,15 @@
|
||||
test, toJSON, toString, valueOf
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
// Create a JSON object only if one does not already exist. We create the
|
||||
// methods in a closure to avoid creating global variables.
|
||||
|
||||
if (!this.JSON) {
|
||||
JSON = {};
|
||||
this.JSON = {};
|
||||
}
|
||||
|
||||
(function () {
|
||||
|
||||
function f(n) {
|
||||
@@ -172,12 +173,13 @@ if (!this.JSON) {
|
||||
|
||||
Date.prototype.toJSON = function (key) {
|
||||
|
||||
return this.getUTCFullYear() + '-' +
|
||||
return isFinite(this.valueOf()) ?
|
||||
this.getUTCFullYear() + '-' +
|
||||
f(this.getUTCMonth() + 1) + '-' +
|
||||
f(this.getUTCDate()) + 'T' +
|
||||
f(this.getUTCHours()) + ':' +
|
||||
f(this.getUTCMinutes()) + ':' +
|
||||
f(this.getUTCSeconds()) + 'Z';
|
||||
f(this.getUTCSeconds()) + 'Z' : null;
|
||||
};
|
||||
|
||||
String.prototype.toJSON =
|
||||
@@ -222,7 +224,6 @@ if (!this.JSON) {
|
||||
|
||||
|
||||
function str(key, holder) {
|
||||
|
||||
// Produce a string from holder[key].
|
||||
|
||||
var i, // The loop counter.
|
||||
@@ -351,7 +352,6 @@ if (!this.JSON) {
|
||||
|
||||
if (typeof JSON.stringify !== 'function') {
|
||||
JSON.stringify = function (value, replacer, space) {
|
||||
|
||||
// The stringify method takes a value and an optional replacer, and an optional
|
||||
// space parameter, and returns a JSON text. The replacer can be a function
|
||||
// that can replace values, or an array of strings that will select the keys.
|
||||
@@ -475,4 +475,4 @@ replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
||||
throw new SyntaxError('JSON.parse');
|
||||
};
|
||||
}
|
||||
})();
|
||||
}());
|
||||
|
||||
1
pages
Submodule
1
pages
Submodule
Submodule pages added at 5e843e087b
101
spec/runner.html
101
spec/runner.html
@@ -3,72 +3,79 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Test Runner</title>
|
||||
|
||||
<script type="text/javascript">
|
||||
// yes, really keep this here to keep us honest, but only for jasmine's own runner! [xw]
|
||||
undefined = "diz be undefined yo";
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="../src/base.js"></script>
|
||||
<script type="text/javascript" src="../src/util.js"></script>
|
||||
<script type="text/javascript" src="../src/Env.js"></script>
|
||||
<script type="text/javascript" src="../src/ActionCollection.js"></script>
|
||||
<script type="text/javascript" src="../src/Reporter.js"></script>
|
||||
<script type="text/javascript" src="../src/Block.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../src/JsApiReporter.js"></script>
|
||||
<script type="text/javascript" src="../src/Matchers.js"></script>
|
||||
<script type="text/javascript" src="../src/mock-timeout.js"></script>
|
||||
<script type="text/javascript" src="../src/MultiReporter.js"></script>
|
||||
<script type="text/javascript" src="../src/NestedResults.js"></script>
|
||||
<script type="text/javascript" src="../src/PrettyPrinter.js"></script>
|
||||
<script type="text/javascript" src="../src/QueuedFunction.js"></script>
|
||||
<script type="text/javascript" src="../src/Reporters.js"></script>
|
||||
<script type="text/javascript" src="../src/Queue.js"></script>
|
||||
<script type="text/javascript" src="../src/Runner.js"></script>
|
||||
<script type="text/javascript" src="../src/Spec.js"></script>
|
||||
<script type="text/javascript" src="../src/Suite.js"></script>
|
||||
<script type="text/javascript" src="../src/mock-timeout.js"></script>
|
||||
<script type="text/javascript" src="../src/WaitsBlock.js"></script>
|
||||
<script type="text/javascript" src="../src/WaitsForBlock.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../lib/TrivialReporter.js"></script>
|
||||
<script type="text/javascript" src="../src/html/TrivialReporter.js"></script>
|
||||
<script type="text/javascript" src="../lib/consolex.js"></script>
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="suites/BaseSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/CustomMatchersSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/EnvSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/ExceptionsSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/JsApiReporterSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/MatchersSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/MockClockSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/MultiReporterSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/NestedResultsSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/PrettyPrintSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/ReporterSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/RunnerSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/QueueSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/SpecSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/SpecRunningSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/SpySpec.js"></script>
|
||||
<script type="text/javascript" src="suites/SuiteSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/TrivialReporterSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/WaitsForBlockSpec.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
jasmine.include('suites/EnvTest.js', true);
|
||||
jasmine.include('suites/ExceptionsTest.js', true);
|
||||
jasmine.include('suites/MatchersTest.js', true);
|
||||
jasmine.include('suites/MultiReporterTest.js', true);
|
||||
jasmine.include('suites/NestedResultsTest.js', true);
|
||||
jasmine.include('suites/PrettyPrintTest.js', true);
|
||||
jasmine.include('suites/ReporterTest.js', true);
|
||||
jasmine.include('suites/RunnerTest.js', true);
|
||||
jasmine.include('suites/SpecRunningTest.js', true);
|
||||
jasmine.include('suites/SpyTest.js', true);
|
||||
(function() {
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.updateInterval = 1000;
|
||||
|
||||
var trivialReporter = new jasmine.TrivialReporter();
|
||||
|
||||
jasmineEnv.addReporter(trivialReporter);
|
||||
|
||||
jasmineEnv.specFilter = function(spec) {
|
||||
return trivialReporter.specFilter(spec);
|
||||
};
|
||||
|
||||
window.onload = function() {
|
||||
jasmineEnv.execute();
|
||||
};
|
||||
})();
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
.spec {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.passed {
|
||||
background-color: lightgreen;
|
||||
}
|
||||
|
||||
.failed {
|
||||
background-color: pink;
|
||||
}
|
||||
|
||||
.resultMessage {
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.stackTrace {
|
||||
white-space: pre;
|
||||
font-size: .8em;
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
<link href="../src/html/jasmine.css" rel="stylesheet"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.addReporter(new jasmine.TrivialReporter());
|
||||
jasmineEnv.execute();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
27
spec/suites/BaseSpec.js
Normal file
27
spec/suites/BaseSpec.js
Normal file
@@ -0,0 +1,27 @@
|
||||
describe("base.js", function() {
|
||||
describe("jasmine.MessageResult", function() {
|
||||
it("#toString should pretty-print and concatenate each part of the message", function() {
|
||||
var values = ["log", "message", 123, {key: "value"}, "FTW!"];
|
||||
var messageResult = new jasmine.MessageResult(values);
|
||||
expect(messageResult.toString()).toEqual("log message 123 { key : 'value' } FTW!");
|
||||
});
|
||||
});
|
||||
|
||||
describe("jasmine.log", function() {
|
||||
it("should accept n arguments", function() {
|
||||
spyOn(jasmine.getEnv().currentSpec, 'log');
|
||||
jasmine.log(1, 2, 3);
|
||||
expect(jasmine.getEnv().currentSpec.log).toHaveBeenCalledWith(1, 2, 3);
|
||||
});
|
||||
});
|
||||
|
||||
describe("jasmine.getGlobal", function() {
|
||||
it("should return the global object", function() {
|
||||
var globalObject = (function() {
|
||||
return this;
|
||||
})();
|
||||
|
||||
expect(jasmine.getGlobal()).toBe(globalObject);
|
||||
});
|
||||
});
|
||||
});
|
||||
88
spec/suites/CustomMatchersSpec.js
Normal file
88
spec/suites/CustomMatchersSpec.js
Normal file
@@ -0,0 +1,88 @@
|
||||
describe("Custom Matchers", function() {
|
||||
var env;
|
||||
var fakeTimer;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
});
|
||||
|
||||
it("should be easy to add more matchers local to a spec, suite, etc.", function() {
|
||||
var spec1, spec2, spec1Matcher, spec2Matcher;
|
||||
var suite = env.describe('some suite', function() {
|
||||
env.beforeEach(function() {
|
||||
this.addMatchers({ matcherForSuite: function(expected) {
|
||||
return "matcherForSuite: actual: " + this.actual + "; expected: " + expected;
|
||||
} });
|
||||
});
|
||||
|
||||
spec1 = env.it('spec with an expectation').runs(function () {
|
||||
this.addMatchers({ matcherForSpec: function(expected) {
|
||||
return "matcherForSpec: actual: " + this.actual + "; expected: " + expected;
|
||||
} });
|
||||
spec1Matcher = this.expect("xxx");
|
||||
});
|
||||
|
||||
spec2 = env.it('spec with failing expectation').runs(function () {
|
||||
spec2Matcher = this.expect("yyy");
|
||||
});
|
||||
});
|
||||
|
||||
suite.execute();
|
||||
|
||||
expect(spec1Matcher.matcherForSuite("expected")).toEqual("matcherForSuite: actual: xxx; expected: expected");
|
||||
expect(spec1Matcher.matcherForSpec("expected")).toEqual("matcherForSpec: actual: xxx; expected: expected");
|
||||
|
||||
expect(spec2Matcher.matcherForSuite("expected")).toEqual("matcherForSuite: actual: yyy; expected: expected");
|
||||
expect(spec2Matcher.matcherForSpec).toBe(jasmine.undefined);
|
||||
});
|
||||
|
||||
it("should generate messages with the same rules as for regular matchers when this.report() is not called", function() {
|
||||
var spec;
|
||||
var suite = env.describe('some suite', function() {
|
||||
spec = env.it('spec with an expectation').runs(function () {
|
||||
this.addMatchers({
|
||||
toBeTrue: function() {
|
||||
return this.actual === true;
|
||||
}
|
||||
});
|
||||
this.expect(true).toBeTrue();
|
||||
this.expect(false).toBeTrue();
|
||||
});
|
||||
});
|
||||
|
||||
suite.execute();
|
||||
var passResult = new jasmine.ExpectationResult({passed: true, matcherName: 'toBeTrue',
|
||||
actual: true, expected: jasmine.undefined, message: "Passed." });
|
||||
var failResult = new jasmine.ExpectationResult({passed: false, matcherName: 'toBeTrue',
|
||||
actual: false, expected: jasmine.undefined, message: "Expected false to be true." });
|
||||
failResult.trace = jasmine.any(Object);
|
||||
expect(spec.results().getItems()).toEqual([passResult, failResult]);
|
||||
});
|
||||
|
||||
it("should pass args", function() {
|
||||
var matcherCallArgs = [];
|
||||
var spec;
|
||||
var suite = env.describe('some suite', function() {
|
||||
spec = env.it('spec with an expectation').runs(function () {
|
||||
this.addMatchers({
|
||||
toBeTrue: function() {
|
||||
matcherCallArgs.push(jasmine.util.argsToArray(arguments));
|
||||
return this.actual === true;
|
||||
}
|
||||
});
|
||||
this.expect(true).toBeTrue();
|
||||
this.expect(false).toBeTrue('arg');
|
||||
this.expect(true).toBeTrue('arg1', 'arg2');
|
||||
});
|
||||
});
|
||||
|
||||
suite.execute();
|
||||
var results = spec.results().getItems();
|
||||
expect(results[0].expected).toEqual(jasmine.undefined);
|
||||
expect(results[1].expected).toEqual('arg');
|
||||
expect(results[2].expected).toEqual(['arg1', 'arg2']);
|
||||
|
||||
expect(matcherCallArgs).toEqual([[], ['arg'], ['arg1', 'arg2']]);
|
||||
});
|
||||
});
|
||||
158
spec/suites/EnvSpec.js
Normal file
158
spec/suites/EnvSpec.js
Normal file
@@ -0,0 +1,158 @@
|
||||
describe("jasmine.Env", function() {
|
||||
var env;
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
});
|
||||
|
||||
describe('ids', function () {
|
||||
it('nextSpecId should return consecutive integers, starting at 0', function () {
|
||||
expect(env.nextSpecId()).toEqual(0);
|
||||
expect(env.nextSpecId()).toEqual(1);
|
||||
expect(env.nextSpecId()).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("reporting", function() {
|
||||
var fakeReporter;
|
||||
|
||||
beforeEach(function() {
|
||||
fakeReporter = jasmine.createSpyObj("fakeReporter", ["log"]);
|
||||
});
|
||||
|
||||
describe('version', function () {
|
||||
var oldVersion;
|
||||
|
||||
beforeEach(function () {
|
||||
oldVersion = jasmine.version_;
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
jasmine.version_ = oldVersion;
|
||||
});
|
||||
|
||||
it('should raise an error if version is not set', function () {
|
||||
jasmine.version_ = null;
|
||||
var exception;
|
||||
try {
|
||||
env.version();
|
||||
}
|
||||
catch (e) {
|
||||
exception = e;
|
||||
}
|
||||
expect(exception.message).toEqual('Version not set');
|
||||
});
|
||||
|
||||
it("version should return the current version as an int", function() {
|
||||
jasmine.version_ = {
|
||||
"major": 1,
|
||||
"minor": 9,
|
||||
"build": 7,
|
||||
"revision": 8
|
||||
};
|
||||
expect(env.version()).toEqual({
|
||||
"major": 1,
|
||||
"minor": 9,
|
||||
"build": 7,
|
||||
"revision": 8
|
||||
});
|
||||
});
|
||||
|
||||
describe("versionString", function() {
|
||||
it("should return a stringified version number", function() {
|
||||
jasmine.version_ = {
|
||||
"major": 1,
|
||||
"minor": 9,
|
||||
"build": 7,
|
||||
"revision": 8
|
||||
};
|
||||
expect(env.versionString()).toEqual("1.9.7 revision 8");
|
||||
});
|
||||
|
||||
it("should return a nice string when version is unknown", function() {
|
||||
jasmine.version_ = null;
|
||||
expect(env.versionString()).toEqual("version unknown");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("should allow reporters to be registered", function() {
|
||||
env.addReporter(fakeReporter);
|
||||
env.reporter.log("message");
|
||||
expect(fakeReporter.log).toHaveBeenCalledWith("message");
|
||||
});
|
||||
});
|
||||
|
||||
describe("equality testing", function() {
|
||||
describe("with custom equality testers", function() {
|
||||
var aObj, bObj, isEqual;
|
||||
|
||||
beforeEach(function() {
|
||||
env.addEqualityTester(function(a, b) {
|
||||
aObj = a;
|
||||
bObj = b;
|
||||
return isEqual;
|
||||
});
|
||||
});
|
||||
|
||||
it("should call the custom equality tester with two objects for comparison", function() {
|
||||
env.equals_("1", "2");
|
||||
expect(aObj).toEqual("1");
|
||||
expect(bObj).toEqual("2");
|
||||
});
|
||||
|
||||
describe("when the custom equality tester returns false", function() {
|
||||
beforeEach(function() {
|
||||
isEqual = false;
|
||||
});
|
||||
|
||||
it("should give custom equality testers precedence", function() {
|
||||
expect(env.equals_('abc', 'abc')).toBeFalsy();
|
||||
var o = new Object();
|
||||
expect(env.equals_(o, o)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("when the custom equality tester returns true", function() {
|
||||
beforeEach(function() {
|
||||
isEqual = true;
|
||||
});
|
||||
|
||||
it("should give custom equality testers precedence", function() {
|
||||
expect(env.equals_('abc', 'def')).toBeTruthy();
|
||||
expect(env.equals_(true, false)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the custom equality tester returns undefined", function() {
|
||||
beforeEach(function() {
|
||||
isEqual = jasmine.undefined;
|
||||
});
|
||||
|
||||
it("should use normal equality rules", function() {
|
||||
expect(env.equals_('abc', 'abc')).toBeTruthy();
|
||||
expect(env.equals_('abc', 'def')).toBeFalsy();
|
||||
});
|
||||
|
||||
describe("even if there are several", function() {
|
||||
beforeEach(function() {
|
||||
env.addEqualityTester(function(a, b) { return jasmine.undefined; });
|
||||
env.addEqualityTester(function(a, b) { return jasmine.undefined; });
|
||||
});
|
||||
|
||||
it("should use normal equality rules", function() {
|
||||
expect(env.equals_('abc', 'abc')).toBeTruthy();
|
||||
expect(env.equals_('abc', 'def')).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("should evaluate custom equality testers in the order they are declared", function() {
|
||||
isEqual = false;
|
||||
env.addEqualityTester(function(a, b) { return true; });
|
||||
expect(env.equals_('abc', 'abc')).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,17 +0,0 @@
|
||||
describe("jasmine.Env", function() {
|
||||
describe("reporting", function() {
|
||||
var env;
|
||||
var fakeReporter;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
fakeReporter = jasmine.createSpyObj("fakeReporter", ["log"]);
|
||||
});
|
||||
|
||||
it("should allow reporters to be registered", function() {
|
||||
env.addReporter(fakeReporter);
|
||||
env.reporter.log("message");
|
||||
expect(fakeReporter.log).wasCalledWith("message");
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -3,9 +3,10 @@ describe('Exceptions:', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
});
|
||||
|
||||
it('jasmine.formatException formats Firefox exception maessages as expected', function() {
|
||||
it('jasmine.formatException formats Firefox exception messages as expected', function() {
|
||||
var sampleFirefoxException = {
|
||||
fileName: 'foo.js',
|
||||
line: '1978',
|
||||
@@ -18,7 +19,7 @@ describe('Exceptions:', function() {
|
||||
expect(jasmine.util.formatException(sampleFirefoxException)).toEqual(expected);
|
||||
});
|
||||
|
||||
it('jasmine.formatException formats Webkit exception maessages as expected', function() {
|
||||
it('jasmine.formatException formats Webkit exception messages as expected', function() {
|
||||
var sampleWebkitException = {
|
||||
sourceURL: 'foo.js',
|
||||
lineNumber: '1978',
|
||||
@@ -72,27 +73,35 @@ describe('Exceptions:', function() {
|
||||
});
|
||||
});
|
||||
|
||||
var runner = env.currentRunner;
|
||||
var runner = env.currentRunner();
|
||||
suite.execute();
|
||||
fakeTimer.tick(300); //TODO: setting this to a large number causes failures, but shouldn't
|
||||
fakeTimer.tick(2500);
|
||||
|
||||
var resultsForSpec0 = suite.specs[0].getResults();
|
||||
var resultsForSpec1 = suite.specs[1].getResults();
|
||||
var resultsForSpec2 = suite.specs[2].getResults();
|
||||
var resultsForSpec3 = suite.specs[3].getResults();
|
||||
|
||||
expect(suite.getResults().totalCount).toEqual(6);
|
||||
expect(resultsForSpec0.getItems()[0].passed).toEqual(false);
|
||||
expect(resultsForSpec0.getItems()[0].message).toMatch(/fake error 1/);
|
||||
var suiteResults = suite.results();
|
||||
var specResults = suiteResults.getItems();
|
||||
|
||||
expect(resultsForSpec1.getItems()[0].passed).toEqual(false),
|
||||
expect(resultsForSpec1.getItems()[0].message).toMatch(/fake error 2/),
|
||||
expect(resultsForSpec1.getItems()[1].passed).toEqual(true);
|
||||
expect(suiteResults.passed()).toEqual(false);
|
||||
//
|
||||
expect(specResults.length).toEqual(5);
|
||||
expect(specResults[0].passed()).toMatch(false);
|
||||
var blockResults = specResults[0].getItems();
|
||||
expect(blockResults[0].passed()).toEqual(false);
|
||||
expect(blockResults[0].message).toMatch(/fake error 1/);
|
||||
|
||||
expect(resultsForSpec2.getItems()[0].passed).toEqual(true);
|
||||
expect(specResults[1].passed()).toEqual(false);
|
||||
var blockResults = specResults[1].getItems();
|
||||
expect(blockResults[0].passed()).toEqual(false);
|
||||
expect(blockResults[0].message).toMatch(/fake error 2/),
|
||||
expect(blockResults[1].passed()).toEqual(true);
|
||||
|
||||
expect(specResults[2].passed()).toEqual(true);
|
||||
|
||||
expect(specResults[3].passed()).toEqual(false);
|
||||
blockResults = specResults[3].getItems();
|
||||
expect(blockResults[0].message).toMatch(/fake error 3/);
|
||||
|
||||
expect(specResults[4].passed()).toEqual(true);
|
||||
|
||||
expect(resultsForSpec3.getItems()[0].passed).toEqual(false);
|
||||
expect(resultsForSpec3.getItems()[0].message).toMatch(/fake error 3/);
|
||||
});
|
||||
|
||||
});
|
||||
103
spec/suites/JsApiReporterSpec.js
Normal file
103
spec/suites/JsApiReporterSpec.js
Normal file
@@ -0,0 +1,103 @@
|
||||
describe('jasmine.jsApiReporter', function() {
|
||||
describe('results', function () {
|
||||
var reporter, spec1, spec2, spec3, expectedSpec1Results, expectedSpec2Results;
|
||||
var env;
|
||||
var suite, nestedSuite, nestedSpec;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
|
||||
suite = env.describe("top-level suite", function() {
|
||||
spec1 = env.it("spec 1", function() {
|
||||
this.expect(true).toEqual(true);
|
||||
|
||||
});
|
||||
|
||||
spec2 = env.it("spec 2", function() {
|
||||
this.expect(true).toEqual(false);
|
||||
});
|
||||
|
||||
nestedSuite = env.describe("nested suite", function() {
|
||||
nestedSpec = env.it("nested spec", function() {
|
||||
expect(true).toEqual(true);
|
||||
})
|
||||
});
|
||||
|
||||
spec3 = env.it("spec 3", function() {
|
||||
this.log('some debug message');
|
||||
});
|
||||
});
|
||||
|
||||
reporter = new jasmine.JsApiReporter();
|
||||
env.addReporter(reporter);
|
||||
|
||||
env.execute();
|
||||
|
||||
expectedSpec1Results = {
|
||||
messages: spec1.results().getItems(),
|
||||
result: "passed"
|
||||
};
|
||||
expectedSpec2Results = {
|
||||
messages: spec2.results().getItems(),
|
||||
result: "failed"
|
||||
};
|
||||
});
|
||||
|
||||
it('resultForSpec() should return the result for the given spec', function () {
|
||||
expect(reporter.resultsForSpec(spec1.id)).toEqual(expectedSpec1Results);
|
||||
expect(reporter.resultsForSpec(spec2.id)).toEqual(expectedSpec2Results);
|
||||
});
|
||||
|
||||
it('results() should return a hash of all results, indexed by spec id', function () {
|
||||
expect(reporter.results()[spec1.id]).toEqual(expectedSpec1Results);
|
||||
expect(reporter.results()[spec2.id]).toEqual(expectedSpec2Results);
|
||||
});
|
||||
|
||||
it("should return nested suites as children of their parents", function() {
|
||||
expect(reporter.suites()).toEqual([
|
||||
{ id: 0, name: 'top-level suite', type: 'suite',
|
||||
children: [
|
||||
{ id: 0, name: 'spec 1', type: 'spec', children: [ ] },
|
||||
{ id: 1, name: 'spec 2', type: 'spec', children: [ ] },
|
||||
{ id: 1, name: 'nested suite', type: 'suite',
|
||||
children: [
|
||||
{ id: 2, name: 'nested spec', type: 'spec', children: [ ] }
|
||||
]
|
||||
},
|
||||
{ id: 3, name: 'spec 3', type: 'spec', children: [ ] }
|
||||
]
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
describe("#summarizeResult_", function() {
|
||||
it("should summarize a passing result", function() {
|
||||
var result = reporter.results()[spec1.id];
|
||||
var summarizedResult = reporter.summarizeResult_(result);
|
||||
expect(summarizedResult.result).toEqual('passed');
|
||||
expect(summarizedResult.messages.length).toEqual(1);
|
||||
expect(summarizedResult.messages[0].message).toEqual(result.messages[0].message);
|
||||
expect(summarizedResult.messages[0].passed).toBeTruthy();
|
||||
expect(summarizedResult.messages[0].type).toEqual('expect');
|
||||
expect(summarizedResult.messages[0].text).toBeUndefined();
|
||||
expect(summarizedResult.messages[0].trace.stack).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should have a stack trace for failing specs", function() {
|
||||
var result = reporter.results()[spec2.id];
|
||||
var summarizedResult = reporter.summarizeResult_(result);
|
||||
expect(summarizedResult.result).toEqual('failed');
|
||||
expect(summarizedResult.messages[0].trace.stack).toEqual(result.messages[0].trace.stack);
|
||||
});
|
||||
|
||||
it("should have messages for specs with messages", function() {
|
||||
var result = reporter.results()[spec3.id];
|
||||
var summarizedResult = reporter.summarizeResult_(result);
|
||||
expect(summarizedResult.result).toEqual('passed');
|
||||
expect(summarizedResult.messages[0].type).toEqual('log');
|
||||
expect(summarizedResult.messages[0].text).toEqual('some debug message');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
716
spec/suites/MatchersSpec.js
Normal file
716
spec/suites/MatchersSpec.js
Normal file
@@ -0,0 +1,716 @@
|
||||
describe("jasmine.Matchers", function() {
|
||||
var env, spec;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
|
||||
var suite = env.describe("suite", function() {
|
||||
spec = env.it("spec", function() {
|
||||
});
|
||||
});
|
||||
spyOn(spec, 'addMatcherResult');
|
||||
});
|
||||
|
||||
function match(value) {
|
||||
return spec.expect(value);
|
||||
}
|
||||
|
||||
function lastResult() {
|
||||
return spec.addMatcherResult.mostRecentCall.args[0];
|
||||
}
|
||||
|
||||
it("toEqual with primitives, objects, dates, etc.", function() {
|
||||
expect(match(true).toEqual(true)).toEqual(true);
|
||||
|
||||
expect(match({foo:'bar'}).toEqual(null)).toEqual(false);
|
||||
|
||||
var functionA = function() {
|
||||
return 'hi';
|
||||
};
|
||||
var functionB = function() {
|
||||
return 'hi';
|
||||
};
|
||||
expect(match({foo:functionA}).toEqual({foo:functionB})).toEqual(false);
|
||||
expect(match({foo:functionA}).toEqual({foo:functionA})).toEqual(true);
|
||||
|
||||
expect((match(false).toEqual(true))).toEqual(false);
|
||||
|
||||
var circularGraph = {};
|
||||
circularGraph.referenceToSelf = circularGraph;
|
||||
expect((match(circularGraph).toEqual(circularGraph))).toEqual(true);
|
||||
|
||||
expect((match(new Date(2008, 1, 3, 15, 17, 19, 1234)).toEqual(new Date(2009, 1, 3, 15, 17, 19, 1234)))).toEqual(false);
|
||||
expect((match(new Date(2008, 1, 3, 15, 17, 19, 1234)).toEqual(new Date(2008, 1, 3, 15, 17, 19, 1234)))).toEqual(true);
|
||||
|
||||
|
||||
expect(match(true).toNotEqual(false)).toEqual(true);
|
||||
expect((match(true).toNotEqual(true))).toEqual(false);
|
||||
|
||||
expect((match(['a', 'b']).toEqual(['a', jasmine.undefined]))).toEqual(false);
|
||||
expect((match(['a', 'b']).toEqual(['a', 'b', jasmine.undefined]))).toEqual(false);
|
||||
|
||||
expect((match(new String("cat")).toEqual("cat"))).toBe(true);
|
||||
expect((match(new String("cat")).toNotEqual("cat"))).toBe(false);
|
||||
|
||||
expect((match(new Number(5)).toEqual(5))).toBe(true);
|
||||
expect((match(new Number('5')).toEqual(5))).toBe(true);
|
||||
expect((match(new Number(5)).toNotEqual(5))).toBe(false);
|
||||
expect((match(new Number('5')).toNotEqual(5))).toBe(false);
|
||||
});
|
||||
|
||||
it("toEqual with DOM nodes", function() {
|
||||
var nodeA = document.createElement('div');
|
||||
var nodeB = document.createElement('div');
|
||||
expect((match(nodeA).toEqual(nodeA))).toEqual(true);
|
||||
expect((match(nodeA).toEqual(nodeB))).toEqual(false);
|
||||
});
|
||||
|
||||
it("toEqual to build an Expectation Result", function() {
|
||||
var actual = 'a';
|
||||
var matcher = match(actual);
|
||||
var expected = 'b';
|
||||
matcher.toEqual(expected);
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toEqual");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toMatch(jasmine.pp(actual));
|
||||
expect(result.message).toMatch(jasmine.pp(expected));
|
||||
expect(result.expected).toEqual(expected);
|
||||
expect(result.actual).toEqual(actual);
|
||||
});
|
||||
|
||||
it("toNotEqual to build an Expectation Result", function() {
|
||||
var str = 'a';
|
||||
var matcher = match(str);
|
||||
matcher.toNotEqual(str);
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toNotEqual");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toMatch(jasmine.pp(str));
|
||||
expect(result.message).toMatch('not');
|
||||
expect(result.expected).toEqual(str);
|
||||
expect(result.actual).toEqual(str);
|
||||
});
|
||||
|
||||
it('toBe should return true only if the expected and actual items === each other', function() {
|
||||
var a = {};
|
||||
var b = {};
|
||||
//noinspection UnnecessaryLocalVariableJS
|
||||
var c = a;
|
||||
expect((match(a).toBe(b))).toEqual(false);
|
||||
expect((match(a).toBe(a))).toEqual(true);
|
||||
expect((match(a).toBe(c))).toEqual(true);
|
||||
expect((match(a).toNotBe(b))).toEqual(true);
|
||||
expect((match(a).toNotBe(a))).toEqual(false);
|
||||
expect((match(a).toNotBe(c))).toEqual(false);
|
||||
});
|
||||
|
||||
it("toBe to build an ExpectationResult", function() {
|
||||
var expected = 'b';
|
||||
var actual = 'a';
|
||||
var matcher = match(actual);
|
||||
matcher.toBe(expected);
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toBe");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toMatch(jasmine.pp(actual));
|
||||
expect(result.message).toMatch(jasmine.pp(expected));
|
||||
expect(result.expected).toEqual(expected);
|
||||
expect(result.actual).toEqual(actual);
|
||||
});
|
||||
|
||||
it("toNotBe to build an ExpectationResult", function() {
|
||||
var str = 'a';
|
||||
var matcher = match(str);
|
||||
matcher.toNotBe(str);
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toNotBe");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toMatch(str);
|
||||
expect(result.expected).toEqual(str);
|
||||
expect(result.actual).toEqual(str);
|
||||
});
|
||||
|
||||
it("toMatch and #toNotMatch should perform regular expression matching on strings", function() {
|
||||
expect((match('foobarbel').toMatch(/bar/))).toEqual(true);
|
||||
expect((match('foobazbel').toMatch(/bar/))).toEqual(false);
|
||||
|
||||
expect((match('foobarbel').toMatch("bar"))).toEqual(true);
|
||||
expect((match('foobazbel').toMatch("bar"))).toEqual(false);
|
||||
|
||||
expect((match('foobarbel').toNotMatch(/bar/))).toEqual(false);
|
||||
expect((match('foobazbel').toNotMatch(/bar/))).toEqual(true);
|
||||
|
||||
expect((match('foobarbel').toNotMatch("bar"))).toEqual(false);
|
||||
expect((match('foobazbel').toNotMatch("bar"))).toEqual(true);
|
||||
});
|
||||
|
||||
it("toMatch w/ RegExp to build an ExpectationResult", function() {
|
||||
var actual = 'a';
|
||||
var matcher = match(actual);
|
||||
var expected = /b/;
|
||||
matcher.toMatch(expected);
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toMatch");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toMatch(jasmine.pp(actual));
|
||||
expect(result.message).toMatch(expected.toString());
|
||||
expect(result.expected).toEqual(expected);
|
||||
expect(result.actual).toEqual(actual);
|
||||
});
|
||||
|
||||
it("toMatch w/ String to build an ExpectationResult", function() {
|
||||
var actual = 'a';
|
||||
var matcher = match(actual);
|
||||
var expected = 'b';
|
||||
matcher.toMatch(expected);
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toMatch");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toEqual("Expected 'a' to match 'b'.");
|
||||
expect(result.expected).toEqual(expected);
|
||||
expect(result.actual).toEqual(actual);
|
||||
});
|
||||
|
||||
it("toNotMatch w/ RegExp to build an ExpectationResult", function() {
|
||||
var actual = 'a';
|
||||
var matcher = match(actual);
|
||||
var expected = /a/;
|
||||
matcher.toNotMatch(expected);
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toNotMatch");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toEqual("Expected 'a' to not match /a/.");
|
||||
expect(result.expected).toEqual(expected);
|
||||
expect(result.actual).toEqual(actual);
|
||||
});
|
||||
|
||||
it("toNotMatch w/ String to build an ExpectationResult", function() {
|
||||
var str = 'a';
|
||||
var matcher = match(str);
|
||||
matcher.toNotMatch(str);
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toNotMatch");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toEqual("Expected 'a' to not match 'a'.");
|
||||
expect(result.expected).toEqual(str);
|
||||
expect(result.actual).toEqual(str);
|
||||
});
|
||||
|
||||
it("toBeDefined", function() {
|
||||
expect(match('foo').toBeDefined()).toEqual(true);
|
||||
expect(match(jasmine.undefined).toBeDefined()).toEqual(false);
|
||||
});
|
||||
|
||||
it("toBeDefined to build an ExpectationResult", function() {
|
||||
var matcher = match(jasmine.undefined);
|
||||
matcher.toBeDefined();
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toBeDefined");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toEqual('Expected undefined to be defined.');
|
||||
expect(result.actual).toEqual(jasmine.undefined);
|
||||
});
|
||||
|
||||
it("toBeUndefined", function() {
|
||||
expect(match('foo').toBeUndefined()).toEqual(false);
|
||||
expect(match(jasmine.undefined).toBeUndefined()).toEqual(true);
|
||||
});
|
||||
|
||||
it("toBeNull", function() {
|
||||
expect(match(null).toBeNull()).toEqual(true);
|
||||
expect(match(jasmine.undefined).toBeNull()).toEqual(false);
|
||||
expect(match("foo").toBeNull()).toEqual(false);
|
||||
});
|
||||
|
||||
it("toBeNull w/ String to build an ExpectationResult", function() {
|
||||
var actual = 'a';
|
||||
var matcher = match(actual);
|
||||
matcher.toBeNull();
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toBeNull");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toMatch(jasmine.pp(actual));
|
||||
expect(result.message).toMatch('null');
|
||||
expect(result.actual).toEqual(actual);
|
||||
});
|
||||
|
||||
it("toBeNull w/ Object to build an ExpectationResult", function() {
|
||||
var actual = {a: 'b'};
|
||||
var matcher = match(actual);
|
||||
matcher.toBeNull();
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toBeNull");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toMatch(jasmine.pp(actual));
|
||||
expect(result.message).toMatch('null');
|
||||
expect(result.actual).toEqual(actual);
|
||||
});
|
||||
|
||||
it("toBeFalsy", function() {
|
||||
expect(match(false).toBeFalsy()).toEqual(true);
|
||||
expect(match(true).toBeFalsy()).toEqual(false);
|
||||
expect(match(jasmine.undefined).toBeFalsy()).toEqual(true);
|
||||
expect(match(0).toBeFalsy()).toEqual(true);
|
||||
expect(match("").toBeFalsy()).toEqual(true);
|
||||
});
|
||||
|
||||
it("toBeFalsy to build an ExpectationResult", function() {
|
||||
var actual = 'a';
|
||||
var matcher = match(actual);
|
||||
matcher.toBeFalsy();
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toBeFalsy");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toMatch(jasmine.pp(actual));
|
||||
expect(result.message).toMatch('falsy');
|
||||
expect(result.actual).toEqual(actual);
|
||||
});
|
||||
|
||||
it("toBeTruthy", function() {
|
||||
expect(match(false).toBeTruthy()).toEqual(false);
|
||||
expect(match(true).toBeTruthy()).toEqual(true);
|
||||
expect(match(jasmine.undefined).toBeTruthy()).toEqual(false);
|
||||
expect(match(0).toBeTruthy()).toEqual(false);
|
||||
expect(match("").toBeTruthy()).toEqual(false);
|
||||
expect(match("hi").toBeTruthy()).toEqual(true);
|
||||
expect(match(5).toBeTruthy()).toEqual(true);
|
||||
expect(match({foo: 1}).toBeTruthy()).toEqual(true);
|
||||
});
|
||||
|
||||
it("toBeTruthy to build an ExpectationResult", function() {
|
||||
var matcher = match(false);
|
||||
matcher.toBeTruthy();
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toBeTruthy");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toEqual("Expected false to be truthy.");
|
||||
expect(result.actual).toEqual(false);
|
||||
});
|
||||
|
||||
it("toEqual", function() {
|
||||
expect(match(jasmine.undefined).toEqual(jasmine.undefined)).toEqual(true);
|
||||
expect(match({foo:'bar'}).toEqual({foo:'bar'})).toEqual(true);
|
||||
expect(match("foo").toEqual({bar: jasmine.undefined})).toEqual(false);
|
||||
expect(match({foo: jasmine.undefined}).toEqual("goo")).toEqual(false);
|
||||
expect(match({foo: {bar :jasmine.undefined}}).toEqual("goo")).toEqual(false);
|
||||
});
|
||||
|
||||
it("toEqual with jasmine.any()", function() {
|
||||
expect(match("foo").toEqual(jasmine.any(String))).toEqual(true);
|
||||
expect(match(3).toEqual(jasmine.any(Number))).toEqual(true);
|
||||
expect(match("foo").toEqual(jasmine.any(Function))).toEqual(false);
|
||||
expect(match("foo").toEqual(jasmine.any(Object))).toEqual(false);
|
||||
expect(match({someObj:'foo'}).toEqual(jasmine.any(Object))).toEqual(true);
|
||||
expect(match({someObj:'foo'}).toEqual(jasmine.any(Function))).toEqual(false);
|
||||
expect(match(function() {
|
||||
}).toEqual(jasmine.any(Object))).toEqual(false);
|
||||
expect(match(["foo", "goo"]).toEqual(["foo", jasmine.any(String)])).toEqual(true);
|
||||
expect(match(function() {
|
||||
}).toEqual(jasmine.any(Function))).toEqual(true);
|
||||
expect(match(["a", function() {
|
||||
}]).toEqual(["a", jasmine.any(Function)])).toEqual(true);
|
||||
});
|
||||
|
||||
it("toEqual handles circular objects ok", function() {
|
||||
expect(match({foo: "bar", baz: jasmine.undefined}).toEqual({foo: "bar", baz: jasmine.undefined})).toEqual(true);
|
||||
expect(match({foo:['bar','baz','quux']}).toEqual({foo:['bar','baz','quux']})).toEqual(true);
|
||||
expect(match({foo: {bar:'baz'}, quux:'corge'}).toEqual({foo:{bar:'baz'}, quux:'corge'})).toEqual(true);
|
||||
|
||||
var circularObject = {};
|
||||
var secondCircularObject = {};
|
||||
circularObject.field = circularObject;
|
||||
secondCircularObject.field = secondCircularObject;
|
||||
expect(match(circularObject).toEqual(secondCircularObject)).toEqual(true);
|
||||
});
|
||||
|
||||
it("toNotEqual as slightly surprising behavior, but is it intentional?", function() {
|
||||
expect(match({x:"x", y:"y", z:"w"}).toNotEqual({x:"x", y:"y", z:"z"})).toEqual(true);
|
||||
expect(match({x:"x", y:"y", w:"z"}).toNotEqual({x:"x", y:"y", z:"z"})).toEqual(true);
|
||||
expect(match({x:"x", y:"y", z:"z"}).toNotEqual({w: "w", x:"x", y:"y", z:"z"})).toEqual(true);
|
||||
expect(match({w: "w", x:"x", y:"y", z:"z"}).toNotEqual({x:"x", y:"y", z:"z"})).toEqual(true);
|
||||
});
|
||||
|
||||
it("toEqual handles arrays", function() {
|
||||
expect(match([1, "A"]).toEqual([1, "A"])).toEqual(true);
|
||||
});
|
||||
|
||||
it("toContain and toNotContain", function() {
|
||||
expect(match('ABC').toContain('A')).toEqual(true);
|
||||
expect(match('ABC').toContain('X')).toEqual(false);
|
||||
|
||||
expect(match(['A', 'B', 'C']).toContain('A')).toEqual(true);
|
||||
expect(match(['A', 'B', 'C']).toContain('F')).toEqual(false);
|
||||
expect(match(['A', 'B', 'C']).toNotContain('F')).toEqual(true);
|
||||
expect(match(['A', 'B', 'C']).toNotContain('A')).toEqual(false);
|
||||
|
||||
expect(match(['A', {some:'object'}, 'C']).toContain({some:'object'})).toEqual(true);
|
||||
expect(match(['A', {some:'object'}, 'C']).toContain({some:'other object'})).toEqual(false);
|
||||
});
|
||||
|
||||
it("toContain to build an ExpectationResult", function() {
|
||||
var actual = ['a','b','c'];
|
||||
var matcher = match(actual);
|
||||
var expected = 'x';
|
||||
matcher.toContain(expected);
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toContain");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toMatch(jasmine.pp(actual));
|
||||
expect(result.message).toMatch('contain');
|
||||
expect(result.message).toMatch(jasmine.pp(expected));
|
||||
expect(result.actual).toEqual(actual);
|
||||
expect(result.expected).toEqual(expected);
|
||||
});
|
||||
|
||||
it("toNotContain to build an ExpectationResult", function() {
|
||||
var actual = ['a','b','c'];
|
||||
var matcher = match(actual);
|
||||
var expected = 'b';
|
||||
matcher.toNotContain(expected);
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toNotContain");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toMatch(jasmine.pp(actual));
|
||||
expect(result.message).toMatch('not contain');
|
||||
expect(result.message).toMatch(jasmine.pp(expected));
|
||||
expect(result.actual).toEqual(actual);
|
||||
expect(result.expected).toEqual(expected);
|
||||
});
|
||||
|
||||
it("toBeLessThan should pass if actual is less than expected", function() {
|
||||
expect(match(37).toBeLessThan(42)).toEqual(true);
|
||||
expect(match(37).toBeLessThan(-42)).toEqual(false);
|
||||
expect(match(37).toBeLessThan(37)).toEqual(false);
|
||||
});
|
||||
|
||||
it("toBeLessThan to build an ExpectationResult", function() {
|
||||
var actual = 3;
|
||||
var matcher = match(actual);
|
||||
var expected = 1;
|
||||
matcher.toBeLessThan(expected);
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toBeLessThan");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toMatch(jasmine.pp(actual) + ' to be less than');
|
||||
expect(result.message).toMatch(jasmine.pp(expected));
|
||||
expect(result.actual).toEqual(actual);
|
||||
expect(result.expected).toEqual(expected);
|
||||
});
|
||||
|
||||
it("toBeGreaterThan should pass if actual is greater than expected", function() {
|
||||
expect(match(37).toBeGreaterThan(42)).toEqual(false);
|
||||
expect(match(37).toBeGreaterThan(-42)).toEqual(true);
|
||||
expect(match(37).toBeGreaterThan(37)).toEqual(false);
|
||||
});
|
||||
|
||||
it("toBeGreaterThan to build an ExpectationResult", function() {
|
||||
var actual = 1;
|
||||
var matcher = match(actual);
|
||||
var expected = 3;
|
||||
matcher.toBeGreaterThan(expected);
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toBeGreaterThan");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toMatch(jasmine.pp(actual) + ' to be greater than');
|
||||
expect(result.message).toMatch(jasmine.pp(expected));
|
||||
expect(result.actual).toEqual(actual);
|
||||
expect(result.expected).toEqual(expected);
|
||||
});
|
||||
|
||||
it("toThrow", function() {
|
||||
var expected = match(function() {
|
||||
throw new Error("Fake Error");
|
||||
});
|
||||
expect(expected.toThrow()).toEqual(true);
|
||||
expect(expected.toThrow("Fake Error")).toEqual(true);
|
||||
expect(expected.toThrow(new Error("Fake Error"))).toEqual(true);
|
||||
|
||||
expect(expected.toThrow("Other Error")).toEqual(false);
|
||||
var result = lastResult();
|
||||
expect(result.message).toMatch("Other Error");
|
||||
|
||||
expect(expected.toThrow(new Error("Other Error"))).toEqual(false);
|
||||
result = lastResult();
|
||||
expect(result.message).toMatch("Other Error");
|
||||
|
||||
var exception;
|
||||
try {
|
||||
(function () {
|
||||
new jasmine.Matchers(env, 'not-a-function', spec).toThrow();
|
||||
})();
|
||||
} catch (e) {
|
||||
exception = e;
|
||||
}
|
||||
|
||||
expect(exception).toBeDefined();
|
||||
expect(exception.message).toEqual('Actual is not a function');
|
||||
|
||||
|
||||
expect(match(function() {
|
||||
}).toThrow()).toEqual(false);
|
||||
result = lastResult();
|
||||
expect(result.message).toEqual('Expected function to throw an exception.');
|
||||
});
|
||||
|
||||
describe(".not.matcher", function() {
|
||||
it("should invert the sense of any matcher", function() {
|
||||
expect(match(37).not.toBeGreaterThan(42)).toEqual(true);
|
||||
expect(match(42).not.toBeGreaterThan(37)).toEqual(false);
|
||||
expect(match("abc").not.toEqual("def")).toEqual(true);
|
||||
expect(match("abc").not.toEqual("abc")).toEqual(false);
|
||||
});
|
||||
|
||||
it("should provide an inverted default message", function() {
|
||||
match(37).not.toBeGreaterThan(42);
|
||||
expect(lastResult().message).toEqual("Passed.");
|
||||
|
||||
match(42).not.toBeGreaterThan(37);
|
||||
expect(lastResult().message).toEqual("Expected 42 not to be greater than 37.");
|
||||
});
|
||||
|
||||
it("should use the second message when the matcher sets an array of custom messages", function() {
|
||||
spec.addMatchers({
|
||||
custom: function() {
|
||||
this.message = function() {
|
||||
return ['Expected it was called.', 'Expected it wasn\'t called.'];
|
||||
};
|
||||
return this.actual;
|
||||
}
|
||||
});
|
||||
|
||||
match(true).custom();
|
||||
expect(lastResult().message).toEqual("Passed.");
|
||||
match(false).custom();
|
||||
expect(lastResult().message).toEqual("Expected it was called.");
|
||||
match(true).not.custom();
|
||||
expect(lastResult().message).toEqual("Expected it wasn't called.");
|
||||
match(false).not.custom();
|
||||
expect(lastResult().message).toEqual("Passed.");
|
||||
});
|
||||
});
|
||||
|
||||
describe("spy matchers >>", function() {
|
||||
var TestClass;
|
||||
beforeEach(function() {
|
||||
TestClass = {
|
||||
normalFunction: function() {
|
||||
},
|
||||
spyFunction: jasmine.createSpy("My spy")
|
||||
};
|
||||
});
|
||||
|
||||
function shouldThrowAnExceptionWhenInvokedOnANonSpy(methodName) {
|
||||
return function() {
|
||||
expect(function() {
|
||||
match(TestClass.normalFunction)[methodName]();
|
||||
}).toThrow('Expected a spy, but got Function.');
|
||||
|
||||
expect(function() {
|
||||
match(jasmine.undefined)[methodName]();
|
||||
}).toThrow('Expected a spy, but got undefined.');
|
||||
|
||||
expect(function() {
|
||||
match({some:'object'})[methodName]();
|
||||
}).toThrow('Expected a spy, but got { some : \'object\' }.');
|
||||
|
||||
expect(function() {
|
||||
match("<b>")[methodName]();
|
||||
}).toThrow('Expected a spy, but got \'<b>\'.');
|
||||
};
|
||||
}
|
||||
|
||||
describe("toHaveBeenCalled", function() {
|
||||
it("should pass if the spy was called", function() {
|
||||
expect(match(TestClass.spyFunction).toHaveBeenCalled()).toEqual(false);
|
||||
|
||||
TestClass.spyFunction();
|
||||
expect(match(TestClass.spyFunction).toHaveBeenCalled()).toEqual(true);
|
||||
});
|
||||
|
||||
it("should throw an exception when invoked with any arguments", function() {
|
||||
expect(function() {
|
||||
match(TestClass.normalFunction).toHaveBeenCalled("unwanted argument");
|
||||
}).toThrow('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith');
|
||||
});
|
||||
|
||||
it('should throw an exception when invoked on a non-spy', shouldThrowAnExceptionWhenInvokedOnANonSpy('toHaveBeenCalled'));
|
||||
});
|
||||
|
||||
describe("wasCalled", function() {
|
||||
it("should alias toHaveBeenCalled", function() {
|
||||
spyOn(TestClass, 'normalFunction');
|
||||
|
||||
TestClass.normalFunction();
|
||||
|
||||
expect(TestClass.normalFunction).wasCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("wasNotCalled", function() {
|
||||
it("should pass iff the spy was not called", function() {
|
||||
expect(match(TestClass.spyFunction).wasNotCalled()).toEqual(true);
|
||||
|
||||
TestClass.spyFunction();
|
||||
expect(match(TestClass.spyFunction).wasNotCalled()).toEqual(false);
|
||||
});
|
||||
|
||||
it("should throw an exception when invoked with any arguments", function() {
|
||||
expect(function() {
|
||||
match(TestClass.normalFunction).wasNotCalled("unwanted argument");
|
||||
}).toThrow('wasNotCalled does not take arguments');
|
||||
});
|
||||
|
||||
it('should throw an exception when invoked on a non-spy', shouldThrowAnExceptionWhenInvokedOnANonSpy('wasNotCalled'));
|
||||
});
|
||||
|
||||
describe("toHaveBeenCalledWith", function() {
|
||||
it('toHaveBeenCalledWith should return true if it was called with the expected args', function() {
|
||||
TestClass.spyFunction('a', 'b', 'c');
|
||||
expect(match(TestClass.spyFunction).toHaveBeenCalledWith('a', 'b', 'c')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should return false if it was not called with the expected args', function() {
|
||||
TestClass.spyFunction('a', 'b', 'c');
|
||||
var expected = match(TestClass.spyFunction);
|
||||
expect(expected.toHaveBeenCalledWith('c', 'b', 'a')).toEqual(false);
|
||||
var result = lastResult();
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.expected).toEqual(['c', 'b', 'a']);
|
||||
expect(result.actual.mostRecentCall.args).toEqual(['a', 'b', 'c']);
|
||||
expect(result.message).toContain(jasmine.pp(result.expected));
|
||||
expect(result.message).toContain(jasmine.pp(result.actual.mostRecentCall.args));
|
||||
});
|
||||
|
||||
it('should return false if it was not called', function() {
|
||||
var expected = match(TestClass.spyFunction);
|
||||
expect(expected.toHaveBeenCalledWith('c', 'b', 'a')).toEqual(false);
|
||||
var result = lastResult();
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.expected).toEqual(['c', 'b', 'a']);
|
||||
expect(result.actual.argsForCall).toEqual([]);
|
||||
expect(result.message).toContain(jasmine.pp(result.expected));
|
||||
});
|
||||
|
||||
it('should allow matches across multiple calls', function() {
|
||||
var expected = match(TestClass.spyFunction);
|
||||
TestClass.spyFunction('a', 'b', 'c');
|
||||
TestClass.spyFunction('d', 'e', 'f');
|
||||
expect(expected.toHaveBeenCalledWith('a', 'b', 'c')).toEqual(true);
|
||||
expect(expected.toHaveBeenCalledWith('d', 'e', 'f')).toEqual(true);
|
||||
expect(expected.toHaveBeenCalledWith('x', 'y', 'z')).toEqual(false);
|
||||
});
|
||||
|
||||
it('should throw an exception when invoked on a non-spy', shouldThrowAnExceptionWhenInvokedOnANonSpy('toHaveBeenCalledWith'));
|
||||
|
||||
describe("to build an ExpectationResult", function () {
|
||||
beforeEach(function() {
|
||||
var currentSuite;
|
||||
var spec;
|
||||
currentSuite = env.describe('default current suite', function() {
|
||||
spec = env.it();
|
||||
}, spec);
|
||||
TestClass = { someFunction: function(a, b) {
|
||||
} };
|
||||
spec.spyOn(TestClass, 'someFunction');
|
||||
});
|
||||
|
||||
it("should should handle the case of a spy", function() {
|
||||
TestClass.someFunction('a', 'c');
|
||||
var matcher = match(TestClass.someFunction);
|
||||
matcher.toHaveBeenCalledWith('a', 'b');
|
||||
|
||||
var result = lastResult();
|
||||
expect(result.matcherName).toEqual("toHaveBeenCalledWith");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toContain(jasmine.pp(['a', 'b']));
|
||||
expect(result.message).toContain(jasmine.pp(['a', 'c']));
|
||||
expect(result.actual).toEqual(TestClass.someFunction);
|
||||
expect(result.expected).toEqual(['a','b']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("wasCalledWith", function() {
|
||||
it("should alias toHaveBeenCalledWith", function() {
|
||||
spyOn(TestClass, 'normalFunction');
|
||||
|
||||
TestClass.normalFunction(123);
|
||||
|
||||
expect(TestClass.normalFunction).wasCalledWith(123);
|
||||
});
|
||||
});
|
||||
|
||||
describe("wasNotCalledWith", function() {
|
||||
it('should return true if the spy was NOT called with the expected args', function() {
|
||||
TestClass.spyFunction('a', 'b', 'c');
|
||||
expect(match(TestClass.spyFunction).wasNotCalledWith('c', 'b', 'a')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should return false if it WAS called with the expected args', function() {
|
||||
TestClass.spyFunction('a', 'b', 'c');
|
||||
var expected = match(TestClass.spyFunction);
|
||||
expect(expected.wasNotCalledWith('a', 'b', 'c')).toEqual(false);
|
||||
var result = lastResult();
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.expected).toEqual(['a', 'b', 'c']);
|
||||
expect(result.actual.mostRecentCall.args).toEqual(['a', 'b', 'c']);
|
||||
expect(result.message).toContain(jasmine.pp(result.expected));
|
||||
});
|
||||
|
||||
it('should return true if it was not called', function() {
|
||||
var expected = match(TestClass.spyFunction);
|
||||
expect(expected.wasNotCalledWith('c', 'b', 'a')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should allow matches across multiple calls', function() {
|
||||
var expected = match(TestClass.spyFunction);
|
||||
TestClass.spyFunction('a', 'b', 'c');
|
||||
TestClass.spyFunction('d', 'e', 'f');
|
||||
expect(expected.wasNotCalledWith('a', 'b', 'c')).toEqual(false);
|
||||
expect(expected.wasNotCalledWith('d', 'e', 'f')).toEqual(false);
|
||||
expect(expected.wasNotCalledWith('x', 'y', 'z')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should throw an exception when invoked on a non-spy', shouldThrowAnExceptionWhenInvokedOnANonSpy('wasNotCalledWith'));
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
@@ -1,301 +0,0 @@
|
||||
describe("jasmine.Matchers", function() {
|
||||
var env;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
});
|
||||
|
||||
function match(value) {
|
||||
return new jasmine.Matchers(env, value);
|
||||
}
|
||||
|
||||
function detailsFor(actual, matcherName, matcherArgs) {
|
||||
var matcher = match(actual);
|
||||
matcher[matcherName].apply(matcher, matcherArgs);
|
||||
expect(matcher.getResults().getItems().length).toEqual(1);
|
||||
return matcher.getResults().getItems()[0].details;
|
||||
}
|
||||
|
||||
it("toEqual with primitives, objects, dates, html nodes, etc.", function() {
|
||||
expect(match(true).toEqual(true)).toEqual(true);
|
||||
|
||||
expect(match({foo:'bar'}).toEqual(null)).toEqual(false);
|
||||
|
||||
var functionA = function() { return 'hi'; };
|
||||
var functionB = function() { return 'hi'; };
|
||||
expect(match({foo:functionA}).toEqual({foo:functionB})).toEqual(false);
|
||||
expect(match({foo:functionA}).toEqual({foo:functionA})).toEqual(true);
|
||||
|
||||
expect((match(false).toEqual(true))).toEqual(false);
|
||||
|
||||
var circularGraph = {};
|
||||
circularGraph.referenceToSelf = circularGraph;
|
||||
expect((match(circularGraph).toEqual(circularGraph))).toEqual(true);
|
||||
|
||||
var nodeA = document.createElement('div');
|
||||
var nodeB = document.createElement('div');
|
||||
expect((match(nodeA).toEqual(nodeA))).toEqual(true);
|
||||
expect((match(nodeA).toEqual(nodeB))).toEqual(false);
|
||||
|
||||
expect((match(new Date(2008, 1, 3, 15, 17, 19, 1234)).toEqual(new Date(2009, 1, 3, 15, 17, 19, 1234)))).toEqual(false);
|
||||
expect((match(new Date(2008, 1, 3, 15, 17, 19, 1234)).toEqual(new Date(2008, 1, 3, 15, 17, 19, 1234)))).toEqual(true);
|
||||
|
||||
|
||||
expect(match(true).toNotEqual(false)).toEqual(true);
|
||||
expect((match(true).toNotEqual(true))).toEqual(false);
|
||||
|
||||
expect((match(['a', 'b']).toEqual(['a', undefined]))).toEqual(false);
|
||||
expect((match(['a', 'b']).toEqual(['a', 'b', undefined]))).toEqual(false);
|
||||
});
|
||||
|
||||
it('toBe should return true only if the expected and actual items === each other', function() {
|
||||
var a = {};
|
||||
var b = {};
|
||||
//noinspection UnnecessaryLocalVariableJS
|
||||
var c = a;
|
||||
expect((match(a).toBe(b))).toEqual(false);
|
||||
expect((match(a).toBe(a))).toEqual(true);
|
||||
expect((match(a).toBe(c))).toEqual(true);
|
||||
expect((match(a).toNotBe(b))).toEqual(true);
|
||||
expect((match(a).toNotBe(a))).toEqual(false);
|
||||
expect((match(a).toNotBe(c))).toEqual(false);
|
||||
});
|
||||
|
||||
|
||||
it("toMatch and #toNotMatch should perform regular expression matching on strings", function() {
|
||||
expect((match('foobarbel').toMatch(/bar/))).toEqual(true);
|
||||
expect((match('foobazbel').toMatch(/bar/))).toEqual(false);
|
||||
|
||||
expect((match('foobarbel').toMatch("bar"))).toEqual(true);
|
||||
expect((match('foobazbel').toMatch("bar"))).toEqual(false);
|
||||
|
||||
expect((match('foobarbel').toNotMatch(/bar/))).toEqual(false);
|
||||
expect((match('foobazbel').toNotMatch(/bar/))).toEqual(true);
|
||||
|
||||
expect((match('foobarbel').toNotMatch("bar"))).toEqual(false);
|
||||
expect((match('foobazbel').toNotMatch("bar"))).toEqual(true);
|
||||
});
|
||||
|
||||
it("toBeDefined", function() {
|
||||
expect(match('foo').toBeDefined()).toEqual(true);
|
||||
expect(match(undefined).toBeDefined()).toEqual(false);
|
||||
});
|
||||
|
||||
it("toBeNull", function() {
|
||||
expect(match(null).toBeNull()).toEqual(true);
|
||||
expect(match(undefined).toBeNull()).toEqual(false);
|
||||
expect(match("foo").toBeNull()).toEqual(false);
|
||||
});
|
||||
|
||||
it("toBeFalsy", function() {
|
||||
expect(match(false).toBeFalsy()).toEqual(true);
|
||||
expect(match(true).toBeFalsy()).toEqual(false);
|
||||
expect(match(undefined).toBeFalsy()).toEqual(true);
|
||||
expect(match(0).toBeFalsy()).toEqual(true);
|
||||
expect(match("").toBeFalsy()).toEqual(true);
|
||||
});
|
||||
|
||||
it("toBeTruthy", function() {
|
||||
expect(match(false).toBeTruthy()).toEqual(false);
|
||||
expect(match(true).toBeTruthy()).toEqual(true);
|
||||
expect(match(undefined).toBeTruthy()).toEqual(false);
|
||||
expect(match(0).toBeTruthy()).toEqual(false);
|
||||
expect(match("").toBeTruthy()).toEqual(false);
|
||||
expect(match("hi").toBeTruthy()).toEqual(true);
|
||||
expect(match(5).toBeTruthy()).toEqual(true);
|
||||
expect(match({foo: 1}).toBeTruthy()).toEqual(true);
|
||||
});
|
||||
|
||||
it("toEqual", function() {
|
||||
expect(match(undefined).toEqual(undefined)).toEqual(true);
|
||||
expect(match({foo:'bar'}).toEqual({foo:'bar'})).toEqual(true);
|
||||
expect(match("foo").toEqual({bar: undefined})).toEqual(false);
|
||||
expect(match({foo: undefined}).toEqual("goo")).toEqual(false);
|
||||
expect(match({foo: {bar :undefined}}).toEqual("goo")).toEqual(false);
|
||||
});
|
||||
|
||||
it("toEqual with jasmine.any()", function() {
|
||||
expect(match("foo").toEqual(jasmine.any(String))).toEqual(true);
|
||||
expect(match(3).toEqual(jasmine.any(Number))).toEqual(true);
|
||||
expect(match("foo").toEqual(jasmine.any(Function))).toEqual(false);
|
||||
expect(match("foo").toEqual(jasmine.any(Object))).toEqual(false);
|
||||
expect(match({someObj:'foo'}).toEqual(jasmine.any(Object))).toEqual(true);
|
||||
expect(match({someObj:'foo'}).toEqual(jasmine.any(Function))).toEqual(false);
|
||||
expect(match(function() {}).toEqual(jasmine.any(Object))).toEqual(false);
|
||||
expect(match(["foo", "goo"]).toEqual(["foo", jasmine.any(String)])).toEqual(true);
|
||||
expect(match(function() {}).toEqual(jasmine.any(Function))).toEqual(true);
|
||||
expect(match(["a", function() {}]).toEqual(["a", jasmine.any(Function)])).toEqual(true);
|
||||
});
|
||||
|
||||
it("toEqual handles circular objects ok", function() {
|
||||
expect(match({foo: "bar", baz: undefined}).toEqual({foo: "bar", baz: undefined})).toEqual(true);
|
||||
expect(match({foo:['bar','baz','quux']}).toEqual({foo:['bar','baz','quux']})).toEqual(true);
|
||||
expect(match({foo: {bar:'baz'}, quux:'corge'}).toEqual({foo:{bar:'baz'}, quux:'corge'})).toEqual(true);
|
||||
|
||||
var circularObject = {};
|
||||
var secondCircularObject = {};
|
||||
circularObject.field = circularObject;
|
||||
secondCircularObject.field = secondCircularObject;
|
||||
expect(match(circularObject).toEqual(secondCircularObject)).toEqual(true);
|
||||
});
|
||||
|
||||
it("toNotEqual as slightly surprising behavior, but is it intentional?", function() {
|
||||
expect(match({x:"x", y:"y", z:"w"}).toNotEqual({x:"x", y:"y", z:"z"})).toEqual(true);
|
||||
expect(match({x:"x", y:"y", w:"z"}).toNotEqual({x:"x", y:"y", z:"z"})).toEqual(true);
|
||||
expect(match({x:"x", y:"y", z:"z"}).toNotEqual({w: "w", x:"x", y:"y", z:"z"})).toEqual(true);
|
||||
expect(match({w: "w", x:"x", y:"y", z:"z"}).toNotEqual({x:"x", y:"y", z:"z"})).toEqual(true);
|
||||
});
|
||||
|
||||
it("toEqual handles arrays", function() {
|
||||
expect(match([1, "A"]).toEqual([1, "A"])).toEqual(true);
|
||||
});
|
||||
|
||||
it("toContain and toNotContain", function() {
|
||||
expect(match('ABC').toContain('A')).toEqual(true);
|
||||
expect(match('ABC').toContain('X')).toEqual(false);
|
||||
|
||||
expect(match(['A', 'B', 'C']).toContain('A')).toEqual(true);
|
||||
expect(match(['A', 'B', 'C']).toContain('F')).toEqual(false);
|
||||
expect(match(['A', 'B', 'C']).toNotContain('F')).toEqual(true);
|
||||
expect(match(['A', 'B', 'C']).toNotContain('A')).toEqual(false);
|
||||
|
||||
expect(match(['A', {some:'object'}, 'C']).toContain({some:'object'})).toEqual(true);
|
||||
expect(match(['A', {some:'object'}, 'C']).toContain({some:'other object'})).toEqual(false);
|
||||
|
||||
expect(detailsFor('abc', 'toContain', ['x'])).toEqual({
|
||||
matcherName: 'toContain', expected: 'x', actual: 'abc'
|
||||
});
|
||||
});
|
||||
|
||||
it("toThrow", function() {
|
||||
var expected = new jasmine.Matchers(env, function() {
|
||||
throw new Error("Fake Error");
|
||||
});
|
||||
expect(expected.toThrow()).toEqual(true);
|
||||
expect(expected.toThrow("Fake Error")).toEqual(true);
|
||||
expect(expected.toThrow(new Error("Fake Error"))).toEqual(true);
|
||||
expect(expected.toThrow("Other Error")).toEqual(false);
|
||||
expect(expected.toThrow(new Error("Other Error"))).toEqual(false);
|
||||
|
||||
expect(match(function() {}).toThrow()).toEqual(false);
|
||||
});
|
||||
|
||||
it("wasCalled, wasNotCalled, wasCalledWith", function() {
|
||||
var currentSuite;
|
||||
var spec;
|
||||
currentSuite = env.describe('default current suite', function() {
|
||||
spec = env.it();
|
||||
});
|
||||
|
||||
var TestClass = { someFunction: function() {
|
||||
} };
|
||||
|
||||
var expected;
|
||||
expect(match(TestClass.someFunction).wasCalled()).toEqual(false);
|
||||
expect(match(TestClass.someFunction).wasNotCalled()).toEqual(false);
|
||||
|
||||
spec.spyOn(TestClass, 'someFunction');
|
||||
|
||||
expect(match(TestClass.someFunction).wasCalled()).toEqual(false);
|
||||
expect(match(TestClass.someFunction).wasNotCalled()).toEqual(true);
|
||||
|
||||
|
||||
TestClass.someFunction();
|
||||
expect(match(TestClass.someFunction).wasCalled()).toEqual(true);
|
||||
expect(match(TestClass.someFunction).wasCalled('some arg')).toEqual(false);
|
||||
expect(match(TestClass.someFunction).wasNotCalled()).toEqual(false);
|
||||
|
||||
TestClass.someFunction('a', 'b', 'c');
|
||||
expect(match(TestClass.someFunction).wasCalledWith('a', 'b', 'c')).toEqual(true);
|
||||
|
||||
expected = match(TestClass.someFunction);
|
||||
expect(expected.wasCalledWith('c', 'b', 'a')).toEqual(false);
|
||||
expect(expected.getResults().getItems()[0].passed).toEqual(false);
|
||||
|
||||
TestClass.someFunction.reset();
|
||||
TestClass.someFunction('a', 'b', 'c');
|
||||
TestClass.someFunction('d', 'e', 'f');
|
||||
expect(expected.wasCalledWith('a', 'b', 'c')).toEqual(true);
|
||||
expect(expected.wasCalledWith('d', 'e', 'f')).toEqual(true);
|
||||
expect(expected.wasCalledWith('x', 'y', 'z')).toEqual(false);
|
||||
|
||||
expect(detailsFor(TestClass.someFunction, 'wasCalledWith', ['x', 'y', 'z'])).toEqual({
|
||||
matcherName: 'wasCalledWith', expected: ['x', 'y', 'z'], actual: TestClass.someFunction.argsForCall
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it("should report mismatches in some nice way", function() {
|
||||
var results = new jasmine.NestedResults();
|
||||
var expected = new jasmine.Matchers(env, true, results);
|
||||
expected.toEqual(true);
|
||||
expected.toEqual(false);
|
||||
|
||||
expect(results.getItems().length).toEqual(2);
|
||||
|
||||
expect(results.getItems()[0].passed).toEqual(true);
|
||||
|
||||
expect(results.getItems()[1].passed).toEqual(false);
|
||||
|
||||
results = new jasmine.NestedResults();
|
||||
expected = new jasmine.Matchers(env, false, results);
|
||||
expected.toEqual(true);
|
||||
|
||||
var expectedMessage = 'Expected<br /><br />true<br /><br />but got<br /><br />false<br />';
|
||||
expect(results.getItems()[0].message).toEqual(expectedMessage);
|
||||
|
||||
results = new jasmine.NestedResults();
|
||||
expected = new jasmine.Matchers(env, null, results);
|
||||
expected.toEqual('not null');
|
||||
|
||||
expectedMessage = 'Expected<br /><br />\'not null\'<br /><br />but got<br /><br />null<br />';
|
||||
expect(results.getItems()[0].message).toEqual(expectedMessage);
|
||||
|
||||
results = new jasmine.NestedResults();
|
||||
expected = new jasmine.Matchers(env, undefined, results);
|
||||
expected.toEqual('not undefined');
|
||||
|
||||
expectedMessage = 'Expected<br /><br />\'not undefined\'<br /><br />but got<br /><br />undefined<br />';
|
||||
expect(results.getItems()[0].message).toEqual(expectedMessage);
|
||||
|
||||
|
||||
results = new jasmine.NestedResults();
|
||||
expected = new jasmine.Matchers(env, {foo:'one',baz:'two', more: 'blah'}, results);
|
||||
expected.toEqual({foo:'one', bar: '<b>three</b> &', baz: '2'});
|
||||
|
||||
expectedMessage =
|
||||
"Expected<br /><br />{ foo : 'one', bar : '<b>three</b> &', baz : '2' }<br /><br />but got<br /><br />{ foo : 'one', baz : 'two', more : 'blah' }<br />" +
|
||||
"<br /><br />Different Keys:<br />" +
|
||||
"expected has key 'bar', but missing from <b>actual</b>.<br />" +
|
||||
"<b>expected</b> missing key 'more', but present in actual.<br />" +
|
||||
"<br /><br />Different Values:<br />" +
|
||||
"'bar' was<br /><br />'<b>three</b> &'<br /><br />in expected, but was<br /><br />'undefined'<br /><br />in actual.<br /><br />" +
|
||||
"'baz' was<br /><br />'2'<br /><br />in expected, but was<br /><br />'two'<br /><br />in actual.<br /><br />";
|
||||
var actualMessage = results.getItems()[0].message;
|
||||
expect(actualMessage).toEqual(expectedMessage);
|
||||
|
||||
|
||||
results = new jasmine.NestedResults();
|
||||
expected = new jasmine.Matchers(env, true, results);
|
||||
expected.toEqual(true);
|
||||
|
||||
expect(results.getItems()[0].message).toEqual('Passed.');
|
||||
|
||||
|
||||
expected = new jasmine.Matchers(env, [1, 2, 3], results);
|
||||
results.getItems().length = 0;
|
||||
expected.toEqual([1, 2, 3]);
|
||||
expect(results.getItems()[0].passed).toEqual(true);
|
||||
|
||||
expected = new jasmine.Matchers(env, [1, 2, 3], results);
|
||||
results.getItems().length = 0;
|
||||
expected.toEqual([{}, {}, {}]);
|
||||
expect(results.getItems()[0].passed).toEqual(false);
|
||||
|
||||
expected = new jasmine.Matchers(env, [{}, {}, {}], results);
|
||||
results.getItems().length = 0;
|
||||
expected.toEqual([1, 2, 3]);
|
||||
expect(results.getItems()[0].passed).toEqual(false);
|
||||
});
|
||||
|
||||
});
|
||||
38
spec/suites/MockClockSpec.js
Normal file
38
spec/suites/MockClockSpec.js
Normal file
@@ -0,0 +1,38 @@
|
||||
describe("MockClock", function () {
|
||||
|
||||
beforeEach(function() {
|
||||
jasmine.Clock.useMock();
|
||||
});
|
||||
|
||||
describe("setTimeout", function () {
|
||||
it("should mock the clock when useMock is in a beforeEach", function() {
|
||||
var expected = false;
|
||||
setTimeout(function() {
|
||||
expected = true;
|
||||
}, 30000);
|
||||
expect(expected).toBe(false);
|
||||
jasmine.Clock.tick(30001);
|
||||
expect(expected).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("setInterval", function () {
|
||||
it("should mock the clock when useMock is in a beforeEach", function() {
|
||||
var interval = 0;
|
||||
setInterval(function() {
|
||||
interval++;
|
||||
}, 30000);
|
||||
expect(interval).toEqual(0);
|
||||
jasmine.Clock.tick(30001);
|
||||
expect(interval).toEqual(1);
|
||||
jasmine.Clock.tick(30001);
|
||||
expect(interval).toEqual(2);
|
||||
jasmine.Clock.tick(1);
|
||||
expect(interval).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
it("shouldn't complain if you call jasmine.Clock.useMock() more than once", function() {
|
||||
jasmine.Clock.useMock();
|
||||
});
|
||||
});
|
||||
45
spec/suites/MultiReporterSpec.js
Normal file
45
spec/suites/MultiReporterSpec.js
Normal file
@@ -0,0 +1,45 @@
|
||||
describe("jasmine.MultiReporter", function() {
|
||||
var multiReporter, fakeReporter1, fakeReporter2;
|
||||
|
||||
beforeEach(function() {
|
||||
multiReporter = new jasmine.MultiReporter();
|
||||
fakeReporter1 = jasmine.createSpyObj("fakeReporter1", ["reportSpecResults"]);
|
||||
fakeReporter2 = jasmine.createSpyObj("fakeReporter2", ["reportSpecResults", "reportRunnerStarting"]);
|
||||
multiReporter.addReporter(fakeReporter1);
|
||||
multiReporter.addReporter(fakeReporter2);
|
||||
});
|
||||
|
||||
it("should support all the method calls that jasmine.Reporter supports", function() {
|
||||
var delegate = {};
|
||||
multiReporter.addReporter(delegate);
|
||||
|
||||
this.addMatchers({
|
||||
toDelegateMethod: function(methodName) {
|
||||
delegate[methodName] = jasmine.createSpy(methodName);
|
||||
this.actual[methodName]("whatever argument");
|
||||
|
||||
return delegate[methodName].wasCalled
|
||||
&& delegate[methodName].mostRecentCall.args.length == 1
|
||||
&& delegate[methodName].mostRecentCall.args[0] == "whatever argument";
|
||||
}
|
||||
});
|
||||
|
||||
expect(multiReporter).toDelegateMethod('reportRunnerStarting');
|
||||
expect(multiReporter).toDelegateMethod('reportRunnerResults');
|
||||
expect(multiReporter).toDelegateMethod('reportSuiteResults');
|
||||
expect(multiReporter).toDelegateMethod('reportSpecStarting');
|
||||
expect(multiReporter).toDelegateMethod('reportSpecResults');
|
||||
expect(multiReporter).toDelegateMethod('log');
|
||||
});
|
||||
|
||||
it("should delegate to any and all subreporters", function() {
|
||||
multiReporter.reportSpecResults('blah', 'foo');
|
||||
expect(fakeReporter1.reportSpecResults).toHaveBeenCalledWith('blah', 'foo');
|
||||
expect(fakeReporter2.reportSpecResults).toHaveBeenCalledWith('blah', 'foo');
|
||||
});
|
||||
|
||||
it("should quietly skip delegating to any subreporters which lack the given method", function() {
|
||||
multiReporter.reportRunnerStarting('blah', 'foo');
|
||||
expect(fakeReporter2.reportRunnerStarting).toHaveBeenCalledWith('blah', 'foo');
|
||||
});
|
||||
});
|
||||
@@ -1,30 +0,0 @@
|
||||
describe("jasmine.MultiReporter", function() {
|
||||
var multiReporter, fakeReporter1, fakeReporter2;
|
||||
|
||||
beforeEach(function() {
|
||||
multiReporter = new jasmine.MultiReporter();
|
||||
fakeReporter1 = jasmine.createSpyObj("fakeReporter1", ["reportSpecResults"]);
|
||||
fakeReporter2 = jasmine.createSpyObj("fakeReporter2", ["reportSpecResults", "reportRunnerStarting"]);
|
||||
multiReporter.addReporter(fakeReporter1);
|
||||
multiReporter.addReporter(fakeReporter2);
|
||||
});
|
||||
|
||||
it("should support all the method calls that jasmine.Reporter supports", function() {
|
||||
multiReporter.reportRunnerStarting();
|
||||
multiReporter.reportRunnerResults();
|
||||
multiReporter.reportSuiteResults();
|
||||
multiReporter.reportSpecResults();
|
||||
multiReporter.log();
|
||||
});
|
||||
|
||||
it("should delegate to any and all subreporters", function() {
|
||||
multiReporter.reportSpecResults('blah', 'foo');
|
||||
expect(fakeReporter1.reportSpecResults).wasCalledWith('blah', 'foo');
|
||||
expect(fakeReporter2.reportSpecResults).wasCalledWith('blah', 'foo');
|
||||
});
|
||||
|
||||
it("should quietly skip delegating to any subreporters which lack the given method", function() {
|
||||
multiReporter.reportRunnerStarting('blah', 'foo');
|
||||
expect(fakeReporter2.reportRunnerStarting).wasCalledWith('blah', 'foo');
|
||||
});
|
||||
});
|
||||
@@ -3,14 +3,18 @@ describe('jasmine.NestedResults', function() {
|
||||
// Leaf case
|
||||
var results = new jasmine.NestedResults();
|
||||
|
||||
results.addResult({passed: true, message: 'Passed.'});
|
||||
results.addResult(new jasmine.ExpectationResult({
|
||||
matcherName: "foo", passed: true, message: 'Passed.', actual: 'bar', expected: 'bar'}
|
||||
));
|
||||
|
||||
expect(results.getItems().length).toEqual(1);
|
||||
expect(results.totalCount).toEqual(1);
|
||||
expect(results.passedCount).toEqual(1);
|
||||
expect(results.failedCount).toEqual(0);
|
||||
|
||||
results.addResult({passed: false, message: 'FAIL.'});
|
||||
results.addResult(new jasmine.ExpectationResult({
|
||||
matcherName: "baz", passed: false, message: 'FAIL.', actual: "corge", expected: "quux"
|
||||
}));
|
||||
|
||||
expect(results.getItems().length).toEqual(2);
|
||||
expect(results.totalCount).toEqual(2);
|
||||
@@ -21,12 +25,21 @@ describe('jasmine.NestedResults', function() {
|
||||
it('should roll up counts for nested results', function() {
|
||||
// Branch case
|
||||
var leafResultsOne = new jasmine.NestedResults();
|
||||
leafResultsOne.addResult({passed: true, message: ''});
|
||||
leafResultsOne.addResult({passed: false, message: ''});
|
||||
leafResultsOne.addResult(new jasmine.ExpectationResult({
|
||||
matcherName: "toSomething", passed: true, message: 'message', actual: '', expected:''
|
||||
}));
|
||||
|
||||
leafResultsOne.addResult(new jasmine.ExpectationResult({
|
||||
matcherName: "toSomethingElse", passed: false, message: 'message', actual: 'a', expected: 'b'
|
||||
}));
|
||||
|
||||
var leafResultsTwo = new jasmine.NestedResults();
|
||||
leafResultsTwo.addResult({passed: true, message: ''});
|
||||
leafResultsTwo.addResult({passed: false, message: ''});
|
||||
leafResultsTwo.addResult(new jasmine.ExpectationResult({
|
||||
matcherName: "toSomething", passed: true, message: 'message', actual: '', expected: ''
|
||||
}));
|
||||
leafResultsTwo.addResult(new jasmine.ExpectationResult({
|
||||
matcherName: "toSomethineElse", passed: false, message: 'message', actual: 'c', expected: 'd'
|
||||
}));
|
||||
|
||||
var branchResults = new jasmine.NestedResults();
|
||||
branchResults.addResult(leafResultsOne);
|
||||
@@ -38,4 +51,4 @@ describe('jasmine.NestedResults', function() {
|
||||
expect(branchResults.failedCount).toEqual(2);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
@@ -8,14 +8,14 @@ describe("jasmine.pp", function () {
|
||||
expect(jasmine.pp(true)).toEqual("true");
|
||||
expect(jasmine.pp(false)).toEqual("false");
|
||||
expect(jasmine.pp(null)).toEqual("null");
|
||||
expect(jasmine.pp(undefined)).toEqual("undefined");
|
||||
expect(jasmine.pp(jasmine.undefined)).toEqual("undefined");
|
||||
expect(jasmine.pp(3)).toEqual("3");
|
||||
expect(jasmine.pp(-3.14)).toEqual("-3.14");
|
||||
});
|
||||
|
||||
it("should stringify arrays properly", function() {
|
||||
expect(jasmine.pp([1, 2])).toEqual("[ 1, 2 ]");
|
||||
expect(jasmine.pp([1, 'foo', {}, undefined, null])).toEqual("[ 1, 'foo', { }, undefined, null ]");
|
||||
expect(jasmine.pp([1, 'foo', {}, jasmine.undefined, null])).toEqual("[ 1, 'foo', { }, undefined, null ]");
|
||||
});
|
||||
|
||||
it("should indicate circular array references", function() {
|
||||
@@ -27,8 +27,13 @@ describe("jasmine.pp", function () {
|
||||
|
||||
it("should stringify objects properly", function() {
|
||||
expect(jasmine.pp({foo: 'bar'})).toEqual("{ foo : 'bar' }");
|
||||
expect(jasmine.pp({foo:'bar', baz:3, nullValue: null, undefinedValue: undefined})).toEqual("{ foo : 'bar', baz : 3, nullValue : null, undefinedValue : undefined }");
|
||||
expect(jasmine.pp({foo: function () { }, bar: [1, 2, 3]})).toEqual("{ foo : Function, bar : [ 1, 2, 3 ] }");
|
||||
expect(jasmine.pp({foo:'bar', baz:3, nullValue: null, undefinedValue: jasmine.undefined})).toEqual("{ foo : 'bar', baz : 3, nullValue : null, undefinedValue : undefined }");
|
||||
expect(jasmine.pp({foo: function () {
|
||||
}, bar: [1, 2, 3]})).toEqual("{ foo : Function, bar : [ 1, 2, 3 ] }");
|
||||
});
|
||||
|
||||
it("should stringify RegExp objects properly", function() {
|
||||
expect(jasmine.pp(/x|y|z/)).toEqual("/x|y|z/");
|
||||
});
|
||||
|
||||
it("should indicate circular object references", function() {
|
||||
@@ -39,8 +44,18 @@ describe("jasmine.pp", function () {
|
||||
|
||||
it("should indicate getters on objects as such", function() {
|
||||
var sampleValue = {id: 1};
|
||||
sampleValue.__defineGetter__('calculatedValue', function() { throw new Error("don't call me!"); });
|
||||
expect(jasmine.pp(sampleValue)).toEqual("{ id : 1, calculatedValue : <getter> }");
|
||||
if (sampleValue.__defineGetter__) {
|
||||
//not supported in IE!
|
||||
sampleValue.__defineGetter__('calculatedValue', function() {
|
||||
throw new Error("don't call me!");
|
||||
});
|
||||
}
|
||||
if (sampleValue.__defineGetter__) {
|
||||
expect(jasmine.pp(sampleValue)).toEqual("{ id : 1, calculatedValue : <getter> }");
|
||||
}
|
||||
else {
|
||||
expect(jasmine.pp(sampleValue)).toEqual("{ id : 1 }");
|
||||
}
|
||||
});
|
||||
|
||||
it("should stringify HTML nodes properly", function() {
|
||||
@@ -54,8 +69,24 @@ describe("jasmine.pp", function () {
|
||||
expect(jasmine.pp('some <b>html string</b> &', false)).toEqual('\'some <b>html string</b> &\'');
|
||||
});
|
||||
|
||||
it("should abbreviate window objects", function() {
|
||||
expect(jasmine.pp(window)).toEqual("<window>");
|
||||
it("should abbreviate the global (usually window) object", function() {
|
||||
expect(jasmine.pp(jasmine.getGlobal())).toEqual("<global>");
|
||||
});
|
||||
|
||||
it("should stringify Date objects properly", function() {
|
||||
var now = new Date();
|
||||
expect(jasmine.pp(now)).toEqual("Date(" + now.toString() + ")");
|
||||
});
|
||||
|
||||
it("should stringify spy objects properly", function() {
|
||||
var TestObject = {
|
||||
someFunction: function() {
|
||||
}
|
||||
};
|
||||
spyOn(TestObject, 'someFunction');
|
||||
expect(jasmine.pp(TestObject.someFunction)).toEqual("spy on someFunction");
|
||||
|
||||
expect(jasmine.pp(jasmine.createSpy("something"))).toEqual("spy on something");
|
||||
});
|
||||
|
||||
});
|
||||
23
spec/suites/QueueSpec.js
Normal file
23
spec/suites/QueueSpec.js
Normal file
@@ -0,0 +1,23 @@
|
||||
describe("jasmine.Queue", function() {
|
||||
it("should not call itself recursively, so we don't get stack overflow errors", function() {
|
||||
var queue = new jasmine.Queue(new jasmine.Env());
|
||||
queue.add(new jasmine.Block(null, function() {}));
|
||||
queue.add(new jasmine.Block(null, function() {}));
|
||||
queue.add(new jasmine.Block(null, function() {}));
|
||||
queue.add(new jasmine.Block(null, function() {}));
|
||||
|
||||
var nestCount = 0;
|
||||
var maxNestCount = 0;
|
||||
var nextCallCount = 0;
|
||||
queue.next_ = function() {
|
||||
nestCount++;
|
||||
if (nestCount > maxNestCount) maxNestCount = nestCount;
|
||||
|
||||
jasmine.Queue.prototype.next_.apply(queue, arguments);
|
||||
nestCount--;
|
||||
};
|
||||
|
||||
queue.start();
|
||||
expect(maxNestCount).toEqual(1);
|
||||
});
|
||||
});
|
||||
@@ -1,11 +1,13 @@
|
||||
describe('jasmine.Reporter', function() {
|
||||
var env;
|
||||
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
});
|
||||
|
||||
it('should ', function() {
|
||||
it('should get called from the test runner', function() {
|
||||
env.describe('Suite for JSON Reporter with Callbacks', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
@@ -31,23 +33,19 @@ describe('jasmine.Reporter', function() {
|
||||
var bar = 0;
|
||||
var baz = 0;
|
||||
|
||||
var specCallback = function (results) {
|
||||
foo++;
|
||||
};
|
||||
var suiteCallback = function (results) {
|
||||
bar++;
|
||||
};
|
||||
var runnerCallback = function (results) {
|
||||
baz++;
|
||||
};
|
||||
|
||||
env.reporter = jasmine.Reporters.reporter({
|
||||
specCallback: specCallback,
|
||||
suiteCallback: suiteCallback,
|
||||
runnerCallback: runnerCallback
|
||||
env.addReporter({
|
||||
reportSpecResults: function() {
|
||||
foo++;
|
||||
},
|
||||
reportSuiteResults: function() {
|
||||
bar++;
|
||||
},
|
||||
reportRunnerResults: function() {
|
||||
baz++;
|
||||
}
|
||||
});
|
||||
|
||||
var runner = env.currentRunner;
|
||||
var runner = env.currentRunner();
|
||||
runner.execute();
|
||||
|
||||
expect(foo).toEqual(3); // 'foo was expected to be 3, was ' + foo);
|
||||
267
spec/suites/RunnerSpec.js
Normal file
267
spec/suites/RunnerSpec.js
Normal file
@@ -0,0 +1,267 @@
|
||||
describe('RunnerTest', function() {
|
||||
var fakeTimer;
|
||||
var env;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
|
||||
fakeTimer = new jasmine.FakeTimer();
|
||||
env.setTimeout = fakeTimer.setTimeout;
|
||||
env.clearTimeout = fakeTimer.clearTimeout;
|
||||
env.setInterval = fakeTimer.setInterval;
|
||||
env.clearInterval = fakeTimer.clearInterval;
|
||||
});
|
||||
|
||||
describe('beforeEach', function() {
|
||||
it('should run before each spec for all suites', function () {
|
||||
var foo;
|
||||
env.beforeEach(function () {
|
||||
foo = 0;
|
||||
});
|
||||
|
||||
env.describe('suite 1', function () {
|
||||
env.it('test 1-1', function() {
|
||||
foo++;
|
||||
this.expect(foo).toEqual(1);
|
||||
});
|
||||
env.it('test 1-2', function() {
|
||||
foo++;
|
||||
this.expect(foo).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('suite 2', function () {
|
||||
env.it('test 2-1', function() {
|
||||
foo++;
|
||||
this.expect(foo).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
env.currentRunner().execute();
|
||||
|
||||
var runnerResults = env.currentRunner().results();
|
||||
expect(runnerResults.totalCount).toEqual(3);
|
||||
expect(runnerResults.passedCount).toEqual(3);
|
||||
});
|
||||
|
||||
|
||||
it('should provide all specs', function () {
|
||||
var foo;
|
||||
env.beforeEach(function () {
|
||||
foo = 0;
|
||||
});
|
||||
|
||||
env.describe('suite 1', function () {
|
||||
env.it('test 1-1', function() {
|
||||
foo++;
|
||||
this.expect(foo).toEqual(1);
|
||||
});
|
||||
env.it('test 1-2', function() {
|
||||
foo++;
|
||||
this.expect(foo).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('suite 2', function () {
|
||||
env.it('test 2-1', function() {
|
||||
foo++;
|
||||
this.expect(foo).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
env.currentRunner().execute();
|
||||
|
||||
|
||||
expect(env.currentRunner().specs().length).toEqual(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('afterEach', function() {
|
||||
it('should run after each spec for all suites', function () {
|
||||
var foo = 3;
|
||||
env.afterEach(function () {
|
||||
foo = foo - 1;
|
||||
});
|
||||
|
||||
env.describe('suite 1', function () {
|
||||
env.it('test 1-1', function() {
|
||||
this.expect(foo).toEqual(3);
|
||||
});
|
||||
env.it('test 1-2', function() {
|
||||
this.expect(foo).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('suite 2', function () {
|
||||
env.it('test 2-1', function() {
|
||||
this.expect(foo).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
env.currentRunner().execute();
|
||||
|
||||
var runnerResults = env.currentRunner().results();
|
||||
expect(runnerResults.totalCount).toEqual(3);
|
||||
expect(runnerResults.passedCount).toEqual(3);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should run child suites and specs and generate results when execute is called', function() {
|
||||
env.describe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('another suite description', function () {
|
||||
env.it('should be another test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.currentRunner().execute();
|
||||
|
||||
var runnerResults = env.currentRunner().results();
|
||||
expect(runnerResults.totalCount).toEqual(2);
|
||||
expect(runnerResults.passedCount).toEqual(1);
|
||||
expect(runnerResults.failedCount).toEqual(1);
|
||||
});
|
||||
|
||||
|
||||
it('should ignore suites that have been x\'d', function() {
|
||||
env.xdescribe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('another suite description', function () {
|
||||
env.it('should be another test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.currentRunner().execute();
|
||||
|
||||
var runnerResults = env.currentRunner().results();
|
||||
expect(runnerResults.totalCount).toEqual(1);
|
||||
expect(runnerResults.passedCount).toEqual(0);
|
||||
expect(runnerResults.failedCount).toEqual(1);
|
||||
});
|
||||
|
||||
it('should roll up results from all specs', function() {
|
||||
env.describe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('another suite description', function () {
|
||||
env.it('should be another test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.currentRunner().execute();
|
||||
|
||||
var results = env.currentRunner().results();
|
||||
expect(results.totalCount).toEqual(2);
|
||||
expect(results.passedCount).toEqual(1);
|
||||
expect(results.failedCount).toEqual(1);
|
||||
});
|
||||
|
||||
describe('reporting', function () {
|
||||
var fakeReporter;
|
||||
beforeEach(function () {
|
||||
fakeReporter = jasmine.createSpyObj("fakeReporter", ["log", "reportRunnerStarting", "reportRunnerResults"]);
|
||||
env.addReporter(fakeReporter);
|
||||
});
|
||||
|
||||
it('should report runner results when the runner has completed running', function() {
|
||||
env.describe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('another suite description', function () {
|
||||
env.it('should be another test', function() {
|
||||
this.waits(200);
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.currentRunner().execute();
|
||||
expect(fakeReporter.reportRunnerResults).not.toHaveBeenCalled();
|
||||
fakeTimer.tick(200);
|
||||
//This blows up the JSApiReporter.
|
||||
//expect(fakeReporter.reportRunnerResults).toHaveBeenCalledWith(env.currentRunner);
|
||||
expect(fakeReporter.reportRunnerResults).toHaveBeenCalled();
|
||||
expect(fakeReporter.reportRunnerResults.mostRecentCall.args[0].results()).toEqual(env.currentRunner().results());
|
||||
});
|
||||
});
|
||||
|
||||
it("should report when the tests start running", function() {
|
||||
var fakeReporter = jasmine.createSpyObj("fakeReporter", ["log", "reportRunnerStarting"]);
|
||||
env.addReporter(fakeReporter);
|
||||
|
||||
|
||||
var runner = new jasmine.Runner(env);
|
||||
runner.arbitraryVariable = 'foo';
|
||||
spyOn(runner.queue, 'start');
|
||||
expect(fakeReporter.reportRunnerStarting).not.toHaveBeenCalled();
|
||||
runner.execute();
|
||||
expect(fakeReporter.reportRunnerStarting).toHaveBeenCalled();
|
||||
var reportedRunner = fakeReporter.reportRunnerStarting.mostRecentCall.args[0];
|
||||
expect(reportedRunner.arbitraryVariable).toEqual('foo');
|
||||
expect(runner.queue.start).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe("when suites are nested", function() {
|
||||
var suite1, suite2, suite3;
|
||||
|
||||
function suiteNames(suites) {
|
||||
var suiteDescriptions = [];
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
suiteDescriptions.push(suites[i].getFullName());
|
||||
}
|
||||
return suiteDescriptions;
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
suite1 = env.describe("suite 1", function() {
|
||||
suite2 = env.describe("suite 2", function() {
|
||||
});
|
||||
});
|
||||
suite3 = env.describe("suite 3", function() {});
|
||||
});
|
||||
|
||||
it("#suites should return a flat array of all suites, including nested suites", function() {
|
||||
var suites = env.currentRunner().suites();
|
||||
expect(suiteNames(suites)).toEqual([suite1.getFullName(), suite2.getFullName(), suite3.getFullName()]);
|
||||
});
|
||||
|
||||
it("#topLevelSuites should return a flat array of all top-level suites only", function() {
|
||||
var suites = env.currentRunner().topLevelSuites();
|
||||
expect(suiteNames(suites)).toEqual([suite1.getFullName(), suite3.getFullName()]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,126 +0,0 @@
|
||||
describe('RunnerTest', function() {
|
||||
var env;
|
||||
beforeEach(function () {
|
||||
env = new jasmine.Env();
|
||||
});
|
||||
|
||||
it('should be able to add a suite', function() {
|
||||
env.describe('one suite description', function () {
|
||||
env.it('should be a test');
|
||||
});
|
||||
expect(env.currentRunner.suites.length).toEqual(1); // "Runner expected one suite, got " + env.currentRunner.suites.length);
|
||||
});
|
||||
|
||||
it('should be able to push multiple suites', function() {
|
||||
env.describe('one suite description', function () {
|
||||
env.it('should be a test');
|
||||
});
|
||||
env.describe('another suite description', function () {
|
||||
env.it('should be a test');
|
||||
});
|
||||
expect(env.currentRunner.suites.length).toEqual(2); //"Runner expected two suites, but got " + env.currentRunner.suites.length);
|
||||
});
|
||||
|
||||
it('should run child suites and specs and generate results when execute is called', function() {
|
||||
env.describe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('another suite description', function () {
|
||||
env.it('should be another test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.currentRunner.execute();
|
||||
|
||||
expect(env.currentRunner.suites.length).toEqual(2); // "Runner expected two suites, got " + env.currentRunner.suites.length);
|
||||
expect(env.currentRunner.suites[0].specs[0].results.getItems()[0].passed).toEqual(true); //"Runner should have run specs in first suite");
|
||||
expect(env.currentRunner.suites[1].specs[0].results.getItems()[0].passed).toEqual(false); //"Runner should have run specs in second suite");
|
||||
});
|
||||
|
||||
it('should ignore suites that have been x\'d', function() {
|
||||
env.xdescribe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('another suite description', function () {
|
||||
env.it('should be another test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.currentRunner.execute();
|
||||
|
||||
expect(env.currentRunner.suites.length).toEqual(1); // "Runner expected 1 suite, got " + env.currentRunner.suites.length);
|
||||
expect(env.currentRunner.suites[0].specs[0].results.getItems()[0].passed).toEqual(false); // "Runner should have run specs in first suite");
|
||||
expect(env.currentRunner.suites[1]).toEqual(undefined); // "Second suite should be undefined, but was " + reporter.toJSON(env.currentRunner.suites[1]));
|
||||
});
|
||||
|
||||
it('should roll up results from all specs', function() {
|
||||
var env = new jasmine.Env();
|
||||
env.describe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('another suite description', function () {
|
||||
env.it('should be another test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.currentRunner.execute();
|
||||
|
||||
var results = env.currentRunner.getResults();
|
||||
expect(results.totalCount).toEqual(2);
|
||||
expect(results.passedCount).toEqual(1);
|
||||
expect(results.failedCount).toEqual(1);
|
||||
});
|
||||
|
||||
it('should set the finished flag when #finished is called', function(){
|
||||
env.currentRunner.finish();
|
||||
|
||||
expect(env.currentRunner.finished).toEqual(true);
|
||||
});
|
||||
|
||||
it('should call the finish callback when the runner is finished', function() {
|
||||
var foo = 0;
|
||||
|
||||
env.currentRunner.finishCallback = function() {
|
||||
foo++;
|
||||
};
|
||||
|
||||
env.currentRunner.finish();
|
||||
|
||||
expect(env.currentRunner.finished).toEqual(true);
|
||||
expect(foo).toEqual(1);
|
||||
});
|
||||
|
||||
it("should report when the tests start running", function() {
|
||||
var fakeReporter = jasmine.createSpyObj("fakeReporter", ["log", "reportRunnerStarting"]);
|
||||
env.addReporter(fakeReporter);
|
||||
|
||||
var runner = new jasmine.Runner(env);
|
||||
runner.execute();
|
||||
expect(fakeReporter.reportRunnerStarting).wasCalledWith(env.currentRunner);
|
||||
});
|
||||
|
||||
});
|
||||
1195
spec/suites/SpecRunningSpec.js
Normal file
1195
spec/suites/SpecRunningSpec.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,763 +0,0 @@
|
||||
describe("jasmine spec running", function () {
|
||||
var env;
|
||||
var fakeTimer;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
|
||||
fakeTimer = new jasmine.FakeTimer();
|
||||
env.setTimeout = fakeTimer.setTimeout;
|
||||
env.clearTimeout = fakeTimer.clearTimeout;
|
||||
env.setInterval = fakeTimer.setInterval;
|
||||
env.clearInterval = fakeTimer.clearInterval;
|
||||
});
|
||||
|
||||
it('should assign spec ids sequentially', function() {
|
||||
var it0, it1, it2, it3, it4;
|
||||
env.describe('test suite', function() {
|
||||
it0 = env.it('spec 0', function() {
|
||||
});
|
||||
it1 = env.it('spec 1', function() {
|
||||
});
|
||||
it2 = env.xit('spec 2', function() {
|
||||
});
|
||||
it3 = env.it('spec 3', function() {
|
||||
});
|
||||
});
|
||||
env.describe('test suite 2', function() {
|
||||
it4 = env.it('spec 4', function() {
|
||||
});
|
||||
});
|
||||
|
||||
expect(it0.id).toEqual(0);
|
||||
expect(it1.id).toEqual(1);
|
||||
expect(it2.id).toEqual(2);
|
||||
expect(it3.id).toEqual(3);
|
||||
expect(it4.id).toEqual(4);
|
||||
});
|
||||
|
||||
|
||||
it("should build up some objects with results we can inspect", function() {
|
||||
var specWithNoBody, specWithExpectation, specWithFailingExpectations, specWithMultipleExpectations;
|
||||
|
||||
var suite = env.describe('default current suite', function() {
|
||||
specWithNoBody = env.it('new spec');
|
||||
|
||||
specWithExpectation = env.it('spec with an expectation').runs(function () {
|
||||
var foo = 'bar';
|
||||
this.expect(foo).toEqual('bar');
|
||||
});
|
||||
|
||||
specWithFailingExpectations = env.it('spec with failing expectation').runs(function () {
|
||||
var foo = 'bar';
|
||||
this.expect(foo).toEqual('baz');
|
||||
});
|
||||
|
||||
specWithMultipleExpectations = env.it('spec with multiple assertions').runs(function () {
|
||||
var foo = 'bar';
|
||||
var baz = 'quux';
|
||||
|
||||
this.expect(foo).toEqual('bar');
|
||||
this.expect(baz).toEqual('quux');
|
||||
});
|
||||
});
|
||||
|
||||
suite.execute();
|
||||
|
||||
expect(specWithNoBody.description).toEqual('new spec');
|
||||
|
||||
expect(specWithExpectation.results.getItems().length).toEqual(1); // "Results aren't there after a spec was executed"
|
||||
expect(specWithExpectation.results.getItems()[0].passed).toEqual(true); // "Results has a result, but it's true"
|
||||
expect(specWithExpectation.results.description).toEqual('spec with an expectation'); // "Spec's results did not get the spec's description"
|
||||
|
||||
expect(specWithFailingExpectations.results.getItems()[0].passed).toEqual(false); // "Expectation that failed, passed"
|
||||
|
||||
expect(specWithMultipleExpectations.results.getItems().length).toEqual(2); // "Spec doesn't support multiple expectations"
|
||||
});
|
||||
|
||||
it("should work without a runs block", function() {
|
||||
var another_spec;
|
||||
var currentSuite = env.describe('default current suite', function() {
|
||||
another_spec = env.it('spec with an expectation', function () {
|
||||
var foo = 'bar';
|
||||
this.expect(foo).toEqual('bar');
|
||||
this.expect(foo).toEqual('baz');
|
||||
});
|
||||
});
|
||||
|
||||
another_spec.execute();
|
||||
another_spec.done = true;
|
||||
|
||||
expect(another_spec.results.getItems().length).toEqual(2);
|
||||
expect(another_spec.results.getItems()[0].passed).toEqual(true); // "In a spec without a run block, expected first expectation result to be true but was false"
|
||||
expect(another_spec.results.getItems()[1].passed).toEqual(false); // "In a spec without a run block, expected second expectation result to be false but was true";
|
||||
expect(another_spec.results.description).toEqual('spec with an expectation'); // "In a spec without a run block, results did not include the spec's description";
|
||||
});
|
||||
|
||||
it("should run asynchronous tests", function () {
|
||||
var foo = 0;
|
||||
|
||||
//set a bogus suite for the spec to attach to
|
||||
// jasmine.getEnv().currentSuite = {specs: []};
|
||||
|
||||
var a_spec;
|
||||
env.describe('test async spec', function() {
|
||||
a_spec = env.it('simple queue test', function () {
|
||||
this.runs(function () {
|
||||
foo++;
|
||||
});
|
||||
this.runs(function () {
|
||||
this.expect(foo).toEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
expect(a_spec.queue.length).toEqual(1,
|
||||
'Expected spec queue length to be 1, was ' + a_spec.queue.length);
|
||||
|
||||
a_spec.execute();
|
||||
expect(a_spec.queue.length).toEqual(3,
|
||||
'Expected spec queue length to be 3, was ' + a_spec.queue.length);
|
||||
|
||||
foo = 0;
|
||||
env.describe('test async spec', function() {
|
||||
a_spec = env.it('spec w/ queued statments', function () {
|
||||
this.runs(function () {
|
||||
foo++;
|
||||
});
|
||||
this.runs(function () {
|
||||
this.expect(foo).toEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
a_spec.execute();
|
||||
|
||||
expect(a_spec.results.getItems().length).toEqual(1); // 'No call to waits(): Spec queue did not run all functions';
|
||||
expect(a_spec.results.getItems()[0].passed).toEqual(true); // 'No call to waits(): Queued expectation failed';
|
||||
|
||||
foo = 0;
|
||||
env.describe('test async spec', function() {
|
||||
a_spec = env.it('spec w/ queued statments', function () {
|
||||
this.runs(function () {
|
||||
fakeTimer.setTimeout(function() {
|
||||
foo++;
|
||||
}, 500);
|
||||
});
|
||||
this.waits(1000);
|
||||
this.runs(function() {
|
||||
this.expect(foo).toEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
a_spec.execute();
|
||||
expect(a_spec.results.getItems().length).toEqual(0);
|
||||
|
||||
fakeTimer.tick(500);
|
||||
expect(a_spec.results.getItems().length).toEqual(0);
|
||||
|
||||
fakeTimer.tick(500);
|
||||
expect(a_spec.results.getItems().length).toEqual(1); // 'Calling waits(): Spec queue did not run all functions';
|
||||
|
||||
expect(a_spec.results.getItems()[0].passed).toEqual(true); // 'Calling waits(): Queued expectation failed';
|
||||
|
||||
var bar = 0;
|
||||
var another_spec;
|
||||
env.describe('test async spec', function() {
|
||||
another_spec = env.it('spec w/ queued statments', function () {
|
||||
this.runs(function () {
|
||||
fakeTimer.setTimeout(function() {
|
||||
bar++;
|
||||
}, 250);
|
||||
|
||||
});
|
||||
this.waits(500);
|
||||
this.runs(function () {
|
||||
fakeTimer.setTimeout(function() {
|
||||
bar++;
|
||||
}, 250);
|
||||
});
|
||||
this.waits(500);
|
||||
this.runs(function () {
|
||||
this.expect(bar).toEqual(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
expect(another_spec.queue.length).toEqual(1); // 'Calling 2 waits(): Expected queue length to be 1, got ' + another_spec.queue.length;
|
||||
|
||||
another_spec.execute();
|
||||
|
||||
fakeTimer.tick(1000);
|
||||
expect(another_spec.queue.length).toEqual(4); // 'Calling 2 waits(): Expected queue length to be 4, got ' + another_spec.queue.length;
|
||||
|
||||
expect(another_spec.results.getItems().length).toEqual(1); // 'Calling 2 waits(): Spec queue did not run all functions';
|
||||
|
||||
expect(another_spec.results.getItems()[0].passed).toEqual(true); // 'Calling 2 waits(): Queued expectation failed';
|
||||
|
||||
var baz = 0;
|
||||
var yet_another_spec;
|
||||
env.describe('test async spec', function() {
|
||||
yet_another_spec = env.it('spec w/ async fail', function () {
|
||||
this.runs(function () {
|
||||
fakeTimer.setTimeout(function() {
|
||||
baz++;
|
||||
}, 250);
|
||||
});
|
||||
this.waits(100);
|
||||
this.runs(function() {
|
||||
this.expect(baz).toEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
yet_another_spec.execute();
|
||||
fakeTimer.tick(250);
|
||||
|
||||
expect(yet_another_spec.queue.length).toEqual(3); // 'Calling 2 waits(): Expected queue length to be 3, got ' + another_spec.queue.length);
|
||||
expect(yet_another_spec.results.getItems().length).toEqual(1); // 'Calling 2 waits(): Spec queue did not run all functions');
|
||||
expect(yet_another_spec.results.getItems()[0].passed).toEqual(false); // 'Calling 2 waits(): Queued expectation failed');
|
||||
});
|
||||
|
||||
it("testAsyncSpecsWithMockSuite", function () {
|
||||
var bar = 0;
|
||||
var another_spec;
|
||||
env.describe('test async spec', function() {
|
||||
another_spec = env.it('spec w/ queued statments', function () {
|
||||
this.runs(function () {
|
||||
fakeTimer.setTimeout(function() {
|
||||
bar++;
|
||||
}, 250);
|
||||
});
|
||||
this.waits(500);
|
||||
this.runs(function () {
|
||||
fakeTimer.setTimeout(function() {
|
||||
bar++;
|
||||
}, 250);
|
||||
});
|
||||
this.waits(1500);
|
||||
this.runs(function() {
|
||||
this.expect(bar).toEqual(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
another_spec.execute();
|
||||
fakeTimer.tick(2000);
|
||||
expect(another_spec.queue.length).toEqual(4); // 'Calling 2 waits(): Expected queue length to be 4, got ' + another_spec.queue.length);
|
||||
expect(another_spec.results.getItems().length).toEqual(1); // 'Calling 2 waits(): Spec queue did not run all functions');
|
||||
expect(another_spec.results.getItems()[0].passed).toEqual(true); // 'Calling 2 waits(): Queued expectation failed');
|
||||
});
|
||||
|
||||
it("testWaitsFor", function() {
|
||||
var doneWaiting = false;
|
||||
var runsBlockExecuted = false;
|
||||
|
||||
var spec;
|
||||
env.describe('foo', function() {
|
||||
spec = env.it('has a waits for', function() {
|
||||
this.runs(function() {
|
||||
});
|
||||
|
||||
this.waitsFor(500, function() {
|
||||
return doneWaiting;
|
||||
});
|
||||
|
||||
this.runs(function() {
|
||||
runsBlockExecuted = true;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
spec.execute();
|
||||
expect(runsBlockExecuted).toEqual(false); //, 'should not have executed runs block yet');
|
||||
fakeTimer.tick(100);
|
||||
doneWaiting = true;
|
||||
fakeTimer.tick(100);
|
||||
expect(runsBlockExecuted).toEqual(true); //, 'should have executed runs block');
|
||||
});
|
||||
|
||||
it("testWaitsForFailsWithMessage", function() {
|
||||
var spec;
|
||||
env.describe('foo', function() {
|
||||
spec = env.it('has a waits for', function() {
|
||||
this.runs(function() {
|
||||
});
|
||||
|
||||
this.waitsFor(500, function() {
|
||||
return false; // force a timeout
|
||||
}, 'my awesome condition');
|
||||
|
||||
this.runs(function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
spec.execute();
|
||||
fakeTimer.tick(1000);
|
||||
var actual = spec.results.getItems()[0].message;
|
||||
var expected = 'timeout: timed out after 500 msec waiting for my awesome condition';
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
|
||||
it("testWaitsForFailsIfTimeout", function() {
|
||||
var runsBlockExecuted = false;
|
||||
|
||||
var spec;
|
||||
env.describe('foo', function() {
|
||||
spec = env.it('has a waits for', function() {
|
||||
this.runs(function() {
|
||||
});
|
||||
|
||||
this.waitsFor(500, function() {
|
||||
return false; // force a timeout
|
||||
});
|
||||
|
||||
this.runs(function() {
|
||||
runsBlockExecuted = true;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
spec.execute();
|
||||
expect(runsBlockExecuted).toEqual(false, 'should not have executed runs block yet');
|
||||
fakeTimer.tick(100);
|
||||
expect(runsBlockExecuted).toEqual(false, 'should not have executed runs block yet');
|
||||
fakeTimer.tick(400);
|
||||
expect(runsBlockExecuted).toEqual(false, 'should have timed out, so the second runs block should not have been called');
|
||||
var actual = spec.results.getItems()[0].message;
|
||||
var expected = 'timeout: timed out after 500 msec waiting for something to happen';
|
||||
expect(actual).toEqual(expected,
|
||||
'expected "' + expected + '" but found "' + actual + '"');
|
||||
});
|
||||
|
||||
it("testSpecAfter", function() {
|
||||
var log = "";
|
||||
var spec;
|
||||
var suite = env.describe("has after", function() {
|
||||
spec = env.it('spec with after', function() {
|
||||
this.runs(function() {
|
||||
log += "spec";
|
||||
});
|
||||
});
|
||||
});
|
||||
spec.after(function() {
|
||||
log += "after1";
|
||||
});
|
||||
spec.after(function() {
|
||||
log += "after2";
|
||||
});
|
||||
|
||||
suite.execute();
|
||||
expect(log).toEqual("specafter2after1"); // "after function should be executed in reverse order after spec runs");
|
||||
});
|
||||
|
||||
describe('test suite declaration', function() {
|
||||
var suite;
|
||||
var dummyFunction = function() {};
|
||||
|
||||
it('should give the suite a description', function() {
|
||||
suite = env.describe('one suite description', dummyFunction);
|
||||
expect(suite.description).toEqual('one suite description'); // 'Suite did not get a description');
|
||||
});
|
||||
|
||||
it('should add tests to suites declared by the passed function', function() {
|
||||
suite = env.describe('one suite description', function () {
|
||||
env.it('should be a test');
|
||||
});
|
||||
|
||||
expect(suite.specs.length).toEqual(1); // 'Suite did not get a spec pushed');
|
||||
expect(suite.specs[0].queue.length).toEqual(0); // "Suite's Spec should not have queuedFunctions");
|
||||
});
|
||||
|
||||
it('should enqueue functions for multipart tests', function() {
|
||||
suite = env.describe('one suite description', function () {
|
||||
env.it('should be a test with queuedFunctions', function() {
|
||||
this.runs(function() {
|
||||
var foo = 0;
|
||||
foo++;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
expect(suite.specs[0].queue.length).toEqual(1); // "Suite's spec did not get a function pushed");
|
||||
});
|
||||
|
||||
it('should enqueue functions for multipart tests and support waits, and run any ready runs() blocks', function() {
|
||||
var foo = 0;
|
||||
var bar = 0;
|
||||
|
||||
suite = env.describe('one suite description', function () {
|
||||
env.it('should be a test with queuedFunctions', function() {
|
||||
this.runs(function() {
|
||||
foo++;
|
||||
});
|
||||
this.waits(100);
|
||||
this.runs(function() {
|
||||
bar++;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
expect(suite.specs[0].queue.length).toEqual(1); // "Suite's spec length should have been 1, was " + suite.specs[0].queue.length);
|
||||
suite.execute();
|
||||
expect(suite.specs[0].queue.length).toEqual(3); // "Suite's spec length should have been 3, was " + suite.specs[0].queue.length);
|
||||
expect(foo).toEqual(1);
|
||||
expect(bar).toEqual(0);
|
||||
|
||||
fakeTimer.tick(100);
|
||||
expect(bar).toEqual(1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it("testBeforeAndAfterCallbacks", function () {
|
||||
|
||||
var suiteWithBefore = env.describe('one suite with a before', function () {
|
||||
|
||||
this.beforeEach(function () {
|
||||
this.foo = 1;
|
||||
});
|
||||
|
||||
env.it('should be a spec', function () {
|
||||
this.runs(function() {
|
||||
this.foo++;
|
||||
this.expect(this.foo).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
env.it('should be another spec', function () {
|
||||
this.runs(function() {
|
||||
this.foo++;
|
||||
this.expect(this.foo).toEqual(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suiteWithBefore.execute();
|
||||
var suite = suiteWithBefore;
|
||||
expect(suite.beforeEachFunction); // "testBeforeAndAfterCallbacks: Suite's beforeEach was not defined");
|
||||
expect(suite.specs[0].results.getItems()[0].passed).toEqual(true); // "testBeforeAndAfterCallbacks: the first spec's foo should have been 2");
|
||||
expect(suite.specs[1].results.getItems()[0].passed).toEqual(true); // "testBeforeAndAfterCallbacks: the second spec's this.foo should have been 2");
|
||||
|
||||
var suiteWithAfter = env.describe('one suite with an after_each', function () {
|
||||
|
||||
env.it('should be a spec with an after_each', function () {
|
||||
this.runs(function() {
|
||||
this.foo = 0;
|
||||
this.foo++;
|
||||
this.expect(this.foo).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
env.it('should be another spec with an after_each', function () {
|
||||
this.runs(function() {
|
||||
this.foo = 0;
|
||||
this.foo++;
|
||||
this.expect(this.foo).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
this.afterEach(function () {
|
||||
this.foo = 0;
|
||||
});
|
||||
});
|
||||
|
||||
suiteWithAfter.execute();
|
||||
var suite = suiteWithAfter;
|
||||
expect(suite.afterEachFunction); // "testBeforeAndAfterCallbacks: Suite's afterEach was not defined");
|
||||
expect(suite.specs[0].results.getItems()[0].passed).toEqual(true); // "testBeforeAndAfterCallbacks: afterEach failure: " + suite.results.getItems()[0].results[0].message);
|
||||
expect(suite.specs[0].foo).toEqual(0); // "testBeforeAndAfterCallbacks: afterEach failure: foo was not reset to 0");
|
||||
expect(suite.specs[1].results.getItems()[0].passed).toEqual(true); // "testBeforeAndAfterCallbacks: afterEach failure: " + suite.results.getItems()[0].results[0].message);
|
||||
expect(suite.specs[1].foo).toEqual(0); // "testBeforeAndAfterCallbacks: afterEach failure: foo was not reset to 0");
|
||||
|
||||
});
|
||||
|
||||
it("testBeforeExecutesSafely", function() {
|
||||
var report = "";
|
||||
var suite = env.describe('before fails on first test, passes on second', function() {
|
||||
var counter = 0;
|
||||
this.beforeEach(function() {
|
||||
counter++;
|
||||
if (counter == 1) {
|
||||
throw "before failure";
|
||||
}
|
||||
});
|
||||
env.it("first should not run because before fails", function() {
|
||||
this.runs(function() {
|
||||
report += "first";
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
env.it("second should run and pass because before passes", function() {
|
||||
this.runs(function() {
|
||||
report += "second";
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite.execute();
|
||||
|
||||
expect(report).toEqual("firstsecond"); // "both tests should run");
|
||||
expect(suite.specs[0].results.getItems()[0].passed).toEqual(false); // "1st spec should fail");
|
||||
expect(suite.specs[1].results.getItems()[0].passed).toEqual(true); // "2nd spec should pass");
|
||||
|
||||
expect(suite.specs[0].results.getItems()[0].passed).toEqual(false); // "1st spec should fail");
|
||||
expect(suite.specs[1].results.getItems()[0].passed).toEqual(true); // "2nd spec should pass");
|
||||
});
|
||||
|
||||
it("testAfterExecutesSafely", function() {
|
||||
var report = "";
|
||||
var suite = env.describe('after fails on first test, then passes', function() {
|
||||
var counter = 0;
|
||||
this.afterEach(function() {
|
||||
counter++;
|
||||
if (counter == 1) {
|
||||
throw "after failure";
|
||||
}
|
||||
});
|
||||
env.it("first should run, expectation passes, but spec fails because after fails", function() {
|
||||
this.runs(function() {
|
||||
report += "first";
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
env.it("second should run and pass because after passes", function() {
|
||||
this.runs(function() {
|
||||
report += "second";
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
env.it("third should run and pass because after passes", function() {
|
||||
this.runs(function() {
|
||||
report += "third";
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite.execute();
|
||||
|
||||
expect(report).toEqual("firstsecondthird"); // "all tests should run");
|
||||
//After each errors should not go in spec results because it confuses the count.
|
||||
expect(suite.specs.length).toEqual(3, 'testAfterExecutesSafely should have results for three specs');
|
||||
expect(suite.specs[0].results.getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 1st spec should pass");
|
||||
expect(suite.specs[1].results.getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 2nd spec should pass");
|
||||
expect(suite.specs[2].results.getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 3rd spec should pass");
|
||||
|
||||
expect(suite.specs[0].results.getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 1st result for 1st suite spec should pass");
|
||||
expect(suite.specs[0].results.getItems()[1].passed).toEqual(false, "testAfterExecutesSafely 2nd result for 1st suite spec should fail because afterEach failed");
|
||||
expect(suite.specs[1].results.getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 2nd suite spec should pass");
|
||||
expect(suite.specs[2].results.getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 3rd suite spec should pass");
|
||||
});
|
||||
|
||||
it("testNestedDescribes", function() {
|
||||
var actions = [];
|
||||
|
||||
env.describe('Something', function() {
|
||||
env.beforeEach(function() {
|
||||
actions.push('outer beforeEach');
|
||||
});
|
||||
|
||||
env.afterEach(function() {
|
||||
actions.push('outer afterEach');
|
||||
});
|
||||
|
||||
env.it('does it 1', function() {
|
||||
actions.push('outer it 1');
|
||||
});
|
||||
|
||||
env.describe('Inner 1', function() {
|
||||
env.beforeEach(function() {
|
||||
actions.push('inner 1 beforeEach');
|
||||
});
|
||||
|
||||
env.afterEach(function() {
|
||||
actions.push('inner 1 afterEach');
|
||||
});
|
||||
|
||||
env.it('does it 2', function() {
|
||||
actions.push('inner 1 it');
|
||||
});
|
||||
});
|
||||
|
||||
env.it('does it 3', function() {
|
||||
actions.push('outer it 2');
|
||||
});
|
||||
|
||||
env.describe('Inner 2', function() {
|
||||
env.beforeEach(function() {
|
||||
actions.push('inner 2 beforeEach');
|
||||
});
|
||||
|
||||
env.afterEach(function() {
|
||||
actions.push('inner 2 afterEach');
|
||||
});
|
||||
|
||||
env.it('does it 2', function() {
|
||||
actions.push('inner 2 it');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
|
||||
var expected = [
|
||||
"outer beforeEach",
|
||||
"outer it 1",
|
||||
"outer afterEach",
|
||||
|
||||
"outer beforeEach",
|
||||
"inner 1 beforeEach",
|
||||
"inner 1 it",
|
||||
"inner 1 afterEach",
|
||||
"outer afterEach",
|
||||
|
||||
"outer beforeEach",
|
||||
"outer it 2",
|
||||
"outer afterEach",
|
||||
|
||||
"outer beforeEach",
|
||||
"inner 2 beforeEach",
|
||||
"inner 2 it",
|
||||
"inner 2 afterEach",
|
||||
"outer afterEach"
|
||||
];
|
||||
expect(env.equals_(actions, expected)).toEqual(true); // "nested describes order failed: <blockquote>" + jasmine.pp(actions) + "</blockquote> wanted <blockquote>" + jasmine.pp(expected) + "</blockquote");
|
||||
});
|
||||
|
||||
it("builds up nested names", function() {
|
||||
var nestedSpec;
|
||||
env.describe('Test Subject', function() {
|
||||
env.describe('when under circumstance A', function() {
|
||||
env.describe('and circumstance B', function() {
|
||||
nestedSpec = env.it('behaves thusly', function() {});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
expect(nestedSpec.getFullName()).toEqual('Test Subject when under circumstance A and circumstance B behaves thusly.'); //, "Spec.fullName was incorrect: " + nestedSpec.getFullName());
|
||||
});
|
||||
|
||||
it("should bind 'this' to the running spec within the spec body", function() {
|
||||
var suite = env.describe('one suite description', function () {
|
||||
env.it('should be a test with queuedFunctions', function() {
|
||||
this.runs(function() {
|
||||
this.foo = 0;
|
||||
this.foo++;
|
||||
});
|
||||
|
||||
this.runs(function() {
|
||||
var that = this;
|
||||
fakeTimer.setTimeout(function() {
|
||||
that.foo++;
|
||||
}, 250);
|
||||
});
|
||||
|
||||
this.runs(function() {
|
||||
this.expect(this.foo).toEqual(2);
|
||||
});
|
||||
|
||||
this.waits(300);
|
||||
|
||||
this.runs(function() {
|
||||
this.expect(this.foo).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
suite.execute();
|
||||
fakeTimer.tick(600);
|
||||
|
||||
expect(suite.specs[0].foo).toEqual(2); // "Spec does not maintain scope in between functions");
|
||||
expect(suite.specs[0].results.getItems().length).toEqual(2); // "Spec did not get results for all expectations");
|
||||
expect(suite.specs[0].results.getItems()[0].passed).toEqual(false); // "Spec did not return false for a failed expectation");
|
||||
expect(suite.specs[0].results.getItems()[1].passed).toEqual(true); // "Spec did not return true for a passing expectation");
|
||||
});
|
||||
|
||||
it("shouldn't run disabled tests", function() {
|
||||
var xitSpecWasRun = false;
|
||||
var suite = env.describe('default current suite', function() {
|
||||
env.xit('disabled spec').runs(function () {
|
||||
xitSpecWasRun = true;
|
||||
});
|
||||
|
||||
env.it('enabled spec').runs(function () {
|
||||
var foo = 'bar';
|
||||
expect(foo).toEqual('bar');
|
||||
});
|
||||
});
|
||||
|
||||
suite.execute();
|
||||
expect(suite.specs.length).toEqual(1);
|
||||
expect(xitSpecWasRun).toEqual(false);
|
||||
});
|
||||
|
||||
it('shouldn\'t execute specs in disabled suites', function() {
|
||||
var spy = jasmine.createSpy();
|
||||
var disabledSuite = env.xdescribe('a disabled suite', function() {
|
||||
env.it('enabled spec, but should not be run', function() {
|
||||
spy();
|
||||
});
|
||||
});
|
||||
|
||||
disabledSuite.execute();
|
||||
|
||||
expect(spy).wasNotCalled();
|
||||
});
|
||||
|
||||
it('#explodes should throw an exception when it is called inside a spec', function() {
|
||||
var exceptionMessage = false;
|
||||
var anotherSuite = env.describe('Spec', function () {
|
||||
env.it('plodes', function() {
|
||||
try {
|
||||
this.explodes();
|
||||
}
|
||||
catch (e) {
|
||||
exceptionMessage = e;
|
||||
}
|
||||
expect(exceptionMessage).toNotEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
anotherSuite.execute();
|
||||
|
||||
expect(exceptionMessage).toEqual('explodes function should not have been called');
|
||||
});
|
||||
|
||||
it("should be easy to add more matchers local to a spec, suite, etc.", function() {
|
||||
var spec1, spec2, spec1Matcher, spec2Matcher;
|
||||
|
||||
var suite = env.describe('some suite', function() {
|
||||
env.beforeEach(function() {
|
||||
this.addMatchers({ matcherForSuite: function(expected) {
|
||||
return "matcherForSuite: actual: " + this.actual + "; expected: " + expected;
|
||||
} });
|
||||
});
|
||||
|
||||
spec1 = env.it('spec with an expectation').runs(function () {
|
||||
this.addMatchers( { matcherForSpec: function(expected) {
|
||||
return "matcherForSpec: actual: " + this.actual + "; expected: " + expected;
|
||||
} });
|
||||
spec1Matcher = this.expect("xxx");
|
||||
});
|
||||
|
||||
spec2 = env.it('spec with failing expectation').runs(function () {
|
||||
spec2Matcher = this.expect("yyy");
|
||||
});
|
||||
});
|
||||
|
||||
suite.execute();
|
||||
|
||||
expect(spec1Matcher.matcherForSuite("expected")).toEqual("matcherForSuite: actual: xxx; expected: expected");
|
||||
expect(spec1Matcher.matcherForSpec("expected")).toEqual("matcherForSpec: actual: xxx; expected: expected");
|
||||
|
||||
expect(spec2Matcher.matcherForSuite("expected")).toEqual("matcherForSuite: actual: yyy; expected: expected");
|
||||
expect(spec2Matcher.matcherForSpec).toBe(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
124
spec/suites/SpecSpec.js
Normal file
124
spec/suites/SpecSpec.js
Normal file
@@ -0,0 +1,124 @@
|
||||
describe('Spec', function () {
|
||||
var env, suite;
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
suite = new jasmine.Suite(env, 'suite 1');
|
||||
});
|
||||
|
||||
describe('initialization', function () {
|
||||
|
||||
it('should raise an error if an env is not passed', function () {
|
||||
try {
|
||||
new jasmine.Spec();
|
||||
}
|
||||
catch (e) {
|
||||
expect(e.message).toEqual('jasmine.Env() required');
|
||||
}
|
||||
});
|
||||
|
||||
it('should raise an error if a suite is not passed', function () {
|
||||
try {
|
||||
new jasmine.Spec(env);
|
||||
}
|
||||
catch (e) {
|
||||
expect(e.message).toEqual('jasmine.Suite() required');
|
||||
}
|
||||
});
|
||||
|
||||
it('should assign sequential ids for specs belonging to the same env', function () {
|
||||
var spec1 = new jasmine.Spec(env, suite);
|
||||
var spec2 = new jasmine.Spec(env, suite);
|
||||
var spec3 = new jasmine.Spec(env, suite);
|
||||
expect(spec1.id).toEqual(0);
|
||||
expect(spec2.id).toEqual(1);
|
||||
expect(spec3.id).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
it('getFullName returns suite & spec description', function () {
|
||||
var spec = new jasmine.Spec(env, suite, 'spec 1');
|
||||
expect(spec.getFullName()).toEqual('suite 1 spec 1.')
|
||||
});
|
||||
|
||||
describe('results', function () {
|
||||
var spec, results;
|
||||
beforeEach(function () {
|
||||
spec = new jasmine.Spec(env, suite);
|
||||
results = spec.results();
|
||||
expect(results.totalCount).toEqual(0);
|
||||
spec.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('results shows the total number of expectations for each spec after execution', function () {
|
||||
expect(results.totalCount).toEqual(0);
|
||||
spec.execute();
|
||||
expect(results.totalCount).toEqual(2);
|
||||
});
|
||||
|
||||
it('results shows the number of passed expectations for each spec after execution', function () {
|
||||
expect(results.passedCount).toEqual(0);
|
||||
spec.execute();
|
||||
expect(results.passedCount).toEqual(2);
|
||||
});
|
||||
|
||||
it('results shows the number of failed expectations for each spec after execution', function () {
|
||||
spec.runs(function () {
|
||||
this.expect(true).toEqual(false);
|
||||
});
|
||||
expect(results.failedCount).toEqual(0);
|
||||
spec.execute();
|
||||
expect(results.failedCount).toEqual(1);
|
||||
});
|
||||
|
||||
describe('results.passed', function () {
|
||||
it('is true if all spec expectations pass', function () {
|
||||
spec.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
spec.execute();
|
||||
expect(results.passed()).toEqual(true);
|
||||
});
|
||||
|
||||
it('is false if one spec expectation fails', function () {
|
||||
spec.runs(function () {
|
||||
this.expect(true).toEqual(false);
|
||||
});
|
||||
spec.execute();
|
||||
expect(results.passed()).toEqual(false);
|
||||
});
|
||||
|
||||
it('a spec with no expectations will return true', function () {
|
||||
var specWithoutExpectations = new jasmine.Spec(env, suite);
|
||||
specWithoutExpectations.runs(function() {
|
||||
|
||||
});
|
||||
specWithoutExpectations.execute();
|
||||
expect(results.passed()).toEqual(true);
|
||||
});
|
||||
|
||||
it('an unexecuted spec will return true', function () {
|
||||
expect(results.passed()).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
it("includes log messages, which may contain arbitary objects", function() {
|
||||
spec.runs(function() {
|
||||
this.log("here's some log message", {key: 'value'}, 123);
|
||||
});
|
||||
spec.execute();
|
||||
var items = results.getItems();
|
||||
expect(items).toEqual([
|
||||
jasmine.any(jasmine.ExpectationResult),
|
||||
jasmine.any(jasmine.ExpectationResult),
|
||||
jasmine.any(jasmine.MessageResult)
|
||||
]);
|
||||
var logResult = items[2];
|
||||
expect(logResult.values).toEqual(["here's some log message", {key: 'value'}, 123]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -33,8 +33,8 @@ describe('Spies', function () {
|
||||
|
||||
TestClass.someFunction('foo');
|
||||
TestClass.someFunction('bar');
|
||||
expect(TestClass.someFunction.argsForCall[0]).toEqual(['foo']);
|
||||
expect(TestClass.someFunction.argsForCall[1]).toEqual(['bar']);
|
||||
expect(TestClass.someFunction.calls[0].args).toEqual(['foo']);
|
||||
expect(TestClass.someFunction.calls[1].args).toEqual(['bar']);
|
||||
expect(TestClass.someFunction.mostRecentCall.args).toEqual(['bar']);
|
||||
});
|
||||
|
||||
@@ -169,19 +169,33 @@ describe('Spies', function () {
|
||||
var TestClass = { someFunction: function() {} };
|
||||
this.spyOn(TestClass, 'someFunction');
|
||||
|
||||
expect(TestClass.someFunction).wasNotCalled();
|
||||
expect(TestClass.someFunction).not.toHaveBeenCalled();
|
||||
TestClass.someFunction();
|
||||
expect(TestClass.someFunction).wasCalled();
|
||||
expect(TestClass.someFunction).toHaveBeenCalled();
|
||||
TestClass.someFunction.reset();
|
||||
expect(TestClass.someFunction).wasNotCalled();
|
||||
expect(TestClass.someFunction).not.toHaveBeenCalled();
|
||||
expect(TestClass.someFunction.callCount).toEqual(0);
|
||||
});
|
||||
|
||||
it("should create an object with a bunch of spy methods when you call jasmine.createSpyObj()", function() {
|
||||
var spyObj = jasmine.createSpyObj('BaseName', ['method1', 'method2']);
|
||||
expect(spyObj).toEqual({ method1: jasmine.any(Function), method2: jasmine.any(Function)});
|
||||
expect(spyObj.method1.identity).toEqual('BaseName.method1');
|
||||
expect(spyObj.method2.identity).toEqual('BaseName.method2');
|
||||
describe("createSpyObj", function() {
|
||||
it("should create an object with a bunch of spy methods when you call jasmine.createSpyObj()", function() {
|
||||
var spyObj = jasmine.createSpyObj('BaseName', ['method1', 'method2']);
|
||||
expect(spyObj).toEqual({ method1: jasmine.any(Function), method2: jasmine.any(Function)});
|
||||
expect(spyObj.method1.identity).toEqual('BaseName.method1');
|
||||
expect(spyObj.method2.identity).toEqual('BaseName.method2');
|
||||
});
|
||||
|
||||
it("should throw if you do not pass an array argument", function() {
|
||||
expect(function() {
|
||||
jasmine.createSpyObj('BaseName');
|
||||
}).toThrow('createSpyObj requires a non-empty array of method names to create spies for');
|
||||
});
|
||||
|
||||
it("should throw if you pass an empty array argument", function() {
|
||||
expect(function() {
|
||||
jasmine.createSpyObj('BaseName');
|
||||
}).toThrow('createSpyObj requires a non-empty array of method names to create spies for');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
120
spec/suites/SuiteSpec.js
Normal file
120
spec/suites/SuiteSpec.js
Normal file
@@ -0,0 +1,120 @@
|
||||
describe('Suite', function() {
|
||||
var fakeTimer;
|
||||
var env;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
|
||||
fakeTimer = new jasmine.FakeTimer();
|
||||
env.setTimeout = fakeTimer.setTimeout;
|
||||
env.clearTimeout = fakeTimer.clearTimeout;
|
||||
env.setInterval = fakeTimer.setInterval;
|
||||
env.clearInterval = fakeTimer.clearInterval;
|
||||
});
|
||||
|
||||
describe('Specs', function () {
|
||||
var suite;
|
||||
|
||||
beforeEach(function() {
|
||||
suite = env.describe('Suite 1', function () {
|
||||
env.it('Spec 1', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
env.it('Spec 2', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
env.describe('Suite 2', function () {
|
||||
env.it('Spec 3', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
env.it('Spec 4', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('#specs should return all immediate children that are specs.', function () {
|
||||
var suiteSpecs = suite.specs();
|
||||
expect(suiteSpecs.length).toEqual(3);
|
||||
expect(suiteSpecs[0].description).toEqual('Spec 1');
|
||||
expect(suiteSpecs[1].description).toEqual('Spec 2');
|
||||
expect(suiteSpecs[2].description).toEqual('Spec 4');
|
||||
});
|
||||
|
||||
it("#suites should return all immediate children that are suites.", function() {
|
||||
var nestedSuites = suite.suites();
|
||||
expect(nestedSuites.length).toEqual(1);
|
||||
expect(nestedSuites[0].description).toEqual('Suite 2');
|
||||
});
|
||||
|
||||
it("#children should return all immediate children including suites and specs.", function() {
|
||||
var children = suite.children();
|
||||
expect(children.length).toEqual(4);
|
||||
expect(children[0].description).toEqual('Spec 1');
|
||||
expect(children[1].description).toEqual('Spec 2');
|
||||
expect(children[2].description).toEqual('Suite 2');
|
||||
expect(children[3].description).toEqual('Spec 4');
|
||||
});
|
||||
});
|
||||
|
||||
describe('SpecCount', function () {
|
||||
|
||||
it('should keep a count of the number of specs that are run', function() {
|
||||
var suite = env.describe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
env.it('should be another test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
env.it('should be a third test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
expect(suite.specs().length).toEqual(3);
|
||||
});
|
||||
|
||||
it('specCount should be correct even with runs/waits blocks', function() {
|
||||
var suite = env.describe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
env.it('should be another test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
this.waits(10);
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
env.it('should be a third test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
expect(suite.specs().length).toEqual(3);
|
||||
});
|
||||
});
|
||||
});
|
||||
235
spec/suites/TrivialReporterSpec.js
Normal file
235
spec/suites/TrivialReporterSpec.js
Normal file
@@ -0,0 +1,235 @@
|
||||
describe("TrivialReporter", function() {
|
||||
var env;
|
||||
var trivialReporter;
|
||||
var body;
|
||||
var fakeDocument;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
|
||||
body = document.createElement("body");
|
||||
fakeDocument = { body: body, location: { search: "" } };
|
||||
trivialReporter = new jasmine.TrivialReporter(fakeDocument);
|
||||
});
|
||||
|
||||
function fakeSpec(name) {
|
||||
return {
|
||||
getFullName: function() {
|
||||
return name;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function findElements(divs, withClass) {
|
||||
var els = [];
|
||||
for (var i = 0; i < divs.length; i++) {
|
||||
if (divs[i].className == withClass) els.push(divs[i]);
|
||||
}
|
||||
return els;
|
||||
}
|
||||
|
||||
function findElement(divs, withClass) {
|
||||
var els = findElements(divs, withClass);
|
||||
if (els.length > 0) return els[0];
|
||||
throw new Error("couldn't find div with class " + withClass);
|
||||
}
|
||||
|
||||
it("should run only specs beginning with spec parameter", function() {
|
||||
fakeDocument.location.search = "?spec=run%20this";
|
||||
expect(trivialReporter.specFilter(fakeSpec("run this"))).toBeTruthy();
|
||||
expect(trivialReporter.specFilter(fakeSpec("not the right spec"))).toBeFalsy();
|
||||
expect(trivialReporter.specFilter(fakeSpec("not run this"))).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should display empty divs for every suite when the runner is starting", function() {
|
||||
trivialReporter.reportRunnerStarting({
|
||||
env: env,
|
||||
suites: function() {
|
||||
return [ new jasmine.Suite({}, "suite 1", null, null) ];
|
||||
}
|
||||
});
|
||||
|
||||
var divs = findElements(body.getElementsByTagName("div"), "suite");
|
||||
expect(divs.length).toEqual(1);
|
||||
expect(divs[0].innerHTML).toContain("suite 1");
|
||||
});
|
||||
|
||||
describe('Matcher reporting', function () {
|
||||
var getResultMessageDiv = function (body) {
|
||||
var divs = body.getElementsByTagName("div");
|
||||
for (var i = 0; i < divs.length; i++) {
|
||||
if (divs[i].className.match(/resultMessage/)) {
|
||||
return divs[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var runner, spec, fakeTimer;
|
||||
beforeEach(function () {
|
||||
fakeTimer = new jasmine.FakeTimer();
|
||||
env.setTimeout = fakeTimer.setTimeout;
|
||||
env.clearTimeout = fakeTimer.clearTimeout;
|
||||
env.setInterval = fakeTimer.setInterval;
|
||||
env.clearInterval = fakeTimer.clearInterval;
|
||||
runner = env.currentRunner();
|
||||
var suite = new jasmine.Suite(env, 'some suite');
|
||||
runner.add(suite);
|
||||
spec = new jasmine.Spec(env, suite, 'some spec');
|
||||
suite.add(spec);
|
||||
fakeDocument.location.search = "?";
|
||||
env.addReporter(trivialReporter);
|
||||
});
|
||||
|
||||
describe('toContain', function () {
|
||||
it('should show actual and expected', function () {
|
||||
spec.runs(function () {
|
||||
this.expect('foo').toContain('bar');
|
||||
});
|
||||
runner.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
var resultEl = getResultMessageDiv(body);
|
||||
expect(resultEl.innerHTML).toMatch(/foo/);
|
||||
expect(resultEl.innerHTML).toMatch(/bar/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("failure messages (integration)", function () {
|
||||
var spec, results, expectationResult;
|
||||
|
||||
beforeEach(function() {
|
||||
results = {
|
||||
passed: function() {
|
||||
return false;
|
||||
},
|
||||
getItems: function() {
|
||||
}};
|
||||
|
||||
var suite1 = new jasmine.Suite(env, "suite 1", null, null);
|
||||
|
||||
spec = {
|
||||
suite: suite1,
|
||||
getFullName: function() {
|
||||
return "foo";
|
||||
},
|
||||
results: function() {
|
||||
return results;
|
||||
}
|
||||
};
|
||||
|
||||
trivialReporter.reportRunnerStarting({
|
||||
env: env,
|
||||
suites: function() {
|
||||
return [ suite1 ];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("should add the failure message to the DOM (non-toEquals matchers)", function() {
|
||||
expectationResult = new jasmine.ExpectationResult({
|
||||
matcherName: "toBeNull", passed: false, message: "Expected 'a' to be null, but it was not"
|
||||
});
|
||||
|
||||
spyOn(results, 'getItems').andReturn([expectationResult]);
|
||||
|
||||
trivialReporter.reportSpecResults(spec);
|
||||
|
||||
var divs = body.getElementsByTagName("div");
|
||||
var errorDiv = findElement(divs, 'resultMessage fail');
|
||||
expect(errorDiv.innerHTML).toEqual("Expected 'a' to be null, but it was not");
|
||||
});
|
||||
|
||||
it("should add the failure message to the DOM (non-toEquals matchers) html escaping", function() {
|
||||
expectationResult = new jasmine.ExpectationResult({
|
||||
matcherName: "toBeNull", passed: false, message: "Expected '1 < 2' to <b>e null, & it was not"
|
||||
});
|
||||
|
||||
spyOn(results, 'getItems').andReturn([expectationResult]);
|
||||
|
||||
trivialReporter.reportSpecResults(spec);
|
||||
|
||||
var divs = body.getElementsByTagName("div");
|
||||
var errorDiv = findElement(divs, 'resultMessage fail');
|
||||
expect(errorDiv.innerHTML).toEqual("Expected '1 < 2' to <b>e null, & it was not");
|
||||
});
|
||||
});
|
||||
|
||||
describe("log messages", function() {
|
||||
it("should appear in the report", function() {
|
||||
env.describe("suite", function() {
|
||||
env.it("will have log messages", function() {
|
||||
this.log("this is a", "multipart log message");
|
||||
});
|
||||
});
|
||||
|
||||
env.addReporter(trivialReporter);
|
||||
env.execute();
|
||||
|
||||
var divs = body.getElementsByTagName("div");
|
||||
var errorDiv = findElement(divs, 'resultMessage log');
|
||||
expect(errorDiv.innerHTML).toEqual("this is a multipart log message");
|
||||
});
|
||||
});
|
||||
|
||||
describe("duplicate example names", function() {
|
||||
it("should report failures correctly", function() {
|
||||
var suite1 = env.describe("suite", function() {
|
||||
env.it("will have log messages", function() {
|
||||
this.log("this one fails!");
|
||||
this.expect(true).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
var suite2 = env.describe("suite", function() {
|
||||
env.it("will have log messages", function() {
|
||||
this.log("this one passes!");
|
||||
this.expect(true).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
env.addReporter(trivialReporter);
|
||||
env.execute();
|
||||
|
||||
var divs = body.getElementsByTagName("div");
|
||||
var passedSpecDiv = findElement(divs, 'suite passed');
|
||||
expect(passedSpecDiv.className).toEqual('suite passed');
|
||||
expect(passedSpecDiv.innerHTML).toContain("this one passes!");
|
||||
expect(passedSpecDiv.innerHTML).not.toContain("this one fails!");
|
||||
|
||||
var failedSpecDiv = findElement(divs, 'suite failed');
|
||||
expect(failedSpecDiv.className).toEqual('suite failed');
|
||||
expect(failedSpecDiv.innerHTML).toContain("this one fails!");
|
||||
expect(failedSpecDiv.innerHTML).not.toContain("this one passes!");
|
||||
});
|
||||
});
|
||||
|
||||
describe('#reportSpecStarting', function() {
|
||||
var spec1;
|
||||
beforeEach(function () {
|
||||
env.describe("suite 1", function() {
|
||||
spec1 = env.it("spec 1", function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('DOES NOT log running specs by default', function() {
|
||||
spyOn(trivialReporter, 'log');
|
||||
|
||||
trivialReporter.reportSpecStarting(spec1);
|
||||
|
||||
expect(trivialReporter.log).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('logs running specs when log_running_specs is true', function() {
|
||||
trivialReporter.logRunningSpecs = true;
|
||||
spyOn(trivialReporter, 'log');
|
||||
|
||||
trivialReporter.reportSpecStarting(spec1);
|
||||
|
||||
expect(trivialReporter.log).toHaveBeenCalledWith('>> Jasmine Running suite 1 spec 1...');
|
||||
});
|
||||
});
|
||||
});
|
||||
40
spec/suites/UtilSpec.js
Normal file
40
spec/suites/UtilSpec.js
Normal file
@@ -0,0 +1,40 @@
|
||||
describe("jasmine.util", function() {
|
||||
describe("extend", function () {
|
||||
it("should add properies to a destination object ", function() {
|
||||
var destination = {baz: 'baz'};
|
||||
jasmine.util.extend(destination, {
|
||||
foo: 'foo', bar: 'bar'
|
||||
});
|
||||
expect(destination).toEqual({foo: 'foo', bar: 'bar', baz: 'baz'});
|
||||
});
|
||||
|
||||
it("should replace properies that already exist on a destination object", function() {
|
||||
var destination = {foo: 'foo'};
|
||||
jasmine.util.extend(destination, {
|
||||
foo: 'bar'
|
||||
});
|
||||
expect(destination).toEqual({foo: 'bar'});
|
||||
jasmine.util.extend(destination, {
|
||||
foo: null
|
||||
});
|
||||
expect(destination).toEqual({foo: null});
|
||||
});
|
||||
});
|
||||
|
||||
describe("isArray_", function() {
|
||||
it("should return true if the argument is an array", function() {
|
||||
expect(jasmine.isArray_([])).toBe(true);
|
||||
expect(jasmine.isArray_(['a'])).toBe(true);
|
||||
expect(jasmine.isArray_(new Array())).toBe(true);
|
||||
});
|
||||
|
||||
it("should return false if the argument is not an array", function() {
|
||||
expect(jasmine.isArray_(undefined)).toBe(false);
|
||||
expect(jasmine.isArray_({})).toBe(false);
|
||||
expect(jasmine.isArray_(function() {})).toBe(false);
|
||||
expect(jasmine.isArray_('foo')).toBe(false);
|
||||
expect(jasmine.isArray_(5)).toBe(false);
|
||||
expect(jasmine.isArray_(null)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
87
spec/suites/WaitsForBlockSpec.js
Normal file
87
spec/suites/WaitsForBlockSpec.js
Normal file
@@ -0,0 +1,87 @@
|
||||
describe('WaitsForBlock', function () {
|
||||
var env, suite, timeout, spec, message, onComplete, fakeTimer;
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
suite = new jasmine.Suite(env, 'suite 1');
|
||||
timeout = 1000;
|
||||
spec = new jasmine.Spec(env, suite);
|
||||
message = "some error message";
|
||||
onComplete = jasmine.createSpy("onComplete");
|
||||
});
|
||||
|
||||
it('onComplete should be called if the latchFunction returns true', function () {
|
||||
var latchFunction = function() {
|
||||
return true;
|
||||
};
|
||||
var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
|
||||
expect(onComplete).wasNotCalled();
|
||||
block.execute(onComplete);
|
||||
expect(onComplete).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('latchFunction should run in same scope as spec', function () {
|
||||
var result;
|
||||
var latchFunction = function() {
|
||||
result = this.scopedValue;
|
||||
};
|
||||
spec.scopedValue = 'foo';
|
||||
var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
|
||||
block.execute(onComplete);
|
||||
expect(result).toEqual('foo');
|
||||
});
|
||||
|
||||
it('should fail spec and call onComplete if there is an error in the latchFunction', function() {
|
||||
var latchFunction = jasmine.createSpy('latchFunction').andThrow('some error');
|
||||
spyOn(spec, 'fail');
|
||||
var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
|
||||
block.execute(onComplete);
|
||||
expect(spec.fail).toHaveBeenCalledWith('some error');
|
||||
expect(onComplete).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe("if latchFunction returns false", function() {
|
||||
var latchFunction, fakeTimer;
|
||||
beforeEach(function() {
|
||||
latchFunction = jasmine.createSpy('latchFunction').andReturn(false);
|
||||
fakeTimer = new jasmine.FakeTimer();
|
||||
env.setTimeout = fakeTimer.setTimeout;
|
||||
env.clearTimeout = fakeTimer.clearTimeout;
|
||||
env.setInterval = fakeTimer.setInterval;
|
||||
env.clearInterval = fakeTimer.clearInterval;
|
||||
});
|
||||
|
||||
it('latchFunction should be retried after 100 ms', function () {
|
||||
var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
|
||||
expect(latchFunction).wasNotCalled();
|
||||
block.execute(onComplete);
|
||||
expect(latchFunction.callCount).toEqual(1);
|
||||
fakeTimer.tick(50);
|
||||
expect(latchFunction.callCount).toEqual(1);
|
||||
fakeTimer.tick(50);
|
||||
expect(latchFunction.callCount).toEqual(2);
|
||||
});
|
||||
|
||||
it('onComplete should be called if latchFunction returns true before timeout', function () {
|
||||
var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
|
||||
expect(onComplete).wasNotCalled();
|
||||
block.execute(onComplete);
|
||||
expect(onComplete).wasNotCalled();
|
||||
latchFunction.andReturn(true);
|
||||
fakeTimer.tick(100);
|
||||
expect(onComplete).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('spec should fail with the passed message if the timeout is reached (and not call onComplete)', function () {
|
||||
spyOn(spec, 'fail');
|
||||
var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
|
||||
block.execute(onComplete);
|
||||
expect(spec.fail).wasNotCalled();
|
||||
fakeTimer.tick(timeout);
|
||||
expect(spec.fail).toHaveBeenCalled();
|
||||
var failMessage = spec.fail.mostRecentCall.args[0].message;
|
||||
expect(failMessage).toMatch(message);
|
||||
expect(onComplete).wasNotCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,92 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @constructor
|
||||
* @param {jasmine.Env} env
|
||||
*/
|
||||
jasmine.ActionCollection = function(env) {
|
||||
this.env = env;
|
||||
this.actions = [];
|
||||
this.index = 0;
|
||||
this.finished = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Marks the collection as done & calls the finish callback, if there is one
|
||||
*/
|
||||
jasmine.ActionCollection.prototype.finish = function() {
|
||||
if (this.finishCallback) {
|
||||
this.finishCallback();
|
||||
}
|
||||
this.finished = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Starts executing the queue of functions/actions.
|
||||
*/
|
||||
jasmine.ActionCollection.prototype.execute = function() {
|
||||
if (this.actions.length > 0) {
|
||||
this.next();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the current action.
|
||||
*/
|
||||
jasmine.ActionCollection.prototype.getCurrentAction = function() {
|
||||
return this.actions[this.index];
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the next queued function/action. If there are no more in the queue, calls #finish.
|
||||
*/
|
||||
jasmine.ActionCollection.prototype.next = function() {
|
||||
if (this.index >= this.actions.length) {
|
||||
this.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
var currentAction = this.getCurrentAction();
|
||||
|
||||
currentAction.execute(this);
|
||||
|
||||
if (currentAction.afterCallbacks) {
|
||||
for (var i = 0; i < currentAction.afterCallbacks.length; i++) {
|
||||
try {
|
||||
currentAction.afterCallbacks[i]();
|
||||
} catch (e) {
|
||||
alert(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.waitForDone(currentAction);
|
||||
};
|
||||
|
||||
jasmine.ActionCollection.prototype.waitForDone = function(action) {
|
||||
var self = this;
|
||||
var afterExecute = function afterExecute() {
|
||||
self.index++;
|
||||
self.next();
|
||||
};
|
||||
|
||||
if (action.finished) {
|
||||
var now = new Date().getTime();
|
||||
if (this.env.updateInterval && now - this.env.lastUpdate > this.env.updateInterval) {
|
||||
this.env.lastUpdate = now;
|
||||
this.env.setTimeout(afterExecute, 0);
|
||||
} else {
|
||||
afterExecute();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var id = this.env.setInterval(function() {
|
||||
if (action.finished) {
|
||||
self.env.clearInterval(id);
|
||||
afterExecute();
|
||||
}
|
||||
}, 150);
|
||||
};
|
||||
22
src/Block.js
Normal file
22
src/Block.js
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Blocks are functions with executable code that make up a spec.
|
||||
*
|
||||
* @constructor
|
||||
* @param {jasmine.Env} env
|
||||
* @param {Function} func
|
||||
* @param {jasmine.Spec} spec
|
||||
*/
|
||||
jasmine.Block = function(env, func, spec) {
|
||||
this.env = env;
|
||||
this.func = func;
|
||||
this.spec = spec;
|
||||
};
|
||||
|
||||
jasmine.Block.prototype.execute = function(onComplete) {
|
||||
try {
|
||||
this.func.apply(this.spec);
|
||||
} catch (e) {
|
||||
this.spec.fail(e);
|
||||
}
|
||||
onComplete();
|
||||
};
|
||||
124
src/Env.js
124
src/Env.js
@@ -6,12 +6,11 @@
|
||||
jasmine.Env = function() {
|
||||
this.currentSpec = null;
|
||||
this.currentSuite = null;
|
||||
this.currentRunner = new jasmine.Runner(this);
|
||||
this.currentlyRunningTests = false;
|
||||
this.currentRunner_ = new jasmine.Runner(this);
|
||||
|
||||
this.reporter = new jasmine.MultiReporter();
|
||||
|
||||
this.updateInterval = 0;
|
||||
this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL;
|
||||
this.lastUpdate = 0;
|
||||
this.specFilter = function() {
|
||||
return true;
|
||||
@@ -20,6 +19,14 @@ jasmine.Env = function() {
|
||||
this.nextSpecId_ = 0;
|
||||
this.nextSuiteId_ = 0;
|
||||
this.equalityTesters_ = [];
|
||||
|
||||
// wrap matchers
|
||||
this.matchersClass = function() {
|
||||
jasmine.Matchers.apply(this, arguments);
|
||||
};
|
||||
jasmine.util.inherit(this.matchersClass, jasmine.Matchers);
|
||||
|
||||
jasmine.Matchers.wrapInto_(jasmine.Matchers.prototype, this.matchersClass);
|
||||
};
|
||||
|
||||
|
||||
@@ -28,6 +35,43 @@ jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout;
|
||||
jasmine.Env.prototype.setInterval = jasmine.setInterval;
|
||||
jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
|
||||
|
||||
/**
|
||||
* @returns an object containing jasmine version build info, if set.
|
||||
*/
|
||||
jasmine.Env.prototype.version = function () {
|
||||
if (jasmine.version_) {
|
||||
return jasmine.version_;
|
||||
} else {
|
||||
throw new Error('Version not set');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns string containing jasmine version build info, if set.
|
||||
*/
|
||||
jasmine.Env.prototype.versionString = function() {
|
||||
if (jasmine.version_) {
|
||||
var version = this.version();
|
||||
return version.major + "." + version.minor + "." + version.build + " revision " + version.revision;
|
||||
} else {
|
||||
return "version unknown";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns a sequential integer starting at 0
|
||||
*/
|
||||
jasmine.Env.prototype.nextSpecId = function () {
|
||||
return this.nextSpecId_++;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns a sequential integer starting at 0
|
||||
*/
|
||||
jasmine.Env.prototype.nextSuiteId = function () {
|
||||
return this.nextSuiteId_++;
|
||||
};
|
||||
|
||||
/**
|
||||
* Register a reporter to receive status updates from Jasmine.
|
||||
* @param {jasmine.Reporter} reporter An object which will receive status updates.
|
||||
@@ -37,7 +81,7 @@ jasmine.Env.prototype.addReporter = function(reporter) {
|
||||
};
|
||||
|
||||
jasmine.Env.prototype.execute = function() {
|
||||
this.currentRunner.execute();
|
||||
this.currentRunner_.execute();
|
||||
};
|
||||
|
||||
jasmine.Env.prototype.describe = function(description, specDefinitions) {
|
||||
@@ -45,26 +89,50 @@ jasmine.Env.prototype.describe = function(description, specDefinitions) {
|
||||
|
||||
var parentSuite = this.currentSuite;
|
||||
if (parentSuite) {
|
||||
parentSuite.specs.push(suite);
|
||||
parentSuite.add(suite);
|
||||
} else {
|
||||
this.currentRunner.suites.push(suite);
|
||||
this.currentRunner_.add(suite);
|
||||
}
|
||||
|
||||
this.currentSuite = suite;
|
||||
|
||||
specDefinitions.call(suite);
|
||||
var declarationError = null;
|
||||
try {
|
||||
specDefinitions.call(suite);
|
||||
} catch(e) {
|
||||
declarationError = e;
|
||||
}
|
||||
|
||||
this.currentSuite = parentSuite;
|
||||
|
||||
if (declarationError) {
|
||||
this.it("encountered a declaration exception", function() {
|
||||
throw declarationError;
|
||||
});
|
||||
}
|
||||
|
||||
return suite;
|
||||
};
|
||||
|
||||
jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {
|
||||
this.currentSuite.beforeEach(beforeEachFunction);
|
||||
if (this.currentSuite) {
|
||||
this.currentSuite.beforeEach(beforeEachFunction);
|
||||
} else {
|
||||
this.currentRunner_.beforeEach(beforeEachFunction);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Env.prototype.currentRunner = function () {
|
||||
return this.currentRunner_;
|
||||
};
|
||||
|
||||
jasmine.Env.prototype.afterEach = function(afterEachFunction) {
|
||||
this.currentSuite.afterEach(afterEachFunction);
|
||||
if (this.currentSuite) {
|
||||
this.currentSuite.afterEach(afterEachFunction);
|
||||
} else {
|
||||
this.currentRunner_.afterEach(afterEachFunction);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {
|
||||
@@ -76,11 +144,11 @@ jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {
|
||||
|
||||
jasmine.Env.prototype.it = function(description, func) {
|
||||
var spec = new jasmine.Spec(this, this.currentSuite, description);
|
||||
this.currentSuite.specs.push(spec);
|
||||
this.currentSuite.add(spec);
|
||||
this.currentSpec = spec;
|
||||
|
||||
if (func) {
|
||||
spec.addToQueue(func);
|
||||
spec.runs(func);
|
||||
}
|
||||
|
||||
return spec;
|
||||
@@ -88,7 +156,7 @@ jasmine.Env.prototype.it = function(description, func) {
|
||||
|
||||
jasmine.Env.prototype.xit = function(desc, func) {
|
||||
return {
|
||||
id: this.nextSpecId_++,
|
||||
id: this.nextSpecId(),
|
||||
runs: function() {
|
||||
}
|
||||
};
|
||||
@@ -103,23 +171,23 @@ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchVal
|
||||
b.__Jasmine_been_here_before__ = a;
|
||||
|
||||
var hasKey = function(obj, keyName) {
|
||||
return obj != null && obj[keyName] !== undefined;
|
||||
return obj != null && obj[keyName] !== jasmine.undefined;
|
||||
};
|
||||
|
||||
for (var property in b) {
|
||||
if (!hasKey(a, property) && hasKey(b, property)) {
|
||||
mismatchKeys.push("expected has key '" + property + "', but missing from <b>actual</b>.");
|
||||
mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
|
||||
}
|
||||
}
|
||||
for (property in a) {
|
||||
if (!hasKey(b, property) && hasKey(a, property)) {
|
||||
mismatchKeys.push("<b>expected</b> missing key '" + property + "', but present in actual.");
|
||||
mismatchKeys.push("expected missing key '" + property + "', but present in actual.");
|
||||
}
|
||||
}
|
||||
for (property in b) {
|
||||
if (property == '__Jasmine_been_here_before__') continue;
|
||||
if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) {
|
||||
mismatchValues.push("'" + property + "' was<br /><br />'" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "'<br /><br />in expected, but was<br /><br />'" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "'<br /><br />in actual.<br />");
|
||||
mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,10 +204,16 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
||||
mismatchKeys = mismatchKeys || [];
|
||||
mismatchValues = mismatchValues || [];
|
||||
|
||||
for (var i = 0; i < this.equalityTesters_.length; i++) {
|
||||
var equalityTester = this.equalityTesters_[i];
|
||||
var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
|
||||
if (result !== jasmine.undefined) return result;
|
||||
}
|
||||
|
||||
if (a === b) return true;
|
||||
|
||||
if (a === undefined || a === null || b === undefined || b === null) {
|
||||
return (a == undefined && b == undefined);
|
||||
if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {
|
||||
return (a == jasmine.undefined && b == jasmine.undefined);
|
||||
}
|
||||
|
||||
if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {
|
||||
@@ -158,14 +232,16 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
||||
return b.matches(a);
|
||||
}
|
||||
|
||||
if (typeof a === "object" && typeof b === "object") {
|
||||
return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
|
||||
if (jasmine.isString_(a) && jasmine.isString_(b)) {
|
||||
return (a == b);
|
||||
}
|
||||
|
||||
for (var i = 0; i < this.equalityTesters_.length; i++) {
|
||||
var equalityTester = this.equalityTesters_[i];
|
||||
var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
|
||||
if (result !== undefined) return result;
|
||||
if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) {
|
||||
return (a == b);
|
||||
}
|
||||
|
||||
if (typeof a === "object" && typeof b === "object") {
|
||||
return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
|
||||
}
|
||||
|
||||
//Straight check
|
||||
|
||||
@@ -5,36 +5,49 @@
|
||||
jasmine.JsApiReporter = function() {
|
||||
this.started = false;
|
||||
this.finished = false;
|
||||
this.suites = [];
|
||||
this.results = {};
|
||||
this.suites_ = [];
|
||||
this.results_ = {};
|
||||
};
|
||||
|
||||
jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
this.started = true;
|
||||
|
||||
for (var i = 0; i < runner.suites.length; i++) {
|
||||
var suite = runner.suites[i];
|
||||
this.suites.push(this.summarize_(suite));
|
||||
var suites = runner.topLevelSuites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
this.suites_.push(this.summarize_(suite));
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.JsApiReporter.prototype.suites = function() {
|
||||
return this.suites_;
|
||||
};
|
||||
|
||||
jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
|
||||
var isSuite = suiteOrSpec instanceof jasmine.Suite;
|
||||
var summary = {
|
||||
id: suiteOrSpec.id,
|
||||
name: suiteOrSpec.description,
|
||||
type: suiteOrSpec instanceof jasmine.Suite ? 'suite' : 'spec',
|
||||
type: isSuite ? 'suite' : 'spec',
|
||||
children: []
|
||||
};
|
||||
|
||||
if (suiteOrSpec.specs) {
|
||||
for (var i = 0; i < suiteOrSpec.specs.length; i++) {
|
||||
summary.children.push(this.summarize_(suiteOrSpec.specs[i]));
|
||||
|
||||
if (isSuite) {
|
||||
var children = suiteOrSpec.children();
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
summary.children.push(this.summarize_(children[i]));
|
||||
}
|
||||
}
|
||||
|
||||
return summary;
|
||||
};
|
||||
|
||||
jasmine.JsApiReporter.prototype.results = function() {
|
||||
return this.results_;
|
||||
};
|
||||
|
||||
jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) {
|
||||
return this.results_[specId];
|
||||
};
|
||||
|
||||
//noinspection JSUnusedLocalSymbols
|
||||
jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) {
|
||||
this.finished = true;
|
||||
@@ -46,9 +59,9 @@ jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) {
|
||||
|
||||
//noinspection JSUnusedLocalSymbols
|
||||
jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) {
|
||||
this.results[spec.id] = {
|
||||
messages: spec.results.getItems(),
|
||||
result: spec.results.failedCount > 0 ? "failed" : "passed"
|
||||
this.results_[spec.id] = {
|
||||
messages: spec.results().getItems(),
|
||||
result: spec.results().failedCount > 0 ? "failed" : "passed"
|
||||
};
|
||||
};
|
||||
|
||||
@@ -56,3 +69,34 @@ jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) {
|
||||
jasmine.JsApiReporter.prototype.log = function(str) {
|
||||
};
|
||||
|
||||
jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){
|
||||
var results = {};
|
||||
for (var i = 0; i < specIds.length; i++) {
|
||||
var specId = specIds[i];
|
||||
results[specId] = this.summarizeResult_(this.results_[specId]);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
|
||||
var summaryMessages = [];
|
||||
var messagesLength = result.messages.length;
|
||||
for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) {
|
||||
var resultMessage = result.messages[messageIndex];
|
||||
summaryMessages.push({
|
||||
text: resultMessage.type == 'log' ? resultMessage.toString() : jasmine.undefined,
|
||||
passed: resultMessage.passed ? resultMessage.passed() : true,
|
||||
type: resultMessage.type,
|
||||
message: resultMessage.message,
|
||||
trace: {
|
||||
stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
result : result.result,
|
||||
messages : summaryMessages
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
326
src/Matchers.js
326
src/Matchers.js
@@ -1,245 +1,309 @@
|
||||
jasmine.Matchers = function(env, actual, results) {
|
||||
/**
|
||||
* @constructor
|
||||
* @param {jasmine.Env} env
|
||||
* @param actual
|
||||
* @param {jasmine.Spec} spec
|
||||
*/
|
||||
jasmine.Matchers = function(env, actual, spec, opt_isNot) {
|
||||
this.env = env;
|
||||
this.actual = actual;
|
||||
this.passing_message = 'Passed.';
|
||||
this.results = results || new jasmine.NestedResults();
|
||||
this.spec = spec;
|
||||
this.isNot = opt_isNot || false;
|
||||
this.reportWasCalled_ = false;
|
||||
};
|
||||
|
||||
// todo: @deprecated as of Jasmine 0.11, remove soon [xw]
|
||||
jasmine.Matchers.pp = function(str) {
|
||||
return jasmine.util.htmlEscape(jasmine.pp(str));
|
||||
};
|
||||
|
||||
jasmine.Matchers.prototype.getResults = function() {
|
||||
return this.results;
|
||||
throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!");
|
||||
};
|
||||
|
||||
// todo: @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. [xw]
|
||||
jasmine.Matchers.prototype.report = function(result, failing_message, details) {
|
||||
this.results.addResult(new jasmine.ExpectationResult(result, result ? this.passing_message : failing_message, details));
|
||||
return result;
|
||||
throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs");
|
||||
};
|
||||
|
||||
jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) {
|
||||
for (var methodName in prototype) {
|
||||
if (methodName == 'report') continue;
|
||||
var orig = prototype[methodName];
|
||||
matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
|
||||
return function() {
|
||||
var matcherArgs = jasmine.util.argsToArray(arguments);
|
||||
var result = matcherFunction.apply(this, arguments);
|
||||
|
||||
if (this.isNot) {
|
||||
result = !result;
|
||||
}
|
||||
|
||||
if (this.reportWasCalled_) return result;
|
||||
|
||||
var message;
|
||||
if (!result) {
|
||||
if (this.message) {
|
||||
message = this.message.apply(this, arguments);
|
||||
if (jasmine.isArray_(message)) {
|
||||
message = message[this.isNot ? 1 : 0];
|
||||
}
|
||||
} else {
|
||||
var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
|
||||
message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate;
|
||||
if (matcherArgs.length > 0) {
|
||||
for (var i = 0; i < matcherArgs.length; i++) {
|
||||
if (i > 0) message += ",";
|
||||
message += " " + jasmine.pp(matcherArgs[i]);
|
||||
}
|
||||
}
|
||||
message += ".";
|
||||
}
|
||||
}
|
||||
var expectationResult = new jasmine.ExpectationResult({
|
||||
matcherName: matcherName,
|
||||
passed: result,
|
||||
expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0],
|
||||
actual: this.actual,
|
||||
message: message
|
||||
});
|
||||
this.spec.addMatcherResult(expectationResult);
|
||||
return result;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Matcher that compares the actual to the expected using ===.
|
||||
*
|
||||
* toBe: compares the actual to the expected using ===
|
||||
* @param expected
|
||||
*/
|
||||
jasmine.Matchers.prototype.toBe = function(expected) {
|
||||
return this.report(this.actual === expected, 'Expected<br /><br />' + jasmine.Matchers.pp(expected)
|
||||
+ '<br /><br />to be the same object as<br /><br />' + jasmine.Matchers.pp(this.actual)
|
||||
+ '<br />');
|
||||
return this.actual === expected;
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that compares the actual to the expected using !==
|
||||
* toNotBe: compares the actual to the expected using !==
|
||||
* @param expected
|
||||
*/
|
||||
jasmine.Matchers.prototype.toNotBe = function(expected) {
|
||||
return this.report(this.actual !== expected, 'Expected<br /><br />' + jasmine.Matchers.pp(expected)
|
||||
+ '<br /><br />to be a different object from actual, but they were the same.');
|
||||
return this.actual !== expected;
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc.
|
||||
* toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc.
|
||||
*
|
||||
* @param expected
|
||||
*/
|
||||
jasmine.Matchers.prototype.toEqual = function(expected) {
|
||||
var mismatchKeys = [];
|
||||
var mismatchValues = [];
|
||||
|
||||
var formatMismatches = function(name, array) {
|
||||
if (array.length == 0) return '';
|
||||
var errorOutput = '<br /><br />Different ' + name + ':<br />';
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
errorOutput += array[i] + '<br />';
|
||||
}
|
||||
return errorOutput;
|
||||
};
|
||||
|
||||
return this.report(this.env.equals_(this.actual, expected, mismatchKeys, mismatchValues),
|
||||
'Expected<br /><br />' + jasmine.Matchers.pp(expected)
|
||||
+ '<br /><br />but got<br /><br />' + jasmine.Matchers.pp(this.actual)
|
||||
+ '<br />'
|
||||
+ formatMismatches('Keys', mismatchKeys)
|
||||
+ formatMismatches('Values', mismatchValues), {
|
||||
matcherName: 'toEqual', expected: expected, actual: this.actual
|
||||
});
|
||||
return this.env.equals_(this.actual, expected);
|
||||
};
|
||||
/** @deprecated */
|
||||
jasmine.Matchers.prototype.should_equal = jasmine.Matchers.prototype.toEqual;
|
||||
|
||||
/**
|
||||
* Matcher that compares the actual to the expected using the ! of jasmine.Matchers.toEqual
|
||||
* toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
|
||||
* @param expected
|
||||
*/
|
||||
jasmine.Matchers.prototype.toNotEqual = function(expected) {
|
||||
return this.report(!this.env.equals_(this.actual, expected),
|
||||
'Expected ' + jasmine.Matchers.pp(expected) + ' to not equal ' + jasmine.Matchers.pp(this.actual) + ', but it does.');
|
||||
return !this.env.equals_(this.actual, expected);
|
||||
};
|
||||
/** @deprecated */
|
||||
jasmine.Matchers.prototype.should_not_equal = jasmine.Matchers.prototype.toNotEqual;
|
||||
|
||||
/**
|
||||
* Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes
|
||||
* a pattern or a String.
|
||||
*
|
||||
* @param reg_exp
|
||||
* @param expected
|
||||
*/
|
||||
jasmine.Matchers.prototype.toMatch = function(reg_exp) {
|
||||
return this.report((new RegExp(reg_exp).test(this.actual)),
|
||||
'Expected ' + jasmine.Matchers.pp(this.actual) + ' to match ' + reg_exp + '.');
|
||||
jasmine.Matchers.prototype.toMatch = function(expected) {
|
||||
return new RegExp(expected).test(this.actual);
|
||||
};
|
||||
/** @deprecated */
|
||||
jasmine.Matchers.prototype.should_match = jasmine.Matchers.prototype.toMatch;
|
||||
|
||||
/**
|
||||
* Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
|
||||
* @param reg_exp
|
||||
* @param expected
|
||||
*/
|
||||
jasmine.Matchers.prototype.toNotMatch = function(reg_exp) {
|
||||
return this.report((!new RegExp(reg_exp).test(this.actual)),
|
||||
'Expected ' + jasmine.Matchers.pp(this.actual) + ' to not match ' + reg_exp + '.');
|
||||
jasmine.Matchers.prototype.toNotMatch = function(expected) {
|
||||
return !(new RegExp(expected).test(this.actual));
|
||||
};
|
||||
/** @deprecated */
|
||||
jasmine.Matchers.prototype.should_not_match = jasmine.Matchers.prototype.toNotMatch;
|
||||
|
||||
/**
|
||||
* Matcher that compares the acutal to undefined.
|
||||
* Matcher that compares the actual to jasmine.undefined.
|
||||
*/
|
||||
jasmine.Matchers.prototype.toBeDefined = function() {
|
||||
return this.report((this.actual !== undefined),
|
||||
'Expected a value to be defined but it was undefined.');
|
||||
return (this.actual !== jasmine.undefined);
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that compares the actual to jasmine.undefined.
|
||||
*/
|
||||
jasmine.Matchers.prototype.toBeUndefined = function() {
|
||||
return (this.actual === jasmine.undefined);
|
||||
};
|
||||
/** @deprecated */
|
||||
jasmine.Matchers.prototype.should_be_defined = jasmine.Matchers.prototype.toBeDefined;
|
||||
|
||||
/**
|
||||
* Matcher that compares the actual to null.
|
||||
*
|
||||
*/
|
||||
jasmine.Matchers.prototype.toBeNull = function() {
|
||||
return this.report((this.actual === null),
|
||||
'Expected a value to be null but it was ' + jasmine.Matchers.pp(this.actual) + '.');
|
||||
return (this.actual === null);
|
||||
};
|
||||
/** @deprecated */
|
||||
jasmine.Matchers.prototype.should_be_null = jasmine.Matchers.prototype.toBeNull;
|
||||
|
||||
/**
|
||||
* Matcher that boolean not-nots the actual.
|
||||
*/
|
||||
jasmine.Matchers.prototype.toBeTruthy = function() {
|
||||
return this.report(!!this.actual,
|
||||
'Expected a value to be truthy but it was ' + jasmine.Matchers.pp(this.actual) + '.');
|
||||
return !!this.actual;
|
||||
};
|
||||
/** @deprecated */
|
||||
jasmine.Matchers.prototype.should_be_truthy = jasmine.Matchers.prototype.toBeTruthy;
|
||||
|
||||
|
||||
/**
|
||||
* Matcher that boolean nots the actual.
|
||||
*/
|
||||
jasmine.Matchers.prototype.toBeFalsy = function() {
|
||||
return this.report(!this.actual,
|
||||
'Expected a value to be falsy but it was ' + jasmine.Matchers.pp(this.actual) + '.');
|
||||
return !this.actual;
|
||||
};
|
||||
/** @deprecated */
|
||||
jasmine.Matchers.prototype.should_be_falsy = jasmine.Matchers.prototype.toBeFalsy;
|
||||
|
||||
/**
|
||||
* Matcher that checks to see if the acutal, a Jasmine spy, was called.
|
||||
*/
|
||||
|
||||
/** @deprecated Use expect(xxx).toHaveBeenCalled() instead */
|
||||
jasmine.Matchers.prototype.wasCalled = function() {
|
||||
if (!this.actual || !this.actual.isSpy) {
|
||||
return this.report(false, 'Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
|
||||
}
|
||||
if (arguments.length > 0) {
|
||||
return this.report(false, 'wasCalled matcher does not take arguments');
|
||||
}
|
||||
return this.report((this.actual.wasCalled),
|
||||
'Expected spy "' + this.actual.identity + '" to have been called, but it was not.');
|
||||
return this.toHaveBeenCalled();
|
||||
};
|
||||
/** @deprecated */
|
||||
jasmine.Matchers.prototype.was_called = jasmine.Matchers.prototype.wasCalled;
|
||||
|
||||
/**
|
||||
* Matcher that checks to see if the acutal, a Jasmine spy, was not called.
|
||||
* Matcher that checks to see if the actual, a Jasmine spy, was called.
|
||||
*/
|
||||
jasmine.Matchers.prototype.toHaveBeenCalled = function() {
|
||||
if (arguments.length > 0) {
|
||||
throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith');
|
||||
}
|
||||
|
||||
if (!jasmine.isSpy(this.actual)) {
|
||||
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
||||
}
|
||||
|
||||
this.message = function() {
|
||||
return "Expected spy " + this.actual.identity + " to have been called.";
|
||||
};
|
||||
|
||||
return this.actual.wasCalled;
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that checks to see if the actual, a Jasmine spy, was not called.
|
||||
*
|
||||
* @deprecated Use expect(xxx).not.toHaveBeenCalled() instead
|
||||
*/
|
||||
jasmine.Matchers.prototype.wasNotCalled = function() {
|
||||
if (!this.actual || !this.actual.isSpy) {
|
||||
return this.report(false, 'Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
|
||||
if (arguments.length > 0) {
|
||||
throw new Error('wasNotCalled does not take arguments');
|
||||
}
|
||||
return this.report((!this.actual.wasCalled),
|
||||
'Expected spy "' + this.actual.identity + '" to not have been called, but it was.');
|
||||
|
||||
if (!jasmine.isSpy(this.actual)) {
|
||||
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
||||
}
|
||||
|
||||
this.message = function() {
|
||||
return "Expected spy " + this.actual.identity + " to not have been called.";
|
||||
};
|
||||
|
||||
return !this.actual.wasCalled;
|
||||
};
|
||||
|
||||
/** @deprecated Use expect(xxx).toHaveBeenCalledWith() instead */
|
||||
jasmine.Matchers.prototype.wasCalledWith = function() {
|
||||
return this.toHaveBeenCalledWith.apply(this, arguments);
|
||||
};
|
||||
/** @deprecated */
|
||||
jasmine.Matchers.prototype.was_not_called = jasmine.Matchers.prototype.wasNotCalled;
|
||||
|
||||
/**
|
||||
* Matcher that checks to see if the acutal, a Jasmine spy, was called with a set of parameters.
|
||||
* Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
*/
|
||||
jasmine.Matchers.prototype.wasCalledWith = function() {
|
||||
if (!this.actual || !this.actual.isSpy) {
|
||||
return this.report(false, 'Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.', {
|
||||
matcherName: 'wasCalledWith'
|
||||
});
|
||||
jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
|
||||
var expectedArgs = jasmine.util.argsToArray(arguments);
|
||||
if (!jasmine.isSpy(this.actual)) {
|
||||
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
||||
}
|
||||
this.message = function() {
|
||||
if (this.actual.callCount == 0) {
|
||||
return "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.";
|
||||
} else {
|
||||
return "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall);
|
||||
}
|
||||
};
|
||||
|
||||
return this.env.contains_(this.actual.argsForCall, expectedArgs);
|
||||
};
|
||||
|
||||
/** @deprecated Use expect(xxx).not.toHaveBeenCalledWith() instead */
|
||||
jasmine.Matchers.prototype.wasNotCalledWith = function() {
|
||||
var expectedArgs = jasmine.util.argsToArray(arguments);
|
||||
if (!jasmine.isSpy(this.actual)) {
|
||||
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
||||
}
|
||||
|
||||
var args = jasmine.util.argsToArray(arguments);
|
||||
this.message = function() {
|
||||
return "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was";
|
||||
};
|
||||
|
||||
return this.report(this.env.contains_(this.actual.argsForCall, args),
|
||||
'Expected ' + jasmine.Matchers.pp(this.actual.argsForCall) + ' to contain ' + jasmine.Matchers.pp(args) + ', but it does not.', {
|
||||
matcherName: 'wasCalledWith', expected: args, actual: this.actual.argsForCall
|
||||
});
|
||||
return !this.env.contains_(this.actual.argsForCall, expectedArgs);
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that checks that the expected item is an element in the actual Array.
|
||||
*
|
||||
* @param {Object} item
|
||||
* @param {Object} expected
|
||||
*/
|
||||
jasmine.Matchers.prototype.toContain = function(item) {
|
||||
return this.report(this.env.contains_(this.actual, item),
|
||||
'Expected ' + jasmine.Matchers.pp(this.actual) + ' to contain ' + jasmine.Matchers.pp(item) + ', but it does not.', {
|
||||
matcherName: 'toContain', expected: item, actual: this.actual
|
||||
});
|
||||
jasmine.Matchers.prototype.toContain = function(expected) {
|
||||
return this.env.contains_(this.actual, expected);
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that checks that the expected item is NOT an element in the actual Array.
|
||||
*
|
||||
* @param {Object} item
|
||||
* @param {Object} expected
|
||||
*/
|
||||
jasmine.Matchers.prototype.toNotContain = function(item) {
|
||||
return this.report(!this.env.contains_(this.actual, item),
|
||||
'Expected ' + jasmine.Matchers.pp(this.actual) + ' not to contain ' + jasmine.Matchers.pp(item) + ', but it does.');
|
||||
jasmine.Matchers.prototype.toNotContain = function(expected) {
|
||||
return !this.env.contains_(this.actual, expected);
|
||||
};
|
||||
|
||||
jasmine.Matchers.prototype.toBeLessThan = function(expected) {
|
||||
return this.actual < expected;
|
||||
};
|
||||
|
||||
jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
|
||||
return this.actual > expected;
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that checks that the expected exception was thrown by the actual.
|
||||
*
|
||||
* @param {String} expectedException
|
||||
* @param {String} expected
|
||||
*/
|
||||
jasmine.Matchers.prototype.toThrow = function(expectedException) {
|
||||
var exception = null;
|
||||
jasmine.Matchers.prototype.toThrow = function(expected) {
|
||||
var result = false;
|
||||
var exception;
|
||||
if (typeof this.actual != 'function') {
|
||||
throw new Error('Actual is not a function');
|
||||
}
|
||||
try {
|
||||
this.actual();
|
||||
} catch (e) {
|
||||
exception = e;
|
||||
}
|
||||
if (expectedException !== undefined) {
|
||||
if (exception == null) {
|
||||
return this.report(false, "Expected function to throw " + jasmine.Matchers.pp(expectedException) + ", but it did not.");
|
||||
}
|
||||
return this.report(
|
||||
this.env.equals_(
|
||||
exception.message || exception,
|
||||
expectedException.message || expectedException),
|
||||
"Expected function to throw " + jasmine.Matchers.pp(expectedException) + ", but it threw " + jasmine.Matchers.pp(exception) + ".");
|
||||
} else {
|
||||
return this.report(exception != null, "Expected function to throw an exception, but it did not.");
|
||||
if (exception) {
|
||||
result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected));
|
||||
}
|
||||
|
||||
this.message = function() {
|
||||
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
|
||||
return ["Expected function to throw", expected.message || expected, ", but it threw", exception.message || exception].join(' ');
|
||||
} else {
|
||||
return "Expected function to throw an exception.";
|
||||
}
|
||||
};
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
jasmine.Matchers.Any = function(expectedClass) {
|
||||
|
||||
@@ -11,7 +11,14 @@ jasmine.MultiReporter.prototype.addReporter = function(reporter) {
|
||||
};
|
||||
|
||||
(function() {
|
||||
var functionNames = ["reportRunnerStarting", "reportRunnerResults", "reportSuiteResults", "reportSpecResults", "log"];
|
||||
var functionNames = [
|
||||
"reportRunnerStarting",
|
||||
"reportRunnerResults",
|
||||
"reportSuiteResults",
|
||||
"reportSpecStarting",
|
||||
"reportSpecResults",
|
||||
"log"
|
||||
];
|
||||
for (var i = 0; i < functionNames.length; i++) {
|
||||
var functionName = functionNames[i];
|
||||
jasmine.MultiReporter.prototype[functionName] = (function(functionName) {
|
||||
|
||||
@@ -38,11 +38,11 @@ jasmine.NestedResults.prototype.rollupCounts = function(result) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Tracks a result's message.
|
||||
* @param message
|
||||
* Adds a log message.
|
||||
* @param values Array of message parts which will be concatenated later.
|
||||
*/
|
||||
jasmine.NestedResults.prototype.log = function(message) {
|
||||
this.items_.push(new jasmine.MessageResult(message));
|
||||
jasmine.NestedResults.prototype.log = function(values) {
|
||||
this.items_.push(new jasmine.MessageResult(values));
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -57,12 +57,12 @@ jasmine.NestedResults.prototype.getItems = function() {
|
||||
* @param {jasmine.ExpectationResult|jasmine.NestedResults} result
|
||||
*/
|
||||
jasmine.NestedResults.prototype.addResult = function(result) {
|
||||
if (result.type != 'MessageResult') {
|
||||
if (result.type != 'log') {
|
||||
if (result.items_) {
|
||||
this.rollupCounts(result);
|
||||
} else {
|
||||
this.totalCount++;
|
||||
if (result.passed) {
|
||||
if (result.passed()) {
|
||||
this.passedCount++;
|
||||
} else {
|
||||
this.failedCount++;
|
||||
@@ -75,6 +75,6 @@ jasmine.NestedResults.prototype.addResult = function(result) {
|
||||
/**
|
||||
* @returns {Boolean} True if <b>everything</b> below passed
|
||||
*/
|
||||
jasmine.NestedResults.prototype.__defineGetter__('passed', function() {
|
||||
jasmine.NestedResults.prototype.passed = function() {
|
||||
return this.passedCount === this.totalCount;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -9,26 +9,28 @@ jasmine.PrettyPrinter = function() {
|
||||
* Formats a value in a nice, human-readable string.
|
||||
*
|
||||
* @param value
|
||||
* @returns {String}
|
||||
*/
|
||||
jasmine.PrettyPrinter.prototype.format = function(value) {
|
||||
if (this.ppNestLevel_ > 40) {
|
||||
// return '(jasmine.pp nested too deeply!)';
|
||||
throw new Error('jasmine.PrettyPrinter: format() nested too deeply!');
|
||||
}
|
||||
|
||||
this.ppNestLevel_++;
|
||||
try {
|
||||
if (value === undefined) {
|
||||
if (value === jasmine.undefined) {
|
||||
this.emitScalar('undefined');
|
||||
} else if (value === null) {
|
||||
this.emitScalar('null');
|
||||
} else if (value.navigator && value.frames && value.setTimeout) {
|
||||
this.emitScalar('<window>');
|
||||
} else if (value === jasmine.getGlobal()) {
|
||||
this.emitScalar('<global>');
|
||||
} else if (value instanceof jasmine.Matchers.Any) {
|
||||
this.emitScalar(value.toString());
|
||||
} else if (typeof value === 'string') {
|
||||
this.emitString(value);
|
||||
} else if (jasmine.isSpy(value)) {
|
||||
this.emitScalar("spy on " + value.identity);
|
||||
} else if (value instanceof RegExp) {
|
||||
this.emitScalar(value.toString());
|
||||
} else if (typeof value === 'function') {
|
||||
this.emitScalar('Function');
|
||||
} else if (typeof value.nodeType === 'number') {
|
||||
@@ -56,7 +58,7 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
|
||||
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
|
||||
for (var property in obj) {
|
||||
if (property == '__Jasmine_been_here_before__') continue;
|
||||
fn(property, obj.__lookupGetter__(property) != null);
|
||||
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) != null) : false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
94
src/Queue.js
Normal file
94
src/Queue.js
Normal file
@@ -0,0 +1,94 @@
|
||||
jasmine.Queue = function(env) {
|
||||
this.env = env;
|
||||
this.blocks = [];
|
||||
this.running = false;
|
||||
this.index = 0;
|
||||
this.offset = 0;
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.addBefore = function(block) {
|
||||
this.blocks.unshift(block);
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.add = function(block) {
|
||||
this.blocks.push(block);
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.insertNext = function(block) {
|
||||
this.blocks.splice((this.index + this.offset + 1), 0, block);
|
||||
this.offset++;
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.start = function(onComplete) {
|
||||
this.running = true;
|
||||
this.onComplete = onComplete;
|
||||
this.next_();
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.isRunning = function() {
|
||||
return this.running;
|
||||
};
|
||||
|
||||
jasmine.Queue.LOOP_DONT_RECURSE = true;
|
||||
|
||||
jasmine.Queue.prototype.next_ = function() {
|
||||
var self = this;
|
||||
var goAgain = true;
|
||||
|
||||
while (goAgain) {
|
||||
goAgain = false;
|
||||
|
||||
if (self.index < self.blocks.length) {
|
||||
var calledSynchronously = true;
|
||||
var completedSynchronously = false;
|
||||
|
||||
var onComplete = function () {
|
||||
if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {
|
||||
completedSynchronously = true;
|
||||
return;
|
||||
}
|
||||
|
||||
self.offset = 0;
|
||||
self.index++;
|
||||
|
||||
var now = new Date().getTime();
|
||||
if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {
|
||||
self.env.lastUpdate = now;
|
||||
self.env.setTimeout(function() {
|
||||
self.next_();
|
||||
}, 0);
|
||||
} else {
|
||||
if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {
|
||||
goAgain = true;
|
||||
} else {
|
||||
self.next_();
|
||||
}
|
||||
}
|
||||
};
|
||||
self.blocks[self.index].execute(onComplete);
|
||||
|
||||
calledSynchronously = false;
|
||||
if (completedSynchronously) {
|
||||
onComplete();
|
||||
}
|
||||
|
||||
} else {
|
||||
self.running = false;
|
||||
if (self.onComplete) {
|
||||
self.onComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.results = function() {
|
||||
var results = new jasmine.NestedResults();
|
||||
for (var i = 0; i < this.blocks.length; i++) {
|
||||
if (this.blocks[i].results) {
|
||||
results.addResult(this.blocks[i].results());
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
/**
|
||||
* QueuedFunction is how ActionCollections' actions are implemented
|
||||
*
|
||||
* @constructor
|
||||
* @param {jasmine.Env} env
|
||||
* @param {Function} func
|
||||
* @param {Number} timeout
|
||||
* @param {Function} latchFunction
|
||||
* @param {jasmine.Spec} spec
|
||||
*/
|
||||
jasmine.QueuedFunction = function(env, func, timeout, latchFunction, spec) {
|
||||
this.env = env;
|
||||
this.func = func;
|
||||
this.timeout = timeout;
|
||||
this.latchFunction = latchFunction;
|
||||
this.spec = spec;
|
||||
|
||||
this.totalTimeSpentWaitingForLatch = 0;
|
||||
this.latchTimeoutIncrement = 100;
|
||||
};
|
||||
|
||||
jasmine.QueuedFunction.prototype.next = function() {
|
||||
this.spec.finish(); // default value is to be done after one function
|
||||
};
|
||||
|
||||
jasmine.QueuedFunction.prototype.safeExecute = function() {
|
||||
this.env.reporter.log('>> Jasmine Running ' + this.spec.suite.description + ' ' + this.spec.description + '...');
|
||||
|
||||
try {
|
||||
this.func.apply(this.spec);
|
||||
} catch (e) {
|
||||
this.fail(e);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.QueuedFunction.prototype.execute = function() {
|
||||
var self = this;
|
||||
var executeNow = function() {
|
||||
self.safeExecute();
|
||||
self.next();
|
||||
};
|
||||
|
||||
var executeLater = function() {
|
||||
self.env.setTimeout(executeNow, self.timeout);
|
||||
};
|
||||
|
||||
var executeNowOrLater = function() {
|
||||
var latchFunctionResult;
|
||||
|
||||
try {
|
||||
latchFunctionResult = self.latchFunction.apply(self.spec);
|
||||
} catch (e) {
|
||||
self.fail(e);
|
||||
self.next();
|
||||
return;
|
||||
}
|
||||
|
||||
if (latchFunctionResult) {
|
||||
executeNow();
|
||||
} else if (self.totalTimeSpentWaitingForLatch >= self.timeout) {
|
||||
var message = 'timed out after ' + self.timeout + ' msec waiting for ' + (self.latchFunction.description || 'something to happen');
|
||||
self.fail({
|
||||
name: 'timeout',
|
||||
message: message
|
||||
});
|
||||
self.next();
|
||||
} else {
|
||||
self.totalTimeSpentWaitingForLatch += self.latchTimeoutIncrement;
|
||||
self.env.setTimeout(executeNowOrLater, self.latchTimeoutIncrement);
|
||||
}
|
||||
};
|
||||
|
||||
if (this.latchFunction !== undefined) {
|
||||
executeNowOrLater();
|
||||
} else if (this.timeout > 0) {
|
||||
executeLater();
|
||||
} else {
|
||||
executeNow();
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.QueuedFunction.prototype.fail = function(e) {
|
||||
this.spec.results.addResult(new jasmine.ExpectationResult(false, jasmine.util.formatException(e), null));
|
||||
};
|
||||
@@ -17,6 +17,10 @@ jasmine.Reporter.prototype.reportRunnerResults = function(runner) {
|
||||
jasmine.Reporter.prototype.reportSuiteResults = function(suite) {
|
||||
};
|
||||
|
||||
//noinspection JSUnusedLocalSymbols
|
||||
jasmine.Reporter.prototype.reportSpecStarting = function(spec) {
|
||||
};
|
||||
|
||||
//noinspection JSUnusedLocalSymbols
|
||||
jasmine.Reporter.prototype.reportSpecResults = function(spec) {
|
||||
};
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/* JasmineReporters.reporter
|
||||
* Base object that will get called whenever a Spec, Suite, or Runner is done. It is up to
|
||||
* descendants of this object to do something with the results (see json_reporter.js)
|
||||
*/
|
||||
jasmine.Reporters = {};
|
||||
|
||||
jasmine.Reporters.reporter = function(callbacks) {
|
||||
var that = {
|
||||
callbacks: callbacks || {},
|
||||
|
||||
doCallback: function(callback, results) {
|
||||
if (callback) {
|
||||
callback(results);
|
||||
}
|
||||
},
|
||||
|
||||
reportRunnerResults: function(runner) {
|
||||
that.doCallback(that.callbacks.runnerCallback, runner);
|
||||
},
|
||||
reportSuiteResults: function(suite) {
|
||||
that.doCallback(that.callbacks.suiteCallback, suite);
|
||||
},
|
||||
reportSpecResults: function(spec) {
|
||||
that.doCallback(that.callbacks.specCallback, spec);
|
||||
},
|
||||
log: function (str) {
|
||||
if (console && console.log) console.log(str);
|
||||
}
|
||||
};
|
||||
|
||||
return that;
|
||||
};
|
||||
|
||||
@@ -5,27 +5,73 @@
|
||||
* @param {jasmine.Env} env
|
||||
*/
|
||||
jasmine.Runner = function(env) {
|
||||
jasmine.ActionCollection.call(this, env);
|
||||
|
||||
this.suites = this.actions;
|
||||
var self = this;
|
||||
self.env = env;
|
||||
self.queue = new jasmine.Queue(env);
|
||||
self.before_ = [];
|
||||
self.after_ = [];
|
||||
self.suites_ = [];
|
||||
};
|
||||
jasmine.util.inherit(jasmine.Runner, jasmine.ActionCollection);
|
||||
|
||||
jasmine.Runner.prototype.execute = function() {
|
||||
if (this.env.reporter.reportRunnerStarting) {
|
||||
this.env.reporter.reportRunnerStarting(this);
|
||||
var self = this;
|
||||
if (self.env.reporter.reportRunnerStarting) {
|
||||
self.env.reporter.reportRunnerStarting(this);
|
||||
}
|
||||
jasmine.ActionCollection.prototype.execute.call(this);
|
||||
self.queue.start(function () {
|
||||
self.finishCallback();
|
||||
});
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) {
|
||||
beforeEachFunction.typeName = 'beforeEach';
|
||||
this.before_.splice(0,0,beforeEachFunction);
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.afterEach = function(afterEachFunction) {
|
||||
afterEachFunction.typeName = 'afterEach';
|
||||
this.after_.splice(0,0,afterEachFunction);
|
||||
};
|
||||
|
||||
|
||||
jasmine.Runner.prototype.finishCallback = function() {
|
||||
this.env.reporter.reportRunnerResults(this);
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.getResults = function() {
|
||||
var results = new jasmine.NestedResults();
|
||||
for (var i = 0; i < this.suites.length; i++) {
|
||||
results.rollupCounts(this.suites[i].getResults());
|
||||
}
|
||||
return results;
|
||||
jasmine.Runner.prototype.addSuite = function(suite) {
|
||||
this.suites_.push(suite);
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.add = function(block) {
|
||||
if (block instanceof jasmine.Suite) {
|
||||
this.addSuite(block);
|
||||
}
|
||||
this.queue.add(block);
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.specs = function () {
|
||||
var suites = this.suites();
|
||||
var specs = [];
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
specs = specs.concat(suites[i].specs());
|
||||
}
|
||||
return specs;
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.suites = function() {
|
||||
return this.suites_;
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.topLevelSuites = function() {
|
||||
var topLevelSuites = [];
|
||||
for (var i = 0; i < this.suites_.length; i++) {
|
||||
if (!this.suites_[i].parentSuite) {
|
||||
topLevelSuites.push(this.suites_[i]);
|
||||
}
|
||||
}
|
||||
return topLevelSuites;
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.results = function() {
|
||||
return this.queue.results();
|
||||
};
|
||||
197
src/Spec.js
197
src/Spec.js
@@ -7,82 +7,94 @@
|
||||
* @param {String} description
|
||||
*/
|
||||
jasmine.Spec = function(env, suite, description) {
|
||||
this.id = env.nextSpecId_++;
|
||||
this.env = env;
|
||||
this.suite = suite;
|
||||
this.description = description;
|
||||
this.queue = [];
|
||||
this.currentTimeout = 0;
|
||||
this.currentLatchFunction = undefined;
|
||||
this.finished = false;
|
||||
this.afterCallbacks = [];
|
||||
this.spies_ = [];
|
||||
if (!env) {
|
||||
throw new Error('jasmine.Env() required');
|
||||
}
|
||||
if (!suite) {
|
||||
throw new Error('jasmine.Suite() required');
|
||||
}
|
||||
var spec = this;
|
||||
spec.id = env.nextSpecId ? env.nextSpecId() : null;
|
||||
spec.env = env;
|
||||
spec.suite = suite;
|
||||
spec.description = description;
|
||||
spec.queue = new jasmine.Queue(env);
|
||||
|
||||
this.results = new jasmine.NestedResults();
|
||||
this.results.description = description;
|
||||
this.runs = this.addToQueue;
|
||||
this.matchersClass = null;
|
||||
spec.afterCallbacks = [];
|
||||
spec.spies_ = [];
|
||||
|
||||
spec.results_ = new jasmine.NestedResults();
|
||||
spec.results_.description = description;
|
||||
spec.matchersClass = null;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.getFullName = function() {
|
||||
return this.suite.getFullName() + ' ' + this.description + '.';
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.getResults = function() {
|
||||
return this.results;
|
||||
|
||||
jasmine.Spec.prototype.results = function() {
|
||||
return this.results_;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.addToQueue = function(func) {
|
||||
var queuedFunction = new jasmine.QueuedFunction(this.env, func, this.currentTimeout, this.currentLatchFunction, this);
|
||||
this.queue.push(queuedFunction);
|
||||
/**
|
||||
* All parameters are pretty-printed and concatenated together, then written to the spec's output.
|
||||
*
|
||||
* Be careful not to leave calls to <code>jasmine.log</code> in production code.
|
||||
*/
|
||||
jasmine.Spec.prototype.log = function() {
|
||||
return this.results_.log(arguments);
|
||||
};
|
||||
|
||||
if (this.queue.length > 1) {
|
||||
var previousQueuedFunction = this.queue[this.queue.length - 2];
|
||||
previousQueuedFunction.next = function() {
|
||||
queuedFunction.execute();
|
||||
};
|
||||
jasmine.Spec.prototype.runs = function (func) {
|
||||
var block = new jasmine.Block(this.env, func, this);
|
||||
this.addToQueue(block);
|
||||
return this;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.addToQueue = function (block) {
|
||||
if (this.queue.isRunning()) {
|
||||
this.queue.insertNext(block);
|
||||
} else {
|
||||
this.queue.add(block);
|
||||
}
|
||||
|
||||
this.resetTimeout();
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @deprecated
|
||||
* @param {jasmine.ExpectationResult} result
|
||||
*/
|
||||
jasmine.Spec.prototype.expects_that = function(actual) {
|
||||
return this.expect(actual);
|
||||
jasmine.Spec.prototype.addMatcherResult = function(result) {
|
||||
this.results_.addResult(result);
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
jasmine.Spec.prototype.expect = function(actual) {
|
||||
return new (this.getMatchersClass_())(this.env, actual, this.results);
|
||||
var positive = new (this.getMatchersClass_())(this.env, actual, this);
|
||||
positive.not = new (this.getMatchersClass_())(this.env, actual, this, true);
|
||||
return positive;
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
jasmine.Spec.prototype.waits = function(timeout) {
|
||||
this.currentTimeout = timeout;
|
||||
this.currentLatchFunction = undefined;
|
||||
var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this);
|
||||
this.addToQueue(waitsFunc);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
jasmine.Spec.prototype.waitsFor = function(timeout, latchFunction, message) {
|
||||
this.currentTimeout = timeout;
|
||||
this.currentLatchFunction = latchFunction;
|
||||
this.currentLatchFunction.description = message;
|
||||
jasmine.Spec.prototype.waitsFor = function(timeout, latchFunction, timeoutMessage) {
|
||||
var waitsForFunc = new jasmine.WaitsForBlock(this.env, timeout, latchFunction, timeoutMessage, this);
|
||||
this.addToQueue(waitsForFunc);
|
||||
return this;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.fail = function (e) {
|
||||
var expectationResult = new jasmine.ExpectationResult({
|
||||
passed: false,
|
||||
message: e ? jasmine.util.formatException(e) : 'Exception'
|
||||
});
|
||||
this.results_.addResult(expectationResult);
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.getMatchersClass_ = function() {
|
||||
return this.matchersClass || jasmine.Matchers;
|
||||
return this.matchersClass || this.env.matchersClass;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {
|
||||
@@ -91,76 +103,71 @@ jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {
|
||||
parent.apply(this, arguments);
|
||||
};
|
||||
jasmine.util.inherit(newMatchersClass, parent);
|
||||
for (var method in matchersPrototype) {
|
||||
newMatchersClass.prototype[method] = matchersPrototype[method];
|
||||
}
|
||||
jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass);
|
||||
this.matchersClass = newMatchersClass;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.resetTimeout = function() {
|
||||
this.currentTimeout = 0;
|
||||
this.currentLatchFunction = undefined;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.finishCallback = function() {
|
||||
this.env.reporter.reportSpecResults(this);
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.finish = function() {
|
||||
this.safeExecuteAfters();
|
||||
|
||||
jasmine.Spec.prototype.finish = function(onComplete) {
|
||||
this.removeAllSpies();
|
||||
this.finishCallback();
|
||||
this.finished = true;
|
||||
if (onComplete) {
|
||||
onComplete();
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.after = function(doAfter) {
|
||||
this.afterCallbacks.unshift(doAfter);
|
||||
if (this.queue.isRunning()) {
|
||||
this.queue.add(new jasmine.Block(this.env, doAfter, this));
|
||||
} else {
|
||||
this.afterCallbacks.unshift(doAfter);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.execute = function() {
|
||||
if (!this.env.specFilter(this)) {
|
||||
this.results.skipped = true;
|
||||
this.finishCallback();
|
||||
this.finished = true;
|
||||
jasmine.Spec.prototype.execute = function(onComplete) {
|
||||
var spec = this;
|
||||
if (!spec.env.specFilter(spec)) {
|
||||
spec.results_.skipped = true;
|
||||
spec.finish(onComplete);
|
||||
return;
|
||||
}
|
||||
|
||||
this.env.currentSpec = this;
|
||||
this.env.currentlyRunningTests = true;
|
||||
this.env.reporter.reportSpecStarting(this);
|
||||
|
||||
this.safeExecuteBefores();
|
||||
spec.env.currentSpec = spec;
|
||||
|
||||
if (this.queue[0]) {
|
||||
this.queue[0].execute();
|
||||
} else {
|
||||
this.finish();
|
||||
}
|
||||
this.env.currentlyRunningTests = false;
|
||||
spec.addBeforesAndAftersToQueue();
|
||||
|
||||
spec.queue.start(function () {
|
||||
spec.finish(onComplete);
|
||||
});
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.safeExecuteBefores = function() {
|
||||
var befores = [];
|
||||
jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {
|
||||
var runner = this.env.currentRunner();
|
||||
var i;
|
||||
|
||||
for (var suite = this.suite; suite; suite = suite.parentSuite) {
|
||||
if (suite.beforeEachFunction) befores.push(suite.beforeEachFunction);
|
||||
for (i = 0; i < suite.before_.length; i++) {
|
||||
this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this));
|
||||
}
|
||||
}
|
||||
|
||||
while (befores.length) {
|
||||
this.safeExecuteBeforeOrAfter(befores.pop());
|
||||
for (i = 0; i < runner.before_.length; i++) {
|
||||
this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this));
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.safeExecuteAfters = function() {
|
||||
for (var suite = this.suite; suite; suite = suite.parentSuite) {
|
||||
if (suite.afterEachFunction) this.safeExecuteBeforeOrAfter(suite.afterEachFunction);
|
||||
for (i = 0; i < this.afterCallbacks.length; i++) {
|
||||
this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this));
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.safeExecuteBeforeOrAfter = function(func) {
|
||||
try {
|
||||
func.apply(this);
|
||||
} catch (e) {
|
||||
this.results.addResult(new jasmine.ExpectationResult(false, func.typeName + '() fail: ' + jasmine.util.formatException(e), null));
|
||||
for (suite = this.suite; suite; suite = suite.parentSuite) {
|
||||
for (i = 0; i < suite.after_.length; i++) {
|
||||
this.queue.add(new jasmine.Block(this.env, suite.after_[i], this));
|
||||
}
|
||||
}
|
||||
for (i = 0; i < runner.after_.length; i++) {
|
||||
this.queue.add(new jasmine.Block(this.env, runner.after_[i], this));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -169,11 +176,11 @@ jasmine.Spec.prototype.explodes = function() {
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) {
|
||||
if (obj == undefined) {
|
||||
if (obj == jasmine.undefined) {
|
||||
throw "spyOn could not find an object to spy upon for " + methodName + "()";
|
||||
}
|
||||
|
||||
if (!ignoreMethodDoesntExist && obj[methodName] === undefined) {
|
||||
if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) {
|
||||
throw methodName + '() method does not exist';
|
||||
}
|
||||
|
||||
|
||||
69
src/Suite.js
69
src/Suite.js
@@ -8,17 +8,18 @@
|
||||
* @param {jasmine.Suite} parentSuite
|
||||
*/
|
||||
jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
|
||||
jasmine.ActionCollection.call(this, env);
|
||||
|
||||
this.id = env.nextSuiteId_++;
|
||||
this.description = description;
|
||||
this.specs = this.actions;
|
||||
this.parentSuite = parentSuite;
|
||||
|
||||
this.beforeEachFunction = null;
|
||||
this.afterEachFunction = null;
|
||||
var self = this;
|
||||
self.id = env.nextSuiteId ? env.nextSuiteId() : null;
|
||||
self.description = description;
|
||||
self.queue = new jasmine.Queue(env);
|
||||
self.parentSuite = parentSuite;
|
||||
self.env = env;
|
||||
self.before_ = [];
|
||||
self.after_ = [];
|
||||
self.children_ = [];
|
||||
self.suites_ = [];
|
||||
self.specs_ = [];
|
||||
};
|
||||
jasmine.util.inherit(jasmine.Suite, jasmine.ActionCollection);
|
||||
|
||||
jasmine.Suite.prototype.getFullName = function() {
|
||||
var fullName = this.description;
|
||||
@@ -28,28 +29,54 @@ jasmine.Suite.prototype.getFullName = function() {
|
||||
return fullName;
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.finishCallback = function() {
|
||||
jasmine.Suite.prototype.finish = function(onComplete) {
|
||||
this.env.reporter.reportSuiteResults(this);
|
||||
this.finished = true;
|
||||
if (typeof(onComplete) == 'function') {
|
||||
onComplete();
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) {
|
||||
beforeEachFunction.typeName = 'beforeEach';
|
||||
this.beforeEachFunction = beforeEachFunction;
|
||||
this.before_.unshift(beforeEachFunction);
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.afterEach = function(afterEachFunction) {
|
||||
afterEachFunction.typeName = 'afterEach';
|
||||
this.afterEachFunction = afterEachFunction;
|
||||
this.after_.unshift(afterEachFunction);
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.getResults = function() {
|
||||
var results = new jasmine.NestedResults();
|
||||
results.description = this.description;
|
||||
results.id = this.id;
|
||||
|
||||
for (var i = 0; i < this.specs.length; i++) {
|
||||
results.rollupCounts(this.specs[i].getResults());
|
||||
jasmine.Suite.prototype.results = function() {
|
||||
return this.queue.results();
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.add = function(suiteOrSpec) {
|
||||
this.children_.push(suiteOrSpec);
|
||||
if (suiteOrSpec instanceof jasmine.Suite) {
|
||||
this.suites_.push(suiteOrSpec);
|
||||
this.env.currentRunner().addSuite(suiteOrSpec);
|
||||
} else {
|
||||
this.specs_.push(suiteOrSpec);
|
||||
}
|
||||
return results;
|
||||
this.queue.add(suiteOrSpec);
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.specs = function() {
|
||||
return this.specs_;
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.suites = function() {
|
||||
return this.suites_;
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.children = function() {
|
||||
return this.children_;
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.execute = function(onComplete) {
|
||||
var self = this;
|
||||
this.queue.start(function () {
|
||||
self.finish(onComplete);
|
||||
});
|
||||
};
|
||||
13
src/WaitsBlock.js
Normal file
13
src/WaitsBlock.js
Normal file
@@ -0,0 +1,13 @@
|
||||
jasmine.WaitsBlock = function(env, timeout, spec) {
|
||||
this.timeout = timeout;
|
||||
jasmine.Block.call(this, env, null, spec);
|
||||
};
|
||||
|
||||
jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block);
|
||||
|
||||
jasmine.WaitsBlock.prototype.execute = function (onComplete) {
|
||||
this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
|
||||
this.env.setTimeout(function () {
|
||||
onComplete();
|
||||
}, this.timeout);
|
||||
};
|
||||
37
src/WaitsForBlock.js
Normal file
37
src/WaitsForBlock.js
Normal file
@@ -0,0 +1,37 @@
|
||||
jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) {
|
||||
this.timeout = timeout;
|
||||
this.latchFunction = latchFunction;
|
||||
this.message = message;
|
||||
this.totalTimeSpentWaitingForLatch = 0;
|
||||
jasmine.Block.call(this, env, null, spec);
|
||||
};
|
||||
|
||||
jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block);
|
||||
|
||||
jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 100;
|
||||
|
||||
jasmine.WaitsForBlock.prototype.execute = function (onComplete) {
|
||||
var self = this;
|
||||
self.env.reporter.log('>> Jasmine waiting for ' + (self.message || 'something to happen'));
|
||||
var latchFunctionResult;
|
||||
try {
|
||||
latchFunctionResult = self.latchFunction.apply(self.spec);
|
||||
} catch (e) {
|
||||
self.spec.fail(e);
|
||||
onComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
if (latchFunctionResult) {
|
||||
onComplete();
|
||||
} else if (self.totalTimeSpentWaitingForLatch >= self.timeout) {
|
||||
var message = 'timed out after ' + self.timeout + ' msec waiting for ' + (self.message || 'something to happen');
|
||||
self.spec.fail({
|
||||
name: 'timeout',
|
||||
message: message
|
||||
});
|
||||
} else {
|
||||
self.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT;
|
||||
self.env.setTimeout(function () { self.execute(onComplete); }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT);
|
||||
}
|
||||
};
|
||||
210
src/base.js
210
src/base.js
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
|
||||
*
|
||||
*
|
||||
* @namespace
|
||||
*/
|
||||
var jasmine = {};
|
||||
@@ -13,7 +13,29 @@ jasmine.unimplementedMethod_ = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Allows for bound functions to be comapred. Internal use only.
|
||||
* Use <code>jasmine.undefined</code> instead of <code>undefined</code>, since <code>undefined</code> is just
|
||||
* a plain old variable and may be redefined by somebody else.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
jasmine.undefined = jasmine.___undefined___;
|
||||
|
||||
/**
|
||||
* Default interval for event loop yields. Small values here may result in slow test running. Zero means no updates until all tests have completed.
|
||||
*
|
||||
*/
|
||||
jasmine.DEFAULT_UPDATE_INTERVAL = 250;
|
||||
|
||||
jasmine.getGlobal = function() {
|
||||
function getGlobal() {
|
||||
return this;
|
||||
}
|
||||
|
||||
return getGlobal();
|
||||
};
|
||||
|
||||
/**
|
||||
* Allows for bound functions to be compared. Internal use only.
|
||||
*
|
||||
* @ignore
|
||||
* @private
|
||||
@@ -22,28 +44,57 @@ jasmine.unimplementedMethod_ = function() {
|
||||
*/
|
||||
jasmine.bindOriginal_ = function(base, name) {
|
||||
var original = base[name];
|
||||
return function() {
|
||||
return original.apply(base, arguments);
|
||||
};
|
||||
if (original.apply) {
|
||||
return function() {
|
||||
return original.apply(base, arguments);
|
||||
};
|
||||
} else {
|
||||
// IE support
|
||||
return jasmine.getGlobal()[name];
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.setTimeout = jasmine.bindOriginal_(window, 'setTimeout');
|
||||
jasmine.clearTimeout = jasmine.bindOriginal_(window, 'clearTimeout');
|
||||
jasmine.setInterval = jasmine.bindOriginal_(window, 'setInterval');
|
||||
jasmine.clearInterval = jasmine.bindOriginal_(window, 'clearInterval');
|
||||
jasmine.setTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'setTimeout');
|
||||
jasmine.clearTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearTimeout');
|
||||
jasmine.setInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'setInterval');
|
||||
jasmine.clearInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearInterval');
|
||||
|
||||
jasmine.MessageResult = function(text) {
|
||||
this.type = 'MessageResult';
|
||||
this.text = text;
|
||||
jasmine.MessageResult = function(values) {
|
||||
this.type = 'log';
|
||||
this.values = values;
|
||||
this.trace = new Error(); // todo: test better
|
||||
};
|
||||
|
||||
jasmine.ExpectationResult = function(passed, message, details) {
|
||||
this.type = 'ExpectationResult';
|
||||
this.passed = passed;
|
||||
this.message = message;
|
||||
this.details = details;
|
||||
this.trace = new Error(message); // todo: test better
|
||||
jasmine.MessageResult.prototype.toString = function() {
|
||||
var text = "";
|
||||
for(var i = 0; i < this.values.length; i++) {
|
||||
if (i > 0) text += " ";
|
||||
if (jasmine.isString_(this.values[i])) {
|
||||
text += this.values[i];
|
||||
} else {
|
||||
text += jasmine.pp(this.values[i]);
|
||||
}
|
||||
}
|
||||
return text;
|
||||
};
|
||||
|
||||
jasmine.ExpectationResult = function(params) {
|
||||
this.type = 'expect';
|
||||
this.matcherName = params.matcherName;
|
||||
this.passed_ = params.passed;
|
||||
this.expected = params.expected;
|
||||
this.actual = params.actual;
|
||||
|
||||
this.message = this.passed_ ? 'Passed.' : params.message;
|
||||
this.trace = this.passed_ ? '' : new Error(this.message);
|
||||
};
|
||||
|
||||
jasmine.ExpectationResult.prototype.toString = function () {
|
||||
return this.message;
|
||||
};
|
||||
|
||||
jasmine.ExpectationResult.prototype.passed = function () {
|
||||
return this.passed_;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -60,11 +111,38 @@ jasmine.getEnv = function() {
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
jasmine.isArray_ = function(value) {
|
||||
return value &&
|
||||
typeof value === 'object' &&
|
||||
typeof value.length === 'number' &&
|
||||
typeof value.splice === 'function' &&
|
||||
!(value.propertyIsEnumerable('length'));
|
||||
return jasmine.isA_("Array", value);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* @private
|
||||
* @param value
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
jasmine.isString_ = function(value) {
|
||||
return jasmine.isA_("String", value);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* @private
|
||||
* @param value
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
jasmine.isNumber_ = function(value) {
|
||||
return jasmine.isA_("Number", value);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* @private
|
||||
* @param {String} typeName
|
||||
* @param value
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
jasmine.isA_ = function(typeName, value) {
|
||||
return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -94,7 +172,7 @@ jasmine.isDomNode = function(obj) {
|
||||
*
|
||||
* @example
|
||||
* // don't care about which function is passed in, as long as it's a function
|
||||
* expect(mySpy).wasCalledWith(jasmine.any(Function));
|
||||
* expect(mySpy).toHaveBeenCalledWith(jasmine.any(Function));
|
||||
*
|
||||
* @param {Class} clazz
|
||||
* @returns matchable object of the type clazz
|
||||
@@ -109,11 +187,12 @@ jasmine.any = function(clazz) {
|
||||
* Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine
|
||||
* expectation syntax. Spies can be checked if they were called or not and what the calling params were.
|
||||
*
|
||||
* A Spy has the following mehtod: wasCalled, callCount, mostRecentCall, and argsForCall (see docs)
|
||||
* A Spy has the following fields: wasCalled, callCount, mostRecentCall, and argsForCall (see docs).
|
||||
*
|
||||
* Spies are torn down at the end of every spec.
|
||||
*
|
||||
* Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj.
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* // a stub
|
||||
* var myStub = jasmine.createSpy('myStub'); // can be used anywhere
|
||||
@@ -139,8 +218,8 @@ jasmine.any = function(clazz) {
|
||||
*
|
||||
* // mock example
|
||||
* foo.not(7 == 7);
|
||||
* expect(foo.not).wasCalled();
|
||||
* expect(foo.not).wasCalledWith(true);
|
||||
* expect(foo.not).toHaveBeenCalled();
|
||||
* expect(foo.not).toHaveBeenCalledWith(true);
|
||||
*
|
||||
* @constructor
|
||||
* @see spyOn, jasmine.createSpy, jasmine.createSpyObj
|
||||
@@ -156,9 +235,10 @@ jasmine.Spy = function(name) {
|
||||
*/
|
||||
this.isSpy = true;
|
||||
/**
|
||||
* The acutal function this spy stubs.
|
||||
* The actual function this spy stubs.
|
||||
*/
|
||||
this.plan = function() {};
|
||||
this.plan = function() {
|
||||
};
|
||||
/**
|
||||
* Tracking of the most recent call to the spy.
|
||||
* @example
|
||||
@@ -179,6 +259,7 @@ jasmine.Spy = function(name) {
|
||||
* mySpy.argsForCall[1] = [7, 8];
|
||||
*/
|
||||
this.argsForCall = [];
|
||||
this.calls = [];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -188,7 +269,7 @@ jasmine.Spy = function(name) {
|
||||
* var foo = {
|
||||
* bar: function() { // do some stuff }
|
||||
* }
|
||||
*
|
||||
*
|
||||
* // defining a spy on an existing property: foo.bar
|
||||
* spyOn(foo, 'bar').andCallThrough();
|
||||
*/
|
||||
@@ -273,6 +354,7 @@ jasmine.Spy.prototype.reset = function() {
|
||||
this.wasCalled = false;
|
||||
this.callCount = 0;
|
||||
this.argsForCall = [];
|
||||
this.calls = [];
|
||||
this.mostRecentCall = {};
|
||||
};
|
||||
|
||||
@@ -282,27 +364,34 @@ jasmine.createSpy = function(name) {
|
||||
spyObj.wasCalled = true;
|
||||
spyObj.callCount++;
|
||||
var args = jasmine.util.argsToArray(arguments);
|
||||
//spyObj.mostRecentCall = {
|
||||
// object: this,
|
||||
// args: args
|
||||
//};
|
||||
spyObj.mostRecentCall.object = this;
|
||||
spyObj.mostRecentCall.args = args;
|
||||
spyObj.argsForCall.push(args);
|
||||
spyObj.calls.push({object: this, args: args});
|
||||
return spyObj.plan.apply(this, arguments);
|
||||
};
|
||||
|
||||
var spy = new jasmine.Spy(name);
|
||||
|
||||
for(var prop in spy) {
|
||||
|
||||
for (var prop in spy) {
|
||||
spyObj[prop] = spy[prop];
|
||||
}
|
||||
|
||||
|
||||
spyObj.reset();
|
||||
|
||||
return spyObj;
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether an object is a spy.
|
||||
*
|
||||
* @param {jasmine.Spy|Object} putativeSpy
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
jasmine.isSpy = function(putativeSpy) {
|
||||
return putativeSpy && putativeSpy.isSpy;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something
|
||||
* large in one call.
|
||||
@@ -311,6 +400,9 @@ jasmine.createSpy = function(name) {
|
||||
* @param {Array} methodNames array of names of methods to make spies
|
||||
*/
|
||||
jasmine.createSpyObj = function(baseName, methodNames) {
|
||||
if (!jasmine.isArray_(methodNames) || methodNames.length == 0) {
|
||||
throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
|
||||
}
|
||||
var obj = {};
|
||||
for (var i = 0; i < methodNames.length; i++) {
|
||||
obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]);
|
||||
@@ -318,8 +410,14 @@ jasmine.createSpyObj = function(baseName, methodNames) {
|
||||
return obj;
|
||||
};
|
||||
|
||||
jasmine.log = function(message) {
|
||||
jasmine.getEnv().currentSpec.getResults().log(message);
|
||||
/**
|
||||
* All parameters are pretty-printed and concatenated together, then written to the current spec's output.
|
||||
*
|
||||
* Be careful not to leave calls to <code>jasmine.log</code> in production code.
|
||||
*/
|
||||
jasmine.log = function() {
|
||||
var spec = jasmine.getEnv().currentSpec;
|
||||
spec.log.apply(spec, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -401,7 +499,7 @@ var waits = function(timeout) {
|
||||
|
||||
/**
|
||||
* Waits for the latchFunction to return true before proceeding to the next runs()-defined block.
|
||||
*
|
||||
*
|
||||
* @param {Number} timeout
|
||||
* @param {Function} latchFunction
|
||||
* @param {String} message
|
||||
@@ -462,10 +560,8 @@ var xdescribe = function(description, specDefinitions) {
|
||||
};
|
||||
|
||||
|
||||
jasmine.XmlHttpRequest = XMLHttpRequest;
|
||||
|
||||
// Provide the XMLHttpRequest class for IE 5.x-6.x:
|
||||
if (typeof XMLHttpRequest == "undefined") jasmine.XmlHttpRequest = function() {
|
||||
jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
|
||||
try {
|
||||
return new ActiveXObject("Msxml2.XMLHTTP.6.0");
|
||||
} catch(e) {
|
||||
@@ -483,28 +579,4 @@ if (typeof XMLHttpRequest == "undefined") jasmine.XmlHttpRequest = function() {
|
||||
} catch(e) {
|
||||
}
|
||||
throw new Error("This browser does not support XMLHttpRequest.");
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds suite files to an HTML document so that they are executed, thus adding them to the current
|
||||
* Jasmine environment.
|
||||
*
|
||||
* @param {String} url path to the file to include
|
||||
* @param {Boolean} opt_global
|
||||
*/
|
||||
jasmine.include = function(url, opt_global) {
|
||||
if (opt_global) {
|
||||
document.write('<script type="text/javascript" src="' + url + '"></' + 'script>');
|
||||
} else {
|
||||
var xhr;
|
||||
try {
|
||||
xhr = new jasmine.XmlHttpRequest();
|
||||
xhr.open("GET", url, false);
|
||||
xhr.send(null);
|
||||
} catch(e) {
|
||||
throw new Error("couldn't fetch " + url + ": " + e);
|
||||
}
|
||||
|
||||
return eval(xhr.responseText);
|
||||
}
|
||||
};
|
||||
} : XMLHttpRequest;
|
||||
|
||||
182
src/html/TrivialReporter.js
Normal file
182
src/html/TrivialReporter.js
Normal file
@@ -0,0 +1,182 @@
|
||||
jasmine.TrivialReporter = function(doc) {
|
||||
this.document = doc || document;
|
||||
this.suiteDivs = {};
|
||||
this.logRunningSpecs = false;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
||||
var el = document.createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(document.createTextNode(child));
|
||||
} else {
|
||||
if (child) { el.appendChild(child); }
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == "className") {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
var showPassed, showSkipped;
|
||||
|
||||
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
|
||||
this.createDom('div', { className: 'banner' },
|
||||
this.createDom('div', { className: 'logo' },
|
||||
"Jasmine",
|
||||
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
||||
this.createDom('div', { className: 'options' },
|
||||
"Show ",
|
||||
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
||||
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
||||
)
|
||||
),
|
||||
|
||||
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
||||
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
||||
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
||||
);
|
||||
|
||||
this.document.body.appendChild(this.outerDiv);
|
||||
|
||||
var suites = runner.suites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
var suiteDiv = this.createDom('div', { className: 'suite' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
||||
this.suiteDivs[suite.id] = suiteDiv;
|
||||
var parentDiv = this.outerDiv;
|
||||
if (suite.parentSuite) {
|
||||
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
||||
}
|
||||
parentDiv.appendChild(suiteDiv);
|
||||
}
|
||||
|
||||
this.startedAt = new Date();
|
||||
|
||||
var self = this;
|
||||
showPassed.onchange = function(evt) {
|
||||
if (evt.target.checked) {
|
||||
self.outerDiv.className += ' show-passed';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
||||
}
|
||||
};
|
||||
|
||||
showSkipped.onchange = function(evt) {
|
||||
if (evt.target.checked) {
|
||||
self.outerDiv.className += ' show-skipped';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
||||
var results = runner.results();
|
||||
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
||||
this.runnerDiv.setAttribute("class", className);
|
||||
//do it twice for IE
|
||||
this.runnerDiv.setAttribute("className", className);
|
||||
var specs = runner.specs();
|
||||
var specCount = 0;
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
if (this.specFilter(specs[i])) {
|
||||
specCount++;
|
||||
}
|
||||
}
|
||||
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
||||
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
||||
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
||||
|
||||
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
||||
var results = suite.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.totalCount == 0) { // todo: change this to check results.skipped
|
||||
status = 'skipped';
|
||||
}
|
||||
this.suiteDivs[suite.id].className += " " + status;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
||||
if (this.logRunningSpecs) {
|
||||
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||
var results = spec.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
||||
title: spec.getFullName()
|
||||
}, spec.description));
|
||||
|
||||
|
||||
var resultItems = results.getItems();
|
||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
|
||||
if (result.type == 'log') {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||
|
||||
if (result.trace.stack) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (messagesDiv.childNodes.length > 0) {
|
||||
specDiv.appendChild(messagesDiv);
|
||||
}
|
||||
|
||||
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.log = function() {
|
||||
var console = jasmine.getGlobal().console;
|
||||
if (console && console.log) console.log.apply(console, arguments);
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.getLocation = function() {
|
||||
return this.document.location;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
||||
var paramMap = {};
|
||||
var params = this.getLocation().search.substring(1).split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||
}
|
||||
|
||||
if (!paramMap["spec"]) return true;
|
||||
return spec.getFullName().indexOf(paramMap["spec"]) == 0;
|
||||
};
|
||||
166
src/html/jasmine.css
Normal file
166
src/html/jasmine.css
Normal file
@@ -0,0 +1,166 @@
|
||||
body {
|
||||
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
|
||||
}
|
||||
|
||||
|
||||
.jasmine_reporter a:visited, .jasmine_reporter a {
|
||||
color: #303;
|
||||
}
|
||||
|
||||
.jasmine_reporter a:hover, .jasmine_reporter a:active {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.run_spec {
|
||||
float:right;
|
||||
padding-right: 5px;
|
||||
font-size: .8em;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.jasmine_reporter {
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.banner {
|
||||
color: #303;
|
||||
background-color: #fef;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
float: left;
|
||||
font-size: 1.1em;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.logo .version {
|
||||
font-size: .6em;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.runner.running {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
|
||||
.options {
|
||||
text-align: right;
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.suite {
|
||||
border: 1px outset gray;
|
||||
margin: 5px 0;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.suite .suite {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.suite.passed {
|
||||
background-color: #dfd;
|
||||
}
|
||||
|
||||
.suite.failed {
|
||||
background-color: #fdd;
|
||||
}
|
||||
|
||||
.spec {
|
||||
margin: 5px;
|
||||
padding-left: 1em;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.spec.failed, .spec.passed, .spec.skipped {
|
||||
padding-bottom: 5px;
|
||||
border: 1px solid gray;
|
||||
}
|
||||
|
||||
.spec.failed {
|
||||
background-color: #fbb;
|
||||
border-color: red;
|
||||
}
|
||||
|
||||
.spec.passed {
|
||||
background-color: #bfb;
|
||||
border-color: green;
|
||||
}
|
||||
|
||||
.spec.skipped {
|
||||
background-color: #bbb;
|
||||
}
|
||||
|
||||
.messages {
|
||||
border-left: 1px dashed gray;
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
.passed {
|
||||
background-color: #cfc;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.failed {
|
||||
background-color: #fbb;
|
||||
}
|
||||
|
||||
.skipped {
|
||||
color: #777;
|
||||
background-color: #eee;
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
/*.resultMessage {*/
|
||||
/*white-space: pre;*/
|
||||
/*}*/
|
||||
|
||||
.resultMessage span.result {
|
||||
display: block;
|
||||
line-height: 2em;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.resultMessage .mismatch {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.stackTrace {
|
||||
white-space: pre;
|
||||
font-size: .8em;
|
||||
margin-left: 10px;
|
||||
max-height: 5em;
|
||||
overflow: auto;
|
||||
border: 1px inset red;
|
||||
padding: 1em;
|
||||
background: #eef;
|
||||
}
|
||||
|
||||
.finished-at {
|
||||
padding-left: 1em;
|
||||
font-size: .6em;
|
||||
}
|
||||
|
||||
.show-passed .passed,
|
||||
.show-skipped .skipped {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
#jasmine_content {
|
||||
position:fixed;
|
||||
right: 100%;
|
||||
}
|
||||
|
||||
.runner {
|
||||
border: 1px solid gray;
|
||||
display: block;
|
||||
margin: 5px 0;
|
||||
padding: 2px 0 2px 10px;
|
||||
}
|
||||
@@ -1,158 +1,183 @@
|
||||
// Mock setTimeout, clearTimeout
|
||||
// Contributed by Pivotal Computer Systems, www.pivotalsf.com
|
||||
|
||||
jasmine.FakeTimer = function() {
|
||||
this.reset();
|
||||
|
||||
var self = this;
|
||||
self.setTimeout = function(funcToCall, millis) {
|
||||
self.timeoutsMade++;
|
||||
self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false);
|
||||
return self.timeoutsMade;
|
||||
};
|
||||
|
||||
self.setInterval = function(funcToCall, millis) {
|
||||
self.timeoutsMade++;
|
||||
self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true);
|
||||
return self.timeoutsMade;
|
||||
};
|
||||
|
||||
self.clearTimeout = function(timeoutKey) {
|
||||
self.scheduledFunctions[timeoutKey] = undefined;
|
||||
};
|
||||
|
||||
self.clearInterval = function(timeoutKey) {
|
||||
self.scheduledFunctions[timeoutKey] = undefined;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
jasmine.FakeTimer.prototype.reset = function() {
|
||||
this.timeoutsMade = 0;
|
||||
this.scheduledFunctions = {};
|
||||
this.nowMillis = 0;
|
||||
};
|
||||
|
||||
jasmine.FakeTimer.prototype.tick = function(millis) {
|
||||
var oldMillis = this.nowMillis;
|
||||
var newMillis = oldMillis + millis;
|
||||
this.runFunctionsWithinRange(oldMillis, newMillis);
|
||||
this.nowMillis = newMillis;
|
||||
};
|
||||
|
||||
jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) {
|
||||
var scheduledFunc;
|
||||
var funcsToRun = [];
|
||||
for (var timeoutKey in this.scheduledFunctions) {
|
||||
scheduledFunc = this.scheduledFunctions[timeoutKey];
|
||||
if (scheduledFunc != undefined &&
|
||||
scheduledFunc.runAtMillis >= oldMillis &&
|
||||
scheduledFunc.runAtMillis <= nowMillis) {
|
||||
funcsToRun.push(scheduledFunc);
|
||||
this.scheduledFunctions[timeoutKey] = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
if (funcsToRun.length > 0) {
|
||||
funcsToRun.sort(function(a, b) {
|
||||
return a.runAtMillis - b.runAtMillis;
|
||||
});
|
||||
for (var i = 0; i < funcsToRun.length; ++i) {
|
||||
try {
|
||||
var funcToRun = funcsToRun[i];
|
||||
this.nowMillis = funcToRun.runAtMillis;
|
||||
funcToRun.funcToCall();
|
||||
if (funcToRun.recurring) {
|
||||
this.scheduleFunction(funcToRun.timeoutKey,
|
||||
funcToRun.funcToCall,
|
||||
funcToRun.millis,
|
||||
true);
|
||||
}
|
||||
} catch(e) {
|
||||
}
|
||||
}
|
||||
this.runFunctionsWithinRange(oldMillis, nowMillis);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) {
|
||||
this.scheduledFunctions[timeoutKey] = {
|
||||
runAtMillis: this.nowMillis + millis,
|
||||
funcToCall: funcToCall,
|
||||
recurring: recurring,
|
||||
timeoutKey: timeoutKey,
|
||||
millis: millis
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
jasmine.Clock = {
|
||||
defaultFakeTimer: new jasmine.FakeTimer(),
|
||||
|
||||
reset: function() {
|
||||
jasmine.Clock.assertInstalled();
|
||||
jasmine.Clock.defaultFakeTimer.reset();
|
||||
},
|
||||
|
||||
tick: function(millis) {
|
||||
jasmine.Clock.assertInstalled();
|
||||
jasmine.Clock.defaultFakeTimer.tick(millis);
|
||||
},
|
||||
|
||||
runFunctionsWithinRange: function(oldMillis, nowMillis) {
|
||||
jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis);
|
||||
},
|
||||
|
||||
scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {
|
||||
jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring);
|
||||
},
|
||||
|
||||
useMock: function() {
|
||||
var spec = jasmine.getEnv().currentSpec;
|
||||
spec.after(jasmine.Clock.uninstallMock);
|
||||
|
||||
jasmine.Clock.installMock();
|
||||
},
|
||||
|
||||
installMock: function() {
|
||||
jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer;
|
||||
},
|
||||
|
||||
uninstallMock: function() {
|
||||
jasmine.Clock.assertInstalled();
|
||||
jasmine.Clock.installed = jasmine.Clock.real;
|
||||
},
|
||||
|
||||
real: {
|
||||
setTimeout: window.setTimeout,
|
||||
clearTimeout: window.clearTimeout,
|
||||
setInterval: window.setInterval,
|
||||
clearInterval: window.clearInterval
|
||||
},
|
||||
|
||||
assertInstalled: function() {
|
||||
if (jasmine.Clock.installed != jasmine.Clock.defaultFakeTimer) {
|
||||
throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
|
||||
}
|
||||
},
|
||||
|
||||
installed: null
|
||||
};
|
||||
jasmine.Clock.installed = jasmine.Clock.real;
|
||||
|
||||
window.setTimeout = function(funcToCall, millis) {
|
||||
return jasmine.Clock.installed.setTimeout.apply(this, arguments);
|
||||
};
|
||||
|
||||
window.setInterval = function(funcToCall, millis) {
|
||||
return jasmine.Clock.installed.setInterval.apply(this, arguments);
|
||||
};
|
||||
|
||||
window.clearTimeout = function(timeoutKey) {
|
||||
return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
|
||||
};
|
||||
|
||||
window.clearInterval = function(timeoutKey) {
|
||||
return jasmine.Clock.installed.clearInterval.apply(this, arguments);
|
||||
};
|
||||
|
||||
// Mock setTimeout, clearTimeout
|
||||
// Contributed by Pivotal Computer Systems, www.pivotalsf.com
|
||||
|
||||
jasmine.FakeTimer = function() {
|
||||
this.reset();
|
||||
|
||||
var self = this;
|
||||
self.setTimeout = function(funcToCall, millis) {
|
||||
self.timeoutsMade++;
|
||||
self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false);
|
||||
return self.timeoutsMade;
|
||||
};
|
||||
|
||||
self.setInterval = function(funcToCall, millis) {
|
||||
self.timeoutsMade++;
|
||||
self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true);
|
||||
return self.timeoutsMade;
|
||||
};
|
||||
|
||||
self.clearTimeout = function(timeoutKey) {
|
||||
self.scheduledFunctions[timeoutKey] = jasmine.undefined;
|
||||
};
|
||||
|
||||
self.clearInterval = function(timeoutKey) {
|
||||
self.scheduledFunctions[timeoutKey] = jasmine.undefined;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
jasmine.FakeTimer.prototype.reset = function() {
|
||||
this.timeoutsMade = 0;
|
||||
this.scheduledFunctions = {};
|
||||
this.nowMillis = 0;
|
||||
};
|
||||
|
||||
jasmine.FakeTimer.prototype.tick = function(millis) {
|
||||
var oldMillis = this.nowMillis;
|
||||
var newMillis = oldMillis + millis;
|
||||
this.runFunctionsWithinRange(oldMillis, newMillis);
|
||||
this.nowMillis = newMillis;
|
||||
};
|
||||
|
||||
jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) {
|
||||
var scheduledFunc;
|
||||
var funcsToRun = [];
|
||||
for (var timeoutKey in this.scheduledFunctions) {
|
||||
scheduledFunc = this.scheduledFunctions[timeoutKey];
|
||||
if (scheduledFunc != jasmine.undefined &&
|
||||
scheduledFunc.runAtMillis >= oldMillis &&
|
||||
scheduledFunc.runAtMillis <= nowMillis) {
|
||||
funcsToRun.push(scheduledFunc);
|
||||
this.scheduledFunctions[timeoutKey] = jasmine.undefined;
|
||||
}
|
||||
}
|
||||
|
||||
if (funcsToRun.length > 0) {
|
||||
funcsToRun.sort(function(a, b) {
|
||||
return a.runAtMillis - b.runAtMillis;
|
||||
});
|
||||
for (var i = 0; i < funcsToRun.length; ++i) {
|
||||
try {
|
||||
var funcToRun = funcsToRun[i];
|
||||
this.nowMillis = funcToRun.runAtMillis;
|
||||
funcToRun.funcToCall();
|
||||
if (funcToRun.recurring) {
|
||||
this.scheduleFunction(funcToRun.timeoutKey,
|
||||
funcToRun.funcToCall,
|
||||
funcToRun.millis,
|
||||
true);
|
||||
}
|
||||
} catch(e) {
|
||||
}
|
||||
}
|
||||
this.runFunctionsWithinRange(oldMillis, nowMillis);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) {
|
||||
this.scheduledFunctions[timeoutKey] = {
|
||||
runAtMillis: this.nowMillis + millis,
|
||||
funcToCall: funcToCall,
|
||||
recurring: recurring,
|
||||
timeoutKey: timeoutKey,
|
||||
millis: millis
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @namespace
|
||||
*/
|
||||
jasmine.Clock = {
|
||||
defaultFakeTimer: new jasmine.FakeTimer(),
|
||||
|
||||
reset: function() {
|
||||
jasmine.Clock.assertInstalled();
|
||||
jasmine.Clock.defaultFakeTimer.reset();
|
||||
},
|
||||
|
||||
tick: function(millis) {
|
||||
jasmine.Clock.assertInstalled();
|
||||
jasmine.Clock.defaultFakeTimer.tick(millis);
|
||||
},
|
||||
|
||||
runFunctionsWithinRange: function(oldMillis, nowMillis) {
|
||||
jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis);
|
||||
},
|
||||
|
||||
scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {
|
||||
jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring);
|
||||
},
|
||||
|
||||
useMock: function() {
|
||||
if (!jasmine.Clock.isInstalled()) {
|
||||
var spec = jasmine.getEnv().currentSpec;
|
||||
spec.after(jasmine.Clock.uninstallMock);
|
||||
|
||||
jasmine.Clock.installMock();
|
||||
}
|
||||
},
|
||||
|
||||
installMock: function() {
|
||||
jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer;
|
||||
},
|
||||
|
||||
uninstallMock: function() {
|
||||
jasmine.Clock.assertInstalled();
|
||||
jasmine.Clock.installed = jasmine.Clock.real;
|
||||
},
|
||||
|
||||
real: {
|
||||
setTimeout: jasmine.getGlobal().setTimeout,
|
||||
clearTimeout: jasmine.getGlobal().clearTimeout,
|
||||
setInterval: jasmine.getGlobal().setInterval,
|
||||
clearInterval: jasmine.getGlobal().clearInterval
|
||||
},
|
||||
|
||||
assertInstalled: function() {
|
||||
if (!jasmine.Clock.isInstalled()) {
|
||||
throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
|
||||
}
|
||||
},
|
||||
|
||||
isInstalled: function() {
|
||||
return jasmine.Clock.installed == jasmine.Clock.defaultFakeTimer;
|
||||
},
|
||||
|
||||
installed: null
|
||||
};
|
||||
jasmine.Clock.installed = jasmine.Clock.real;
|
||||
|
||||
//else for IE support
|
||||
jasmine.getGlobal().setTimeout = function(funcToCall, millis) {
|
||||
if (jasmine.Clock.installed.setTimeout.apply) {
|
||||
return jasmine.Clock.installed.setTimeout.apply(this, arguments);
|
||||
} else {
|
||||
return jasmine.Clock.installed.setTimeout(funcToCall, millis);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.getGlobal().setInterval = function(funcToCall, millis) {
|
||||
if (jasmine.Clock.installed.setInterval.apply) {
|
||||
return jasmine.Clock.installed.setInterval.apply(this, arguments);
|
||||
} else {
|
||||
return jasmine.Clock.installed.setInterval(funcToCall, millis);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.getGlobal().clearTimeout = function(timeoutKey) {
|
||||
if (jasmine.Clock.installed.clearTimeout.apply) {
|
||||
return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
|
||||
} else {
|
||||
return jasmine.Clock.installed.clearTimeout(timeoutKey);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.getGlobal().clearInterval = function(timeoutKey) {
|
||||
if (jasmine.Clock.installed.clearTimeout.apply) {
|
||||
return jasmine.Clock.installed.clearInterval.apply(this, arguments);
|
||||
} else {
|
||||
return jasmine.Clock.installed.clearInterval(timeoutKey);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
10
src/util.js
10
src/util.js
@@ -4,13 +4,16 @@
|
||||
jasmine.util = {};
|
||||
|
||||
/**
|
||||
* Declare that a child class inherite it's prototype from the parent class.
|
||||
* Declare that a child class inherit it's prototype from the parent class.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} childClass
|
||||
* @param {Function} parentClass
|
||||
*/
|
||||
jasmine.util.inherit = function(childClass, parentClass) {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
var subclass = function() {
|
||||
};
|
||||
subclass.prototype = parentClass.prototype;
|
||||
@@ -57,3 +60,8 @@ jasmine.util.argsToArray = function(args) {
|
||||
return arrayOfArgs;
|
||||
};
|
||||
|
||||
jasmine.util.extend = function(destination, source) {
|
||||
for (var property in source) destination[property] = source[property];
|
||||
return destination;
|
||||
};
|
||||
|
||||
|
||||
5
src/version.json
Normal file
5
src/version.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"major": 0,
|
||||
"minor": 11,
|
||||
"build": 1
|
||||
}
|
||||
Reference in New Issue
Block a user