Compare commits
169 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6816bc4252 | ||
|
|
04bb56a5b5 | ||
|
|
ed31b9b844 | ||
|
|
4e47b78f1f | ||
|
|
8624a52ee0 | ||
|
|
a4b92b34f4 | ||
|
|
3486e8d166 | ||
|
|
8366ef9be5 | ||
|
|
ab0567c665 | ||
|
|
8676bbf11a | ||
|
|
c0a9d20a02 | ||
|
|
c7cc3b4a29 | ||
|
|
5a2e1b0082 | ||
|
|
f196faf0bb | ||
|
|
850204dfb8 | ||
|
|
7bda3bd728 | ||
|
|
b9c25e88b9 | ||
|
|
13228c304e | ||
|
|
da18479422 | ||
|
|
ba211e4913 | ||
|
|
5f9a965d7c | ||
|
|
3ff59835ea | ||
|
|
9fedf74f32 | ||
|
|
0339fc500a | ||
|
|
227b0c62a3 | ||
|
|
3de60067f0 | ||
|
|
cb1001e6c2 | ||
|
|
d9ded15c45 | ||
|
|
a0bce8031e | ||
|
|
7f7dda7a2c | ||
|
|
15f92b226c | ||
|
|
99aa2247b6 | ||
|
|
314eb63552 | ||
|
|
bd6ca98f9d | ||
|
|
eee75d8eed | ||
|
|
5e0ebadb3d | ||
|
|
738c10fd43 | ||
|
|
8c9ffe3144 | ||
|
|
ab2c916c3a | ||
|
|
290fb3fdcd | ||
|
|
e13c7a55a9 | ||
|
|
604cd6132f | ||
|
|
f6da084642 | ||
|
|
6c0224414c | ||
|
|
c302545ba4 | ||
|
|
954a6a0091 | ||
|
|
11cfaae42a | ||
|
|
6cf2d94f73 | ||
|
|
b578e72c8f | ||
|
|
1da6c7cf85 | ||
|
|
87e808282b | ||
|
|
14067d0785 | ||
|
|
bbf3f6825c | ||
|
|
9b653b9dcb | ||
|
|
b6798cdb06 | ||
|
|
dbd198f7d0 | ||
|
|
5583b6f954 | ||
|
|
db8e636021 | ||
|
|
ebbefafc26 | ||
|
|
b66ffc1277 | ||
|
|
5458f2f18d | ||
|
|
602f5bc08a | ||
|
|
4e4cd30965 | ||
|
|
7224c6adf2 | ||
|
|
5bdd7e8fbf | ||
|
|
1e0381a495 | ||
|
|
c454658c54 | ||
|
|
b7d8b0de71 | ||
|
|
342f0eb9a3 | ||
|
|
44b56093e7 | ||
|
|
bee8132848 | ||
|
|
e5c744f3dc | ||
|
|
4fb5aa14b8 | ||
|
|
43cd73938d | ||
|
|
f38e8e9235 | ||
|
|
fcd5a1948b | ||
|
|
6489b0f400 | ||
|
|
5e3582d8e7 | ||
|
|
33151ed9eb | ||
|
|
3f27ff1c7c | ||
|
|
b59cacf131 | ||
|
|
d6f1f8dec5 | ||
|
|
e0541eca80 | ||
|
|
8b7cb21874 | ||
|
|
ee0ff3b6c8 | ||
|
|
65241565c5 | ||
|
|
a047115eef | ||
|
|
0d4c8d13bb | ||
|
|
17c5e2b10d | ||
|
|
fa71928cad | ||
|
|
3e91ac0889 | ||
|
|
79206ccff5 | ||
|
|
a95c2cfe3f | ||
|
|
e2e2d1b343 | ||
|
|
3b53e469fd | ||
|
|
c8b212f278 | ||
|
|
b3f69852c1 | ||
|
|
1613a376b1 | ||
|
|
1e35e8ba95 | ||
|
|
a6b209bc2f | ||
|
|
2301914549 | ||
|
|
320c42b6cc | ||
|
|
df45b4fede | ||
|
|
c1ab3c9cbe | ||
|
|
d2f2e2b870 | ||
|
|
0f6a7f04b3 | ||
|
|
728af5e556 | ||
|
|
018fd53c10 | ||
|
|
25d73515f3 | ||
|
|
8e317d4026 | ||
|
|
ea4c44904d | ||
|
|
77514bbb80 | ||
|
|
a85c3a4da8 | ||
|
|
0b1e1a0401 | ||
|
|
3374415add | ||
|
|
c2ae3b6b12 | ||
|
|
110cacab19 | ||
|
|
db7879a478 | ||
|
|
e7dbc75fc2 | ||
|
|
a81466d9e7 | ||
|
|
48f42eaa7d | ||
|
|
e5c2572753 | ||
|
|
141fd910f2 | ||
|
|
a93bfd2120 | ||
|
|
4221b2d2c4 | ||
|
|
6ee7fd6ced | ||
|
|
878325e2cf | ||
|
|
80c4f87dd5 | ||
|
|
3f3fa484b2 | ||
|
|
d0ad9b98cd | ||
|
|
375a6f9fda | ||
|
|
c017f0000d | ||
|
|
4097718b66 | ||
|
|
825dab32ff | ||
|
|
f3a7396845 | ||
|
|
850bee5492 | ||
|
|
6028a5d92c | ||
|
|
93a13ab791 | ||
|
|
542f483228 | ||
|
|
459b4c29b6 | ||
|
|
750a9aac6d | ||
|
|
cd55f03912 | ||
|
|
79954311fb | ||
|
|
3f71bcdb2d | ||
|
|
06f05ac57b | ||
|
|
5ea5ec6004 | ||
|
|
f7033f6551 | ||
|
|
7e6e905814 | ||
|
|
a6a1962924 | ||
|
|
50944fea6f | ||
|
|
7bfc4c0a45 | ||
|
|
4be2079482 | ||
|
|
d6f47ea886 | ||
|
|
5061dd066c | ||
|
|
2a847a67e3 | ||
|
|
50223d97d6 | ||
|
|
302e78f1df | ||
|
|
42ad12ec52 | ||
|
|
c41fa7d156 | ||
|
|
0b1449228f | ||
|
|
65a6decd6d | ||
|
|
7cbd86357d | ||
|
|
4f278be2c2 | ||
|
|
f2bc9b5bd8 | ||
|
|
e9d79bc946 | ||
|
|
0b2097b616 | ||
|
|
f02824ae52 | ||
|
|
225c7bdda3 | ||
|
|
e855c898d1 |
7
.codeclimate.yml
Normal file
7
.codeclimate.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
languages:
|
||||||
|
JavaScript: true
|
||||||
|
exclude_paths:
|
||||||
|
- "lib/*"
|
||||||
|
- "dist/*"
|
||||||
|
- "grunt/*"
|
||||||
|
- "images/*"
|
||||||
16
.editorconfig
Normal file
16
.editorconfig
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.{js, json, sh, yml, gemspec}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[{Rakefile, .jshintrc}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.{py}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
17
CONTRIBUTING.md → .github/CONTRIBUTING.md
vendored
17
CONTRIBUTING.md → .github/CONTRIBUTING.md
vendored
@@ -1,6 +1,6 @@
|
|||||||
# Developing for Jasmine Core
|
# Developing for Jasmine Core
|
||||||
|
|
||||||
We welcome your contributions! Thanks for helping make Jasmine a better project for everyone. Please review the backlog and discussion lists before starting work. What you're looking for may already have been done. If it hasn't, the community can help make your contribution better.
|
We welcome your contributions! Thanks for helping make Jasmine a better project for everyone. Please review the backlog and discussion lists before starting work. What you're looking for may already have been done. If it hasn't, the community can help make your contribution better. If you want to contribute but don't know what to work on, [issues tagged ready for work](https://github.com/jasmine/jasmine/labels/ready%20for%20work) should have enough detail to get started.
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
|
||||||
@@ -82,11 +82,11 @@ To install the Node dependencies, you will need Node.js, Npm, and [Grunt](http:/
|
|||||||
|
|
||||||
$ npm install --local
|
$ npm install --local
|
||||||
|
|
||||||
...will install all of the node modules locally. If when you run
|
...will install all of the node modules locally. Now run
|
||||||
|
|
||||||
$ grunt
|
$ grunt
|
||||||
|
|
||||||
...you see that JSHint runs your system is ready.
|
...if you see that JSHint runs, your system is ready.
|
||||||
|
|
||||||
### How to write new Jasmine code
|
### How to write new Jasmine code
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ Follow these tips and your pull request, patch, or suggestion is much more likel
|
|||||||
|
|
||||||
Jasmine uses the [Jasmine Ruby gem](http://github.com/jasmine/jasmine-gem) to test itself in browser.
|
Jasmine uses the [Jasmine Ruby gem](http://github.com/jasmine/jasmine-gem) to test itself in browser.
|
||||||
|
|
||||||
$ rake jasmine
|
$ bundle exec rake jasmine
|
||||||
|
|
||||||
...and then visit `http://localhost:8888` to run specs.
|
...and then visit `http://localhost:8888` to run specs.
|
||||||
|
|
||||||
@@ -115,6 +115,15 @@ Jasmine uses the [Jasmine NPM package](http://github.com/jasmine/jasmine-npm) to
|
|||||||
|
|
||||||
...and then the results will print to the console. All specs run except those that expect a browser (the specs in `spec/html` are ignored).
|
...and then the results will print to the console. All specs run except those that expect a browser (the specs in `spec/html` are ignored).
|
||||||
|
|
||||||
|
The easiest way to run the tests in **Internet Explorer** is to run a VM that has IE installed. It's easy to do this with VirtualBox.
|
||||||
|
|
||||||
|
1. Download and install [VirtualBox](https://www.virtualbox.org/wiki/Downloads).
|
||||||
|
1. Download a VM image [from Microsoft](https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/). Select "VirtualBox" as the platform.
|
||||||
|
1. Unzip the downloaded archive. There should be an OVA file inside.
|
||||||
|
1. In VirtualBox, choose `File > Import Appliance` and select the OVA file. Accept the default settings in the dialog that appears. Now you have a Windows VM!
|
||||||
|
1. Run the VM and start IE.
|
||||||
|
1. With `bundle exec rake jasmine` running on your host machine, navigate to `http://10.0.2.2:8888` in IE.
|
||||||
|
|
||||||
## Before Committing or Submitting a Pull Request
|
## Before Committing or Submitting a Pull Request
|
||||||
|
|
||||||
1. Ensure all specs are green in browser *and* node
|
1. Ensure all specs are green in browser *and* node
|
||||||
17
.github/ISSUE_TEMPLATE.md
vendored
Normal file
17
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
### Are you creating an issue in the correct repository?
|
||||||
|
|
||||||
|
- When in doubt, create an issue here.
|
||||||
|
- If you have an issue with the Jasmine docs, file an issue in the docs repo
|
||||||
|
here: https://github.com/jasmine/jasmine.github.io
|
||||||
|
- This repository is for the core Jasmine framework
|
||||||
|
- If you are using a test runner that wraps Jasmine (Jasmine npm, karma, etc),
|
||||||
|
consider filing an issue with that library if appropriate
|
||||||
|
|
||||||
|
### When submitting an issue, please answer the following:
|
||||||
|
|
||||||
|
- What version are you using?
|
||||||
|
- What environment are you running Jasmine in (node, browser, etc)?
|
||||||
|
- How are you running Jasmine (standalone, npm, karma, etc)?
|
||||||
|
- If possible, include an example spec that demonstrates your issue.
|
||||||
|
|
||||||
|
Thanks for using Jasmine!
|
||||||
13
.travis.yml
13
.travis.yml
@@ -2,7 +2,7 @@ language: ruby
|
|||||||
|
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
rvm: 2.2.0
|
rvm: 2.2.2
|
||||||
|
|
||||||
script: $TEST_COMMAND
|
script: $TEST_COMMAND
|
||||||
|
|
||||||
@@ -17,11 +17,18 @@ env:
|
|||||||
- secure: WSPWhlnC4mWSnSPquX+m1/BCu5ch5NygkaHuM2Nea7lD8oS3XLX8QncZZAsQ4lnNfqoDDuBOizG0AESiqNvE4y6x5qvLLTS6q+ce255ZEMZ71TBdZgDEEvGMEjOPPsVXiXyTQOP1lwOPlrbZvaPgWV7e11KIBab6DfFcQpnvDgo=
|
- secure: WSPWhlnC4mWSnSPquX+m1/BCu5ch5NygkaHuM2Nea7lD8oS3XLX8QncZZAsQ4lnNfqoDDuBOizG0AESiqNvE4y6x5qvLLTS6q+ce255ZEMZ71TBdZgDEEvGMEjOPPsVXiXyTQOP1lwOPlrbZvaPgWV7e11KIBab6DfFcQpnvDgo=
|
||||||
- secure: SW7CJhZnwaNT749Gdnhvqb5rbXlAOsygUAzh9qhtyvbqXKkmJdBIEsO01YF6pbju1X2twE9JvWCOxeZju43NgQChJlPsGbjY2j3k/TdQeTAJesQe2K7ytwghunI30gjEovtRH0T3w1EmcKPH8yj5eBIcB2OYoJHx8KEC7e68q1g=
|
- secure: SW7CJhZnwaNT749Gdnhvqb5rbXlAOsygUAzh9qhtyvbqXKkmJdBIEsO01YF6pbju1X2twE9JvWCOxeZju43NgQChJlPsGbjY2j3k/TdQeTAJesQe2K7ytwghunI30gjEovtRH0T3w1EmcKPH8yj5eBIcB2OYoJHx8KEC7e68q1g=
|
||||||
|
|
||||||
|
addons:
|
||||||
|
sauce_connect: true
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- env:
|
- env:
|
||||||
- USE_SAUCE=false
|
- USE_SAUCE=false
|
||||||
- TEST_COMMAND="bash travis-node-script.sh"
|
- TEST_COMMAND="bash travis-node-script.sh"
|
||||||
|
- env:
|
||||||
|
- JASMINE_BROWSER="safari"
|
||||||
|
- SAUCE_OS="OS X 10.11"
|
||||||
|
- SAUCE_BROWSER_VERSION=9
|
||||||
- env:
|
- env:
|
||||||
- JASMINE_BROWSER="safari"
|
- JASMINE_BROWSER="safari"
|
||||||
- SAUCE_OS="OS X 10.10"
|
- SAUCE_OS="OS X 10.10"
|
||||||
@@ -34,10 +41,6 @@ matrix:
|
|||||||
- JASMINE_BROWSER="safari"
|
- JASMINE_BROWSER="safari"
|
||||||
- SAUCE_OS="OS X 10.8"
|
- SAUCE_OS="OS X 10.8"
|
||||||
- SAUCE_BROWSER_VERSION=6
|
- SAUCE_BROWSER_VERSION=6
|
||||||
- env:
|
|
||||||
- JASMINE_BROWSER="safari"
|
|
||||||
- SAUCE_OS="OS X 10.6"
|
|
||||||
- SAUCE_BROWSER_VERSION=5
|
|
||||||
- env:
|
- env:
|
||||||
- JASMINE_BROWSER="internet explorer"
|
- JASMINE_BROWSER="internet explorer"
|
||||||
- SAUCE_OS="Windows 8.1"
|
- SAUCE_OS="Windows 8.1"
|
||||||
|
|||||||
64
GOALS_2.0.md
64
GOALS_2.0.md
@@ -1,64 +0,0 @@
|
|||||||
# (Vague) Jasmine 2.0 Goals/(Guidelines)
|
|
||||||
|
|
||||||
1. No globals!
|
|
||||||
* jasmine library is entirely inside `jasmine` namespace
|
|
||||||
* globals required for backwards compatibility should be added in `boot.js` (EG, var describe = jasmine.getCurrentEnv().describe lives in boot.js)
|
|
||||||
1. Don't use properties as getters. Use methods.
|
|
||||||
* Properties aren't encapsulated -- can be mutated, unsafe.
|
|
||||||
1. Reporters get data objects (no methods).
|
|
||||||
* easier to refactor as needed
|
|
||||||
1. More unit tests - fewer nasty integration tests
|
|
||||||
|
|
||||||
## Remaining non-story-able work:
|
|
||||||
* Make a `TODO` list
|
|
||||||
|
|
||||||
### Hard
|
|
||||||
* Finish killing Globals
|
|
||||||
* Guidelines:
|
|
||||||
* New objects can have constructors on `jasmine`
|
|
||||||
* Top level functions can live on `jasmine`
|
|
||||||
* Top level (i.e., any `jasmine` property) should only be referenced inside the `Env` constructor
|
|
||||||
* should better allow any object to get jasmine code (Node-friendly)
|
|
||||||
* review everything in base.js
|
|
||||||
* Remove isA functions:
|
|
||||||
* isArray_ - used in matchers and spies
|
|
||||||
* isString_
|
|
||||||
* isDOMNode_
|
|
||||||
* isA_
|
|
||||||
* unimplementedMethod_, used by PrettyPrinter
|
|
||||||
* jasmine.util should be util closure inside of env or something
|
|
||||||
* argsToArray is used for Spies and matching (and can be replaced)
|
|
||||||
* inherit is only for PrettyPrinter now
|
|
||||||
* formatException is used only inside Env/spec
|
|
||||||
* htmlEscape is for messages in matchers - should this be HTML at all?
|
|
||||||
* Pretty printing
|
|
||||||
* move away from pretty printer and to a JSON.stringify implementation?
|
|
||||||
* jasmineToString vs. custom toString ?
|
|
||||||
|
|
||||||
### Easy
|
|
||||||
|
|
||||||
* unify params to ctors: options vs. attrs.
|
|
||||||
* This will be a lot of the TODOs, but clean up & simplify Env.js (is this a 2.1 task?)
|
|
||||||
|
|
||||||
### DONE
|
|
||||||
* Matchers improvements
|
|
||||||
* unit testable DONE
|
|
||||||
* better equality (from Underscore) DONE
|
|
||||||
* addCustomMatchers doesn't explode stack DONE
|
|
||||||
* refactor equals function so that it just loops & recurses over a list of fns (custom and built-in) - 2.1? (Tracker story)
|
|
||||||
* Spies
|
|
||||||
* break these out into their own tests/file DONE
|
|
||||||
|
|
||||||
|
|
||||||
## Other Topics
|
|
||||||
|
|
||||||
* Docs
|
|
||||||
* Docco has gone over well. Should we annotate all the sources and then have Pages be more complex, having tutorials and annotated source like Backbone? Are we small enough?
|
|
||||||
* Need examples for:
|
|
||||||
* How to build a Custom Matcher
|
|
||||||
* How to add a custom equality tester
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2008-2014 Pivotal Labs
|
Copyright (c) 2008-2016 Pivotal Labs
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
|
|||||||
30
README.md
30
README.md
@@ -1,6 +1,7 @@
|
|||||||
<a name="README">[<img src="https://rawgithub.com/jasmine/jasmine/master/images/jasmine-horizontal.svg" width="400px" />](http://jasmine.github.io)</a>
|
<a name="README">[<img src="https://rawgithub.com/jasmine/jasmine/master/images/jasmine-horizontal.svg" width="400px" />](http://jasmine.github.io)</a>
|
||||||
|
|
||||||
[](https://travis-ci.org/jasmine/jasmine) [](https://codeclimate.com/github/pivotal/jasmine)
|
[](https://travis-ci.org/jasmine/jasmine)
|
||||||
|
[](https://codeclimate.com/github/pivotal/jasmine)
|
||||||
|
|
||||||
=======
|
=======
|
||||||
|
|
||||||
@@ -8,7 +9,7 @@
|
|||||||
|
|
||||||
Jasmine is a Behavior Driven Development testing framework for JavaScript. It does not rely on browsers, DOM, or any JavaScript framework. Thus it's suited for websites, [Node.js](http://nodejs.org) projects, or anywhere that JavaScript can run.
|
Jasmine is a Behavior Driven Development testing framework for JavaScript. It does not rely on browsers, DOM, or any JavaScript framework. Thus it's suited for websites, [Node.js](http://nodejs.org) projects, or anywhere that JavaScript can run.
|
||||||
|
|
||||||
Documentation & guides live here: [http://jasmine.github.io](http://jasmine.github.io/)
|
Documentation & guides live here: [http://jasmine.github.io](http://jasmine.github.io/)
|
||||||
For a quick start guide of Jasmine 2.0, see the beginning of [http://jasmine.github.io/2.0/introduction.html](http://jasmine.github.io/2.0/introduction.html)
|
For a quick start guide of Jasmine 2.0, see the beginning of [http://jasmine.github.io/2.0/introduction.html](http://jasmine.github.io/2.0/introduction.html)
|
||||||
|
|
||||||
Upgrading from Jasmine 1.x? Check out the [2.0 release notes](https://github.com/jasmine/jasmine/blob/v2.0.0/release_notes/20.md) for a list of what's new (including breaking interface changes). You can also read the [upgrade guide](http://jasmine.github.io/2.0/upgrading.html).
|
Upgrading from Jasmine 1.x? Check out the [2.0 release notes](https://github.com/jasmine/jasmine/blob/v2.0.0/release_notes/20.md) for a list of what's new (including breaking interface changes). You can also read the [upgrade guide](http://jasmine.github.io/2.0/upgrading.html).
|
||||||
@@ -28,22 +29,27 @@ For the Jasmine Ruby Gem:<br>
|
|||||||
For the Jasmine Python Egg:<br>
|
For the Jasmine Python Egg:<br>
|
||||||
[https://github.com/jasmine/jasmine-py](https://github.com/jasmine/jasmine-py)
|
[https://github.com/jasmine/jasmine-py](https://github.com/jasmine/jasmine-py)
|
||||||
|
|
||||||
To install Jasmine on your local box:
|
For the Jasmine headless browser gulp plugin:<br>
|
||||||
|
[https://github.com/jasmine/gulp-jasmine-browser](https://github.com/jasmine/gulp-jasmine-browser)
|
||||||
|
|
||||||
* Clone Jasmine - `git clone https://github.com/jasmine/jasmine.git`
|
To install Jasmine standalone on your local box:
|
||||||
|
|
||||||
|
* Download the standalone distribution for your desired release from the [releases page](https://github.com/jasmine/jasmine/releases)
|
||||||
* Create a Jasmine directory in your project - `mkdir my-project/jasmine`
|
* Create a Jasmine directory in your project - `mkdir my-project/jasmine`
|
||||||
* Move latest dist to your project directory - `mv jasmine/dist/jasmine-standalone-2.0.0.zip my-project/jasmine`
|
* Move the dist to your project directory - `mv jasmine/dist/jasmine-standalone-2.0.0.zip my-project/jasmine`
|
||||||
* Change directory - `cd my-project/jasmine`
|
* Change directory - `cd my-project/jasmine`
|
||||||
* Unzip the dist - `unzip jasmine-standalone-2.0.0.zip`
|
* Unzip the dist - `unzip jasmine-standalone-2.0.0.zip`
|
||||||
|
|
||||||
Add the following to your HTML file:
|
Add the following to your HTML file:
|
||||||
|
|
||||||
<link rel="shortcut icon" type="image/png" href="jasmine/lib/jasmine-2.0.0/jasmine_favicon.png">
|
```html
|
||||||
<link rel="stylesheet" type="text/css" href="jasmine/lib/jasmine-2.0.0/jasmine.css">
|
<link rel="shortcut icon" type="image/png" href="jasmine/lib/jasmine-2.0.0/jasmine_favicon.png">
|
||||||
|
<link rel="stylesheet" type="text/css" href="jasmine/lib/jasmine-2.0.0/jasmine.css">
|
||||||
|
|
||||||
<script type="text/javascript" src="jasmine/lib/jasmine-2.0.0/jasmine.js"></script>
|
<script type="text/javascript" src="jasmine/lib/jasmine-2.0.0/jasmine.js"></script>
|
||||||
<script type="text/javascript" src="jasmine/lib/jasmine-2.0.0/jasmine-html.js"></script>
|
<script type="text/javascript" src="jasmine/lib/jasmine-2.0.0/jasmine-html.js"></script>
|
||||||
<script type="text/javascript" src="jasmine/lib/jasmine-2.0.0/boot.js"></script>
|
<script type="text/javascript" src="jasmine/lib/jasmine-2.0.0/boot.js"></script>
|
||||||
|
```
|
||||||
|
|
||||||
## Supported environments
|
## Supported environments
|
||||||
|
|
||||||
@@ -62,10 +68,12 @@ Jasmine tests itself across many browsers (Safari, Chrome, Firefox, PhantomJS, a
|
|||||||
* [Davis W. Frank](mailto:dwfrank@pivotal.io), Pivotal Labs
|
* [Davis W. Frank](mailto:dwfrank@pivotal.io), Pivotal Labs
|
||||||
* [Rajan Agaskar](mailto:rajan@pivotal.io), Pivotal Labs
|
* [Rajan Agaskar](mailto:rajan@pivotal.io), Pivotal Labs
|
||||||
* [Gregg Van Hove](mailto:gvanhove@pivotal.io), Pivotal Labs
|
* [Gregg Van Hove](mailto:gvanhove@pivotal.io), Pivotal Labs
|
||||||
|
* [Greg Cobb](mailto:gcobb@pivotal.io), Pivotal Labs
|
||||||
|
* [Chris Amavisca](mailto:camavisca@pivotal.io), Pivotal Labs
|
||||||
|
|
||||||
### Maintainers Emeritus
|
### Maintainers Emeritus
|
||||||
|
|
||||||
* [Christian Williams](mailto:antixian666@gmail.com), Cloud Foundry
|
* [Christian Williams](mailto:antixian666@gmail.com), Cloud Foundry
|
||||||
* Sheel Choksi
|
* Sheel Choksi
|
||||||
|
|
||||||
Copyright (c) 2008-2015 Pivotal Labs. This software is licensed under the MIT License.
|
Copyright (c) 2008-2016 Pivotal Labs. This software is licensed under the MIT License.
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Please attempt to keep commits to `master` small, but cohesive. If a feature is
|
|||||||
|
|
||||||
We attempt to stick to [Semantic Versioning](http://semver.org/). Most of the time, development should be against a new minor version - fixing bugs and adding new features that are backwards compatible.
|
We attempt to stick to [Semantic Versioning](http://semver.org/). Most of the time, development should be against a new minor version - fixing bugs and adding new features that are backwards compatible.
|
||||||
|
|
||||||
The current version lives in the file `/package.json`. This version will be the version number that is currently released. When releasing a new version, update `package.json` and `bower.json` with the new version and `grunt build:copyVersionToGem` to update the gem version number.
|
The current version lives in the file `/package.json`. This version will be the version number that is currently released. When releasing a new version, update `package.json` with the new version and `grunt build:copyVersionToGem` to update the gem version number.
|
||||||
|
|
||||||
This version is used by both `jasmine.js` and the `jasmine-core` Ruby gem.
|
This version is used by both `jasmine.js` and the `jasmine-core` Ruby gem.
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "jasmine-core",
|
"name": "jasmine-core",
|
||||||
"version": "2.3.2",
|
|
||||||
"homepage": "http://jasmine.github.io",
|
"homepage": "http://jasmine.github.io",
|
||||||
"authors": [
|
"authors": [
|
||||||
"slackersoft <gregg@slackersoft.net>"
|
"slackersoft <gregg@slackersoft.net>"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ module.exports = {
|
|||||||
sassDir: 'src/html',
|
sassDir: 'src/html',
|
||||||
outputStyle: 'compact',
|
outputStyle: 'compact',
|
||||||
noLineComments: true,
|
noLineComments: true,
|
||||||
|
bundleExec: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ module.exports = {
|
|||||||
'src/core/base.js',
|
'src/core/base.js',
|
||||||
'src/core/util.js',
|
'src/core/util.js',
|
||||||
'src/core/Spec.js',
|
'src/core/Spec.js',
|
||||||
|
'src/core/Order.js',
|
||||||
'src/core/Env.js',
|
'src/core/Env.js',
|
||||||
'src/core/JsApiReporter.js',
|
'src/core/JsApiReporter.js',
|
||||||
'src/core/PrettyPrinter',
|
'src/core/PrettyPrinter',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2008-2015 Pivotal Labs
|
Copyright (c) 2008-2016 Pivotal Labs
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2008-2015 Pivotal Labs
|
Copyright (c) 2008-2016 Pivotal Labs
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
@@ -77,6 +77,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
var throwingExpectationFailures = queryString.getParam("throwFailures");
|
var throwingExpectationFailures = queryString.getParam("throwFailures");
|
||||||
env.throwOnExpectationFailure(throwingExpectationFailures);
|
env.throwOnExpectationFailure(throwingExpectationFailures);
|
||||||
|
|
||||||
|
var random = queryString.getParam("random");
|
||||||
|
env.randomizeTests(random);
|
||||||
|
|
||||||
|
var seed = queryString.getParam("seed");
|
||||||
|
if (seed) {
|
||||||
|
env.seed(seed);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ## Reporters
|
* ## Reporters
|
||||||
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
|
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
|
||||||
@@ -85,6 +93,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
env: env,
|
env: env,
|
||||||
onRaiseExceptionsClick: function() { queryString.navigateWithNewParam("catch", !env.catchingExceptions()); },
|
onRaiseExceptionsClick: function() { queryString.navigateWithNewParam("catch", !env.catchingExceptions()); },
|
||||||
onThrowExpectationsClick: function() { queryString.navigateWithNewParam("throwFailures", !env.throwingExpectationFailures()); },
|
onThrowExpectationsClick: function() { queryString.navigateWithNewParam("throwFailures", !env.throwingExpectationFailures()); },
|
||||||
|
onRandomClick: function() { queryString.navigateWithNewParam("random", !env.randomTests()); },
|
||||||
addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
|
addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
|
||||||
getContainer: function() { return document.body; },
|
getContainer: function() { return document.body; },
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
|
|||||||
@@ -55,6 +55,14 @@
|
|||||||
var throwingExpectationFailures = queryString.getParam("throwFailures");
|
var throwingExpectationFailures = queryString.getParam("throwFailures");
|
||||||
env.throwOnExpectationFailure(throwingExpectationFailures);
|
env.throwOnExpectationFailure(throwingExpectationFailures);
|
||||||
|
|
||||||
|
var random = queryString.getParam("random");
|
||||||
|
env.randomizeTests(random);
|
||||||
|
|
||||||
|
var seed = queryString.getParam("seed");
|
||||||
|
if (seed) {
|
||||||
|
env.seed(seed);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ## Reporters
|
* ## Reporters
|
||||||
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
|
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
|
||||||
@@ -63,6 +71,7 @@
|
|||||||
env: env,
|
env: env,
|
||||||
onRaiseExceptionsClick: function() { queryString.navigateWithNewParam("catch", !env.catchingExceptions()); },
|
onRaiseExceptionsClick: function() { queryString.navigateWithNewParam("catch", !env.catchingExceptions()); },
|
||||||
onThrowExpectationsClick: function() { queryString.navigateWithNewParam("throwFailures", !env.throwingExpectationFailures()); },
|
onThrowExpectationsClick: function() { queryString.navigateWithNewParam("throwFailures", !env.throwingExpectationFailures()); },
|
||||||
|
onRandomClick: function() { queryString.navigateWithNewParam("random", !env.randomTests()); },
|
||||||
addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
|
addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
|
||||||
getContainer: function() { return document.body; },
|
getContainer: function() { return document.body; },
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2008-2015 Pivotal Labs
|
Copyright (c) 2008-2016 Pivotal Labs
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
@@ -41,6 +41,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
createTextNode = options.createTextNode,
|
createTextNode = options.createTextNode,
|
||||||
onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {},
|
onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {},
|
||||||
onThrowExpectationsClick = options.onThrowExpectationsClick || function() {},
|
onThrowExpectationsClick = options.onThrowExpectationsClick || function() {},
|
||||||
|
onRandomClick = options.onRandomClick || function() {},
|
||||||
addToExistingQueryString = options.addToExistingQueryString || defaultQueryString,
|
addToExistingQueryString = options.addToExistingQueryString || defaultQueryString,
|
||||||
timer = options.timer || noopTimer,
|
timer = options.timer || noopTimer,
|
||||||
results = [],
|
results = [],
|
||||||
@@ -54,19 +55,17 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
this.initialize = function() {
|
this.initialize = function() {
|
||||||
clearPrior();
|
clearPrior();
|
||||||
htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'},
|
htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'},
|
||||||
createDom('div', {className: 'banner'},
|
createDom('div', {className: 'jasmine-banner'},
|
||||||
createDom('a', {className: 'title', href: 'http://jasmine.github.io/', target: '_blank'}),
|
createDom('a', {className: 'jasmine-title', href: 'http://jasmine.github.io/', target: '_blank'}),
|
||||||
createDom('span', {className: 'version'}, j$.version)
|
createDom('span', {className: 'jasmine-version'}, j$.version)
|
||||||
),
|
),
|
||||||
createDom('ul', {className: 'symbol-summary'}),
|
createDom('ul', {className: 'jasmine-symbol-summary'}),
|
||||||
createDom('div', {className: 'alert'}),
|
createDom('div', {className: 'jasmine-alert'}),
|
||||||
createDom('div', {className: 'results'},
|
createDom('div', {className: 'jasmine-results'},
|
||||||
createDom('div', {className: 'failures'})
|
createDom('div', {className: 'jasmine-failures'})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
getContainer().appendChild(htmlReporterMain);
|
getContainer().appendChild(htmlReporterMain);
|
||||||
|
|
||||||
symbols = find('.symbol-summary');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var totalSpecsDefined;
|
var totalSpecsDefined;
|
||||||
@@ -75,7 +74,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
timer.start();
|
timer.start();
|
||||||
};
|
};
|
||||||
|
|
||||||
var summary = createDom('div', {className: 'summary'});
|
var summary = createDom('div', {className: 'jasmine-summary'});
|
||||||
|
|
||||||
var topResults = new j$.ResultsNode({}, '', null),
|
var topResults = new j$.ResultsNode({}, '', null),
|
||||||
currentParent = topResults;
|
currentParent = topResults;
|
||||||
@@ -111,8 +110,12 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
specsExecuted++;
|
specsExecuted++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!symbols){
|
||||||
|
symbols = find('.jasmine-symbol-summary');
|
||||||
|
}
|
||||||
|
|
||||||
symbols.appendChild(createDom('li', {
|
symbols.appendChild(createDom('li', {
|
||||||
className: noExpectations(result) ? 'empty' : result.status,
|
className: noExpectations(result) ? 'jasmine-empty' : 'jasmine-' + result.status,
|
||||||
id: 'spec_' + result.id,
|
id: 'spec_' + result.id,
|
||||||
title: result.fullName
|
title: result.fullName
|
||||||
}
|
}
|
||||||
@@ -122,18 +125,18 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
failureCount++;
|
failureCount++;
|
||||||
|
|
||||||
var failure =
|
var failure =
|
||||||
createDom('div', {className: 'spec-detail failed'},
|
createDom('div', {className: 'jasmine-spec-detail jasmine-failed'},
|
||||||
createDom('div', {className: 'description'},
|
createDom('div', {className: 'jasmine-description'},
|
||||||
createDom('a', {title: result.fullName, href: specHref(result)}, result.fullName)
|
createDom('a', {title: result.fullName, href: specHref(result)}, result.fullName)
|
||||||
),
|
),
|
||||||
createDom('div', {className: 'messages'})
|
createDom('div', {className: 'jasmine-messages'})
|
||||||
);
|
);
|
||||||
var messages = failure.childNodes[1];
|
var messages = failure.childNodes[1];
|
||||||
|
|
||||||
for (var i = 0; i < result.failedExpectations.length; i++) {
|
for (var i = 0; i < result.failedExpectations.length; i++) {
|
||||||
var expectation = result.failedExpectations[i];
|
var expectation = result.failedExpectations[i];
|
||||||
messages.appendChild(createDom('div', {className: 'result-message'}, expectation.message));
|
messages.appendChild(createDom('div', {className: 'jasmine-result-message'}, expectation.message));
|
||||||
messages.appendChild(createDom('div', {className: 'stack-trace'}, expectation.stack));
|
messages.appendChild(createDom('div', {className: 'jasmine-stack-trace'}, expectation.stack));
|
||||||
}
|
}
|
||||||
|
|
||||||
failures.push(failure);
|
failures.push(failure);
|
||||||
@@ -144,86 +147,114 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.jasmineDone = function() {
|
this.jasmineDone = function(doneResult) {
|
||||||
var banner = find('.banner');
|
var banner = find('.jasmine-banner');
|
||||||
var alert = find('.alert');
|
var alert = find('.jasmine-alert');
|
||||||
alert.appendChild(createDom('span', {className: 'duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
|
var order = doneResult && doneResult.order;
|
||||||
|
alert.appendChild(createDom('span', {className: 'jasmine-duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
|
||||||
|
|
||||||
banner.appendChild(
|
banner.appendChild(
|
||||||
createDom('div', { className: 'run-options' },
|
createDom('div', { className: 'jasmine-run-options' },
|
||||||
createDom('span', { className: 'trigger' }, 'Options'),
|
createDom('span', { className: 'jasmine-trigger' }, 'Options'),
|
||||||
createDom('div', { className: 'payload' },
|
createDom('div', { className: 'jasmine-payload' },
|
||||||
createDom('div', { className: 'exceptions' },
|
createDom('div', { className: 'jasmine-exceptions' },
|
||||||
createDom('input', {
|
createDom('input', {
|
||||||
className: 'raise',
|
className: 'jasmine-raise',
|
||||||
id: 'raise-exceptions',
|
id: 'jasmine-raise-exceptions',
|
||||||
type: 'checkbox'
|
type: 'checkbox'
|
||||||
}),
|
}),
|
||||||
createDom('label', { className: 'label', 'for': 'raise-exceptions' }, 'raise exceptions')),
|
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-raise-exceptions' }, 'raise exceptions')),
|
||||||
createDom('div', { className: 'throw-failures' },
|
createDom('div', { className: 'jasmine-throw-failures' },
|
||||||
createDom('input', {
|
createDom('input', {
|
||||||
className: 'throw',
|
className: 'jasmine-throw',
|
||||||
id: 'throw-failures',
|
id: 'jasmine-throw-failures',
|
||||||
type: 'checkbox'
|
type: 'checkbox'
|
||||||
}),
|
}),
|
||||||
createDom('label', { className: 'label', 'for': 'throw-failures' }, 'stop spec on expectation failure'))
|
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-throw-failures' }, 'stop spec on expectation failure')),
|
||||||
|
createDom('div', { className: 'jasmine-random-order' },
|
||||||
|
createDom('input', {
|
||||||
|
className: 'jasmine-random',
|
||||||
|
id: 'jasmine-random-order',
|
||||||
|
type: 'checkbox'
|
||||||
|
}),
|
||||||
|
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-random-order' }, 'run tests in random order'))
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
var raiseCheckbox = find('#raise-exceptions');
|
var raiseCheckbox = find('#jasmine-raise-exceptions');
|
||||||
|
|
||||||
raiseCheckbox.checked = !env.catchingExceptions();
|
raiseCheckbox.checked = !env.catchingExceptions();
|
||||||
raiseCheckbox.onclick = onRaiseExceptionsClick;
|
raiseCheckbox.onclick = onRaiseExceptionsClick;
|
||||||
|
|
||||||
var throwCheckbox = find('#throw-failures');
|
var throwCheckbox = find('#jasmine-throw-failures');
|
||||||
throwCheckbox.checked = env.throwingExpectationFailures();
|
throwCheckbox.checked = env.throwingExpectationFailures();
|
||||||
throwCheckbox.onclick = onThrowExpectationsClick;
|
throwCheckbox.onclick = onThrowExpectationsClick;
|
||||||
|
|
||||||
var optionsMenu = find('.run-options'),
|
var randomCheckbox = find('#jasmine-random-order');
|
||||||
optionsTrigger = optionsMenu.querySelector('.trigger'),
|
randomCheckbox.checked = env.randomTests();
|
||||||
optionsPayload = optionsMenu.querySelector('.payload'),
|
randomCheckbox.onclick = onRandomClick;
|
||||||
isOpen = /\bopen\b/;
|
|
||||||
|
var optionsMenu = find('.jasmine-run-options'),
|
||||||
|
optionsTrigger = optionsMenu.querySelector('.jasmine-trigger'),
|
||||||
|
optionsPayload = optionsMenu.querySelector('.jasmine-payload'),
|
||||||
|
isOpen = /\bjasmine-open\b/;
|
||||||
|
|
||||||
optionsTrigger.onclick = function() {
|
optionsTrigger.onclick = function() {
|
||||||
if (isOpen.test(optionsPayload.className)) {
|
if (isOpen.test(optionsPayload.className)) {
|
||||||
optionsPayload.className = optionsPayload.className.replace(isOpen, '');
|
optionsPayload.className = optionsPayload.className.replace(isOpen, '');
|
||||||
} else {
|
} else {
|
||||||
optionsPayload.className += ' open';
|
optionsPayload.className += ' jasmine-open';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (specsExecuted < totalSpecsDefined) {
|
if (specsExecuted < totalSpecsDefined) {
|
||||||
var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
|
var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
|
||||||
|
var skippedLink = order && order.random ? '?random=true' : '?';
|
||||||
alert.appendChild(
|
alert.appendChild(
|
||||||
createDom('span', {className: 'bar skipped'},
|
createDom('span', {className: 'jasmine-bar jasmine-skipped'},
|
||||||
createDom('a', {href: '?', title: 'Run all specs'}, skippedMessage)
|
createDom('a', {href: skippedLink, title: 'Run all specs'}, skippedMessage)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
var statusBarMessage = '';
|
var statusBarMessage = '';
|
||||||
var statusBarClassName = 'bar ';
|
var statusBarClassName = 'jasmine-bar ';
|
||||||
|
|
||||||
if (totalSpecsDefined > 0) {
|
if (totalSpecsDefined > 0) {
|
||||||
statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
|
statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
|
||||||
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
|
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
|
||||||
statusBarClassName += (failureCount > 0) ? 'failed' : 'passed';
|
statusBarClassName += (failureCount > 0) ? 'jasmine-failed' : 'jasmine-passed';
|
||||||
} else {
|
} else {
|
||||||
statusBarClassName += 'skipped';
|
statusBarClassName += 'jasmine-skipped';
|
||||||
statusBarMessage += 'No specs found';
|
statusBarMessage += 'No specs found';
|
||||||
}
|
}
|
||||||
|
|
||||||
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage));
|
var seedBar;
|
||||||
|
if (order && order.random) {
|
||||||
|
seedBar = createDom('span', {className: 'jasmine-seed-bar'},
|
||||||
|
', randomized with seed ',
|
||||||
|
createDom('a', {title: 'randomized with seed ' + order.seed, href: seedHref(order.seed)}, order.seed)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
for(i = 0; i < failedSuites.length; i++) {
|
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage, seedBar));
|
||||||
|
|
||||||
|
var errorBarClassName = 'jasmine-bar jasmine-errored';
|
||||||
|
var errorBarMessagePrefix = 'AfterAll ';
|
||||||
|
|
||||||
|
for(var i = 0; i < failedSuites.length; i++) {
|
||||||
var failedSuite = failedSuites[i];
|
var failedSuite = failedSuites[i];
|
||||||
for(var j = 0; j < failedSuite.failedExpectations.length; j++) {
|
for(var j = 0; j < failedSuite.failedExpectations.length; j++) {
|
||||||
var errorBarMessage = 'AfterAll ' + failedSuite.failedExpectations[j].message;
|
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessagePrefix + failedSuite.failedExpectations[j].message));
|
||||||
var errorBarClassName = 'bar errored';
|
|
||||||
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var results = find('.results');
|
var globalFailures = (doneResult && doneResult.failedExpectations) || [];
|
||||||
|
for(i = 0; i < globalFailures.length; i++) {
|
||||||
|
var failure = globalFailures[i];
|
||||||
|
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessagePrefix + failure.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
var results = find('.jasmine-results');
|
||||||
results.appendChild(summary);
|
results.appendChild(summary);
|
||||||
|
|
||||||
summaryList(topResults, summary);
|
summaryList(topResults, summary);
|
||||||
@@ -233,8 +264,8 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
for (var i = 0; i < resultsTree.children.length; i++) {
|
for (var i = 0; i < resultsTree.children.length; i++) {
|
||||||
var resultNode = resultsTree.children[i];
|
var resultNode = resultsTree.children[i];
|
||||||
if (resultNode.type == 'suite') {
|
if (resultNode.type == 'suite') {
|
||||||
var suiteListNode = createDom('ul', {className: 'suite', id: 'suite-' + resultNode.result.id},
|
var suiteListNode = createDom('ul', {className: 'jasmine-suite', id: 'suite-' + resultNode.result.id},
|
||||||
createDom('li', {className: 'suite-detail'},
|
createDom('li', {className: 'jasmine-suite-detail'},
|
||||||
createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description)
|
createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -243,8 +274,8 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
domParent.appendChild(suiteListNode);
|
domParent.appendChild(suiteListNode);
|
||||||
}
|
}
|
||||||
if (resultNode.type == 'spec') {
|
if (resultNode.type == 'spec') {
|
||||||
if (domParent.getAttribute('class') != 'specs') {
|
if (domParent.getAttribute('class') != 'jasmine-specs') {
|
||||||
specListNode = createDom('ul', {className: 'specs'});
|
specListNode = createDom('ul', {className: 'jasmine-specs'});
|
||||||
domParent.appendChild(specListNode);
|
domParent.appendChild(specListNode);
|
||||||
}
|
}
|
||||||
var specDescription = resultNode.result.description;
|
var specDescription = resultNode.result.description;
|
||||||
@@ -256,7 +287,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
}
|
}
|
||||||
specListNode.appendChild(
|
specListNode.appendChild(
|
||||||
createDom('li', {
|
createDom('li', {
|
||||||
className: resultNode.result.status,
|
className: 'jasmine-' + resultNode.result.status,
|
||||||
id: 'spec-' + resultNode.result.id
|
id: 'spec-' + resultNode.result.id
|
||||||
},
|
},
|
||||||
createDom('a', {href: specHref(resultNode.result)}, specDescription)
|
createDom('a', {href: specHref(resultNode.result)}, specDescription)
|
||||||
@@ -268,25 +299,25 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
|
|
||||||
if (failures.length) {
|
if (failures.length) {
|
||||||
alert.appendChild(
|
alert.appendChild(
|
||||||
createDom('span', {className: 'menu bar spec-list'},
|
createDom('span', {className: 'jasmine-menu jasmine-bar jasmine-spec-list'},
|
||||||
createDom('span', {}, 'Spec List | '),
|
createDom('span', {}, 'Spec List | '),
|
||||||
createDom('a', {className: 'failures-menu', href: '#'}, 'Failures')));
|
createDom('a', {className: 'jasmine-failures-menu', href: '#'}, 'Failures')));
|
||||||
alert.appendChild(
|
alert.appendChild(
|
||||||
createDom('span', {className: 'menu bar failure-list'},
|
createDom('span', {className: 'jasmine-menu jasmine-bar jasmine-failure-list'},
|
||||||
createDom('a', {className: 'spec-list-menu', href: '#'}, 'Spec List'),
|
createDom('a', {className: 'jasmine-spec-list-menu', href: '#'}, 'Spec List'),
|
||||||
createDom('span', {}, ' | Failures ')));
|
createDom('span', {}, ' | Failures ')));
|
||||||
|
|
||||||
find('.failures-menu').onclick = function() {
|
find('.jasmine-failures-menu').onclick = function() {
|
||||||
setMenuModeTo('failure-list');
|
setMenuModeTo('jasmine-failure-list');
|
||||||
};
|
};
|
||||||
find('.spec-list-menu').onclick = function() {
|
find('.jasmine-spec-list-menu').onclick = function() {
|
||||||
setMenuModeTo('spec-list');
|
setMenuModeTo('jasmine-spec-list');
|
||||||
};
|
};
|
||||||
|
|
||||||
setMenuModeTo('failure-list');
|
setMenuModeTo('jasmine-failure-list');
|
||||||
|
|
||||||
var failureNode = find('.failures');
|
var failureNode = find('.jasmine-failures');
|
||||||
for (var i = 0; i < failures.length; i++) {
|
for (i = 0; i < failures.length; i++) {
|
||||||
failureNode.appendChild(failures[i]);
|
failureNode.appendChild(failures[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -343,6 +374,10 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
return addToExistingQueryString('spec', result.fullName);
|
return addToExistingQueryString('spec', result.fullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function seedHref(seed) {
|
||||||
|
return addToExistingQueryString('seed', seed);
|
||||||
|
}
|
||||||
|
|
||||||
function defaultQueryString(key, value) {
|
function defaultQueryString(key, value) {
|
||||||
return '?' + key + '=' + value;
|
return '?' + key + '=' + value;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2008-2015 Pivotal Labs
|
Copyright (c) 2008-2016 Pivotal Labs
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
|
|||||||
@@ -4,6 +4,6 @@
|
|||||||
#
|
#
|
||||||
module Jasmine
|
module Jasmine
|
||||||
module Core
|
module Core
|
||||||
VERSION = "2.3.2"
|
VERSION = "2.5.2"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
22
package.json
22
package.json
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "jasmine-core",
|
"name": "jasmine-core",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "2.3.2",
|
"version": "2.5.2",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/jasmine/jasmine.git"
|
"url": "https://github.com/jasmine/jasmine.git"
|
||||||
@@ -13,22 +13,22 @@
|
|||||||
"bdd"
|
"bdd"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "./node_modules/.bin/grunt jshint execSpecsInNode"
|
"test": "grunt jshint execSpecsInNode"
|
||||||
},
|
},
|
||||||
"description": "Official packaging of Jasmine's core files for use by Node.js projects.",
|
"description": "Official packaging of Jasmine's core files for use by Node.js projects.",
|
||||||
"homepage": "http://jasmine.github.io",
|
"homepage": "http://jasmine.github.io",
|
||||||
"main": "./lib/jasmine-core.js",
|
"main": "./lib/jasmine-core.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"glob": "~3.2.9",
|
"glob": "~7.0.5",
|
||||||
"grunt": "~0.4.1",
|
"grunt": "^1.0.1",
|
||||||
"grunt-cli": "^0.1.13",
|
"grunt-cli": "^1.2.0",
|
||||||
"grunt-contrib-compass": "~0.6.0",
|
"grunt-contrib-compass": "^1.1.1",
|
||||||
"grunt-contrib-compress": "~0.5.2",
|
"grunt-contrib-compress": "^1.3.0",
|
||||||
"grunt-contrib-concat": "~0.3.0",
|
"grunt-contrib-concat": "^1.0.1",
|
||||||
"grunt-contrib-jshint": "~0.7.0",
|
"grunt-contrib-jshint": "^1.0.0",
|
||||||
"jasmine": "https://github.com/jasmine/jasmine-npm/archive/master.tar.gz",
|
"jasmine": "^2.4.0",
|
||||||
"load-grunt-tasks": "^0.4.0",
|
"load-grunt-tasks": "^0.4.0",
|
||||||
"shelljs": "~0.1.4",
|
"shelljs": "^0.7.0",
|
||||||
"temp": "~0.8.1"
|
"temp": "~0.8.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
release_notes/2.3.3.md
Normal file
14
release_notes/2.3.3.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Jasmine 2.3.3 Release Notes
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
This is a hotfix release to fix a regression with the execution context for `beforeAll`
|
||||||
|
|
||||||
|
## Pull Requests & Issues
|
||||||
|
|
||||||
|
* Set the shared user context correctly when executing the top level suite
|
||||||
|
- Fixes [#846](https://github.com/jasmine/jasmine/issues/846)
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||||
22
release_notes/2.3.4.md
Normal file
22
release_notes/2.3.4.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Jasmine 2.3.4 Release Notes
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
This is a hotfix release to fix a regression with execution ordering
|
||||||
|
|
||||||
|
## Pull Requests & Issues
|
||||||
|
|
||||||
|
* Fix ordering for suites with more than 11 direct children.
|
||||||
|
- Fixes [#850](https://github.com/jasmine/jasmine/issues/850)
|
||||||
|
|
||||||
|
* Update standalone installation instructions to reference the releases page
|
||||||
|
- Fixes [#603](https://github.com/jasmine/jasmine/issues/603)
|
||||||
|
|
||||||
|
* Remove dead CSS class styles
|
||||||
|
- Merges [#849](https://github.com/jasmine/jasmine/issues/849) from @prather-mcs
|
||||||
|
- Merges [#848](https://github.com/jasmine/jasmine/issues/848) from @prather-mcs
|
||||||
|
- Fixes [#847](https://github.com/jasmine/jasmine/issues/847)
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||||
91
release_notes/2.4.0.md
Normal file
91
release_notes/2.4.0.md
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
# Jasmine Core 2.4.0 Release Notes
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
This release contains a number of fixes and pull requests.
|
||||||
|
The most notable is probably that Jasmine now supports randomization of spec order
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
* Run jasmine's specs in random order
|
||||||
|
* Add support for returning run details for reporting randomness
|
||||||
|
* Use className instead of class when creating DOM elements
|
||||||
|
|
||||||
|
|
||||||
|
## Pull Requests & Issues
|
||||||
|
|
||||||
|
* Syntax highlighting in README.md
|
||||||
|
- Merges [#973](https://github.com/jasmine/jasmine/issues/973) from @brunoqc
|
||||||
|
|
||||||
|
* Added a throw error block in describe incase a function with arguments is passed in describe
|
||||||
|
- Fixes [#896](https://github.com/jasmine/jasmine/issues/896)
|
||||||
|
- Merges [#955](https://github.com/jasmine/jasmine/issues/955) from @himajasuman
|
||||||
|
|
||||||
|
* Remove unused `queueableFn` arg from `onException`
|
||||||
|
- Fixes [#958](https://github.com/jasmine/jasmine/issues/958)
|
||||||
|
|
||||||
|
* Remove unused parameter from toThrowError
|
||||||
|
- Merges [#957](https://github.com/jasmine/jasmine/issues/957) from @FuzzySockets
|
||||||
|
|
||||||
|
* Abort spying when the target cannot be spied upon
|
||||||
|
- Fixes [#948](https://github.com/jasmine/jasmine/issues/948)
|
||||||
|
- Merges [#949](https://github.com/jasmine/jasmine/issues/949) from @StephanBijzitter
|
||||||
|
|
||||||
|
* Removed GOALS_2.0.md, doesn't seem to be needed anymore
|
||||||
|
- Merges [#954](https://github.com/jasmine/jasmine/issues/954) from @matthewhuff89
|
||||||
|
|
||||||
|
* Change #xit so that it will output a more BDD-style pending message
|
||||||
|
- Merges [#942](https://github.com/jasmine/jasmine/issues/942) from @lalunamel
|
||||||
|
- Fixes [#930](https://github.com/jasmine/jasmine/issues/930)
|
||||||
|
- Fixes [#912](https://github.com/jasmine/jasmine/issues/912)
|
||||||
|
|
||||||
|
* Allow tests to run in random order
|
||||||
|
- Merges [#927](https://github.com/jasmine/jasmine/issues/927) from @marcioj
|
||||||
|
|
||||||
|
* Use toString for objects if it has been overriden
|
||||||
|
- Merges [#929](https://github.com/jasmine/jasmine/issues/929) from @myitcv
|
||||||
|
- Fixes [#928](https://github.com/jasmine/jasmine/issues/928)
|
||||||
|
|
||||||
|
* Fix circles/x from getting cut off on Mac/chrome
|
||||||
|
- Merges [#932](https://github.com/jasmine/jasmine/issues/932) from @James-Dunn
|
||||||
|
|
||||||
|
* Postpone find() until it is needed
|
||||||
|
- Merges [#924](https://github.com/jasmine/jasmine/issues/924) from @danielalexiuc
|
||||||
|
- Fixes [#917](https://github.com/jasmine/jasmine/issues/917)
|
||||||
|
|
||||||
|
* check for global before assigning
|
||||||
|
* Reverse suite afterEach behavior to match semantics?
|
||||||
|
- Merges [#908](https://github.com/jasmine/jasmine/issues/908) from @mcamac
|
||||||
|
|
||||||
|
* Use badges from shields.io
|
||||||
|
- Merges [#902](https://github.com/jasmine/jasmine/issues/902) from @SimenB
|
||||||
|
|
||||||
|
* xdescribe marks pending, plus associated tests.
|
||||||
|
- Merges [#869](https://github.com/jasmine/jasmine/issues/869) from @ljwall
|
||||||
|
- Fixes [#855](https://github.com/jasmine/jasmine/issues/855)
|
||||||
|
|
||||||
|
* Update glob to latest
|
||||||
|
- Merge [#892](https://github.com/jasmine/jasmine/issues/892) from @obastemur
|
||||||
|
- Fixes [#891](https://github.com/jasmine/jasmine/issues/891)
|
||||||
|
|
||||||
|
* Remove moot `version` property from bower.json
|
||||||
|
- Merges [#874](https://github.com/jasmine/jasmine/issues/874) from @kkirsche
|
||||||
|
|
||||||
|
* add toHaveBeenCalledTimes matcher
|
||||||
|
- Merges [#871](https://github.com/jasmine/jasmine/issues/871) from @logankd
|
||||||
|
- Fixes [#853](https://github.com/jasmine/jasmine/issues/853)
|
||||||
|
|
||||||
|
* Update CONTRIBUTING.md
|
||||||
|
- Merges [#856](https://github.com/jasmine/jasmine/issues/856) from @lpww
|
||||||
|
|
||||||
|
* Make the HtmlReport CSS classes "unique enough"
|
||||||
|
- Merges [#851](https://github.com/jasmine/jasmine/issues/851) from @prather-mcs
|
||||||
|
- Fixes [#844](https://github.com/jasmine/jasmine/issues/844)
|
||||||
|
|
||||||
|
* Raise an error when jasmine.any() isn't passed a constructor
|
||||||
|
- Merges [#854](https://github.com/jasmine/jasmine/issues/854) from @danfinnie
|
||||||
|
- Fixes [#852](https://github.com/jasmine/jasmine/issues/852)
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||||
11
release_notes/2.4.1.md
Normal file
11
release_notes/2.4.1.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Jasmine Core 2.4.1 Release Notes
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
* Run `afterEach` in reverse order declared as before
|
||||||
|
- Reverts [#908](https://github.com/jasmine/jasmine/issues/908)
|
||||||
|
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||||
116
release_notes/2.5.0.md
Normal file
116
release_notes/2.5.0.md
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
# Jasmine 2.5.0 Release Notes
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
This release contains a number of fixes and pull requests.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
* Rename `j$` to `jasmineUnderTest` for specs
|
||||||
|
- Please update any pull requests to simplify merging, thanks.
|
||||||
|
|
||||||
|
## Pull Requests & Issues
|
||||||
|
|
||||||
|
* Prettyprint objects whose constructors have custom toString method
|
||||||
|
- Fixes [#1019](https://github.com/jasmine/jasmine/issues/1019)
|
||||||
|
- Merges [#1099](https://github.com/jasmine/jasmine/issues/1099) from @mbildner
|
||||||
|
|
||||||
|
* Add gulp-jasmine-browser link to readme
|
||||||
|
- Fixes [#1089](https://github.com/jasmine/jasmine/issues/1089)
|
||||||
|
|
||||||
|
* Exclude lib directory from codeclimate
|
||||||
|
- Fixes [#1171](https://github.com/jasmine/jasmine/issues/1171)
|
||||||
|
|
||||||
|
* Add instructions for testing in IE
|
||||||
|
- Merges [#1170](https://github.com/jasmine/jasmine/issues/1170) from @benchristel
|
||||||
|
|
||||||
|
* Update devDependencies and fix issues from this
|
||||||
|
- Merges [#1162](https://github.com/jasmine/jasmine/issues/1162) from @amavisca
|
||||||
|
|
||||||
|
* Remove runnableLookupTable which is no longer used
|
||||||
|
- Merges [#1129](https://github.com/jasmine/jasmine/issues/1129) from @gregeninfrank
|
||||||
|
|
||||||
|
* Make `toEqual` pass for arrays with equivalent properties
|
||||||
|
- Merges [#1155](https://github.com/jasmine/jasmine/issues/1155) from @benchristel
|
||||||
|
|
||||||
|
* Update ruby version on travis to let rack install
|
||||||
|
- Merges [#1152](https://github.com/jasmine/jasmine/issues/1152) from @amavisca
|
||||||
|
|
||||||
|
* Fix jasmine setup in Electron environment
|
||||||
|
- Merges [#1079](https://github.com/jasmine/jasmine/issues/1079) from @skupr
|
||||||
|
- Fixes [#964](https://github.com/jasmine/jasmine/issues/964)
|
||||||
|
|
||||||
|
* Improve errors with the domain and how to use the API
|
||||||
|
- Merges [#1026](https://github.com/jasmine/jasmine/issues/1026) from @dhoko
|
||||||
|
- Fixes [#1025](https://github.com/jasmine/jasmine/issues/1025)
|
||||||
|
|
||||||
|
* The done function now returns null
|
||||||
|
- Merges [#1062](https://github.com/jasmine/jasmine/issues/1062) from @marneborn
|
||||||
|
- Fixes [#992](https://github.com/jasmine/jasmine/issues/992)
|
||||||
|
|
||||||
|
* Add .editorconfig file
|
||||||
|
- Merges [#1058](https://github.com/jasmine/jasmine/issues/1058) from @kapke
|
||||||
|
- Fixes [#1057](https://github.com/jasmine/jasmine/issues/1057)
|
||||||
|
|
||||||
|
* Improve error message when passing a non-function to callFake
|
||||||
|
- Merges [#1059](https://github.com/jasmine/jasmine/issues/1059) from @kapke
|
||||||
|
- Fixes [#1016](https://github.com/jasmine/jasmine/issues/1016)
|
||||||
|
|
||||||
|
* Allow expectations in a global beforeAll or afterAll
|
||||||
|
- Fixes [#811](https://github.com/jasmine/jasmine/issues/811)
|
||||||
|
|
||||||
|
* Correctly tear down spies on inherited methods
|
||||||
|
- Merges [#1036](https://github.com/jasmine/jasmine/issues/1036) from @benchristel
|
||||||
|
- Fixes [#737](https://github.com/jasmine/jasmine/issues/737)
|
||||||
|
|
||||||
|
* Array equality treats undefined elements as equal however they got in there
|
||||||
|
- Fixes [#786](https://github.com/jasmine/jasmine/issues/786)
|
||||||
|
|
||||||
|
* Add support for a fallback reporter
|
||||||
|
- Merges [#1009](https://github.com/jasmine/jasmine/issues/1009) from @mauricioborges
|
||||||
|
|
||||||
|
* Grunt task for compass should prefix command with 'bundle exec'
|
||||||
|
- Merges [#1047](https://github.com/jasmine/jasmine/issues/1047) from @d-reinhold
|
||||||
|
|
||||||
|
* Fix `toEqual` for Microsoft Edge
|
||||||
|
- Merges [#1041](https://github.com/jasmine/jasmine/issues/1041) from @everedifice
|
||||||
|
|
||||||
|
* Update describe error message to no longer assume errant args are `done`
|
||||||
|
- Fixes [#896](https://github.com/jasmine/jasmine/issues/896)
|
||||||
|
|
||||||
|
* Add toBeGreatThanOrEqual and toBeLessThanOrEqual matchers
|
||||||
|
- Merges [#1049](https://github.com/jasmine/jasmine/issues/1049) from @rullopat
|
||||||
|
- Fixes [#1013](https://github.com/jasmine/jasmine/issues/1013)
|
||||||
|
|
||||||
|
* Support call count of 0 with toHaveBeenCalledTimes matcher
|
||||||
|
- Merges [#1048](https://github.com/jasmine/jasmine/issues/1048) from @logankd
|
||||||
|
- Fixes [#994](https://github.com/jasmine/jasmine/issues/994)
|
||||||
|
|
||||||
|
* Correctly clean up spies after a spy is replaced and re-spied upon
|
||||||
|
- Merges [#1011](https://github.com/jasmine/jasmine/issues/1011) from @bodawei
|
||||||
|
- Fixes [#1010](https://github.com/jasmine/jasmine/issues/1010)
|
||||||
|
|
||||||
|
* remove extra topSuite `queueRunner` construction parameter
|
||||||
|
- Merges [#1006](https://github.com/jasmine/jasmine/issues/1006) from @jurko-gospodnetic
|
||||||
|
|
||||||
|
* add option to shallow clone args in call tracker
|
||||||
|
- Merges [#1000](https://github.com/jasmine/jasmine/issues/1000) from @a-r-d
|
||||||
|
- Fixes [#872](https://github.com/jasmine/jasmine/issues/872)
|
||||||
|
|
||||||
|
* Update license year range to 2016
|
||||||
|
- Merges [#1021](https://github.com/jasmine/jasmine/issues/1021) from pra85
|
||||||
|
|
||||||
|
* Persist randomize param in 'run all' links
|
||||||
|
- Merges [#990](https://github.com/jasmine/jasmine/issues/990) from @basawyer
|
||||||
|
|
||||||
|
* make DelayedFunctionScheduler update the mockDate
|
||||||
|
- Fixes [#915](https://github.com/jasmine/jasmine/issues/915)
|
||||||
|
- Merges [#980](https://github.com/jasmine/jasmine/issues/980) from @andrewiggings
|
||||||
|
|
||||||
|
* Allow `spyOn` to allow a respy for functions that have already been spied upon
|
||||||
|
- Merges [#953](https://github.com/jasmine/jasmine/issues/953) from @guy-mograbi-at-gigaspaces
|
||||||
|
- Fixes [#931](https://github.com/jasmine/jasmine/issues/931)
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||||
19
release_notes/2.5.1.md
Normal file
19
release_notes/2.5.1.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Jasmine 2.5.1 Release Notes
|
||||||
|
|
||||||
|
## Pull Requests & Issues
|
||||||
|
|
||||||
|
* fallback on assignment when a spy cannot be deleted
|
||||||
|
- Merges [#1193](https://github.com/jasmine/jasmine/issues/1193) from @seanparmlee
|
||||||
|
- Fixes [#1189](https://github.com/jasmine/jasmine/issues/1189)
|
||||||
|
|
||||||
|
* Fix issue with equality of Arrays in PhantomJS
|
||||||
|
- Merges [#1192](https://github.com/jasmine/jasmine/issues/1192) from @logankd
|
||||||
|
- Fixes [#1188](https://github.com/jasmine/jasmine/issues/1188)
|
||||||
|
|
||||||
|
* Properly tick date along with clock
|
||||||
|
- Fixes [#1190](https://github.com/jasmine/jasmine/issues/1190)
|
||||||
|
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||||
14
release_notes/2.5.2.md
Normal file
14
release_notes/2.5.2.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Jasmine 2.5.2 Release Notes
|
||||||
|
|
||||||
|
## Pull Requests & Issues
|
||||||
|
|
||||||
|
* Allow currently registered reporters to be cleared
|
||||||
|
- [jasmine/jasmine-npm#88](https://github.com/jasmine/jasmine-npm/issues/88)
|
||||||
|
|
||||||
|
|
||||||
|
* Use `isFunction` to check for functionness in `callFake`
|
||||||
|
- Fixes [#1191](https://github.com/jasmine/jasmine/issues/1191)
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||||
@@ -19,7 +19,7 @@ describe("ConsoleReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("reports that the suite has started to the console", function() {
|
it("reports that the suite has started to the console", function() {
|
||||||
var reporter = new j$.ConsoleReporter({
|
var reporter = new jasmineUnderTest.ConsoleReporter({
|
||||||
print: out.print
|
print: out.print
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ describe("ConsoleReporter", function() {
|
|||||||
|
|
||||||
it("starts the provided timer when jasmine starts", function() {
|
it("starts the provided timer when jasmine starts", function() {
|
||||||
var timerSpy = jasmine.createSpyObj('timer', ['start']),
|
var timerSpy = jasmine.createSpyObj('timer', ['start']),
|
||||||
reporter = new j$.ConsoleReporter({
|
reporter = new jasmineUnderTest.ConsoleReporter({
|
||||||
print: out.print,
|
print: out.print,
|
||||||
timer: timerSpy
|
timer: timerSpy
|
||||||
});
|
});
|
||||||
@@ -41,7 +41,7 @@ describe("ConsoleReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("reports a passing spec as a dot", function() {
|
it("reports a passing spec as a dot", function() {
|
||||||
var reporter = new j$.ConsoleReporter({
|
var reporter = new jasmineUnderTest.ConsoleReporter({
|
||||||
print: out.print
|
print: out.print
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ describe("ConsoleReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does not report a disabled spec", function() {
|
it("does not report a disabled spec", function() {
|
||||||
var reporter = new j$.ConsoleReporter({
|
var reporter = new jasmineUnderTest.ConsoleReporter({
|
||||||
print: out.print
|
print: out.print
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ describe("ConsoleReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("reports a failing spec as an 'F'", function() {
|
it("reports a failing spec as an 'F'", function() {
|
||||||
var reporter = new j$.ConsoleReporter({
|
var reporter = new jasmineUnderTest.ConsoleReporter({
|
||||||
print: out.print
|
print: out.print
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ describe("ConsoleReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("reports a pending spec as a '*'", function() {
|
it("reports a pending spec as a '*'", function() {
|
||||||
var reporter = new j$.ConsoleReporter({
|
var reporter = new jasmineUnderTest.ConsoleReporter({
|
||||||
print: out.print
|
print: out.print
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ describe("ConsoleReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("alerts user if there are no specs", function(){
|
it("alerts user if there are no specs", function(){
|
||||||
var reporter = new j$.ConsoleReporter({
|
var reporter = new jasmineUnderTest.ConsoleReporter({
|
||||||
print: out.print
|
print: out.print
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ describe("ConsoleReporter", function() {
|
|||||||
|
|
||||||
it("reports a summary when done (singular spec and time)", function() {
|
it("reports a summary when done (singular spec and time)", function() {
|
||||||
var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
||||||
reporter = new j$.ConsoleReporter({
|
reporter = new jasmineUnderTest.ConsoleReporter({
|
||||||
print: out.print,
|
print: out.print,
|
||||||
timer: timerSpy
|
timer: timerSpy
|
||||||
});
|
});
|
||||||
@@ -114,7 +114,7 @@ describe("ConsoleReporter", function() {
|
|||||||
|
|
||||||
it("reports a summary when done (pluralized specs and seconds)", function() {
|
it("reports a summary when done (pluralized specs and seconds)", function() {
|
||||||
var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
||||||
reporter = new j$.ConsoleReporter({
|
reporter = new jasmineUnderTest.ConsoleReporter({
|
||||||
print: out.print,
|
print: out.print,
|
||||||
timer: timerSpy
|
timer: timerSpy
|
||||||
});
|
});
|
||||||
@@ -148,7 +148,7 @@ describe("ConsoleReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("reports a summary when done that includes stack traces for a failing suite", function() {
|
it("reports a summary when done that includes stack traces for a failing suite", function() {
|
||||||
var reporter = new j$.ConsoleReporter({
|
var reporter = new jasmineUnderTest.ConsoleReporter({
|
||||||
print: out.print
|
print: out.print
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ describe("ConsoleReporter", function() {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
onComplete = jasmine.createSpy('onComplete');
|
onComplete = jasmine.createSpy('onComplete');
|
||||||
reporter = new j$.ConsoleReporter({
|
reporter = new jasmineUnderTest.ConsoleReporter({
|
||||||
print: out.print,
|
print: out.print,
|
||||||
onComplete: onComplete
|
onComplete: onComplete
|
||||||
});
|
});
|
||||||
@@ -210,7 +210,7 @@ describe("ConsoleReporter", function() {
|
|||||||
|
|
||||||
describe("with color", function() {
|
describe("with color", function() {
|
||||||
it("reports that the suite has started to the console", function() {
|
it("reports that the suite has started to the console", function() {
|
||||||
var reporter = new j$.ConsoleReporter({
|
var reporter = new jasmineUnderTest.ConsoleReporter({
|
||||||
print: out.print,
|
print: out.print,
|
||||||
showColors: true
|
showColors: true
|
||||||
});
|
});
|
||||||
@@ -221,7 +221,7 @@ describe("ConsoleReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("reports a passing spec as a dot", function() {
|
it("reports a passing spec as a dot", function() {
|
||||||
var reporter = new j$.ConsoleReporter({
|
var reporter = new jasmineUnderTest.ConsoleReporter({
|
||||||
print: out.print,
|
print: out.print,
|
||||||
showColors: true
|
showColors: true
|
||||||
});
|
});
|
||||||
@@ -232,7 +232,7 @@ describe("ConsoleReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does not report a disabled spec", function() {
|
it("does not report a disabled spec", function() {
|
||||||
var reporter = new j$.ConsoleReporter({
|
var reporter = new jasmineUnderTest.ConsoleReporter({
|
||||||
print: out.print,
|
print: out.print,
|
||||||
showColors: true
|
showColors: true
|
||||||
});
|
});
|
||||||
@@ -243,7 +243,7 @@ describe("ConsoleReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("reports a failing spec as an 'F'", function() {
|
it("reports a failing spec as an 'F'", function() {
|
||||||
var reporter = new j$.ConsoleReporter({
|
var reporter = new jasmineUnderTest.ConsoleReporter({
|
||||||
print: out.print,
|
print: out.print,
|
||||||
showColors: true
|
showColors: true
|
||||||
});
|
});
|
||||||
@@ -254,7 +254,7 @@ describe("ConsoleReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("displays all afterAll exceptions", function() {
|
it("displays all afterAll exceptions", function() {
|
||||||
var reporter = new j$.ConsoleReporter({
|
var reporter = new jasmineUnderTest.ConsoleReporter({
|
||||||
print: out.print,
|
print: out.print,
|
||||||
showColors: true
|
showColors: true
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe("CallTracker", function() {
|
describe("CallTracker", function() {
|
||||||
it("tracks that it was called when executed", function() {
|
it("tracks that it was called when executed", function() {
|
||||||
var callTracker = new j$.CallTracker();
|
var callTracker = new jasmineUnderTest.CallTracker();
|
||||||
|
|
||||||
expect(callTracker.any()).toBe(false);
|
expect(callTracker.any()).toBe(false);
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ describe("CallTracker", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("tracks that number of times that it is executed", function() {
|
it("tracks that number of times that it is executed", function() {
|
||||||
var callTracker = new j$.CallTracker();
|
var callTracker = new jasmineUnderTest.CallTracker();
|
||||||
|
|
||||||
expect(callTracker.count()).toEqual(0);
|
expect(callTracker.count()).toEqual(0);
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ describe("CallTracker", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("tracks the params from each execution", function() {
|
it("tracks the params from each execution", function() {
|
||||||
var callTracker = new j$.CallTracker();
|
var callTracker = new jasmineUnderTest.CallTracker();
|
||||||
|
|
||||||
callTracker.track({object: void 0, args: []});
|
callTracker.track({object: void 0, args: []});
|
||||||
callTracker.track({object: {}, args: [0, "foo"]});
|
callTracker.track({object: {}, args: [0, "foo"]});
|
||||||
@@ -31,13 +31,13 @@ describe("CallTracker", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("returns any empty array when there was no call", function() {
|
it("returns any empty array when there was no call", function() {
|
||||||
var callTracker = new j$.CallTracker();
|
var callTracker = new jasmineUnderTest.CallTracker();
|
||||||
|
|
||||||
expect(callTracker.argsFor(0)).toEqual([]);
|
expect(callTracker.argsFor(0)).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows access for the arguments for all calls", function() {
|
it("allows access for the arguments for all calls", function() {
|
||||||
var callTracker = new j$.CallTracker();
|
var callTracker = new jasmineUnderTest.CallTracker();
|
||||||
|
|
||||||
callTracker.track({object: {}, args: []});
|
callTracker.track({object: {}, args: []});
|
||||||
callTracker.track({object: {}, args: [0, "foo"]});
|
callTracker.track({object: {}, args: [0, "foo"]});
|
||||||
@@ -46,7 +46,7 @@ describe("CallTracker", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("tracks the context and arguments for each call", function() {
|
it("tracks the context and arguments for each call", function() {
|
||||||
var callTracker = new j$.CallTracker();
|
var callTracker = new jasmineUnderTest.CallTracker();
|
||||||
|
|
||||||
callTracker.track({object: {}, args: []});
|
callTracker.track({object: {}, args: []});
|
||||||
callTracker.track({object: {}, args: [0, "foo"]});
|
callTracker.track({object: {}, args: [0, "foo"]});
|
||||||
@@ -57,7 +57,7 @@ describe("CallTracker", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("simplifies access to the arguments for the last (most recent) call", function() {
|
it("simplifies access to the arguments for the last (most recent) call", function() {
|
||||||
var callTracker = new j$.CallTracker();
|
var callTracker = new jasmineUnderTest.CallTracker();
|
||||||
|
|
||||||
callTracker.track();
|
callTracker.track();
|
||||||
callTracker.track({object: {}, args: [0, "foo"]});
|
callTracker.track({object: {}, args: [0, "foo"]});
|
||||||
@@ -69,13 +69,13 @@ describe("CallTracker", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("returns a useful falsy value when there isn't a last (most recent) call", function() {
|
it("returns a useful falsy value when there isn't a last (most recent) call", function() {
|
||||||
var callTracker = new j$.CallTracker();
|
var callTracker = new jasmineUnderTest.CallTracker();
|
||||||
|
|
||||||
expect(callTracker.mostRecent()).toBeFalsy();
|
expect(callTracker.mostRecent()).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("simplifies access to the arguments for the first (oldest) call", function() {
|
it("simplifies access to the arguments for the first (oldest) call", function() {
|
||||||
var callTracker = new j$.CallTracker();
|
var callTracker = new jasmineUnderTest.CallTracker();
|
||||||
|
|
||||||
callTracker.track({object: {}, args: [0, "foo"]});
|
callTracker.track({object: {}, args: [0, "foo"]});
|
||||||
|
|
||||||
@@ -83,14 +83,14 @@ describe("CallTracker", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("returns a useful falsy value when there isn't a first (oldest) call", function() {
|
it("returns a useful falsy value when there isn't a first (oldest) call", function() {
|
||||||
var callTracker = new j$.CallTracker();
|
var callTracker = new jasmineUnderTest.CallTracker();
|
||||||
|
|
||||||
expect(callTracker.first()).toBeFalsy();
|
expect(callTracker.first()).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("allows the tracking to be reset", function() {
|
it("allows the tracking to be reset", function() {
|
||||||
var callTracker = new j$.CallTracker();
|
var callTracker = new jasmineUnderTest.CallTracker();
|
||||||
|
|
||||||
callTracker.track();
|
callTracker.track();
|
||||||
callTracker.track({object: {}, args: [0, "foo"]});
|
callTracker.track({object: {}, args: [0, "foo"]});
|
||||||
@@ -102,4 +102,19 @@ describe("CallTracker", function() {
|
|||||||
expect(callTracker.all()).toEqual([]);
|
expect(callTracker.all()).toEqual([]);
|
||||||
expect(callTracker.mostRecent()).toBeFalsy();
|
expect(callTracker.mostRecent()).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("allows object arguments to be shallow cloned", function() {
|
||||||
|
var callTracker = new jasmineUnderTest.CallTracker();
|
||||||
|
callTracker.saveArgumentsByValue();
|
||||||
|
|
||||||
|
var objectArg = {"foo": "bar"},
|
||||||
|
arrayArg = ["foo", "bar"];
|
||||||
|
|
||||||
|
callTracker.track({object: {}, args: [objectArg, arrayArg, false, undefined, null, NaN, "", 0, 1.0]});
|
||||||
|
|
||||||
|
expect(callTracker.mostRecent().args[0]).not.toBe(objectArg);
|
||||||
|
expect(callTracker.mostRecent().args[0]).toEqual(objectArg);
|
||||||
|
expect(callTracker.mostRecent().args[1]).not.toBe(arrayArg);
|
||||||
|
expect(callTracker.mostRecent().args[1]).toEqual(arrayArg);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ describe("Clock", function() {
|
|||||||
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction"]),
|
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction"]),
|
||||||
delayedFn = jasmine.createSpy("delayedFn"),
|
delayedFn = jasmine.createSpy("delayedFn"),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
||||||
|
|
||||||
fakeGlobal.setTimeout(delayedFn, 0);
|
fakeGlobal.setTimeout(delayedFn, 0);
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ describe("Clock", function() {
|
|||||||
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["removeFunctionWithId"]),
|
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["removeFunctionWithId"]),
|
||||||
delayedFn = jasmine.createSpy("delayedFn"),
|
delayedFn = jasmine.createSpy("delayedFn"),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
||||||
|
|
||||||
fakeGlobal.clearTimeout("foo");
|
fakeGlobal.clearTimeout("foo");
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ describe("Clock", function() {
|
|||||||
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction"]),
|
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction"]),
|
||||||
delayedFn = jasmine.createSpy("delayedFn"),
|
delayedFn = jasmine.createSpy("delayedFn"),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
||||||
|
|
||||||
fakeGlobal.setInterval(delayedFn, 0);
|
fakeGlobal.setInterval(delayedFn, 0);
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ describe("Clock", function() {
|
|||||||
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["removeFunctionWithId"]),
|
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["removeFunctionWithId"]),
|
||||||
delayedFn = jasmine.createSpy("delayedFn"),
|
delayedFn = jasmine.createSpy("delayedFn"),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
||||||
|
|
||||||
fakeGlobal.clearInterval("foo");
|
fakeGlobal.clearInterval("foo");
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ describe("Clock", function() {
|
|||||||
fakeGlobal = { setTimeout: originalFakeSetTimeout },
|
fakeGlobal = { setTimeout: originalFakeSetTimeout },
|
||||||
delayedFunctionSchedulerFactory = jasmine.createSpy('delayedFunctionSchedulerFactory'),
|
delayedFunctionSchedulerFactory = jasmine.createSpy('delayedFunctionSchedulerFactory'),
|
||||||
mockDate = {},
|
mockDate = {},
|
||||||
clock = new j$.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
|
clock = new jasmineUnderTest.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
|
||||||
|
|
||||||
fakeGlobal.setTimeout = replacedSetTimeout;
|
fakeGlobal.setTimeout = replacedSetTimeout;
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ describe("Clock", function() {
|
|||||||
fakeGlobal = { clearTimeout: originalFakeClearTimeout },
|
fakeGlobal = { clearTimeout: originalFakeClearTimeout },
|
||||||
delayedFunctionSchedulerFactory = jasmine.createSpy('delayedFunctionSchedulerFactory'),
|
delayedFunctionSchedulerFactory = jasmine.createSpy('delayedFunctionSchedulerFactory'),
|
||||||
mockDate = {},
|
mockDate = {},
|
||||||
clock = new j$.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
|
clock = new jasmineUnderTest.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
|
||||||
|
|
||||||
fakeGlobal.clearTimeout = replacedClearTimeout;
|
fakeGlobal.clearTimeout = replacedClearTimeout;
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ describe("Clock", function() {
|
|||||||
fakeGlobal = { setInterval: originalFakeSetInterval },
|
fakeGlobal = { setInterval: originalFakeSetInterval },
|
||||||
delayedFunctionSchedulerFactory = jasmine.createSpy('delayedFunctionSchedulerFactory'),
|
delayedFunctionSchedulerFactory = jasmine.createSpy('delayedFunctionSchedulerFactory'),
|
||||||
mockDate = {},
|
mockDate = {},
|
||||||
clock = new j$.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
|
clock = new jasmineUnderTest.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
|
||||||
|
|
||||||
fakeGlobal.setInterval = replacedSetInterval;
|
fakeGlobal.setInterval = replacedSetInterval;
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ describe("Clock", function() {
|
|||||||
fakeGlobal = { clearInterval: originalFakeClearInterval },
|
fakeGlobal = { clearInterval: originalFakeClearInterval },
|
||||||
delayedFunctionSchedulerFactory = jasmine.createSpy('delayedFunctionSchedulerFactory'),
|
delayedFunctionSchedulerFactory = jasmine.createSpy('delayedFunctionSchedulerFactory'),
|
||||||
mockDate = {},
|
mockDate = {},
|
||||||
clock = new j$.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
|
clock = new jasmineUnderTest.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
|
||||||
|
|
||||||
fakeGlobal.clearInterval = replacedClearInterval;
|
fakeGlobal.clearInterval = replacedClearInterval;
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ describe("Clock", function() {
|
|||||||
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction", "reset"]),
|
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction", "reset"]),
|
||||||
delayedFn = jasmine.createSpy("delayedFn"),
|
delayedFn = jasmine.createSpy("delayedFn"),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
||||||
|
|
||||||
clock.install();
|
clock.install();
|
||||||
clock.uninstall();
|
clock.uninstall();
|
||||||
@@ -204,7 +204,7 @@ describe("Clock", function() {
|
|||||||
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction", "reset", "removeFunctionWithId"]),
|
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction", "reset", "removeFunctionWithId"]),
|
||||||
delayedFn = jasmine.createSpy("delayedFn"),
|
delayedFn = jasmine.createSpy("delayedFn"),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
|
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
|
||||||
passedFunctionCalled = false;
|
passedFunctionCalled = false;
|
||||||
|
|
||||||
clock.withMock(function() {
|
clock.withMock(function() {
|
||||||
@@ -251,7 +251,7 @@ describe("Clock", function() {
|
|||||||
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction", "reset", "removeFunctionWithId"]),
|
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction", "reset", "removeFunctionWithId"]),
|
||||||
delayedFn = jasmine.createSpy("delayedFn"),
|
delayedFn = jasmine.createSpy("delayedFn"),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
|
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
|
||||||
passedFunctionCalled = false;
|
passedFunctionCalled = false;
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
@@ -294,7 +294,7 @@ describe("Clock", function() {
|
|||||||
fakeGlobal = { setTimeout: fakeSetTimeout },
|
fakeGlobal = { setTimeout: fakeSetTimeout },
|
||||||
delayedFn = jasmine.createSpy('delayedFn'),
|
delayedFn = jasmine.createSpy('delayedFn'),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
||||||
|
|
||||||
clock.install();
|
clock.install();
|
||||||
clock.setTimeout(delayedFn, 0, 'a', 'b');
|
clock.setTimeout(delayedFn, 0, 'a', 'b');
|
||||||
@@ -311,7 +311,7 @@ describe("Clock", function() {
|
|||||||
fakeGlobal = { setTimeout: fakeSetTimeout },
|
fakeGlobal = { setTimeout: fakeSetTimeout },
|
||||||
delayedFn = jasmine.createSpy('delayedFn'),
|
delayedFn = jasmine.createSpy('delayedFn'),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
|
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
|
||||||
timeoutId;
|
timeoutId;
|
||||||
|
|
||||||
clock.install();
|
clock.install();
|
||||||
@@ -326,7 +326,7 @@ describe("Clock", function() {
|
|||||||
fakeGlobal = { setTimeout: fakeClearTimeout },
|
fakeGlobal = { setTimeout: fakeClearTimeout },
|
||||||
delayedFn = jasmine.createSpy('delayedFn'),
|
delayedFn = jasmine.createSpy('delayedFn'),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
||||||
|
|
||||||
clock.install();
|
clock.install();
|
||||||
clock.clearTimeout(123);
|
clock.clearTimeout(123);
|
||||||
@@ -342,7 +342,7 @@ describe("Clock", function() {
|
|||||||
fakeGlobal = { setInterval: fakeSetInterval },
|
fakeGlobal = { setInterval: fakeSetInterval },
|
||||||
delayedFn = jasmine.createSpy('delayedFn'),
|
delayedFn = jasmine.createSpy('delayedFn'),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
||||||
|
|
||||||
clock.install();
|
clock.install();
|
||||||
clock.setInterval(delayedFn, 0, 'a', 'b');
|
clock.setInterval(delayedFn, 0, 'a', 'b');
|
||||||
@@ -359,7 +359,7 @@ describe("Clock", function() {
|
|||||||
fakeGlobal = { setInterval: fakeSetInterval },
|
fakeGlobal = { setInterval: fakeSetInterval },
|
||||||
delayedFn = jasmine.createSpy('delayedFn'),
|
delayedFn = jasmine.createSpy('delayedFn'),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
|
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
|
||||||
intervalId;
|
intervalId;
|
||||||
|
|
||||||
clock.install();
|
clock.install();
|
||||||
@@ -374,7 +374,7 @@ describe("Clock", function() {
|
|||||||
fakeGlobal = { setInterval: clearInterval },
|
fakeGlobal = { setInterval: clearInterval },
|
||||||
delayedFn = jasmine.createSpy('delayedFn'),
|
delayedFn = jasmine.createSpy('delayedFn'),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
||||||
|
|
||||||
clock.install();
|
clock.install();
|
||||||
clock.clearInterval(123);
|
clock.clearInterval(123);
|
||||||
@@ -384,7 +384,7 @@ describe("Clock", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("gives you a friendly reminder if the Clock is not installed and you tick", function() {
|
it("gives you a friendly reminder if the Clock is not installed and you tick", function() {
|
||||||
var clock = new j$.Clock({}, jasmine.createSpyObj('delayedFunctionScheduler', ['tick']));
|
var clock = new jasmineUnderTest.Clock({}, jasmine.createSpyObj('delayedFunctionScheduler', ['tick']));
|
||||||
expect(function() {
|
expect(function() {
|
||||||
clock.tick(50);
|
clock.tick(50);
|
||||||
}).toThrow();
|
}).toThrow();
|
||||||
@@ -401,7 +401,7 @@ describe("Clock", function() {
|
|||||||
setInterval: fakeSetInterval
|
setInterval: fakeSetInterval
|
||||||
},
|
},
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
||||||
|
|
||||||
fakeSetTimeout.apply = null;
|
fakeSetTimeout.apply = null;
|
||||||
fakeSetInterval.apply = null;
|
fakeSetInterval.apply = null;
|
||||||
@@ -428,9 +428,9 @@ describe("Clock (acceptance)", function() {
|
|||||||
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
||||||
delayedFn3 = jasmine.createSpy('delayedFn3'),
|
delayedFn3 = jasmine.createSpy('delayedFn3'),
|
||||||
recurring1 = jasmine.createSpy('recurring1'),
|
recurring1 = jasmine.createSpy('recurring1'),
|
||||||
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate);
|
clock = new jasmineUnderTest.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate);
|
||||||
|
|
||||||
clock.install();
|
clock.install();
|
||||||
|
|
||||||
@@ -475,9 +475,9 @@ describe("Clock (acceptance)", function() {
|
|||||||
|
|
||||||
it("can clear a previously set timeout", function() {
|
it("can clear a previously set timeout", function() {
|
||||||
var clearedFn = jasmine.createSpy('clearedFn'),
|
var clearedFn = jasmine.createSpy('clearedFn'),
|
||||||
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate),
|
clock = new jasmineUnderTest.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate),
|
||||||
timeoutId;
|
timeoutId;
|
||||||
|
|
||||||
clock.install();
|
clock.install();
|
||||||
@@ -493,9 +493,9 @@ describe("Clock (acceptance)", function() {
|
|||||||
|
|
||||||
it("can clear a previously set interval using that interval's handler", function() {
|
it("can clear a previously set interval using that interval's handler", function() {
|
||||||
var spy = jasmine.createSpy('spy'),
|
var spy = jasmine.createSpy('spy'),
|
||||||
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock({setInterval: function() {}}, function () { return delayedFunctionScheduler; }, mockDate),
|
clock = new jasmineUnderTest.Clock({setInterval: function() {}}, function () { return delayedFunctionScheduler; }, mockDate),
|
||||||
intervalId;
|
intervalId;
|
||||||
|
|
||||||
clock.install();
|
clock.install();
|
||||||
@@ -511,9 +511,9 @@ describe("Clock (acceptance)", function() {
|
|||||||
|
|
||||||
it("correctly schedules functions after the Clock has advanced", function() {
|
it("correctly schedules functions after the Clock has advanced", function() {
|
||||||
var delayedFn1 = jasmine.createSpy('delayedFn1'),
|
var delayedFn1 = jasmine.createSpy('delayedFn1'),
|
||||||
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
|
clock = new jasmineUnderTest.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
|
||||||
|
|
||||||
clock.install();
|
clock.install();
|
||||||
|
|
||||||
@@ -528,9 +528,9 @@ describe("Clock (acceptance)", function() {
|
|||||||
it("correctly schedules functions while the Clock is advancing", function() {
|
it("correctly schedules functions while the Clock is advancing", function() {
|
||||||
var delayedFn1 = jasmine.createSpy('delayedFn1'),
|
var delayedFn1 = jasmine.createSpy('delayedFn1'),
|
||||||
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
||||||
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
|
clock = new jasmineUnderTest.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
|
||||||
|
|
||||||
delayedFn1.and.callFake(function() { clock.setTimeout(delayedFn2, 0); });
|
delayedFn1.and.callFake(function() { clock.setTimeout(delayedFn2, 0); });
|
||||||
clock.install();
|
clock.install();
|
||||||
@@ -547,9 +547,9 @@ describe("Clock (acceptance)", function() {
|
|||||||
it("correctly calls functions scheduled while the Clock is advancing", function() {
|
it("correctly calls functions scheduled while the Clock is advancing", function() {
|
||||||
var delayedFn1 = jasmine.createSpy('delayedFn1'),
|
var delayedFn1 = jasmine.createSpy('delayedFn1'),
|
||||||
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
||||||
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
|
clock = new jasmineUnderTest.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
|
||||||
|
|
||||||
delayedFn1.and.callFake(function() { clock.setTimeout(delayedFn2, 1); });
|
delayedFn1.and.callFake(function() { clock.setTimeout(delayedFn2, 1); });
|
||||||
clock.install();
|
clock.install();
|
||||||
@@ -563,9 +563,9 @@ describe("Clock (acceptance)", function() {
|
|||||||
it("correctly schedules functions scheduled while the Clock is advancing but after the Clock is uninstalled", function() {
|
it("correctly schedules functions scheduled while the Clock is advancing but after the Clock is uninstalled", function() {
|
||||||
var delayedFn1 = jasmine.createSpy('delayedFn1'),
|
var delayedFn1 = jasmine.createSpy('delayedFn1'),
|
||||||
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
||||||
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
clock = new j$.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
|
clock = new jasmineUnderTest.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
|
||||||
|
|
||||||
delayedFn1.and.callFake(function() {
|
delayedFn1.and.callFake(function() {
|
||||||
clock.uninstall();
|
clock.uninstall();
|
||||||
@@ -585,10 +585,10 @@ describe("Clock (acceptance)", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does not mock the Date object by default", function() {
|
it("does not mock the Date object by default", function() {
|
||||||
var delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
global = {Date: Date},
|
global = {Date: Date},
|
||||||
mockDate = new j$.MockDate(global),
|
mockDate = new jasmineUnderTest.MockDate(global),
|
||||||
clock = new j$.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate);
|
clock = new jasmineUnderTest.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate);
|
||||||
|
|
||||||
clock.install();
|
clock.install();
|
||||||
|
|
||||||
@@ -602,10 +602,10 @@ describe("Clock (acceptance)", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("mocks the Date object and sets it to current time", function() {
|
it("mocks the Date object and sets it to current time", function() {
|
||||||
var delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
global = {Date: Date},
|
global = {Date: Date},
|
||||||
mockDate = new j$.MockDate(global),
|
mockDate = new jasmineUnderTest.MockDate(global),
|
||||||
clock = new j$.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate);
|
clock = new jasmineUnderTest.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate);
|
||||||
|
|
||||||
clock.install().mockDate();
|
clock.install().mockDate();
|
||||||
|
|
||||||
@@ -626,10 +626,10 @@ describe("Clock (acceptance)", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("mocks the Date object and sets it to a given time", function() {
|
it("mocks the Date object and sets it to a given time", function() {
|
||||||
var delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
global = {Date: Date},
|
global = {Date: Date},
|
||||||
mockDate = new j$.MockDate(global),
|
mockDate = new jasmineUnderTest.MockDate(global),
|
||||||
clock = new j$.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate),
|
clock = new jasmineUnderTest.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate),
|
||||||
baseTime = new Date(2013, 9, 23);
|
baseTime = new Date(2013, 9, 23);
|
||||||
|
|
||||||
|
|
||||||
@@ -652,4 +652,31 @@ describe("Clock (acceptance)", function() {
|
|||||||
|
|
||||||
expect(timeoutDate).toEqual(baseTime.getTime() + 150);
|
expect(timeoutDate).toEqual(baseTime.getTime() + 150);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("mocks the Date object and updates the date per delayed function", function () {
|
||||||
|
var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
|
global = {Date: Date},
|
||||||
|
mockDate = new jasmineUnderTest.MockDate(global),
|
||||||
|
clock = new jasmineUnderTest.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate),
|
||||||
|
baseTime = new Date();
|
||||||
|
|
||||||
|
clock.install().mockDate(baseTime);
|
||||||
|
|
||||||
|
var actualTimes = [];
|
||||||
|
var pushCurrentTime = function() { actualTimes.push(global.Date().getTime()); };
|
||||||
|
delayedFunctionScheduler.scheduleFunction(pushCurrentTime);
|
||||||
|
delayedFunctionScheduler.scheduleFunction(pushCurrentTime, 1);
|
||||||
|
delayedFunctionScheduler.scheduleFunction(pushCurrentTime, 3);
|
||||||
|
|
||||||
|
clock.tick(1);
|
||||||
|
expect(global.Date().getTime()).toEqual(baseTime.getTime() + 1);
|
||||||
|
|
||||||
|
clock.tick(3);
|
||||||
|
expect(global.Date().getTime()).toEqual(baseTime.getTime() + 4);
|
||||||
|
|
||||||
|
clock.tick(1);
|
||||||
|
expect(global.Date().getTime()).toEqual(baseTime.getTime() + 5);
|
||||||
|
|
||||||
|
expect(actualTimes).toEqual([baseTime.getTime(), baseTime.getTime() + 1, baseTime.getTime() + 3]);
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe("DelayedFunctionScheduler", function() {
|
describe("DelayedFunctionScheduler", function() {
|
||||||
it("schedules a function for later execution", function() {
|
it("schedules a function for later execution", function() {
|
||||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
fn = jasmine.createSpy('fn');
|
fn = jasmine.createSpy('fn');
|
||||||
|
|
||||||
scheduler.scheduleFunction(fn, 0);
|
scheduler.scheduleFunction(fn, 0);
|
||||||
@@ -13,7 +13,7 @@ describe("DelayedFunctionScheduler", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("schedules a string for later execution", function() {
|
it("schedules a string for later execution", function() {
|
||||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
strfn = "horrible = true;";
|
strfn = "horrible = true;";
|
||||||
|
|
||||||
scheduler.scheduleFunction(strfn, 0);
|
scheduler.scheduleFunction(strfn, 0);
|
||||||
@@ -24,7 +24,7 @@ describe("DelayedFunctionScheduler", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#tick defaults to 0", function() {
|
it("#tick defaults to 0", function() {
|
||||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
fn = jasmine.createSpy('fn');
|
fn = jasmine.createSpy('fn');
|
||||||
|
|
||||||
scheduler.scheduleFunction(fn, 0);
|
scheduler.scheduleFunction(fn, 0);
|
||||||
@@ -37,7 +37,7 @@ describe("DelayedFunctionScheduler", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("defaults delay to 0", function() {
|
it("defaults delay to 0", function() {
|
||||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
fn = jasmine.createSpy('fn');
|
fn = jasmine.createSpy('fn');
|
||||||
|
|
||||||
scheduler.scheduleFunction(fn);
|
scheduler.scheduleFunction(fn);
|
||||||
@@ -50,7 +50,7 @@ describe("DelayedFunctionScheduler", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("optionally passes params to scheduled functions", function() {
|
it("optionally passes params to scheduled functions", function() {
|
||||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
fn = jasmine.createSpy('fn');
|
fn = jasmine.createSpy('fn');
|
||||||
|
|
||||||
scheduler.scheduleFunction(fn, 0, ['foo', 'bar']);
|
scheduler.scheduleFunction(fn, 0, ['foo', 'bar']);
|
||||||
@@ -63,7 +63,7 @@ describe("DelayedFunctionScheduler", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("scheduled fns can optionally reoccur", function() {
|
it("scheduled fns can optionally reoccur", function() {
|
||||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
fn = jasmine.createSpy('fn');
|
fn = jasmine.createSpy('fn');
|
||||||
|
|
||||||
scheduler.scheduleFunction(fn, 20, [], true);
|
scheduler.scheduleFunction(fn, 20, [], true);
|
||||||
@@ -85,7 +85,7 @@ describe("DelayedFunctionScheduler", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("increments scheduled fns ids unless one is passed", function() {
|
it("increments scheduled fns ids unless one is passed", function() {
|
||||||
var scheduler = new j$.DelayedFunctionScheduler();
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler();
|
||||||
|
|
||||||
expect(scheduler.scheduleFunction(function() {
|
expect(scheduler.scheduleFunction(function() {
|
||||||
}, 0)).toBe(1);
|
}, 0)).toBe(1);
|
||||||
@@ -98,7 +98,7 @@ describe("DelayedFunctionScheduler", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#removeFunctionWithId removes a previously scheduled function with a given id", function() {
|
it("#removeFunctionWithId removes a previously scheduled function with a given id", function() {
|
||||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
fn = jasmine.createSpy('fn'),
|
fn = jasmine.createSpy('fn'),
|
||||||
timeoutKey;
|
timeoutKey;
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ describe("DelayedFunctionScheduler", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("executes recurring functions interleaved with regular functions in the correct order", function() {
|
it("executes recurring functions interleaved with regular functions in the correct order", function() {
|
||||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
fn = jasmine.createSpy('fn'),
|
fn = jasmine.createSpy('fn'),
|
||||||
recurringCallCount = 0,
|
recurringCallCount = 0,
|
||||||
recurring = jasmine.createSpy('recurring').and.callFake(function() {
|
recurring = jasmine.createSpy('recurring').and.callFake(function() {
|
||||||
@@ -135,7 +135,7 @@ describe("DelayedFunctionScheduler", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("schedules a function for later execution during a tick", function () {
|
it("schedules a function for later execution during a tick", function () {
|
||||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
fn = jasmine.createSpy('fn'),
|
fn = jasmine.createSpy('fn'),
|
||||||
fnDelay = 10;
|
fnDelay = 10;
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ describe("DelayedFunctionScheduler", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#removeFunctionWithId removes a previously scheduled function with a given id during a tick", function () {
|
it("#removeFunctionWithId removes a previously scheduled function with a given id during a tick", function () {
|
||||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
fn = jasmine.createSpy('fn'),
|
fn = jasmine.createSpy('fn'),
|
||||||
fnDelay = 10,
|
fnDelay = 10,
|
||||||
timeoutKey;
|
timeoutKey;
|
||||||
@@ -169,7 +169,7 @@ describe("DelayedFunctionScheduler", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("executes recurring functions interleaved with regular functions and functions scheduled during a tick in the correct order", function () {
|
it("executes recurring functions interleaved with regular functions and functions scheduled during a tick in the correct order", function () {
|
||||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
fn = jasmine.createSpy('fn'),
|
fn = jasmine.createSpy('fn'),
|
||||||
recurringCallCount = 0,
|
recurringCallCount = 0,
|
||||||
recurring = jasmine.createSpy('recurring').and.callFake(function() {
|
recurring = jasmine.createSpy('recurring').and.callFake(function() {
|
||||||
@@ -202,7 +202,7 @@ describe("DelayedFunctionScheduler", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("executes recurring functions after rescheduling them", function () {
|
it("executes recurring functions after rescheduling them", function () {
|
||||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
recurring = function() {
|
recurring = function() {
|
||||||
expect(scheduler.scheduleFunction).toHaveBeenCalled();
|
expect(scheduler.scheduleFunction).toHaveBeenCalled();
|
||||||
};
|
};
|
||||||
@@ -215,7 +215,7 @@ describe("DelayedFunctionScheduler", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("removes functions during a tick that runs the function", function() {
|
it("removes functions during a tick that runs the function", function() {
|
||||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
fn = jasmine.createSpy('fn'),
|
fn = jasmine.createSpy('fn'),
|
||||||
fnDelay = 10,
|
fnDelay = 10,
|
||||||
timeoutKey;
|
timeoutKey;
|
||||||
@@ -234,7 +234,7 @@ describe("DelayedFunctionScheduler", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("removes functions during the first tick that runs the function", function() {
|
it("removes functions during the first tick that runs the function", function() {
|
||||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
fn = jasmine.createSpy('fn'),
|
fn = jasmine.createSpy('fn'),
|
||||||
fnDelay = 10,
|
fnDelay = 10,
|
||||||
timeoutKey;
|
timeoutKey;
|
||||||
@@ -251,5 +251,18 @@ describe("DelayedFunctionScheduler", function() {
|
|||||||
expect(fn).toHaveBeenCalled();
|
expect(fn).toHaveBeenCalled();
|
||||||
expect(fn.calls.count()).toBe(1);
|
expect(fn.calls.count()).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("updates the mockDate per scheduled time", function () {
|
||||||
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
|
tickDate = jasmine.createSpy('tickDate');
|
||||||
|
|
||||||
|
scheduler.scheduleFunction(function() {});
|
||||||
|
scheduler.scheduleFunction(function() {}, 1);
|
||||||
|
|
||||||
|
scheduler.tick(1, tickDate);
|
||||||
|
|
||||||
|
expect(tickDate).toHaveBeenCalledWith(0);
|
||||||
|
expect(tickDate).toHaveBeenCalledWith(1);
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2,20 +2,20 @@
|
|||||||
describe("Env", function() {
|
describe("Env", function() {
|
||||||
var env;
|
var env;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
env = new j$.Env();
|
env = new jasmineUnderTest.Env();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#pending", function() {
|
describe("#pending", function() {
|
||||||
it("throws the Pending Spec exception", function() {
|
it("throws the Pending Spec exception", function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
env.pending();
|
env.pending();
|
||||||
}).toThrow(j$.Spec.pendingSpecExceptionMessage);
|
}).toThrow(jasmineUnderTest.Spec.pendingSpecExceptionMessage);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("throws the Pending Spec exception with a custom message", function() {
|
it("throws the Pending Spec exception with a custom message", function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
env.pending('custom message');
|
env.pending('custom message');
|
||||||
}).toThrow(j$.Spec.pendingSpecExceptionMessage + 'custom message');
|
}).toThrow(jasmineUnderTest.Spec.pendingSpecExceptionMessage + 'custom message');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -26,12 +26,21 @@ describe("Env", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#describe', function () {
|
||||||
|
var spec = function(done){};
|
||||||
|
it("throws the error", function() {
|
||||||
|
expect(function() {
|
||||||
|
env.describe('done method', spec);
|
||||||
|
}).toThrow(new Error('describe does not expect any arguments'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('can configure specs to throw errors on expectation failures', function() {
|
it('can configure specs to throw errors on expectation failures', function() {
|
||||||
env.throwOnExpectationFailure(true);
|
env.throwOnExpectationFailure(true);
|
||||||
|
|
||||||
spyOn(j$, 'Spec');
|
spyOn(jasmineUnderTest, 'Spec');
|
||||||
env.it('foo', function() {});
|
env.it('foo', function() {});
|
||||||
expect(j$.Spec).toHaveBeenCalledWith(jasmine.objectContaining({
|
expect(jasmineUnderTest.Spec).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
throwOnExpectationFailure: true
|
throwOnExpectationFailure: true
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
@@ -39,10 +48,21 @@ describe("Env", function() {
|
|||||||
it('can configure suites to throw errors on expectation failures', function() {
|
it('can configure suites to throw errors on expectation failures', function() {
|
||||||
env.throwOnExpectationFailure(true);
|
env.throwOnExpectationFailure(true);
|
||||||
|
|
||||||
spyOn(j$, 'Suite');
|
spyOn(jasmineUnderTest, 'Suite');
|
||||||
env.describe('foo', function() {});
|
env.describe('foo', function() {});
|
||||||
expect(j$.Suite).toHaveBeenCalledWith(jasmine.objectContaining({
|
expect(jasmineUnderTest.Suite).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
throwOnExpectationFailure: true
|
throwOnExpectationFailure: true
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#xit', function() {
|
||||||
|
it('calls spec.pend with "Temporarily disabled with xit"', function() {
|
||||||
|
var pendSpy = jasmine.createSpy();
|
||||||
|
spyOn(env, 'it').and.returnValue({
|
||||||
|
pend: pendSpy
|
||||||
|
});
|
||||||
|
env.xit();
|
||||||
|
expect(pendSpy).toHaveBeenCalledWith('Temporarily disabled with xit');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ describe("ExceptionFormatter", function() {
|
|||||||
message: 'you got your foo in my bar',
|
message: 'you got your foo in my bar',
|
||||||
name: 'A Classic Mistake'
|
name: 'A Classic Mistake'
|
||||||
},
|
},
|
||||||
exceptionFormatter = new j$.ExceptionFormatter(),
|
exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
||||||
message = exceptionFormatter.message(sampleFirefoxException);
|
message = exceptionFormatter.message(sampleFirefoxException);
|
||||||
|
|
||||||
expect(message).toEqual('A Classic Mistake: you got your foo in my bar in foo.js (line 1978)');
|
expect(message).toEqual('A Classic Mistake: you got your foo in my bar in foo.js (line 1978)');
|
||||||
@@ -20,7 +20,7 @@ describe("ExceptionFormatter", function() {
|
|||||||
message: 'you got your foo in my bar',
|
message: 'you got your foo in my bar',
|
||||||
name: 'A Classic Mistake'
|
name: 'A Classic Mistake'
|
||||||
},
|
},
|
||||||
exceptionFormatter = new j$.ExceptionFormatter(),
|
exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
||||||
message = exceptionFormatter.message(sampleWebkitException);
|
message = exceptionFormatter.message(sampleWebkitException);
|
||||||
|
|
||||||
expect(message).toEqual('A Classic Mistake: you got your foo in my bar in foo.js (line 1978)');
|
expect(message).toEqual('A Classic Mistake: you got your foo in my bar in foo.js (line 1978)');
|
||||||
@@ -31,7 +31,7 @@ describe("ExceptionFormatter", function() {
|
|||||||
message: 'you got your foo in my bar',
|
message: 'you got your foo in my bar',
|
||||||
name: 'A Classic Mistake'
|
name: 'A Classic Mistake'
|
||||||
},
|
},
|
||||||
exceptionFormatter = new j$.ExceptionFormatter(),
|
exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
||||||
message = exceptionFormatter.message(sampleV8);
|
message = exceptionFormatter.message(sampleV8);
|
||||||
|
|
||||||
expect(message).toEqual('A Classic Mistake: you got your foo in my bar');
|
expect(message).toEqual('A Classic Mistake: you got your foo in my bar');
|
||||||
@@ -39,7 +39,7 @@ describe("ExceptionFormatter", function() {
|
|||||||
|
|
||||||
it("formats thrown exceptions that aren't errors", function() {
|
it("formats thrown exceptions that aren't errors", function() {
|
||||||
var thrown = "crazy error",
|
var thrown = "crazy error",
|
||||||
exceptionFormatter = new j$.ExceptionFormatter(),
|
exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
||||||
message = exceptionFormatter.message(thrown);
|
message = exceptionFormatter.message(thrown);
|
||||||
|
|
||||||
expect(message).toEqual("crazy error thrown");
|
expect(message).toEqual("crazy error thrown");
|
||||||
@@ -53,11 +53,11 @@ describe("ExceptionFormatter", function() {
|
|||||||
var error;
|
var error;
|
||||||
try { throw new Error("an error") } catch(e) { error = e; }
|
try { throw new Error("an error") } catch(e) { error = e; }
|
||||||
|
|
||||||
expect(new j$.ExceptionFormatter().stack(error)).toMatch(/ExceptionFormatterSpec\.js.*\d+/)
|
expect(new jasmineUnderTest.ExceptionFormatter().stack(error)).toMatch(/ExceptionFormatterSpec\.js.*\d+/)
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns null if no Error provided", function() {
|
it("returns null if no Error provided", function() {
|
||||||
expect(new j$.ExceptionFormatter().stack()).toBeNull();
|
expect(new jasmineUnderTest.ExceptionFormatter().stack()).toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ describe('Exceptions:', function() {
|
|||||||
var env;
|
var env;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
env = new j$.Env();
|
env = new jasmineUnderTest.Env();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('with break on exception', function() {
|
describe('with break on exception', function() {
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
describe("buildExpectationResult", function() {
|
describe("buildExpectationResult", function() {
|
||||||
it("defaults to passed", function() {
|
it("defaults to passed", function() {
|
||||||
var result = j$.buildExpectationResult({passed: 'some-value'});
|
var result = jasmineUnderTest.buildExpectationResult({passed: 'some-value'});
|
||||||
expect(result.passed).toBe('some-value');
|
expect(result.passed).toBe('some-value');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("message defaults to Passed for passing specs", function() {
|
it("message defaults to Passed for passing specs", function() {
|
||||||
var result = j$.buildExpectationResult({passed: true, message: 'some-value'});
|
var result = jasmineUnderTest.buildExpectationResult({passed: true, message: 'some-value'});
|
||||||
expect(result.message).toBe('Passed.');
|
expect(result.message).toBe('Passed.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("message returns the message for failing expectations", function() {
|
it("message returns the message for failing expectations", function() {
|
||||||
var result = j$.buildExpectationResult({passed: false, message: 'some-value'});
|
var result = jasmineUnderTest.buildExpectationResult({passed: false, message: 'some-value'});
|
||||||
expect(result.message).toBe('some-value');
|
expect(result.message).toBe('some-value');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ describe("buildExpectationResult", function() {
|
|||||||
var fakeError = {message: 'foo'},
|
var fakeError = {message: 'foo'},
|
||||||
messageFormatter = jasmine.createSpy("exception message formatter").and.returnValue(fakeError.message);
|
messageFormatter = jasmine.createSpy("exception message formatter").and.returnValue(fakeError.message);
|
||||||
|
|
||||||
var result = j$.buildExpectationResult(
|
var result = jasmineUnderTest.buildExpectationResult(
|
||||||
{
|
{
|
||||||
passed: false,
|
passed: false,
|
||||||
error: fakeError,
|
error: fakeError,
|
||||||
@@ -33,7 +33,7 @@ describe("buildExpectationResult", function() {
|
|||||||
var fakeError = {stack: 'foo'},
|
var fakeError = {stack: 'foo'},
|
||||||
stackFormatter = jasmine.createSpy("stack formatter").and.returnValue(fakeError.stack);
|
stackFormatter = jasmine.createSpy("stack formatter").and.returnValue(fakeError.stack);
|
||||||
|
|
||||||
var result = j$.buildExpectationResult(
|
var result = jasmineUnderTest.buildExpectationResult(
|
||||||
{
|
{
|
||||||
passed: false,
|
passed: false,
|
||||||
error: fakeError,
|
error: fakeError,
|
||||||
@@ -45,17 +45,17 @@ describe("buildExpectationResult", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("matcherName returns passed matcherName", function() {
|
it("matcherName returns passed matcherName", function() {
|
||||||
var result = j$.buildExpectationResult({matcherName: 'some-value'});
|
var result = jasmineUnderTest.buildExpectationResult({matcherName: 'some-value'});
|
||||||
expect(result.matcherName).toBe('some-value');
|
expect(result.matcherName).toBe('some-value');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("expected returns passed expected", function() {
|
it("expected returns passed expected", function() {
|
||||||
var result = j$.buildExpectationResult({expected: 'some-value'});
|
var result = jasmineUnderTest.buildExpectationResult({expected: 'some-value'});
|
||||||
expect(result.expected).toBe('some-value');
|
expect(result.expected).toBe('some-value');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("actual returns passed actual", function() {
|
it("actual returns passed actual", function() {
|
||||||
var result = j$.buildExpectationResult({actual: 'some-value'});
|
var result = jasmineUnderTest.buildExpectationResult({actual: 'some-value'});
|
||||||
expect(result.actual).toBe('some-value');
|
expect(result.actual).toBe('some-value');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ describe("Expectation", function() {
|
|||||||
},
|
},
|
||||||
expectation;
|
expectation;
|
||||||
|
|
||||||
expectation = new j$.Expectation({
|
expectation = new jasmineUnderTest.Expectation({
|
||||||
customMatchers: matchers
|
customMatchers: matchers
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -20,18 +20,18 @@ describe("Expectation", function() {
|
|||||||
},
|
},
|
||||||
expectation;
|
expectation;
|
||||||
|
|
||||||
j$.Expectation.addCoreMatchers(coreMatchers);
|
jasmineUnderTest.Expectation.addCoreMatchers(coreMatchers);
|
||||||
|
|
||||||
expectation = new j$.Expectation({});
|
expectation = new jasmineUnderTest.Expectation({});
|
||||||
|
|
||||||
expect(expectation.toQuux).toBeDefined();
|
expect(expectation.toQuux).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Factory builds an expectation/negative expectation", function() {
|
it("Factory builds an expectation/negative expectation", function() {
|
||||||
var builtExpectation = j$.Expectation.Factory();
|
var builtExpectation = jasmineUnderTest.Expectation.Factory();
|
||||||
|
|
||||||
expect(builtExpectation instanceof j$.Expectation).toBe(true);
|
expect(builtExpectation instanceof jasmineUnderTest.Expectation).toBe(true);
|
||||||
expect(builtExpectation.not instanceof j$.Expectation).toBe(true);
|
expect(builtExpectation.not instanceof jasmineUnderTest.Expectation).toBe(true);
|
||||||
expect(builtExpectation.not.isNot).toBe(true);
|
expect(builtExpectation.not.isNot).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ describe("Expectation", function() {
|
|||||||
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
||||||
expectation;
|
expectation;
|
||||||
|
|
||||||
expectation = new j$.Expectation({
|
expectation = new jasmineUnderTest.Expectation({
|
||||||
util: util,
|
util: util,
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
customEqualityTesters: customEqualityTesters,
|
customEqualityTesters: customEqualityTesters,
|
||||||
@@ -74,7 +74,7 @@ describe("Expectation", function() {
|
|||||||
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
||||||
expectation;
|
expectation;
|
||||||
|
|
||||||
expectation = new j$.Expectation({
|
expectation = new jasmineUnderTest.Expectation({
|
||||||
util: util,
|
util: util,
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
actual: "an actual",
|
actual: "an actual",
|
||||||
@@ -100,7 +100,7 @@ describe("Expectation", function() {
|
|||||||
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
||||||
expectation;
|
expectation;
|
||||||
|
|
||||||
expectation = new j$.Expectation({
|
expectation = new jasmineUnderTest.Expectation({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
util: util,
|
util: util,
|
||||||
actual: "an actual",
|
actual: "an actual",
|
||||||
@@ -132,7 +132,7 @@ describe("Expectation", function() {
|
|||||||
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
||||||
expectation;
|
expectation;
|
||||||
|
|
||||||
expectation = new j$.Expectation({
|
expectation = new jasmineUnderTest.Expectation({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
util: util,
|
util: util,
|
||||||
actual: "an actual",
|
actual: "an actual",
|
||||||
@@ -166,7 +166,7 @@ describe("Expectation", function() {
|
|||||||
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
||||||
expectation;
|
expectation;
|
||||||
|
|
||||||
expectation = new j$.Expectation({
|
expectation = new jasmineUnderTest.Expectation({
|
||||||
actual: "an actual",
|
actual: "an actual",
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
@@ -199,7 +199,7 @@ describe("Expectation", function() {
|
|||||||
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
||||||
expectation;
|
expectation;
|
||||||
|
|
||||||
expectation = new j$.Expectation({
|
expectation = new jasmineUnderTest.Expectation({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
actual: "an actual",
|
actual: "an actual",
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
@@ -231,7 +231,7 @@ describe("Expectation", function() {
|
|||||||
actual = "an actual",
|
actual = "an actual",
|
||||||
expectation;
|
expectation;
|
||||||
|
|
||||||
expectation = new j$.Expectation({
|
expectation = new jasmineUnderTest.Expectation({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
actual: "an actual",
|
actual: "an actual",
|
||||||
addExpectationResult: addExpectationResult,
|
addExpectationResult: addExpectationResult,
|
||||||
@@ -264,7 +264,7 @@ describe("Expectation", function() {
|
|||||||
actual = "an actual",
|
actual = "an actual",
|
||||||
expectation;
|
expectation;
|
||||||
|
|
||||||
expectation = new j$.Expectation({
|
expectation = new jasmineUnderTest.Expectation({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
actual: "an actual",
|
actual: "an actual",
|
||||||
util: util,
|
util: util,
|
||||||
@@ -300,7 +300,7 @@ describe("Expectation", function() {
|
|||||||
actual = "an actual",
|
actual = "an actual",
|
||||||
expectation;
|
expectation;
|
||||||
|
|
||||||
expectation = new j$.Expectation({
|
expectation = new jasmineUnderTest.Expectation({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
actual: "an actual",
|
actual: "an actual",
|
||||||
addExpectationResult: addExpectationResult,
|
addExpectationResult: addExpectationResult,
|
||||||
@@ -331,7 +331,7 @@ describe("Expectation", function() {
|
|||||||
actual = "an actual",
|
actual = "an actual",
|
||||||
expectation;
|
expectation;
|
||||||
|
|
||||||
expectation = new j$.Expectation({
|
expectation = new jasmineUnderTest.Expectation({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
actual: "an actual",
|
actual: "an actual",
|
||||||
addExpectationResult: addExpectationResult,
|
addExpectationResult: addExpectationResult,
|
||||||
@@ -367,7 +367,7 @@ describe("Expectation", function() {
|
|||||||
actual = "an actual",
|
actual = "an actual",
|
||||||
expectation;
|
expectation;
|
||||||
|
|
||||||
expectation = new j$.Expectation({
|
expectation = new jasmineUnderTest.Expectation({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
actual: "an actual",
|
actual: "an actual",
|
||||||
addExpectationResult: addExpectationResult,
|
addExpectationResult: addExpectationResult,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ xdescribe('JsApiReporter (integration specs)', function() {
|
|||||||
var suite, nestedSuite, nestedSpec;
|
var suite, nestedSuite, nestedSpec;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
env = new j$.Env();
|
env = new jasmineUnderTest.Env();
|
||||||
|
|
||||||
suite = env.describe("top-level suite", function() {
|
suite = env.describe("top-level suite", function() {
|
||||||
spec1 = env.it("spec 1", function() {
|
spec1 = env.it("spec 1", function() {
|
||||||
@@ -25,7 +25,7 @@ xdescribe('JsApiReporter (integration specs)', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter = new j$.JsApiReporter({});
|
reporter = new jasmineUnderTest.JsApiReporter({});
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
|
|
||||||
env.execute();
|
env.execute();
|
||||||
@@ -82,7 +82,7 @@ xdescribe('JsApiReporter (integration specs)', function() {
|
|||||||
describe("JsApiReporter", function() {
|
describe("JsApiReporter", function() {
|
||||||
|
|
||||||
it("knows when a full environment is started", function() {
|
it("knows when a full environment is started", function() {
|
||||||
var reporter = new j$.JsApiReporter({});
|
var reporter = new jasmineUnderTest.JsApiReporter({});
|
||||||
|
|
||||||
expect(reporter.started).toBe(false);
|
expect(reporter.started).toBe(false);
|
||||||
expect(reporter.finished).toBe(false);
|
expect(reporter.finished).toBe(false);
|
||||||
@@ -94,7 +94,7 @@ describe("JsApiReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("knows when a full environment is done", function() {
|
it("knows when a full environment is done", function() {
|
||||||
var reporter = new j$.JsApiReporter({});
|
var reporter = new jasmineUnderTest.JsApiReporter({});
|
||||||
|
|
||||||
expect(reporter.started).toBe(false);
|
expect(reporter.started).toBe(false);
|
||||||
expect(reporter.finished).toBe(false);
|
expect(reporter.finished).toBe(false);
|
||||||
@@ -106,13 +106,13 @@ describe("JsApiReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("defaults to 'loaded' status", function() {
|
it("defaults to 'loaded' status", function() {
|
||||||
var reporter = new j$.JsApiReporter({});
|
var reporter = new jasmineUnderTest.JsApiReporter({});
|
||||||
|
|
||||||
expect(reporter.status()).toEqual('loaded');
|
expect(reporter.status()).toEqual('loaded');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reports 'started' when Jasmine has started", function() {
|
it("reports 'started' when Jasmine has started", function() {
|
||||||
var reporter = new j$.JsApiReporter({});
|
var reporter = new jasmineUnderTest.JsApiReporter({});
|
||||||
|
|
||||||
reporter.jasmineStarted();
|
reporter.jasmineStarted();
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ describe("JsApiReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("reports 'done' when Jasmine is done", function() {
|
it("reports 'done' when Jasmine is done", function() {
|
||||||
var reporter = new j$.JsApiReporter({});
|
var reporter = new jasmineUnderTest.JsApiReporter({});
|
||||||
|
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ describe("JsApiReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("tracks a suite", function() {
|
it("tracks a suite", function() {
|
||||||
var reporter = new j$.JsApiReporter({});
|
var reporter = new jasmineUnderTest.JsApiReporter({});
|
||||||
|
|
||||||
reporter.suiteStarted({
|
reporter.suiteStarted({
|
||||||
id: 123,
|
id: 123,
|
||||||
@@ -151,7 +151,7 @@ describe("JsApiReporter", function() {
|
|||||||
describe("#specResults", function() {
|
describe("#specResults", function() {
|
||||||
var reporter, specResult1, specResult2;
|
var reporter, specResult1, specResult2;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
reporter = new j$.JsApiReporter({});
|
reporter = new jasmineUnderTest.JsApiReporter({});
|
||||||
specResult1 = {
|
specResult1 = {
|
||||||
id: 1,
|
id: 1,
|
||||||
description: "A spec"
|
description: "A spec"
|
||||||
@@ -181,7 +181,7 @@ describe("JsApiReporter", function() {
|
|||||||
describe("#suiteResults", function(){
|
describe("#suiteResults", function(){
|
||||||
var reporter, suiteResult1, suiteResult2;
|
var reporter, suiteResult1, suiteResult2;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
reporter = new j$.JsApiReporter({});
|
reporter = new jasmineUnderTest.JsApiReporter({});
|
||||||
suiteStarted1 = {
|
suiteStarted1 = {
|
||||||
id: 1
|
id: 1
|
||||||
};
|
};
|
||||||
@@ -218,7 +218,7 @@ describe("JsApiReporter", function() {
|
|||||||
describe("#executionTime", function() {
|
describe("#executionTime", function() {
|
||||||
it("should start the timer when jasmine starts", function() {
|
it("should start the timer when jasmine starts", function() {
|
||||||
var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
||||||
reporter = new j$.JsApiReporter({
|
reporter = new jasmineUnderTest.JsApiReporter({
|
||||||
timer: timerSpy
|
timer: timerSpy
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ describe("JsApiReporter", function() {
|
|||||||
|
|
||||||
it("should return the time it took the specs to run, in ms", function() {
|
it("should return the time it took the specs to run, in ms", function() {
|
||||||
var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
||||||
reporter = new j$.JsApiReporter({
|
reporter = new jasmineUnderTest.JsApiReporter({
|
||||||
timer: timerSpy
|
timer: timerSpy
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ describe("JsApiReporter", function() {
|
|||||||
describe("when the specs haven't finished being run", function() {
|
describe("when the specs haven't finished being run", function() {
|
||||||
it("should return undefined", function() {
|
it("should return undefined", function() {
|
||||||
var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
||||||
reporter = new j$.JsApiReporter({
|
reporter = new jasmineUnderTest.JsApiReporter({
|
||||||
timer: timerSpy
|
timer: timerSpy
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -248,4 +248,12 @@ describe("JsApiReporter", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#runDetails', function() {
|
||||||
|
it('should have details about the run', function() {
|
||||||
|
var reporter = new jasmineUnderTest.JsApiReporter({});
|
||||||
|
reporter.jasmineDone({some: {run: 'details'}});
|
||||||
|
expect(reporter.runDetails).toEqual({some: {run: 'details'}});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
describe("FakeDate", function() {
|
describe("FakeDate", function() {
|
||||||
it("does not fail if no global date is found", function() {
|
it("does not fail if no global date is found", function() {
|
||||||
var fakeGlobal = {},
|
var fakeGlobal = {},
|
||||||
mockDate = new j$.MockDate(fakeGlobal);
|
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
@@ -17,7 +17,7 @@ describe("FakeDate", function() {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
fakeGlobal = { Date: globalDate },
|
fakeGlobal = { Date: globalDate },
|
||||||
mockDate = new j$.MockDate(fakeGlobal);
|
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
expect(fakeGlobal.Date).toEqual(globalDate);
|
expect(fakeGlobal.Date).toEqual(globalDate);
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
@@ -32,7 +32,7 @@ describe("FakeDate", function() {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
fakeGlobal = { Date: globalDate },
|
fakeGlobal = { Date: globalDate },
|
||||||
mockDate = new j$.MockDate(fakeGlobal);
|
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
mockDate.uninstall();
|
mockDate.uninstall();
|
||||||
@@ -49,7 +49,7 @@ describe("FakeDate", function() {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
fakeGlobal = { Date: globalDate },
|
fakeGlobal = { Date: globalDate },
|
||||||
mockDate = new j$.MockDate(fakeGlobal);
|
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ describe("FakeDate", function() {
|
|||||||
|
|
||||||
it("can accept a date as time base when installing", function() {
|
it("can accept a date as time base when installing", function() {
|
||||||
var fakeGlobal = { Date: Date },
|
var fakeGlobal = { Date: Date },
|
||||||
mockDate = new j$.MockDate(fakeGlobal),
|
mockDate = new jasmineUnderTest.MockDate(fakeGlobal),
|
||||||
baseDate = new Date();
|
baseDate = new Date();
|
||||||
|
|
||||||
spyOn(baseDate, 'getTime').and.returnValue(123);
|
spyOn(baseDate, 'getTime').and.returnValue(123);
|
||||||
@@ -71,7 +71,7 @@ describe("FakeDate", function() {
|
|||||||
|
|
||||||
it("makes real dates", function() {
|
it("makes real dates", function() {
|
||||||
var fakeGlobal = { Date: Date },
|
var fakeGlobal = { Date: Date },
|
||||||
mockDate = new j$.MockDate(fakeGlobal);
|
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
expect(new fakeGlobal.Date()).toEqual(jasmine.any(Date));
|
expect(new fakeGlobal.Date()).toEqual(jasmine.any(Date));
|
||||||
@@ -89,7 +89,7 @@ describe("FakeDate", function() {
|
|||||||
fakeGlobal = { Date: globalDate };
|
fakeGlobal = { Date: globalDate };
|
||||||
|
|
||||||
globalDate.now = function() {};
|
globalDate.now = function() {};
|
||||||
var mockDate = new j$.MockDate(fakeGlobal);
|
var mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ describe("FakeDate", function() {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
fakeGlobal = { Date: globalDate },
|
fakeGlobal = { Date: globalDate },
|
||||||
mockDate = new j$.MockDate(fakeGlobal);
|
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ describe("FakeDate", function() {
|
|||||||
fakeGlobal = { Date: globalDate };
|
fakeGlobal = { Date: globalDate };
|
||||||
|
|
||||||
globalDate.now = function() {};
|
globalDate.now = function() {};
|
||||||
var mockDate = new j$.MockDate(fakeGlobal);
|
var mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ describe("FakeDate", function() {
|
|||||||
fakeGlobal = { Date: globalDate };
|
fakeGlobal = { Date: globalDate };
|
||||||
|
|
||||||
globalDate.now = function() {};
|
globalDate.now = function() {};
|
||||||
var mockDate = new j$.MockDate(fakeGlobal);
|
var mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ describe("FakeDate", function() {
|
|||||||
|
|
||||||
it("allows creation of a Date in a different time than the mocked time", function() {
|
it("allows creation of a Date in a different time than the mocked time", function() {
|
||||||
var fakeGlobal = { Date: Date },
|
var fakeGlobal = { Date: Date },
|
||||||
mockDate = new j$.MockDate(fakeGlobal);
|
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ describe("FakeDate", function() {
|
|||||||
|
|
||||||
it("allows creation of a Date that isn't fully specified", function() {
|
it("allows creation of a Date that isn't fully specified", function() {
|
||||||
var fakeGlobal = { Date: Date },
|
var fakeGlobal = { Date: Date },
|
||||||
mockDate = new j$.MockDate(fakeGlobal);
|
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ describe("FakeDate", function() {
|
|||||||
|
|
||||||
it('allows creation of a Date with millis', function() {
|
it('allows creation of a Date with millis', function() {
|
||||||
var fakeGlobal = { Date: Date },
|
var fakeGlobal = { Date: Date },
|
||||||
mockDate = new j$.MockDate(fakeGlobal),
|
mockDate = new jasmineUnderTest.MockDate(fakeGlobal),
|
||||||
now = new Date(2014, 3, 15).getTime();
|
now = new Date(2014, 3, 15).getTime();
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
@@ -191,7 +191,7 @@ describe("FakeDate", function() {
|
|||||||
|
|
||||||
it("copies all Date properties to the mocked date", function() {
|
it("copies all Date properties to the mocked date", function() {
|
||||||
var fakeGlobal = { Date: Date },
|
var fakeGlobal = { Date: Date },
|
||||||
mockDate = new j$.MockDate(fakeGlobal);
|
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +1,34 @@
|
|||||||
describe("j$.pp", function () {
|
describe("jasmineUnderTest.pp", function () {
|
||||||
it("should wrap strings in single quotes", function() {
|
it("should wrap strings in single quotes", function() {
|
||||||
expect(j$.pp("some string")).toEqual("'some string'");
|
expect(jasmineUnderTest.pp("some string")).toEqual("'some string'");
|
||||||
expect(j$.pp("som' string")).toEqual("'som' string'");
|
expect(jasmineUnderTest.pp("som' string")).toEqual("'som' string'");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should stringify primitives properly", function() {
|
it("should stringify primitives properly", function() {
|
||||||
expect(j$.pp(true)).toEqual("true");
|
expect(jasmineUnderTest.pp(true)).toEqual("true");
|
||||||
expect(j$.pp(false)).toEqual("false");
|
expect(jasmineUnderTest.pp(false)).toEqual("false");
|
||||||
expect(j$.pp(null)).toEqual("null");
|
expect(jasmineUnderTest.pp(null)).toEqual("null");
|
||||||
expect(j$.pp(jasmine.undefined)).toEqual("undefined");
|
expect(jasmineUnderTest.pp(jasmine.undefined)).toEqual("undefined");
|
||||||
expect(j$.pp(3)).toEqual("3");
|
expect(jasmineUnderTest.pp(3)).toEqual("3");
|
||||||
expect(j$.pp(-3.14)).toEqual("-3.14");
|
expect(jasmineUnderTest.pp(-3.14)).toEqual("-3.14");
|
||||||
expect(j$.pp(-0)).toEqual("-0");
|
expect(jasmineUnderTest.pp(-0)).toEqual("-0");
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('stringify arrays', function() {
|
describe('stringify arrays', function() {
|
||||||
it("should stringify arrays properly", function() {
|
it("should stringify arrays properly", function() {
|
||||||
expect(j$.pp([1, 2])).toEqual("[ 1, 2 ]");
|
expect(jasmineUnderTest.pp([1, 2])).toEqual("[ 1, 2 ]");
|
||||||
expect(j$.pp([1, 'foo', {}, jasmine.undefined, null])).toEqual("[ 1, 'foo', Object({ }), undefined, null ]");
|
expect(jasmineUnderTest.pp([1, 'foo', {}, jasmine.undefined, null])).toEqual("[ 1, 'foo', Object({ }), undefined, null ]");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should truncate arrays that are longer than j$.MAX_PRETTY_PRINT_ARRAY_LENGTH", function() {
|
it("should truncate arrays that are longer than jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH", function() {
|
||||||
var originalMaxLength = j$.MAX_PRETTY_PRINT_ARRAY_LENGTH;
|
var originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH;
|
||||||
var array = [1, 2, 3];
|
var array = [1, 2, 3];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
|
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
|
||||||
expect(j$.pp(array)).toEqual("[ 1, 2, ... ]");
|
expect(jasmineUnderTest.pp(array)).toEqual("[ 1, 2, ... ]");
|
||||||
} finally {
|
} finally {
|
||||||
j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxLength;
|
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxLength;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -36,27 +36,27 @@ describe("j$.pp", function () {
|
|||||||
var arr = [1, 2];
|
var arr = [1, 2];
|
||||||
arr.foo = 'bar';
|
arr.foo = 'bar';
|
||||||
arr.baz = {};
|
arr.baz = {};
|
||||||
expect(j$.pp(arr)).toEqual("[ 1, 2, foo: 'bar', baz: Object({ }) ]");
|
expect(jasmineUnderTest.pp(arr)).toEqual("[ 1, 2, foo: 'bar', baz: Object({ }) ]");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should stringify empty arrays with properties properly", function() {
|
it("should stringify empty arrays with properties properly", function() {
|
||||||
var empty = [];
|
var empty = [];
|
||||||
empty.foo = 'bar';
|
empty.foo = 'bar';
|
||||||
empty.baz = {};
|
empty.baz = {};
|
||||||
expect(j$.pp(empty)).toEqual("[ foo: 'bar', baz: Object({ }) ]");
|
expect(jasmineUnderTest.pp(empty)).toEqual("[ foo: 'bar', baz: Object({ }) ]");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should stringify long arrays with properties properly", function() {
|
it("should stringify long arrays with properties properly", function() {
|
||||||
var originalMaxLength = j$.MAX_PRETTY_PRINT_ARRAY_LENGTH;
|
var originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH;
|
||||||
var long = [1,2,3];
|
var long = [1,2,3];
|
||||||
long.foo = 'bar';
|
long.foo = 'bar';
|
||||||
long.baz = {};
|
long.baz = {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
|
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
|
||||||
expect(j$.pp(long)).toEqual("[ 1, 2, ..., foo: 'bar', baz: Object({ }) ]");
|
expect(jasmineUnderTest.pp(long)).toEqual("[ 1, 2, ..., foo: 'bar', baz: Object({ }) ]");
|
||||||
} finally {
|
} finally {
|
||||||
j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxLength;
|
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxLength;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -64,19 +64,19 @@ describe("j$.pp", function () {
|
|||||||
var array1 = [1, 2];
|
var array1 = [1, 2];
|
||||||
var array2 = [array1];
|
var array2 = [array1];
|
||||||
array1.push(array2);
|
array1.push(array2);
|
||||||
expect(j$.pp(array1)).toEqual("[ 1, 2, [ <circular reference: Array> ] ]");
|
expect(jasmineUnderTest.pp(array1)).toEqual("[ 1, 2, [ <circular reference: Array> ] ]");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not indicate circular references incorrectly", function() {
|
it("should not indicate circular references incorrectly", function() {
|
||||||
var array = [ [1] ];
|
var array = [ [1] ];
|
||||||
expect(j$.pp(array)).toEqual("[ [ 1 ] ]");
|
expect(jasmineUnderTest.pp(array)).toEqual("[ [ 1 ] ]");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should stringify objects properly", function() {
|
it("should stringify objects properly", function() {
|
||||||
expect(j$.pp({foo: 'bar'})).toEqual("Object({ foo: 'bar' })");
|
expect(jasmineUnderTest.pp({foo: 'bar'})).toEqual("Object({ foo: 'bar' })");
|
||||||
expect(j$.pp({foo:'bar', baz:3, nullValue: null, undefinedValue: jasmine.undefined})).toEqual("Object({ foo: 'bar', baz: 3, nullValue: null, undefinedValue: undefined })");
|
expect(jasmineUnderTest.pp({foo:'bar', baz:3, nullValue: null, undefinedValue: jasmine.undefined})).toEqual("Object({ foo: 'bar', baz: 3, nullValue: null, undefinedValue: undefined })");
|
||||||
expect(j$.pp({foo: function () {
|
expect(jasmineUnderTest.pp({foo: function () {
|
||||||
}, bar: [1, 2, 3]})).toEqual("Object({ foo: Function, bar: [ 1, 2, 3 ] })");
|
}, bar: [1, 2, 3]})).toEqual("Object({ foo: Function, bar: [ 1, 2, 3 ] })");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -85,28 +85,28 @@ describe("j$.pp", function () {
|
|||||||
SomeClass.prototype.foo = "inherited foo";
|
SomeClass.prototype.foo = "inherited foo";
|
||||||
var instance = new SomeClass();
|
var instance = new SomeClass();
|
||||||
instance.bar = "my own bar";
|
instance.bar = "my own bar";
|
||||||
expect(j$.pp(instance)).toEqual("SomeClass({ bar: 'my own bar' })");
|
expect(jasmineUnderTest.pp(instance)).toEqual("SomeClass({ bar: 'my own bar' })");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not recurse objects and arrays more deeply than j$.MAX_PRETTY_PRINT_DEPTH", function() {
|
it("should not recurse objects and arrays more deeply than jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH", function() {
|
||||||
var originalMaxDepth = j$.MAX_PRETTY_PRINT_DEPTH;
|
var originalMaxDepth = jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH;
|
||||||
var nestedObject = { level1: { level2: { level3: { level4: "leaf" } } } };
|
var nestedObject = { level1: { level2: { level3: { level4: "leaf" } } } };
|
||||||
var nestedArray = [1, [2, [3, [4, "leaf"]]]];
|
var nestedArray = [1, [2, [3, [4, "leaf"]]]];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
j$.MAX_PRETTY_PRINT_DEPTH = 2;
|
jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH = 2;
|
||||||
expect(j$.pp(nestedObject)).toEqual("Object({ level1: Object({ level2: Object }) })");
|
expect(jasmineUnderTest.pp(nestedObject)).toEqual("Object({ level1: Object({ level2: Object }) })");
|
||||||
expect(j$.pp(nestedArray)).toEqual("[ 1, [ 2, Array ] ]");
|
expect(jasmineUnderTest.pp(nestedArray)).toEqual("[ 1, [ 2, Array ] ]");
|
||||||
|
|
||||||
j$.MAX_PRETTY_PRINT_DEPTH = 3;
|
jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH = 3;
|
||||||
expect(j$.pp(nestedObject)).toEqual("Object({ level1: Object({ level2: Object({ level3: Object }) }) })");
|
expect(jasmineUnderTest.pp(nestedObject)).toEqual("Object({ level1: Object({ level2: Object({ level3: Object }) }) })");
|
||||||
expect(j$.pp(nestedArray)).toEqual("[ 1, [ 2, [ 3, Array ] ] ]");
|
expect(jasmineUnderTest.pp(nestedArray)).toEqual("[ 1, [ 2, [ 3, Array ] ] ]");
|
||||||
|
|
||||||
j$.MAX_PRETTY_PRINT_DEPTH = 4;
|
jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH = 4;
|
||||||
expect(j$.pp(nestedObject)).toEqual("Object({ level1: Object({ level2: Object({ level3: Object({ level4: 'leaf' }) }) }) })");
|
expect(jasmineUnderTest.pp(nestedObject)).toEqual("Object({ level1: Object({ level2: Object({ level3: Object({ level4: 'leaf' }) }) }) })");
|
||||||
expect(j$.pp(nestedArray)).toEqual("[ 1, [ 2, [ 3, [ 4, 'leaf' ] ] ] ]");
|
expect(jasmineUnderTest.pp(nestedArray)).toEqual("[ 1, [ 2, [ 3, [ 4, 'leaf' ] ] ] ]");
|
||||||
} finally {
|
} finally {
|
||||||
j$.MAX_PRETTY_PRINT_DEPTH = originalMaxDepth;
|
jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH = originalMaxDepth;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -115,18 +115,18 @@ describe("j$.pp", function () {
|
|||||||
var frozenObject = {foo: {bar: 'baz'}};
|
var frozenObject = {foo: {bar: 'baz'}};
|
||||||
frozenObject.circular = frozenObject;
|
frozenObject.circular = frozenObject;
|
||||||
frozenObject = Object.freeze(frozenObject);
|
frozenObject = Object.freeze(frozenObject);
|
||||||
expect(j$.pp(frozenObject)).toEqual("Object({ foo: Object({ bar: 'baz' }), circular: <circular reference: Object> })");
|
expect(jasmineUnderTest.pp(frozenObject)).toEqual("Object({ foo: Object({ bar: 'baz' }), circular: <circular reference: Object> })");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should stringify RegExp objects properly", function() {
|
it("should stringify RegExp objects properly", function() {
|
||||||
expect(j$.pp(/x|y|z/)).toEqual("/x|y|z/");
|
expect(jasmineUnderTest.pp(/x|y|z/)).toEqual("/x|y|z/");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should indicate circular object references", function() {
|
it("should indicate circular object references", function() {
|
||||||
var sampleValue = {foo: 'hello'};
|
var sampleValue = {foo: 'hello'};
|
||||||
sampleValue.nested = sampleValue;
|
sampleValue.nested = sampleValue;
|
||||||
expect(j$.pp(sampleValue)).toEqual("Object({ foo: 'hello', nested: <circular reference: Object> })");
|
expect(jasmineUnderTest.pp(sampleValue)).toEqual("Object({ foo: 'hello', nested: <circular reference: Object> })");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should indicate getters on objects as such", function() {
|
it("should indicate getters on objects as such", function() {
|
||||||
@@ -138,39 +138,39 @@ describe("j$.pp", function () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (sampleValue.__defineGetter__) {
|
if (sampleValue.__defineGetter__) {
|
||||||
expect(j$.pp(sampleValue)).toEqual("Object({ id: 1, calculatedValue: <getter> })");
|
expect(jasmineUnderTest.pp(sampleValue)).toEqual("Object({ id: 1, calculatedValue: <getter> })");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
expect(j$.pp(sampleValue)).toEqual("Object({ id: 1 })");
|
expect(jasmineUnderTest.pp(sampleValue)).toEqual("Object({ id: 1 })");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should not do HTML escaping of strings', function() {
|
it('should not do HTML escaping of strings', function() {
|
||||||
expect(j$.pp('some <b>html string</b> &', false)).toEqual('\'some <b>html string</b> &\'');
|
expect(jasmineUnderTest.pp('some <b>html string</b> &', false)).toEqual('\'some <b>html string</b> &\'');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should abbreviate the global (usually window) object", function() {
|
it("should abbreviate the global (usually window) object", function() {
|
||||||
expect(j$.pp(jasmine.getGlobal())).toEqual("<global>");
|
expect(jasmineUnderTest.pp(jasmine.getGlobal())).toEqual("<global>");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should stringify Date objects properly", function() {
|
it("should stringify Date objects properly", function() {
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
expect(j$.pp(now)).toEqual("Date(" + now.toString() + ")");
|
expect(jasmineUnderTest.pp(now)).toEqual("Date(" + now.toString() + ")");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should stringify spy objects properly", function() {
|
it("should stringify spy objects properly", function() {
|
||||||
var TestObject = {
|
var TestObject = {
|
||||||
someFunction: function() {}
|
someFunction: function() {}
|
||||||
},
|
},
|
||||||
env = new j$.Env();
|
env = new jasmineUnderTest.Env();
|
||||||
|
|
||||||
var spyRegistry = new j$.SpyRegistry({currentSpies: function() {return [];}});
|
var spyRegistry = new jasmineUnderTest.SpyRegistry({currentSpies: function() {return [];}});
|
||||||
|
|
||||||
spyRegistry.spyOn(TestObject, 'someFunction');
|
spyRegistry.spyOn(TestObject, 'someFunction');
|
||||||
expect(j$.pp(TestObject.someFunction)).toEqual("spy on someFunction");
|
expect(jasmineUnderTest.pp(TestObject.someFunction)).toEqual("spy on someFunction");
|
||||||
|
|
||||||
expect(j$.pp(j$.createSpy("something"))).toEqual("spy on something");
|
expect(jasmineUnderTest.pp(jasmineUnderTest.createSpy("something"))).toEqual("spy on something");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should stringify objects that implement jasmineToString", function () {
|
it("should stringify objects that implement jasmineToString", function () {
|
||||||
@@ -178,7 +178,24 @@ describe("j$.pp", function () {
|
|||||||
jasmineToString: function () { return "strung"; }
|
jasmineToString: function () { return "strung"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(j$.pp(obj)).toEqual("strung");
|
expect(jasmineUnderTest.pp(obj)).toEqual("strung");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should stringify objects that implement custom toString", function () {
|
||||||
|
var obj = {
|
||||||
|
toString: function () { return "my toString"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(jasmineUnderTest.pp(obj)).toEqual("my toString");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should stringify objects from anonymous constructors with custom toString", function () {
|
||||||
|
var MyAnonymousConstructor = (function() { return function () {}; })();
|
||||||
|
MyAnonymousConstructor.toString = function () { return ''; };
|
||||||
|
|
||||||
|
var a = new MyAnonymousConstructor();
|
||||||
|
|
||||||
|
expect(jasmineUnderTest.pp(a)).toEqual("<anonymous>({ })");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle objects with null prototype", function() {
|
it("should handle objects with null prototype", function() {
|
||||||
@@ -187,6 +204,6 @@ describe("j$.pp", function () {
|
|||||||
var obj = Object.create(null);
|
var obj = Object.create(null);
|
||||||
obj.foo = 'bar';
|
obj.foo = 'bar';
|
||||||
|
|
||||||
expect(j$.pp(obj)).toEqual("null({ foo: 'bar' })");
|
expect(jasmineUnderTest.pp(obj)).toEqual("null({ foo: 'bar' })");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ describe("QueueRunner", function() {
|
|||||||
var calls = [],
|
var calls = [],
|
||||||
queueableFn1 = { fn: jasmine.createSpy('fn1') },
|
queueableFn1 = { fn: jasmine.createSpy('fn1') },
|
||||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn1, queueableFn2]
|
queueableFns: [queueableFn1, queueableFn2]
|
||||||
});
|
});
|
||||||
queueableFn1.fn.and.callFake(function() {
|
queueableFn1.fn.and.callFake(function() {
|
||||||
@@ -23,7 +23,7 @@ describe("QueueRunner", function() {
|
|||||||
var queueableFn1 = { fn: jasmine.createSpy('fn1') },
|
var queueableFn1 = { fn: jasmine.createSpy('fn1') },
|
||||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
||||||
queueableFn3 = { fn: function(done) { asyncContext = this; done(); } },
|
queueableFn3 = { fn: function(done) { asyncContext = this; done(); } },
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn1, queueableFn2, queueableFn3]
|
queueableFns: [queueableFn1, queueableFn2, queueableFn3]
|
||||||
}),
|
}),
|
||||||
asyncContext;
|
asyncContext;
|
||||||
@@ -65,7 +65,7 @@ describe("QueueRunner", function() {
|
|||||||
afterCallback();
|
afterCallback();
|
||||||
setTimeout(done, 100);
|
setTimeout(done, 100);
|
||||||
} },
|
} },
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn1, queueableFn2, queueableFn3],
|
queueableFns: [queueableFn1, queueableFn2, queueableFn3],
|
||||||
onComplete: onComplete
|
onComplete: onComplete
|
||||||
});
|
});
|
||||||
@@ -99,7 +99,7 @@ describe("QueueRunner", function() {
|
|||||||
} },
|
} },
|
||||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
||||||
failFn = jasmine.createSpy('fail'),
|
failFn = jasmine.createSpy('fail'),
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn1, queueableFn2],
|
queueableFns: [queueableFn1, queueableFn2],
|
||||||
fail: failFn
|
fail: failFn
|
||||||
});
|
});
|
||||||
@@ -121,7 +121,7 @@ describe("QueueRunner", function() {
|
|||||||
queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' },
|
queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' },
|
||||||
onComplete = jasmine.createSpy('onComplete'),
|
onComplete = jasmine.createSpy('onComplete'),
|
||||||
onException = jasmine.createSpy('onException'),
|
onException = jasmine.createSpy('onException'),
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
queueableFns: [beforeFn, queueableFn],
|
queueableFns: [beforeFn, queueableFn],
|
||||||
onComplete: onComplete,
|
onComplete: onComplete,
|
||||||
onException: onException
|
onException: onException
|
||||||
@@ -142,7 +142,7 @@ describe("QueueRunner", function() {
|
|||||||
queueableFn = { fn: jasmine.createSpy('fn') },
|
queueableFn = { fn: jasmine.createSpy('fn') },
|
||||||
onComplete = jasmine.createSpy('onComplete'),
|
onComplete = jasmine.createSpy('onComplete'),
|
||||||
onException = jasmine.createSpy('onException'),
|
onException = jasmine.createSpy('onException'),
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
queueableFns: [beforeFn, queueableFn],
|
queueableFns: [beforeFn, queueableFn],
|
||||||
onComplete: onComplete,
|
onComplete: onComplete,
|
||||||
onException: onException,
|
onException: onException,
|
||||||
@@ -151,7 +151,7 @@ describe("QueueRunner", function() {
|
|||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
expect(queueableFn.fn).not.toHaveBeenCalled();
|
expect(queueableFn.fn).not.toHaveBeenCalled();
|
||||||
|
|
||||||
jasmine.clock().tick(j$.DEFAULT_TIMEOUT_INTERVAL);
|
jasmine.clock().tick(jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL);
|
||||||
|
|
||||||
expect(onException).not.toHaveBeenCalled();
|
expect(onException).not.toHaveBeenCalled();
|
||||||
expect(queueableFn.fn).not.toHaveBeenCalled();
|
expect(queueableFn.fn).not.toHaveBeenCalled();
|
||||||
@@ -162,7 +162,7 @@ describe("QueueRunner", function() {
|
|||||||
var queueableFn = { fn: function(done) { throw new Error("error!"); } },
|
var queueableFn = { fn: function(done) { throw new Error("error!"); } },
|
||||||
onComplete = jasmine.createSpy('onComplete'),
|
onComplete = jasmine.createSpy('onComplete'),
|
||||||
onException = jasmine.createSpy('onException'),
|
onException = jasmine.createSpy('onException'),
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn],
|
queueableFns: [queueableFn],
|
||||||
onComplete: onComplete,
|
onComplete: onComplete,
|
||||||
onException: onException
|
onException: onException
|
||||||
@@ -173,7 +173,7 @@ describe("QueueRunner", function() {
|
|||||||
expect(onComplete).toHaveBeenCalled();
|
expect(onComplete).toHaveBeenCalled();
|
||||||
expect(onException).toHaveBeenCalled();
|
expect(onException).toHaveBeenCalled();
|
||||||
|
|
||||||
jasmine.clock().tick(j$.DEFAULT_TIMEOUT_INTERVAL);
|
jasmine.clock().tick(jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL);
|
||||||
expect(onException.calls.count()).toEqual(1);
|
expect(onException.calls.count()).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ describe("QueueRunner", function() {
|
|||||||
var queueableFn = { fn: function(done) { done(); } },
|
var queueableFn = { fn: function(done) { done(); } },
|
||||||
onComplete = jasmine.createSpy('onComplete'),
|
onComplete = jasmine.createSpy('onComplete'),
|
||||||
onException = jasmine.createSpy('onException'),
|
onException = jasmine.createSpy('onException'),
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn],
|
queueableFns: [queueableFn],
|
||||||
onComplete: onComplete,
|
onComplete: onComplete,
|
||||||
onException: onException
|
onException: onException
|
||||||
@@ -191,14 +191,14 @@ describe("QueueRunner", function() {
|
|||||||
|
|
||||||
expect(onComplete).toHaveBeenCalled();
|
expect(onComplete).toHaveBeenCalled();
|
||||||
|
|
||||||
jasmine.clock().tick(j$.DEFAULT_TIMEOUT_INTERVAL);
|
jasmine.clock().tick(jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL);
|
||||||
expect(onException).not.toHaveBeenCalled();
|
expect(onException).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("only moves to the next spec the first time you call done", function() {
|
it("only moves to the next spec the first time you call done", function() {
|
||||||
var queueableFn = { fn: function(done) {done(); done();} },
|
var queueableFn = { fn: function(done) {done(); done();} },
|
||||||
nextQueueableFn = { fn: jasmine.createSpy('nextFn') };
|
nextQueueableFn = { fn: jasmine.createSpy('nextFn') };
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn, nextQueueableFn]
|
queueableFns: [queueableFn, nextQueueableFn]
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -212,7 +212,7 @@ describe("QueueRunner", function() {
|
|||||||
throw new Error('error!');
|
throw new Error('error!');
|
||||||
} },
|
} },
|
||||||
nextQueueableFn = { fn: jasmine.createSpy('nextFn') };
|
nextQueueableFn = { fn: jasmine.createSpy('nextFn') };
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn, nextQueueableFn]
|
queueableFns: [queueableFn, nextQueueableFn]
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -220,6 +220,20 @@ describe("QueueRunner", function() {
|
|||||||
jasmine.clock().tick(1);
|
jasmine.clock().tick(1);
|
||||||
expect(nextQueueableFn.fn.calls.count()).toEqual(1);
|
expect(nextQueueableFn.fn.calls.count()).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should return a null when you call done", function () {
|
||||||
|
// Some promises want handlers to return anything but undefined to help catch "forgotten returns".
|
||||||
|
var doneReturn,
|
||||||
|
queueableFn = { fn: function(done) {
|
||||||
|
doneReturn = done();
|
||||||
|
} },
|
||||||
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
|
queueableFns: [queueableFn]
|
||||||
|
});
|
||||||
|
|
||||||
|
queueRunner.execute();
|
||||||
|
expect(doneReturn).toBe(null);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("calls exception handlers when an exception is thrown in a fn", function() {
|
it("calls exception handlers when an exception is thrown in a fn", function() {
|
||||||
@@ -228,7 +242,7 @@ describe("QueueRunner", function() {
|
|||||||
throw new Error('fake error');
|
throw new Error('fake error');
|
||||||
} },
|
} },
|
||||||
onExceptionCallback = jasmine.createSpy('on exception callback'),
|
onExceptionCallback = jasmine.createSpy('on exception callback'),
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn],
|
queueableFns: [queueableFn],
|
||||||
onException: onExceptionCallback
|
onException: onExceptionCallback
|
||||||
});
|
});
|
||||||
@@ -242,7 +256,7 @@ describe("QueueRunner", function() {
|
|||||||
var queueableFn = { fn: function() {
|
var queueableFn = { fn: function() {
|
||||||
throw new Error('fake error');
|
throw new Error('fake error');
|
||||||
} },
|
} },
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn],
|
queueableFns: [queueableFn],
|
||||||
catchException: function(e) { return false; }
|
catchException: function(e) { return false; }
|
||||||
});
|
});
|
||||||
@@ -255,7 +269,7 @@ describe("QueueRunner", function() {
|
|||||||
it("continues running the functions even after an exception is thrown in an async spec", function() {
|
it("continues running the functions even after an exception is thrown in an async spec", function() {
|
||||||
var queueableFn = { fn: function(done) { throw new Error("error"); } },
|
var queueableFn = { fn: function(done) { throw new Error("error"); } },
|
||||||
nextQueueableFn = { fn: jasmine.createSpy("nextFunction") },
|
nextQueueableFn = { fn: jasmine.createSpy("nextFunction") },
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn, nextQueueableFn]
|
queueableFns: [queueableFn, nextQueueableFn]
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -266,7 +280,7 @@ describe("QueueRunner", function() {
|
|||||||
it("calls a provided complete callback when done", function() {
|
it("calls a provided complete callback when done", function() {
|
||||||
var queueableFn = { fn: jasmine.createSpy('fn') },
|
var queueableFn = { fn: jasmine.createSpy('fn') },
|
||||||
completeCallback = jasmine.createSpy('completeCallback'),
|
completeCallback = jasmine.createSpy('completeCallback'),
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn],
|
queueableFns: [queueableFn],
|
||||||
onComplete: completeCallback
|
onComplete: completeCallback
|
||||||
});
|
});
|
||||||
@@ -281,7 +295,7 @@ describe("QueueRunner", function() {
|
|||||||
afterFn = { fn: jasmine.createSpy('afterFn') },
|
afterFn = { fn: jasmine.createSpy('afterFn') },
|
||||||
completeCallback = jasmine.createSpy('completeCallback'),
|
completeCallback = jasmine.createSpy('completeCallback'),
|
||||||
clearStack = jasmine.createSpy('clearStack'),
|
clearStack = jasmine.createSpy('clearStack'),
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
queueableFns: [asyncFn, afterFn],
|
queueableFns: [asyncFn, afterFn],
|
||||||
clearStack: clearStack,
|
clearStack: clearStack,
|
||||||
onComplete: completeCallback
|
onComplete: completeCallback
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
describe("ReportDispatcher", function() {
|
describe("ReportDispatcher", function() {
|
||||||
|
|
||||||
it("builds an interface of requested methods", function() {
|
it("builds an interface of requested methods", function() {
|
||||||
var dispatcher = new j$.ReportDispatcher(['foo', 'bar', 'baz']);
|
var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar', 'baz']);
|
||||||
|
|
||||||
expect(dispatcher.foo).toBeDefined();
|
expect(dispatcher.foo).toBeDefined();
|
||||||
expect(dispatcher.bar).toBeDefined();
|
expect(dispatcher.bar).toBeDefined();
|
||||||
@@ -9,7 +9,7 @@ describe("ReportDispatcher", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("dispatches requested methods to added reporters", function() {
|
it("dispatches requested methods to added reporters", function() {
|
||||||
var dispatcher = new j$.ReportDispatcher(['foo', 'bar']),
|
var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar']),
|
||||||
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']),
|
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']),
|
||||||
anotherReporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
anotherReporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ describe("ReportDispatcher", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does not dispatch to a reporter if the reporter doesn't accept the method", function() {
|
it("does not dispatch to a reporter if the reporter doesn't accept the method", function() {
|
||||||
var dispatcher = new j$.ReportDispatcher(['foo']),
|
var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo']),
|
||||||
reporter = jasmine.createSpyObj('reporter', ['baz']);
|
reporter = jasmine.createSpyObj('reporter', ['baz']);
|
||||||
|
|
||||||
dispatcher.addReporter(reporter);
|
dispatcher.addReporter(reporter);
|
||||||
@@ -37,4 +37,43 @@ describe("ReportDispatcher", function() {
|
|||||||
dispatcher.foo(123, 456);
|
dispatcher.foo(123, 456);
|
||||||
}).not.toThrow();
|
}).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("allows providing a fallback reporter in case there's no other report", function() {
|
||||||
|
var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar']),
|
||||||
|
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
||||||
|
|
||||||
|
dispatcher.provideFallbackReporter(reporter);
|
||||||
|
dispatcher.foo(123, 456);
|
||||||
|
expect(reporter.foo).toHaveBeenCalledWith(123, 456);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not call fallback reporting methods when another report is provided", function() {
|
||||||
|
var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar']),
|
||||||
|
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']),
|
||||||
|
fallbackReporter = jasmine.createSpyObj('otherReporter', ['foo', 'bar']);
|
||||||
|
|
||||||
|
dispatcher.provideFallbackReporter(fallbackReporter);
|
||||||
|
dispatcher.addReporter(reporter);
|
||||||
|
dispatcher.foo(123, 456);
|
||||||
|
|
||||||
|
expect(reporter.foo).toHaveBeenCalledWith(123, 456);
|
||||||
|
expect(fallbackReporter.foo).not.toHaveBeenCalledWith(123, 456);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("allows registered reporters to be cleared", function() {
|
||||||
|
var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar']),
|
||||||
|
reporter1 = jasmine.createSpyObj('reporter1', ['foo', 'bar']),
|
||||||
|
reporter2 = jasmine.createSpyObj('reporter2', ['foo', 'bar']);
|
||||||
|
|
||||||
|
dispatcher.addReporter(reporter1);
|
||||||
|
dispatcher.foo(123);
|
||||||
|
expect(reporter1.foo).toHaveBeenCalledWith(123);
|
||||||
|
|
||||||
|
dispatcher.clearReporters();
|
||||||
|
dispatcher.addReporter(reporter2);
|
||||||
|
dispatcher.bar(456);
|
||||||
|
|
||||||
|
expect(reporter1.bar).not.toHaveBeenCalled();
|
||||||
|
expect(reporter2.bar).toHaveBeenCalledWith(456);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,36 +1,36 @@
|
|||||||
describe("Spec", function() {
|
describe("Spec", function() {
|
||||||
|
|
||||||
it("#isPendingSpecException returns true for a pending spec exception", function() {
|
it("#isPendingSpecException returns true for a pending spec exception", function() {
|
||||||
var e = new Error(j$.Spec.pendingSpecExceptionMessage);
|
var e = new Error(jasmineUnderTest.Spec.pendingSpecExceptionMessage);
|
||||||
|
|
||||||
expect(j$.Spec.isPendingSpecException(e)).toBe(true);
|
expect(jasmineUnderTest.Spec.isPendingSpecException(e)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#isPendingSpecException returns true for a pending spec exception (even when FF bug is present)", function() {
|
it("#isPendingSpecException returns true for a pending spec exception (even when FF bug is present)", function() {
|
||||||
var fakeError = {
|
var fakeError = {
|
||||||
toString: function() { return "Error: " + j$.Spec.pendingSpecExceptionMessage; }
|
toString: function() { return "Error: " + jasmineUnderTest.Spec.pendingSpecExceptionMessage; }
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(j$.Spec.isPendingSpecException(fakeError)).toBe(true);
|
expect(jasmineUnderTest.Spec.isPendingSpecException(fakeError)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#isPendingSpecException returns true for a pending spec exception with a custom message", function() {
|
it("#isPendingSpecException returns true for a pending spec exception with a custom message", function() {
|
||||||
expect(j$.Spec.isPendingSpecException(j$.Spec.pendingSpecExceptionMessage + 'foo')).toBe(true);
|
expect(jasmineUnderTest.Spec.isPendingSpecException(jasmineUnderTest.Spec.pendingSpecExceptionMessage + 'foo')).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#isPendingSpecException returns false for not a pending spec exception", function() {
|
it("#isPendingSpecException returns false for not a pending spec exception", function() {
|
||||||
var e = new Error("foo");
|
var e = new Error("foo");
|
||||||
|
|
||||||
expect(j$.Spec.isPendingSpecException(e)).toBe(false);
|
expect(jasmineUnderTest.Spec.isPendingSpecException(e)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#isPendingSpecException returns false for thrown values that don't have toString", function() {
|
it("#isPendingSpecException returns false for thrown values that don't have toString", function() {
|
||||||
expect(j$.Spec.isPendingSpecException(void 0)).toBe(false);
|
expect(jasmineUnderTest.Spec.isPendingSpecException(void 0)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("delegates execution to a QueueRunner", function() {
|
it("delegates execution to a QueueRunner", function() {
|
||||||
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
||||||
spec = new j$.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
description: 'my test',
|
description: 'my test',
|
||||||
id: 'some-id',
|
id: 'some-id',
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} },
|
||||||
@@ -45,7 +45,7 @@ describe("Spec", function() {
|
|||||||
it("should call the start callback on execution", function() {
|
it("should call the start callback on execution", function() {
|
||||||
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
||||||
startCallback = jasmine.createSpy('startCallback'),
|
startCallback = jasmine.createSpy('startCallback'),
|
||||||
spec = new j$.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
id: 123,
|
id: 123,
|
||||||
description: 'foo bar',
|
description: 'foo bar',
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} },
|
||||||
@@ -69,7 +69,7 @@ describe("Spec", function() {
|
|||||||
startCallback = jasmine.createSpy('start-callback').and.callFake(function() {
|
startCallback = jasmine.createSpy('start-callback').and.callFake(function() {
|
||||||
expect(beforesWereCalled).toBe(false);
|
expect(beforesWereCalled).toBe(false);
|
||||||
}),
|
}),
|
||||||
spec = new j$.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} },
|
||||||
beforeFns: function() {
|
beforeFns: function() {
|
||||||
return [function() {
|
return [function() {
|
||||||
@@ -93,7 +93,7 @@ describe("Spec", function() {
|
|||||||
expect(before).toHaveBeenCalled();
|
expect(before).toHaveBeenCalled();
|
||||||
expect(after).not.toHaveBeenCalled();
|
expect(after).not.toHaveBeenCalled();
|
||||||
}) },
|
}) },
|
||||||
spec = new j$.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
queueableFn: queueableFn,
|
queueableFn: queueableFn,
|
||||||
beforeAndAfterFns: function() {
|
beforeAndAfterFns: function() {
|
||||||
return {befores: [before], afters: [after]}
|
return {befores: [before], afters: [after]}
|
||||||
@@ -112,7 +112,7 @@ describe("Spec", function() {
|
|||||||
|
|
||||||
startCallback = jasmine.createSpy('startCallback'),
|
startCallback = jasmine.createSpy('startCallback'),
|
||||||
resultCallback = jasmine.createSpy('resultCallback'),
|
resultCallback = jasmine.createSpy('resultCallback'),
|
||||||
spec = new j$.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
onStart: startCallback,
|
onStart: startCallback,
|
||||||
queueableFn: { fn: null },
|
queueableFn: { fn: null },
|
||||||
resultCallback: resultCallback,
|
resultCallback: resultCallback,
|
||||||
@@ -127,7 +127,7 @@ describe("Spec", function() {
|
|||||||
startCallback = jasmine.createSpy('startCallback'),
|
startCallback = jasmine.createSpy('startCallback'),
|
||||||
specBody = jasmine.createSpy('specBody'),
|
specBody = jasmine.createSpy('specBody'),
|
||||||
resultCallback = jasmine.createSpy('resultCallback'),
|
resultCallback = jasmine.createSpy('resultCallback'),
|
||||||
spec = new j$.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
onStart:startCallback,
|
onStart:startCallback,
|
||||||
queueableFn: { fn: specBody },
|
queueableFn: { fn: specBody },
|
||||||
resultCallback: resultCallback,
|
resultCallback: resultCallback,
|
||||||
@@ -152,7 +152,7 @@ describe("Spec", function() {
|
|||||||
startCallback = jasmine.createSpy('startCallback'),
|
startCallback = jasmine.createSpy('startCallback'),
|
||||||
specBody = jasmine.createSpy('specBody'),
|
specBody = jasmine.createSpy('specBody'),
|
||||||
resultCallback = jasmine.createSpy('resultCallback'),
|
resultCallback = jasmine.createSpy('resultCallback'),
|
||||||
spec = new j$.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
onStart:startCallback,
|
onStart:startCallback,
|
||||||
queueableFn: { fn: specBody },
|
queueableFn: { fn: specBody },
|
||||||
resultCallback: resultCallback,
|
resultCallback: resultCallback,
|
||||||
@@ -174,7 +174,7 @@ describe("Spec", function() {
|
|||||||
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
||||||
startCallback = jasmine.createSpy('startCallback'),
|
startCallback = jasmine.createSpy('startCallback'),
|
||||||
resultCallback = jasmine.createSpy('resultCallback'),
|
resultCallback = jasmine.createSpy('resultCallback'),
|
||||||
spec = new j$.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
onStart: startCallback,
|
onStart: startCallback,
|
||||||
resultCallback: resultCallback,
|
resultCallback: resultCallback,
|
||||||
description: "with a spec",
|
description: "with a spec",
|
||||||
@@ -207,7 +207,7 @@ describe("Spec", function() {
|
|||||||
|
|
||||||
it("should call the done callback on execution complete", function() {
|
it("should call the done callback on execution complete", function() {
|
||||||
var done = jasmine.createSpy('done callback'),
|
var done = jasmine.createSpy('done callback'),
|
||||||
spec = new j$.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} },
|
||||||
catchExceptions: function() { return false; },
|
catchExceptions: function() { return false; },
|
||||||
resultCallback: function() {},
|
resultCallback: function() {},
|
||||||
@@ -220,18 +220,18 @@ describe("Spec", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#status returns passing by default", function() {
|
it("#status returns passing by default", function() {
|
||||||
var spec = new j$.Spec({queueableFn: { fn: jasmine.createSpy("spec body")} });
|
var spec = new jasmineUnderTest.Spec({queueableFn: { fn: jasmine.createSpy("spec body")} });
|
||||||
expect(spec.status()).toBe('passed');
|
expect(spec.status()).toBe('passed');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#status returns passed if all expectations in the spec have passed", function() {
|
it("#status returns passed if all expectations in the spec have passed", function() {
|
||||||
var spec = new j$.Spec({queueableFn: { fn: jasmine.createSpy("spec body")} });
|
var spec = new jasmineUnderTest.Spec({queueableFn: { fn: jasmine.createSpy("spec body")} });
|
||||||
spec.addExpectationResult(true);
|
spec.addExpectationResult(true);
|
||||||
expect(spec.status()).toBe('passed');
|
expect(spec.status()).toBe('passed');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#status returns failed if any expectations in the spec have failed", function() {
|
it("#status returns failed if any expectations in the spec have failed", function() {
|
||||||
var spec = new j$.Spec({queueableFn: { fn: jasmine.createSpy("spec body") } });
|
var spec = new jasmineUnderTest.Spec({queueableFn: { fn: jasmine.createSpy("spec body") } });
|
||||||
spec.addExpectationResult(true);
|
spec.addExpectationResult(true);
|
||||||
spec.addExpectationResult(false);
|
spec.addExpectationResult(false);
|
||||||
expect(spec.status()).toBe('failed');
|
expect(spec.status()).toBe('failed');
|
||||||
@@ -239,7 +239,7 @@ describe("Spec", function() {
|
|||||||
|
|
||||||
it("keeps track of passed and failed expectations", function() {
|
it("keeps track of passed and failed expectations", function() {
|
||||||
var resultCallback = jasmine.createSpy('resultCallback'),
|
var resultCallback = jasmine.createSpy('resultCallback'),
|
||||||
spec = new j$.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
queueableFn: { fn: jasmine.createSpy("spec body") },
|
queueableFn: { fn: jasmine.createSpy("spec body") },
|
||||||
expectationResultFactory: function (data) { return data; },
|
expectationResultFactory: function (data) { return data; },
|
||||||
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
||||||
@@ -256,7 +256,7 @@ describe("Spec", function() {
|
|||||||
|
|
||||||
it("throws an ExpectationFailed error upon receiving a failed expectation when 'throwOnExpectationFailure' is set", function() {
|
it("throws an ExpectationFailed error upon receiving a failed expectation when 'throwOnExpectationFailure' is set", function() {
|
||||||
var resultCallback = jasmine.createSpy('resultCallback'),
|
var resultCallback = jasmine.createSpy('resultCallback'),
|
||||||
spec = new j$.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} },
|
||||||
expectationResultFactory: function(data) { return data; },
|
expectationResultFactory: function(data) { return data; },
|
||||||
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
||||||
@@ -267,7 +267,7 @@ describe("Spec", function() {
|
|||||||
spec.addExpectationResult(true, 'passed');
|
spec.addExpectationResult(true, 'passed');
|
||||||
expect(function() {
|
expect(function() {
|
||||||
spec.addExpectationResult(false, 'failed')
|
spec.addExpectationResult(false, 'failed')
|
||||||
}).toThrowError(j$.errors.ExpectationFailed);
|
}).toThrowError(jasmineUnderTest.errors.ExpectationFailed);
|
||||||
|
|
||||||
spec.execute();
|
spec.execute();
|
||||||
|
|
||||||
@@ -277,7 +277,7 @@ describe("Spec", function() {
|
|||||||
|
|
||||||
it("does not throw an ExpectationFailed error when handling an error", function() {
|
it("does not throw an ExpectationFailed error when handling an error", function() {
|
||||||
var resultCallback = jasmine.createSpy('resultCallback'),
|
var resultCallback = jasmine.createSpy('resultCallback'),
|
||||||
spec = new j$.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} },
|
||||||
expectationResultFactory: function(data) { return data; },
|
expectationResultFactory: function(data) { return data; },
|
||||||
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
||||||
@@ -291,7 +291,7 @@ describe("Spec", function() {
|
|||||||
it("can return its full name", function() {
|
it("can return its full name", function() {
|
||||||
var specNameSpy = jasmine.createSpy('specNameSpy').and.returnValue('expected val');
|
var specNameSpy = jasmine.createSpy('specNameSpy').and.returnValue('expected val');
|
||||||
|
|
||||||
var spec = new j$.Spec({
|
var spec = new jasmineUnderTest.Spec({
|
||||||
getSpecName: specNameSpy,
|
getSpecName: specNameSpy,
|
||||||
queueableFn: { fn: null }
|
queueableFn: { fn: null }
|
||||||
});
|
});
|
||||||
@@ -303,9 +303,9 @@ describe("Spec", function() {
|
|||||||
describe("when a spec is marked pending during execution", function() {
|
describe("when a spec is marked pending during execution", function() {
|
||||||
it("should mark the spec as pending", function() {
|
it("should mark the spec as pending", function() {
|
||||||
var fakeQueueRunner = function(opts) {
|
var fakeQueueRunner = function(opts) {
|
||||||
opts.onException(new Error(j$.Spec.pendingSpecExceptionMessage));
|
opts.onException(new Error(jasmineUnderTest.Spec.pendingSpecExceptionMessage));
|
||||||
},
|
},
|
||||||
spec = new j$.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
description: 'my test',
|
description: 'my test',
|
||||||
id: 'some-id',
|
id: 'some-id',
|
||||||
queueableFn: { fn: function() { } },
|
queueableFn: { fn: function() { } },
|
||||||
@@ -320,9 +320,9 @@ describe("Spec", function() {
|
|||||||
|
|
||||||
it("should set the pendingReason", function() {
|
it("should set the pendingReason", function() {
|
||||||
var fakeQueueRunner = function(opts) {
|
var fakeQueueRunner = function(opts) {
|
||||||
opts.onException(new Error(j$.Spec.pendingSpecExceptionMessage + 'custom message'));
|
opts.onException(new Error(jasmineUnderTest.Spec.pendingSpecExceptionMessage + 'custom message'));
|
||||||
},
|
},
|
||||||
spec = new j$.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
description: 'my test',
|
description: 'my test',
|
||||||
id: 'some-id',
|
id: 'some-id',
|
||||||
queueableFn: { fn: function() { } },
|
queueableFn: { fn: function() { } },
|
||||||
@@ -338,7 +338,7 @@ describe("Spec", function() {
|
|||||||
|
|
||||||
it("should log a failure when handling an exception", function() {
|
it("should log a failure when handling an exception", function() {
|
||||||
var resultCallback = jasmine.createSpy('resultCallback'),
|
var resultCallback = jasmine.createSpy('resultCallback'),
|
||||||
spec = new j$.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} },
|
||||||
expectationResultFactory: function(data) { return data; },
|
expectationResultFactory: function(data) { return data; },
|
||||||
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
||||||
@@ -359,41 +359,41 @@ describe("Spec", function() {
|
|||||||
|
|
||||||
it("should not log an additional failure when handling an ExpectationFailed error", function() {
|
it("should not log an additional failure when handling an ExpectationFailed error", function() {
|
||||||
var resultCallback = jasmine.createSpy('resultCallback'),
|
var resultCallback = jasmine.createSpy('resultCallback'),
|
||||||
spec = new j$.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} },
|
||||||
expectationResultFactory: function(data) { return data; },
|
expectationResultFactory: function(data) { return data; },
|
||||||
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
||||||
resultCallback: resultCallback
|
resultCallback: resultCallback
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.onException(new j$.errors.ExpectationFailed());
|
spec.onException(new jasmineUnderTest.errors.ExpectationFailed());
|
||||||
spec.execute();
|
spec.execute();
|
||||||
|
|
||||||
expect(resultCallback.calls.first().args[0].failedExpectations).toEqual([]);
|
expect(resultCallback.calls.first().args[0].failedExpectations).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("retrieves a result with updated status", function() {
|
it("retrieves a result with updated status", function() {
|
||||||
var spec = new j$.Spec({ queueableFn: { fn: function() {} } });
|
var spec = new jasmineUnderTest.Spec({ queueableFn: { fn: function() {} } });
|
||||||
|
|
||||||
expect(spec.getResult().status).toBe('passed');
|
expect(spec.getResult().status).toBe('passed');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("retrives a result with disabled status", function() {
|
it("retrives a result with disabled status", function() {
|
||||||
var spec = new j$.Spec({ queueableFn: { fn: function() {} } });
|
var spec = new jasmineUnderTest.Spec({ queueableFn: { fn: function() {} } });
|
||||||
spec.disable();
|
spec.disable();
|
||||||
|
|
||||||
expect(spec.getResult().status).toBe('disabled');
|
expect(spec.getResult().status).toBe('disabled');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("retrives a result with pending status", function() {
|
it("retrives a result with pending status", function() {
|
||||||
var spec = new j$.Spec({ queueableFn: { fn: function() {} } });
|
var spec = new jasmineUnderTest.Spec({ queueableFn: { fn: function() {} } });
|
||||||
spec.pend();
|
spec.pend();
|
||||||
|
|
||||||
expect(spec.getResult().status).toBe('pending');
|
expect(spec.getResult().status).toBe('pending');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not be executable when disabled", function() {
|
it("should not be executable when disabled", function() {
|
||||||
var spec = new j$.Spec({
|
var spec = new jasmineUnderTest.Spec({
|
||||||
queueableFn: { fn: function() {} }
|
queueableFn: { fn: function() {} }
|
||||||
});
|
});
|
||||||
spec.disable();
|
spec.disable();
|
||||||
@@ -402,7 +402,7 @@ describe("Spec", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should be executable when pending", function() {
|
it("should be executable when pending", function() {
|
||||||
var spec = new j$.Spec({
|
var spec = new jasmineUnderTest.Spec({
|
||||||
queueableFn: { fn: function() {} }
|
queueableFn: { fn: function() {} }
|
||||||
});
|
});
|
||||||
spec.pend();
|
spec.pend();
|
||||||
@@ -411,7 +411,7 @@ describe("Spec", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should be executable when not disabled or pending", function() {
|
it("should be executable when not disabled or pending", function() {
|
||||||
var spec = new j$.Spec({
|
var spec = new jasmineUnderTest.Spec({
|
||||||
queueableFn: { fn: function() {} }
|
queueableFn: { fn: function() {} }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
describe("SpyRegistry", function() {
|
describe("SpyRegistry", function() {
|
||||||
describe("#spyOn", function() {
|
describe("#spyOn", function() {
|
||||||
it("checks for the existence of the object", function() {
|
it("checks for the existence of the object", function() {
|
||||||
var spyRegistry = new j$.SpyRegistry();
|
var spyRegistry = new jasmineUnderTest.SpyRegistry();
|
||||||
expect(function() {
|
expect(function() {
|
||||||
spyRegistry.spyOn(void 0, 'pants');
|
spyRegistry.spyOn(void 0, 'pants');
|
||||||
}).toThrowError(/could not find an object/);
|
}).toThrowError(/could not find an object/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("checks that a method name was passed", function() {
|
it("checks that a method name was passed", function() {
|
||||||
var spyRegistry = new j$.SpyRegistry(),
|
var spyRegistry = new jasmineUnderTest.SpyRegistry(),
|
||||||
subject = {};
|
subject = {};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
@@ -17,7 +17,7 @@ describe("SpyRegistry", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("checks for the existence of the method", function() {
|
it("checks for the existence of the method", function() {
|
||||||
var spyRegistry = new j$.SpyRegistry(),
|
var spyRegistry = new jasmineUnderTest.SpyRegistry(),
|
||||||
subject = {};
|
subject = {};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
@@ -27,7 +27,7 @@ describe("SpyRegistry", function() {
|
|||||||
|
|
||||||
it("checks if it has already been spied upon", function() {
|
it("checks if it has already been spied upon", function() {
|
||||||
var spies = [],
|
var spies = [],
|
||||||
spyRegistry = new j$.SpyRegistry({currentSpies: function() { return spies; }}),
|
spyRegistry = new jasmineUnderTest.SpyRegistry({currentSpies: function() { return spies; }}),
|
||||||
subject = { spiedFunc: function() {} };
|
subject = { spiedFunc: function() {} };
|
||||||
|
|
||||||
spyRegistry.spyOn(subject, 'spiedFunc');
|
spyRegistry.spyOn(subject, 'spiedFunc');
|
||||||
@@ -37,9 +37,38 @@ describe("SpyRegistry", function() {
|
|||||||
}).toThrowError(/has already been spied upon/);
|
}).toThrowError(/has already been spied upon/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("checks if it can be spied upon", function() {
|
||||||
|
// IE 8 doesn't support `definePropery` on non-DOM nodes
|
||||||
|
if (jasmine.getEnv().ieVersion < 9) { return; }
|
||||||
|
|
||||||
|
var scope = {};
|
||||||
|
|
||||||
|
function myFunc() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.defineProperty(scope, 'myFunc', {
|
||||||
|
get: function() {
|
||||||
|
return myFunc;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var spies = [],
|
||||||
|
spyRegistry = new jasmineUnderTest.SpyRegistry({currentSpies: function() { return spies; }}),
|
||||||
|
subject = { spiedFunc: scope.myFunc };
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
|
spyRegistry.spyOn(scope, 'myFunc');
|
||||||
|
}).toThrowError(/is not declared writable or has no setter/);
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
|
spyRegistry.spyOn(subject, 'spiedFunc');
|
||||||
|
}).not.toThrowError(/is not declared writable or has no setter/);
|
||||||
|
});
|
||||||
|
|
||||||
it("overrides the method on the object and returns the spy", function() {
|
it("overrides the method on the object and returns the spy", function() {
|
||||||
var originalFunctionWasCalled = false,
|
var originalFunctionWasCalled = false,
|
||||||
spyRegistry = new j$.SpyRegistry(),
|
spyRegistry = new jasmineUnderTest.SpyRegistry(),
|
||||||
subject = { spiedFunc: function() { originalFunctionWasCalled = true; } };
|
subject = { spiedFunc: function() { originalFunctionWasCalled = true; } };
|
||||||
|
|
||||||
var spy = spyRegistry.spyOn(subject, 'spiedFunc');
|
var spy = spyRegistry.spyOn(subject, 'spiedFunc');
|
||||||
@@ -51,7 +80,7 @@ describe("SpyRegistry", function() {
|
|||||||
describe("#clearSpies", function() {
|
describe("#clearSpies", function() {
|
||||||
it("restores the original functions on the spied-upon objects", function() {
|
it("restores the original functions on the spied-upon objects", function() {
|
||||||
var spies = [],
|
var spies = [],
|
||||||
spyRegistry = new j$.SpyRegistry({currentSpies: function() { return spies; }}),
|
spyRegistry = new jasmineUnderTest.SpyRegistry({currentSpies: function() { return spies; }}),
|
||||||
originalFunction = function() {},
|
originalFunction = function() {},
|
||||||
subject = { spiedFunc: originalFunction };
|
subject = { spiedFunc: originalFunction };
|
||||||
|
|
||||||
@@ -60,5 +89,67 @@ describe("SpyRegistry", function() {
|
|||||||
|
|
||||||
expect(subject.spiedFunc).toBe(originalFunction);
|
expect(subject.spiedFunc).toBe(originalFunction);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("restores the original functions, even when that spy has been replace and re-spied upon", function() {
|
||||||
|
var spies = [],
|
||||||
|
spyRegistry = new jasmineUnderTest.SpyRegistry({currentSpies: function() { return spies; }}),
|
||||||
|
originalFunction = function() {},
|
||||||
|
subject = { spiedFunc: originalFunction };
|
||||||
|
|
||||||
|
spyRegistry.spyOn(subject, 'spiedFunc');
|
||||||
|
|
||||||
|
// replace the original spy with some other function
|
||||||
|
subject.spiedFunc = function() {};
|
||||||
|
|
||||||
|
// spy on the function in that location again
|
||||||
|
spyRegistry.spyOn(subject, 'spiedFunc');
|
||||||
|
|
||||||
|
spyRegistry.clearSpies();
|
||||||
|
|
||||||
|
expect(subject.spiedFunc).toBe(originalFunction);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not add a property that the spied-upon object didn't originally have", function() {
|
||||||
|
// IE 8 doesn't support `Object.create`
|
||||||
|
if (jasmine.getEnv().ieVersion < 9) { return; }
|
||||||
|
|
||||||
|
var spies = [],
|
||||||
|
spyRegistry = new jasmineUnderTest.SpyRegistry({currentSpies: function() { return spies; }}),
|
||||||
|
originalFunction = function() {},
|
||||||
|
subjectParent = {spiedFunc: originalFunction};
|
||||||
|
|
||||||
|
var subject = Object.create(subjectParent);
|
||||||
|
|
||||||
|
expect(subject.hasOwnProperty('spiedFunc')).toBe(false);
|
||||||
|
|
||||||
|
spyRegistry.spyOn(subject, 'spiedFunc');
|
||||||
|
spyRegistry.clearSpies();
|
||||||
|
|
||||||
|
expect(subject.hasOwnProperty('spiedFunc')).toBe(false);
|
||||||
|
expect(subject.spiedFunc).toBe(originalFunction);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("restores the original function when it\'s inherited and cannot be deleted", function() {
|
||||||
|
// IE 8 doesn't support `Object.create` or `Object.defineProperty`
|
||||||
|
if (jasmine.getEnv().ieVersion < 9) { return; }
|
||||||
|
|
||||||
|
var spies = [],
|
||||||
|
spyRegistry = new jasmineUnderTest.SpyRegistry({currentSpies: function() { return spies; }}),
|
||||||
|
originalFunction = function() {},
|
||||||
|
subjectParent = {spiedFunc: originalFunction};
|
||||||
|
|
||||||
|
var subject = Object.create(subjectParent);
|
||||||
|
|
||||||
|
spyRegistry.spyOn(subject, 'spiedFunc');
|
||||||
|
|
||||||
|
// simulate a spy that cannot be deleted
|
||||||
|
Object.defineProperty(subject, 'spiedFunc', {
|
||||||
|
configurable: false
|
||||||
|
});
|
||||||
|
|
||||||
|
spyRegistry.clearSpies();
|
||||||
|
|
||||||
|
expect(jasmineUnderTest.isSpy(subject.spiedFunc)).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ describe('Spies', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("preserves the properties of the spied function", function() {
|
it("preserves the properties of the spied function", function() {
|
||||||
var spy = j$.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
var spy = jasmineUnderTest.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
||||||
|
|
||||||
expect(spy.bob).toEqual("test");
|
expect(spy.bob).toEqual("test");
|
||||||
});
|
});
|
||||||
@@ -18,19 +18,19 @@ describe('Spies', function () {
|
|||||||
TestClass.prototype.someFunction.and = "turkey";
|
TestClass.prototype.someFunction.and = "turkey";
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
j$.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
jasmineUnderTest.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
||||||
}).toThrowError("Jasmine spies would overwrite the 'and' and 'calls' properties on the object being spied upon");
|
}).toThrowError("Jasmine spies would overwrite the 'and' and 'calls' properties on the object being spied upon");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("adds a spyStrategy and callTracker to the spy", function() {
|
it("adds a spyStrategy and callTracker to the spy", function() {
|
||||||
var spy = j$.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
var spy = jasmineUnderTest.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
||||||
|
|
||||||
expect(spy.and).toEqual(jasmine.any(j$.SpyStrategy));
|
expect(spy.and).toEqual(jasmine.any(jasmineUnderTest.SpyStrategy));
|
||||||
expect(spy.calls).toEqual(jasmine.any(j$.CallTracker));
|
expect(spy.calls).toEqual(jasmine.any(jasmineUnderTest.CallTracker));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("tracks the argument of calls", function () {
|
it("tracks the argument of calls", function () {
|
||||||
var spy = j$.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
var spy = jasmineUnderTest.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
||||||
var trackSpy = spyOn(spy.calls, "track");
|
var trackSpy = spyOn(spy.calls, "track");
|
||||||
|
|
||||||
spy("arg");
|
spy("arg");
|
||||||
@@ -39,7 +39,7 @@ describe('Spies', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("tracks the context of calls", function () {
|
it("tracks the context of calls", function () {
|
||||||
var spy = j$.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
var spy = jasmineUnderTest.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
||||||
var trackSpy = spyOn(spy.calls, "track");
|
var trackSpy = spyOn(spy.calls, "track");
|
||||||
|
|
||||||
var contextObject = { spyMethod: spy };
|
var contextObject = { spyMethod: spy };
|
||||||
@@ -49,7 +49,7 @@ describe('Spies', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("tracks the return value of calls", function () {
|
it("tracks the return value of calls", function () {
|
||||||
var spy = j$.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
var spy = jasmineUnderTest.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
||||||
var trackSpy = spyOn(spy.calls, "track");
|
var trackSpy = spyOn(spy.calls, "track");
|
||||||
|
|
||||||
spy.and.returnValue("return value");
|
spy.and.returnValue("return value");
|
||||||
@@ -61,7 +61,7 @@ describe('Spies', function () {
|
|||||||
|
|
||||||
describe("createSpyObj", function() {
|
describe("createSpyObj", function() {
|
||||||
it("should create an object with a bunch of spy methods when you call jasmine.createSpyObj()", function() {
|
it("should create an object with a bunch of spy methods when you call jasmine.createSpyObj()", function() {
|
||||||
var spyObj = j$.createSpyObj('BaseName', ['method1', 'method2']);
|
var spyObj = jasmineUnderTest.createSpyObj('BaseName', ['method1', 'method2']);
|
||||||
|
|
||||||
expect(spyObj).toEqual({ method1: jasmine.any(Function), method2: jasmine.any(Function)});
|
expect(spyObj).toEqual({ method1: jasmine.any(Function), method2: jasmine.any(Function)});
|
||||||
expect(spyObj.method1.and.identity()).toEqual('BaseName.method1');
|
expect(spyObj.method1.and.identity()).toEqual('BaseName.method1');
|
||||||
@@ -69,7 +69,7 @@ describe('Spies', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should allow you to omit the baseName", function() {
|
it("should allow you to omit the baseName", function() {
|
||||||
var spyObj = j$.createSpyObj(['method1', 'method2']);
|
var spyObj = jasmineUnderTest.createSpyObj(['method1', 'method2']);
|
||||||
|
|
||||||
expect(spyObj).toEqual({ method1: jasmine.any(Function), method2: jasmine.any(Function)});
|
expect(spyObj).toEqual({ method1: jasmine.any(Function), method2: jasmine.any(Function)});
|
||||||
expect(spyObj.method1.and.identity()).toEqual('unknown.method1');
|
expect(spyObj.method1.and.identity()).toEqual('unknown.method1');
|
||||||
@@ -78,7 +78,7 @@ describe('Spies', function () {
|
|||||||
|
|
||||||
it("should throw if you do not pass an array argument", function() {
|
it("should throw if you do not pass an array argument", function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
j$.createSpyObj('BaseName');
|
jasmineUnderTest.createSpyObj('BaseName');
|
||||||
}).toThrow("createSpyObj requires a non-empty array of method names to create spies for");
|
}).toThrow("createSpyObj requires a non-empty array of method names to create spies for");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
describe("SpyStrategy", function() {
|
describe("SpyStrategy", function() {
|
||||||
|
|
||||||
it("defaults its name to unknown", function() {
|
it("defaults its name to unknown", function() {
|
||||||
var spyStrategy = new j$.SpyStrategy();
|
var spyStrategy = new jasmineUnderTest.SpyStrategy();
|
||||||
|
|
||||||
expect(spyStrategy.identity()).toEqual("unknown");
|
expect(spyStrategy.identity()).toEqual("unknown");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("takes a name", function() {
|
it("takes a name", function() {
|
||||||
var spyStrategy = new j$.SpyStrategy({name: "foo"});
|
var spyStrategy = new jasmineUnderTest.SpyStrategy({name: "foo"});
|
||||||
|
|
||||||
expect(spyStrategy.identity()).toEqual("foo");
|
expect(spyStrategy.identity()).toEqual("foo");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("stubs an original function, if provided", function() {
|
it("stubs an original function, if provided", function() {
|
||||||
var originalFn = jasmine.createSpy("original"),
|
var originalFn = jasmine.createSpy("original"),
|
||||||
spyStrategy = new j$.SpyStrategy({fn: originalFn});
|
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn});
|
||||||
|
|
||||||
spyStrategy.exec();
|
spyStrategy.exec();
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ describe("SpyStrategy", function() {
|
|||||||
|
|
||||||
it("allows an original function to be called, passed through the params and returns it's value", function() {
|
it("allows an original function to be called, passed through the params and returns it's value", function() {
|
||||||
var originalFn = jasmine.createSpy("original").and.returnValue(42),
|
var originalFn = jasmine.createSpy("original").and.returnValue(42),
|
||||||
spyStrategy = new j$.SpyStrategy({fn: originalFn}),
|
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn}),
|
||||||
returnValue;
|
returnValue;
|
||||||
|
|
||||||
spyStrategy.callThrough();
|
spyStrategy.callThrough();
|
||||||
@@ -36,7 +36,7 @@ describe("SpyStrategy", function() {
|
|||||||
|
|
||||||
it("can return a specified value when executed", function() {
|
it("can return a specified value when executed", function() {
|
||||||
var originalFn = jasmine.createSpy("original"),
|
var originalFn = jasmine.createSpy("original"),
|
||||||
spyStrategy = new j$.SpyStrategy({fn: originalFn}),
|
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn}),
|
||||||
returnValue;
|
returnValue;
|
||||||
|
|
||||||
spyStrategy.returnValue(17);
|
spyStrategy.returnValue(17);
|
||||||
@@ -48,7 +48,7 @@ describe("SpyStrategy", function() {
|
|||||||
|
|
||||||
it("can return specified values in order specified when executed", function() {
|
it("can return specified values in order specified when executed", function() {
|
||||||
var originalFn = jasmine.createSpy("original"),
|
var originalFn = jasmine.createSpy("original"),
|
||||||
spyStrategy = new j$.SpyStrategy({fn: originalFn});
|
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn});
|
||||||
|
|
||||||
spyStrategy.returnValues('value1', 'value2', 'value3');
|
spyStrategy.returnValues('value1', 'value2', 'value3');
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ describe("SpyStrategy", function() {
|
|||||||
|
|
||||||
it("allows an exception to be thrown when executed", function() {
|
it("allows an exception to be thrown when executed", function() {
|
||||||
var originalFn = jasmine.createSpy("original"),
|
var originalFn = jasmine.createSpy("original"),
|
||||||
spyStrategy = new j$.SpyStrategy({fn: originalFn});
|
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn});
|
||||||
|
|
||||||
spyStrategy.throwError(new TypeError("bar"));
|
spyStrategy.throwError(new TypeError("bar"));
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ describe("SpyStrategy", function() {
|
|||||||
|
|
||||||
it("allows a non-Error to be thrown, wrapping it into an exception when executed", function() {
|
it("allows a non-Error to be thrown, wrapping it into an exception when executed", function() {
|
||||||
var originalFn = jasmine.createSpy("original"),
|
var originalFn = jasmine.createSpy("original"),
|
||||||
spyStrategy = new j$.SpyStrategy({fn: originalFn});
|
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn});
|
||||||
|
|
||||||
spyStrategy.throwError("bar");
|
spyStrategy.throwError("bar");
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ describe("SpyStrategy", function() {
|
|||||||
it("allows a fake function to be called instead", function() {
|
it("allows a fake function to be called instead", function() {
|
||||||
var originalFn = jasmine.createSpy("original"),
|
var originalFn = jasmine.createSpy("original"),
|
||||||
fakeFn = jasmine.createSpy("fake").and.returnValue(67),
|
fakeFn = jasmine.createSpy("fake").and.returnValue(67),
|
||||||
spyStrategy = new j$.SpyStrategy({fn: originalFn}),
|
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn}),
|
||||||
returnValue;
|
returnValue;
|
||||||
|
|
||||||
spyStrategy.callFake(fakeFn);
|
spyStrategy.callFake(fakeFn);
|
||||||
@@ -92,10 +92,22 @@ describe("SpyStrategy", function() {
|
|||||||
expect(returnValue).toEqual(67);
|
expect(returnValue).toEqual(67);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('throws an error when a non-function is passed to callFake strategy', function() {
|
||||||
|
var originalFn = jasmine.createSpy('original'),
|
||||||
|
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn}),
|
||||||
|
invalidFakes = [5, 'foo', {}, true, false, null, void 0, new Date(), /.*/];
|
||||||
|
|
||||||
|
spyOn(jasmineUnderTest, 'isFunction_').and.returnValue(false);
|
||||||
|
|
||||||
|
expect(function () {
|
||||||
|
spyStrategy.callFake(function() {});
|
||||||
|
}).toThrowError(/^Argument passed to callFake should be a function, got/);
|
||||||
|
});
|
||||||
|
|
||||||
it("allows a return to plan stubbing after another strategy", function() {
|
it("allows a return to plan stubbing after another strategy", function() {
|
||||||
var originalFn = jasmine.createSpy("original"),
|
var originalFn = jasmine.createSpy("original"),
|
||||||
fakeFn = jasmine.createSpy("fake").and.returnValue(67),
|
fakeFn = jasmine.createSpy("fake").and.returnValue(67),
|
||||||
spyStrategy = new j$.SpyStrategy({fn: originalFn}),
|
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn}),
|
||||||
returnValue;
|
returnValue;
|
||||||
|
|
||||||
spyStrategy.callFake(fakeFn);
|
spyStrategy.callFake(fakeFn);
|
||||||
@@ -103,7 +115,7 @@ describe("SpyStrategy", function() {
|
|||||||
|
|
||||||
expect(originalFn).not.toHaveBeenCalled();
|
expect(originalFn).not.toHaveBeenCalled();
|
||||||
expect(returnValue).toEqual(67);
|
expect(returnValue).toEqual(67);
|
||||||
|
|
||||||
spyStrategy.stub();
|
spyStrategy.stub();
|
||||||
returnValue = spyStrategy.exec();
|
returnValue = spyStrategy.exec();
|
||||||
|
|
||||||
@@ -113,12 +125,12 @@ describe("SpyStrategy", function() {
|
|||||||
it("returns the spy after changing the strategy", function(){
|
it("returns the spy after changing the strategy", function(){
|
||||||
var spy = {},
|
var spy = {},
|
||||||
spyFn = jasmine.createSpy('spyFn').and.returnValue(spy),
|
spyFn = jasmine.createSpy('spyFn').and.returnValue(spy),
|
||||||
spyStrategy = new j$.SpyStrategy({getSpy: spyFn});
|
spyStrategy = new jasmineUnderTest.SpyStrategy({getSpy: spyFn});
|
||||||
|
|
||||||
expect(spyStrategy.callThrough()).toBe(spy);
|
expect(spyStrategy.callThrough()).toBe(spy);
|
||||||
expect(spyStrategy.returnValue()).toBe(spy);
|
expect(spyStrategy.returnValue()).toBe(spy);
|
||||||
expect(spyStrategy.throwError()).toBe(spy);
|
expect(spyStrategy.throwError()).toBe(spy);
|
||||||
expect(spyStrategy.callFake()).toBe(spy);
|
expect(spyStrategy.callFake(function() {})).toBe(spy);
|
||||||
expect(spyStrategy.stub()).toBe(spy);
|
expect(spyStrategy.stub()).toBe(spy);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
describe("Suite", function() {
|
describe("Suite", function() {
|
||||||
|
|
||||||
it("keeps its id", function() {
|
it("keeps its id", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
suite = new j$.Suite({
|
suite = new jasmineUnderTest.Suite({
|
||||||
env: env,
|
env: env,
|
||||||
id: 456,
|
id: 456,
|
||||||
description: "I am a suite"
|
description: "I am a suite"
|
||||||
@@ -11,24 +11,24 @@ describe("Suite", function() {
|
|||||||
expect(suite.id).toEqual(456);
|
expect(suite.id).toEqual(456);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns its full name", function() {
|
it("returns blank full name for top level suite", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
suite = new j$.Suite({
|
suite = new jasmineUnderTest.Suite({
|
||||||
env: env,
|
env: env,
|
||||||
description: "I am a suite"
|
description: "I am a suite"
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(suite.getFullName()).toEqual("I am a suite");
|
expect(suite.getFullName()).toEqual("");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns its full name when it has parent suites", function() {
|
it("returns its full name when it has parent suites", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
parentSuite = new j$.Suite({
|
parentSuite = new jasmineUnderTest.Suite({
|
||||||
env: env,
|
env: env,
|
||||||
description: "I am a parent suite",
|
description: "I am a parent suite",
|
||||||
parentSuite: jasmine.createSpy('pretend top level suite')
|
parentSuite: jasmine.createSpy('pretend top level suite')
|
||||||
}),
|
}),
|
||||||
suite = new j$.Suite({
|
suite = new jasmineUnderTest.Suite({
|
||||||
env: env,
|
env: env,
|
||||||
description: "I am a suite",
|
description: "I am a suite",
|
||||||
parentSuite: parentSuite
|
parentSuite: parentSuite
|
||||||
@@ -38,8 +38,8 @@ describe("Suite", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("adds before functions in order of needed execution", function() {
|
it("adds before functions in order of needed execution", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
suite = new j$.Suite({
|
suite = new jasmineUnderTest.Suite({
|
||||||
env: env,
|
env: env,
|
||||||
description: "I am a suite"
|
description: "I am a suite"
|
||||||
}),
|
}),
|
||||||
@@ -53,8 +53,8 @@ describe("Suite", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("adds after functions in order of needed execution", function() {
|
it("adds after functions in order of needed execution", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
suite = new j$.Suite({
|
suite = new jasmineUnderTest.Suite({
|
||||||
env: env,
|
env: env,
|
||||||
description: "I am a suite"
|
description: "I am a suite"
|
||||||
}),
|
}),
|
||||||
@@ -68,7 +68,7 @@ describe("Suite", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('has a status of failed if any afterAll expectations have failed', function() {
|
it('has a status of failed if any afterAll expectations have failed', function() {
|
||||||
var suite = new j$.Suite({
|
var suite = new jasmineUnderTest.Suite({
|
||||||
expectationResultFactory: function() { return 'hi'; }
|
expectationResultFactory: function() { return 'hi'; }
|
||||||
});
|
});
|
||||||
suite.addChild({ result: { status: 'done' } });
|
suite.addChild({ result: { status: 'done' } });
|
||||||
@@ -78,33 +78,48 @@ describe("Suite", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("retrieves a result with updated status", function() {
|
it("retrieves a result with updated status", function() {
|
||||||
var suite = new j$.Suite({});
|
var suite = new jasmineUnderTest.Suite({});
|
||||||
|
|
||||||
expect(suite.getResult().status).toBe('finished');
|
expect(suite.getResult().status).toBe('finished');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("retrieves a result with disabled status", function() {
|
it("retrieves a result with disabled status", function() {
|
||||||
var suite = new j$.Suite({});
|
var suite = new jasmineUnderTest.Suite({});
|
||||||
suite.disable();
|
suite.disable();
|
||||||
|
|
||||||
expect(suite.getResult().status).toBe('disabled');
|
expect(suite.getResult().status).toBe('disabled');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("retrieves a result with pending status", function() {
|
||||||
|
var suite = new jasmineUnderTest.Suite({});
|
||||||
|
suite.pend();
|
||||||
|
|
||||||
|
expect(suite.getResult().status).toBe('pending');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("priviledges a disabled status over pending status", function() {
|
||||||
|
var suite = new jasmineUnderTest.Suite({});
|
||||||
|
suite.disable();
|
||||||
|
suite.pend();
|
||||||
|
|
||||||
|
expect(suite.getResult().status).toBe('disabled');
|
||||||
|
});
|
||||||
|
|
||||||
it("is executable if not disabled", function() {
|
it("is executable if not disabled", function() {
|
||||||
var suite = new j$.Suite({});
|
var suite = new jasmineUnderTest.Suite({});
|
||||||
|
|
||||||
expect(suite.isExecutable()).toBe(true);
|
expect(suite.isExecutable()).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("is not executable if disabled", function() {
|
it("is not executable if disabled", function() {
|
||||||
var suite = new j$.Suite({});
|
var suite = new jasmineUnderTest.Suite({});
|
||||||
suite.disable();
|
suite.disable();
|
||||||
|
|
||||||
expect(suite.isExecutable()).toBe(false);
|
expect(suite.isExecutable()).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("tells all children about expectation failures, even if one throws", function() {
|
it("tells all children about expectation failures, even if one throws", function() {
|
||||||
var suite = new j$.Suite({}),
|
var suite = new jasmineUnderTest.Suite({}),
|
||||||
child1 = { addExpectationResult: jasmine.createSpy('child1#expectationResult'), result: {} },
|
child1 = { addExpectationResult: jasmine.createSpy('child1#expectationResult'), result: {} },
|
||||||
child2 = { addExpectationResult: jasmine.createSpy('child2#expectationResult'), result: {} };
|
child2 = { addExpectationResult: jasmine.createSpy('child2#expectationResult'), result: {} };
|
||||||
|
|
||||||
@@ -120,7 +135,7 @@ describe("Suite", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("throws an ExpectationFailed when receiving a failed expectation in an afterAll when throwOnExpectationFailure is set", function() {
|
it("throws an ExpectationFailed when receiving a failed expectation in an afterAll when throwOnExpectationFailure is set", function() {
|
||||||
var suite = new j$.Suite({
|
var suite = new jasmineUnderTest.Suite({
|
||||||
expectationResultFactory: function(data) { return data; },
|
expectationResultFactory: function(data) { return data; },
|
||||||
throwOnExpectationFailure: true
|
throwOnExpectationFailure: true
|
||||||
});
|
});
|
||||||
@@ -128,17 +143,17 @@ describe("Suite", function() {
|
|||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
suite.addExpectationResult(false, 'failed');
|
suite.addExpectationResult(false, 'failed');
|
||||||
}).toThrowError(j$.errors.ExpectationFailed);
|
}).toThrowError(jasmineUnderTest.errors.ExpectationFailed);
|
||||||
|
|
||||||
expect(suite.status()).toBe('failed');
|
expect(suite.status()).toBe('failed');
|
||||||
expect(suite.result.failedExpectations).toEqual(['failed']);
|
expect(suite.result.failedExpectations).toEqual(['failed']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not add an additional failure when an expectation fails in an afterAll", function(){
|
it("does not add an additional failure when an expectation fails in an afterAll", function(){
|
||||||
var suite = new j$.Suite({});
|
var suite = new jasmineUnderTest.Suite({});
|
||||||
suite.addChild({ result: { status: 'done' } });
|
suite.addChild({ result: { status: 'done' } });
|
||||||
|
|
||||||
suite.onException(new j$.errors.ExpectationFailed());
|
suite.onException(new jasmineUnderTest.errors.ExpectationFailed());
|
||||||
|
|
||||||
expect(suite.getResult().failedExpectations).toEqual([]);
|
expect(suite.getResult().failedExpectations).toEqual([]);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
describe("Timer", function() {
|
describe("Timer", function() {
|
||||||
it("reports the time elapsed", function() {
|
it("reports the time elapsed", function() {
|
||||||
var fakeNow = jasmine.createSpy('fake Date.now'),
|
var fakeNow = jasmine.createSpy('fake Date.now'),
|
||||||
timer = new j$.Timer({now: fakeNow});
|
timer = new jasmineUnderTest.Timer({now: fakeNow});
|
||||||
|
|
||||||
fakeNow.and.returnValue(100);
|
fakeNow.and.returnValue(100);
|
||||||
timer.start();
|
timer.start();
|
||||||
@@ -22,7 +22,7 @@ describe("Timer", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does not throw even though Date was taken away", function() {
|
it("does not throw even though Date was taken away", function() {
|
||||||
var timer = new j$.Timer();
|
var timer = new jasmineUnderTest.Timer();
|
||||||
|
|
||||||
expect(timer.start).not.toThrow();
|
expect(timer.start).not.toThrow();
|
||||||
expect(timer.elapsed()).toEqual(jasmine.any(Number));
|
expect(timer.elapsed()).toEqual(jasmine.any(Number));
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ describe("TreeProcessor", function() {
|
|||||||
|
|
||||||
it("processes a single executable leaf", function() {
|
it("processes a single executable leaf", function() {
|
||||||
var leaf = new Leaf(),
|
var leaf = new Leaf(),
|
||||||
processor = new j$.TreeProcessor({ tree: leaf, runnableIds: [leaf.id] }),
|
processor = new jasmineUnderTest.TreeProcessor({ tree: leaf, runnableIds: [leaf.id] }),
|
||||||
result = processor.processTree();
|
result = processor.processTree();
|
||||||
|
|
||||||
expect(result.valid).toBe(true);
|
expect(result.valid).toBe(true);
|
||||||
@@ -43,7 +43,7 @@ describe("TreeProcessor", function() {
|
|||||||
|
|
||||||
it("processes a single non-executable leaf", function() {
|
it("processes a single non-executable leaf", function() {
|
||||||
var leaf = new Leaf({ executable: false }),
|
var leaf = new Leaf({ executable: false }),
|
||||||
processor = new j$.TreeProcessor({ tree: leaf, runnableIds: [leaf.id] }),
|
processor = new jasmineUnderTest.TreeProcessor({ tree: leaf, runnableIds: [leaf.id] }),
|
||||||
result = processor.processTree();
|
result = processor.processTree();
|
||||||
|
|
||||||
expect(result.valid).toBe(true);
|
expect(result.valid).toBe(true);
|
||||||
@@ -56,7 +56,7 @@ describe("TreeProcessor", function() {
|
|||||||
|
|
||||||
it("processes a single non-specified leaf", function() {
|
it("processes a single non-specified leaf", function() {
|
||||||
var leaf = new Leaf(),
|
var leaf = new Leaf(),
|
||||||
processor = new j$.TreeProcessor({ tree: leaf, runnableIds: [] }),
|
processor = new jasmineUnderTest.TreeProcessor({ tree: leaf, runnableIds: [] }),
|
||||||
result = processor.processTree();
|
result = processor.processTree();
|
||||||
|
|
||||||
expect(result.valid).toBe(true);
|
expect(result.valid).toBe(true);
|
||||||
@@ -70,7 +70,7 @@ describe("TreeProcessor", function() {
|
|||||||
it("processes a tree with a single leaf with the root specified", function() {
|
it("processes a tree with a single leaf with the root specified", function() {
|
||||||
var leaf = new Leaf(),
|
var leaf = new Leaf(),
|
||||||
parent = new Node({ children: [leaf] }),
|
parent = new Node({ children: [leaf] }),
|
||||||
processor = new j$.TreeProcessor({ tree: parent, runnableIds: [parent.id] }),
|
processor = new jasmineUnderTest.TreeProcessor({ tree: parent, runnableIds: [parent.id] }),
|
||||||
result = processor.processTree();
|
result = processor.processTree();
|
||||||
|
|
||||||
expect(result.valid).toBe(true);
|
expect(result.valid).toBe(true);
|
||||||
@@ -89,7 +89,7 @@ describe("TreeProcessor", function() {
|
|||||||
it("processes a tree with a single non-executable leaf, with the root specified", function() {
|
it("processes a tree with a single non-executable leaf, with the root specified", function() {
|
||||||
var leaf = new Leaf({ executable: false }),
|
var leaf = new Leaf({ executable: false }),
|
||||||
parent = new Node({ children: [leaf] }),
|
parent = new Node({ children: [leaf] }),
|
||||||
processor = new j$.TreeProcessor({ tree: parent, runnableIds: [parent.id] }),
|
processor = new jasmineUnderTest.TreeProcessor({ tree: parent, runnableIds: [parent.id] }),
|
||||||
result = processor.processTree();
|
result = processor.processTree();
|
||||||
|
|
||||||
expect(result.valid).toBe(true);
|
expect(result.valid).toBe(true);
|
||||||
@@ -113,7 +113,7 @@ describe("TreeProcessor", function() {
|
|||||||
childOfDisabled = new Leaf({ executable: true }),
|
childOfDisabled = new Leaf({ executable: true }),
|
||||||
disabledNode = new Node({ executable: false, children: [childOfDisabled] }),
|
disabledNode = new Node({ executable: false, children: [childOfDisabled] }),
|
||||||
root = new Node({ children: [parent, childless, disabledNode] }),
|
root = new Node({ children: [parent, childless, disabledNode] }),
|
||||||
processor = new j$.TreeProcessor({ tree: root, runnableIds: [root.id] }),
|
processor = new jasmineUnderTest.TreeProcessor({ tree: root, runnableIds: [root.id] }),
|
||||||
result = processor.processTree();
|
result = processor.processTree();
|
||||||
|
|
||||||
expect(result.valid).toBe(true);
|
expect(result.valid).toBe(true);
|
||||||
@@ -160,7 +160,7 @@ describe("TreeProcessor", function() {
|
|||||||
leaf3 = new Leaf(),
|
leaf3 = new Leaf(),
|
||||||
reentered = new Node({ noReenter: true, children: [leaf1, leaf2] }),
|
reentered = new Node({ noReenter: true, children: [leaf1, leaf2] }),
|
||||||
root = new Node({ children: [reentered, leaf3] }),
|
root = new Node({ children: [reentered, leaf3] }),
|
||||||
processor = new j$.TreeProcessor({ tree: root, runnableIds: [leaf1.id, leaf3.id, leaf2.id] }),
|
processor = new jasmineUnderTest.TreeProcessor({ tree: root, runnableIds: [leaf1.id, leaf3.id, leaf2.id] }),
|
||||||
result = processor.processTree();
|
result = processor.processTree();
|
||||||
|
|
||||||
expect(result).toEqual({ valid: false });
|
expect(result).toEqual({ valid: false });
|
||||||
@@ -172,7 +172,7 @@ describe("TreeProcessor", function() {
|
|||||||
leaf3 = new Leaf(),
|
leaf3 = new Leaf(),
|
||||||
reentered = new Node({ children: [leaf1, leaf2] }),
|
reentered = new Node({ children: [leaf1, leaf2] }),
|
||||||
root = new Node({ children: [reentered, leaf3] }),
|
root = new Node({ children: [reentered, leaf3] }),
|
||||||
processor = new j$.TreeProcessor({ tree: root, runnableIds: [leaf1.id, leaf3.id, leaf2.id] }),
|
processor = new jasmineUnderTest.TreeProcessor({ tree: root, runnableIds: [leaf1.id, leaf3.id, leaf2.id] }),
|
||||||
result = processor.processTree();
|
result = processor.processTree();
|
||||||
|
|
||||||
expect(result.valid).toBe(true);
|
expect(result.valid).toBe(true);
|
||||||
@@ -184,7 +184,7 @@ describe("TreeProcessor", function() {
|
|||||||
leaf3 = new Leaf(),
|
leaf3 = new Leaf(),
|
||||||
noReentry = new Node({ noReenter: true }),
|
noReentry = new Node({ noReenter: true }),
|
||||||
root = new Node({ children: [noReentry] }),
|
root = new Node({ children: [noReentry] }),
|
||||||
processor = new j$.TreeProcessor({ tree: root, runnableIds: [leaf2.id, leaf1.id, leaf3.id] }),
|
processor = new jasmineUnderTest.TreeProcessor({ tree: root, runnableIds: [leaf2.id, leaf1.id, leaf3.id] }),
|
||||||
result = processor.processTree();
|
result = processor.processTree();
|
||||||
|
|
||||||
expect(result.valid).toBe(true);
|
expect(result.valid).toBe(true);
|
||||||
@@ -194,7 +194,7 @@ describe("TreeProcessor", function() {
|
|||||||
var leaf1 = new Leaf(),
|
var leaf1 = new Leaf(),
|
||||||
noReentry = new Node({ noReenter: true }),
|
noReentry = new Node({ noReenter: true }),
|
||||||
root = new Node({ children: [noReentry] }),
|
root = new Node({ children: [noReentry] }),
|
||||||
processor = new j$.TreeProcessor({ tree: root, runnableIds: [root.id] }),
|
processor = new jasmineUnderTest.TreeProcessor({ tree: root, runnableIds: [root.id] }),
|
||||||
result = processor.processTree();
|
result = processor.processTree();
|
||||||
|
|
||||||
expect(result.valid).toBe(true);
|
expect(result.valid).toBe(true);
|
||||||
@@ -202,9 +202,9 @@ describe("TreeProcessor", function() {
|
|||||||
|
|
||||||
it("runs a single leaf", function() {
|
it("runs a single leaf", function() {
|
||||||
var leaf = new Leaf(),
|
var leaf = new Leaf(),
|
||||||
node = new Node({ children: [leaf] }),
|
node = new Node({ children: [leaf], userContext: { root: 'context' } }),
|
||||||
queueRunner = jasmine.createSpy('queueRunner'),
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
processor = new j$.TreeProcessor({ tree: node, runnableIds: [leaf.id], queueRunnerFactory: queueRunner }),
|
processor = new jasmineUnderTest.TreeProcessor({ tree: node, runnableIds: [leaf.id], queueRunnerFactory: queueRunner }),
|
||||||
treeComplete = jasmine.createSpy('treeComplete');
|
treeComplete = jasmine.createSpy('treeComplete');
|
||||||
|
|
||||||
processor.execute(treeComplete);
|
processor.execute(treeComplete);
|
||||||
@@ -212,6 +212,7 @@ describe("TreeProcessor", function() {
|
|||||||
expect(queueRunner).toHaveBeenCalledWith({
|
expect(queueRunner).toHaveBeenCalledWith({
|
||||||
onComplete: treeComplete,
|
onComplete: treeComplete,
|
||||||
onException: jasmine.any(Function),
|
onException: jasmine.any(Function),
|
||||||
|
userContext: { root: 'context' },
|
||||||
queueableFns: [{ fn: jasmine.any(Function) }]
|
queueableFns: [{ fn: jasmine.any(Function) }]
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -222,11 +223,11 @@ describe("TreeProcessor", function() {
|
|||||||
|
|
||||||
it("runs a node with no children", function() {
|
it("runs a node with no children", function() {
|
||||||
var node = new Node({ userContext: { node: 'context' } }),
|
var node = new Node({ userContext: { node: 'context' } }),
|
||||||
root = new Node({ children: [node] }),
|
root = new Node({ children: [node], userContext: { root: 'context' } }),
|
||||||
nodeStart = jasmine.createSpy('nodeStart'),
|
nodeStart = jasmine.createSpy('nodeStart'),
|
||||||
nodeComplete = jasmine.createSpy('nodeComplete'),
|
nodeComplete = jasmine.createSpy('nodeComplete'),
|
||||||
queueRunner = jasmine.createSpy('queueRunner'),
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
processor = new j$.TreeProcessor({
|
processor = new jasmineUnderTest.TreeProcessor({
|
||||||
tree: root,
|
tree: root,
|
||||||
runnableIds: [node.id],
|
runnableIds: [node.id],
|
||||||
nodeStart: nodeStart,
|
nodeStart: nodeStart,
|
||||||
@@ -241,6 +242,7 @@ describe("TreeProcessor", function() {
|
|||||||
expect(queueRunner).toHaveBeenCalledWith({
|
expect(queueRunner).toHaveBeenCalledWith({
|
||||||
onComplete: treeComplete,
|
onComplete: treeComplete,
|
||||||
onException: jasmine.any(Function),
|
onException: jasmine.any(Function),
|
||||||
|
userContext: { root: 'context' },
|
||||||
queueableFns: [{ fn: jasmine.any(Function) }]
|
queueableFns: [{ fn: jasmine.any(Function) }]
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -267,7 +269,7 @@ describe("TreeProcessor", function() {
|
|||||||
node = new Node({ children: [leaf1, leaf2] }),
|
node = new Node({ children: [leaf1, leaf2] }),
|
||||||
root = new Node({ children: [node] }),
|
root = new Node({ children: [node] }),
|
||||||
queueRunner = jasmine.createSpy('queueRunner'),
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
processor = new j$.TreeProcessor({
|
processor = new jasmineUnderTest.TreeProcessor({
|
||||||
tree: root,
|
tree: root,
|
||||||
runnableIds: [node.id],
|
runnableIds: [node.id],
|
||||||
queueRunnerFactory: queueRunner
|
queueRunnerFactory: queueRunner
|
||||||
@@ -296,7 +298,7 @@ describe("TreeProcessor", function() {
|
|||||||
queueRunner = jasmine.createSpy('queueRunner'),
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
nodeStart = jasmine.createSpy('nodeStart'),
|
nodeStart = jasmine.createSpy('nodeStart'),
|
||||||
nodeComplete = jasmine.createSpy('nodeComplete'),
|
nodeComplete = jasmine.createSpy('nodeComplete'),
|
||||||
processor = new j$.TreeProcessor({
|
processor = new jasmineUnderTest.TreeProcessor({
|
||||||
tree: root,
|
tree: root,
|
||||||
runnableIds: [node.id],
|
runnableIds: [node.id],
|
||||||
queueRunnerFactory: queueRunner,
|
queueRunnerFactory: queueRunner,
|
||||||
@@ -332,7 +334,7 @@ describe("TreeProcessor", function() {
|
|||||||
}),
|
}),
|
||||||
root = new Node({ children: [node] }),
|
root = new Node({ children: [node] }),
|
||||||
queueRunner = jasmine.createSpy('queueRunner'),
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
processor = new j$.TreeProcessor({
|
processor = new jasmineUnderTest.TreeProcessor({
|
||||||
tree: root,
|
tree: root,
|
||||||
runnableIds: [node.id],
|
runnableIds: [node.id],
|
||||||
queueRunnerFactory: queueRunner
|
queueRunnerFactory: queueRunner
|
||||||
@@ -357,7 +359,7 @@ describe("TreeProcessor", function() {
|
|||||||
}),
|
}),
|
||||||
root = new Node({ children: [node] }),
|
root = new Node({ children: [node] }),
|
||||||
queueRunner = jasmine.createSpy('queueRunner'),
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
processor = new j$.TreeProcessor({
|
processor = new jasmineUnderTest.TreeProcessor({
|
||||||
tree: root,
|
tree: root,
|
||||||
runnableIds: [node.id],
|
runnableIds: [node.id],
|
||||||
queueRunnerFactory: queueRunner
|
queueRunnerFactory: queueRunner
|
||||||
@@ -381,7 +383,7 @@ describe("TreeProcessor", function() {
|
|||||||
}),
|
}),
|
||||||
root = new Node({ children: [node] }),
|
root = new Node({ children: [node] }),
|
||||||
queueRunner = jasmine.createSpy('queueRunner'),
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
processor = new j$.TreeProcessor({
|
processor = new jasmineUnderTest.TreeProcessor({
|
||||||
tree: root,
|
tree: root,
|
||||||
runnableIds: [node.id],
|
runnableIds: [node.id],
|
||||||
queueRunnerFactory: queueRunner
|
queueRunnerFactory: queueRunner
|
||||||
@@ -408,7 +410,7 @@ describe("TreeProcessor", function() {
|
|||||||
}),
|
}),
|
||||||
root = new Node({ children: [node] }),
|
root = new Node({ children: [node] }),
|
||||||
queueRunner = jasmine.createSpy('queueRunner'),
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
processor = new j$.TreeProcessor({
|
processor = new jasmineUnderTest.TreeProcessor({
|
||||||
tree: root,
|
tree: root,
|
||||||
runnableIds: [node.id],
|
runnableIds: [node.id],
|
||||||
queueRunnerFactory: queueRunner
|
queueRunnerFactory: queueRunner
|
||||||
@@ -430,7 +432,7 @@ describe("TreeProcessor", function() {
|
|||||||
leaf2 = new Leaf(),
|
leaf2 = new Leaf(),
|
||||||
root = new Node({ children: [leaf1, leaf2] }),
|
root = new Node({ children: [leaf1, leaf2] }),
|
||||||
queueRunner = jasmine.createSpy('queueRunner'),
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
processor = new j$.TreeProcessor({
|
processor = new jasmineUnderTest.TreeProcessor({
|
||||||
tree: root,
|
tree: root,
|
||||||
runnableIds: [leaf2.id, leaf1.id],
|
runnableIds: [leaf2.id, leaf1.id],
|
||||||
queueRunnerFactory: queueRunner
|
queueRunnerFactory: queueRunner
|
||||||
@@ -454,7 +456,7 @@ describe("TreeProcessor", function() {
|
|||||||
nonSpecified = new Leaf(),
|
nonSpecified = new Leaf(),
|
||||||
root = new Node({ children: [nonSpecified, specified] }),
|
root = new Node({ children: [nonSpecified, specified] }),
|
||||||
queueRunner = jasmine.createSpy('queueRunner'),
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
processor = new j$.TreeProcessor({
|
processor = new jasmineUnderTest.TreeProcessor({
|
||||||
tree: root,
|
tree: root,
|
||||||
runnableIds: [specified.id],
|
runnableIds: [specified.id],
|
||||||
queueRunnerFactory: queueRunner
|
queueRunnerFactory: queueRunner
|
||||||
@@ -479,7 +481,7 @@ describe("TreeProcessor", function() {
|
|||||||
specifiedNode = new Node({ children: [childLeaf] }),
|
specifiedNode = new Node({ children: [childLeaf] }),
|
||||||
root = new Node({ children: [specifiedLeaf, specifiedNode] }),
|
root = new Node({ children: [specifiedLeaf, specifiedNode] }),
|
||||||
queueRunner = jasmine.createSpy('queueRunner'),
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
processor = new j$.TreeProcessor({
|
processor = new jasmineUnderTest.TreeProcessor({
|
||||||
tree: root,
|
tree: root,
|
||||||
runnableIds: [specifiedNode.id, specifiedLeaf.id],
|
runnableIds: [specifiedNode.id, specifiedLeaf.id],
|
||||||
queueRunnerFactory: queueRunner
|
queueRunnerFactory: queueRunner
|
||||||
@@ -509,7 +511,7 @@ describe("TreeProcessor", function() {
|
|||||||
reentered = new Node({ children: [leaf1, leaf2, leaf3] }),
|
reentered = new Node({ children: [leaf1, leaf2, leaf3] }),
|
||||||
root = new Node({ children: [reentered, leaf4, leaf5] }),
|
root = new Node({ children: [reentered, leaf4, leaf5] }),
|
||||||
queueRunner = jasmine.createSpy('queueRunner'),
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
processor = new j$.TreeProcessor({
|
processor = new jasmineUnderTest.TreeProcessor({
|
||||||
tree: root,
|
tree: root,
|
||||||
runnableIds: [leaf1.id, leaf4.id, leaf2.id, leaf5.id, leaf3.id],
|
runnableIds: [leaf1.id, leaf4.id, leaf2.id, leaf5.id, leaf3.id],
|
||||||
queueRunnerFactory: queueRunner
|
queueRunnerFactory: queueRunner
|
||||||
@@ -553,7 +555,7 @@ describe("TreeProcessor", function() {
|
|||||||
grandparent = new Node({ children: [parent] }),
|
grandparent = new Node({ children: [parent] }),
|
||||||
root = new Node({ children: [grandparent, leaf4, leaf5] }),
|
root = new Node({ children: [grandparent, leaf4, leaf5] }),
|
||||||
queueRunner = jasmine.createSpy('queueRunner'),
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
processor = new j$.TreeProcessor({
|
processor = new jasmineUnderTest.TreeProcessor({
|
||||||
tree: root,
|
tree: root,
|
||||||
runnableIds: [leaf1.id, leaf4.id, leaf2.id, leaf5.id, leaf3.id],
|
runnableIds: [leaf1.id, leaf4.id, leaf2.id, leaf5.id, leaf3.id],
|
||||||
queueRunnerFactory: queueRunner
|
queueRunnerFactory: queueRunner
|
||||||
@@ -607,7 +609,7 @@ describe("TreeProcessor", function() {
|
|||||||
parent = new Node({ children: [leaf2, leaf3] }),
|
parent = new Node({ children: [leaf2, leaf3] }),
|
||||||
root = new Node({ children: [leaf1, parent] }),
|
root = new Node({ children: [leaf1, parent] }),
|
||||||
queueRunner = jasmine.createSpy('queueRunner'),
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
processor = new j$.TreeProcessor({
|
processor = new jasmineUnderTest.TreeProcessor({
|
||||||
tree: root,
|
tree: root,
|
||||||
runnableIds: [root.id],
|
runnableIds: [root.id],
|
||||||
queueRunnerFactory: queueRunner
|
queueRunnerFactory: queueRunner
|
||||||
@@ -630,4 +632,125 @@ describe("TreeProcessor", function() {
|
|||||||
childFns[1].fn();
|
childFns[1].fn();
|
||||||
expect(leaf3.execute).toHaveBeenCalled();
|
expect(leaf3.execute).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("runs large segments of nodes in the order they were declared", function() {
|
||||||
|
var leaf1 = new Leaf(),
|
||||||
|
leaf2 = new Leaf(),
|
||||||
|
leaf3 = new Leaf(),
|
||||||
|
leaf4 = new Leaf(),
|
||||||
|
leaf5 = new Leaf(),
|
||||||
|
leaf6 = new Leaf(),
|
||||||
|
leaf7 = new Leaf(),
|
||||||
|
leaf8 = new Leaf(),
|
||||||
|
leaf9 = new Leaf(),
|
||||||
|
leaf10 = new Leaf(),
|
||||||
|
leaf11 = new Leaf(),
|
||||||
|
root = new Node({ children: [leaf1, leaf2, leaf3, leaf4, leaf5, leaf6, leaf7, leaf8, leaf9, leaf10, leaf11] }),
|
||||||
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
|
processor = new jasmineUnderTest.TreeProcessor({
|
||||||
|
tree: root,
|
||||||
|
runnableIds: [root.id],
|
||||||
|
queueRunnerFactory: queueRunner
|
||||||
|
});
|
||||||
|
|
||||||
|
processor.execute();
|
||||||
|
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||||
|
expect(queueableFns.length).toBe(11);
|
||||||
|
|
||||||
|
queueableFns[0].fn();
|
||||||
|
expect(leaf1.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[1].fn();
|
||||||
|
expect(leaf2.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[2].fn();
|
||||||
|
expect(leaf3.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[3].fn();
|
||||||
|
expect(leaf4.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[4].fn();
|
||||||
|
expect(leaf5.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[5].fn();
|
||||||
|
expect(leaf6.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[6].fn();
|
||||||
|
expect(leaf7.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[7].fn();
|
||||||
|
expect(leaf8.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[8].fn();
|
||||||
|
expect(leaf9.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[9].fn();
|
||||||
|
expect(leaf10.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[10].fn();
|
||||||
|
expect(leaf11.execute).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("runs nodes in a custom order when orderChildren is overrided", function() {
|
||||||
|
var leaf1 = new Leaf(),
|
||||||
|
leaf2 = new Leaf(),
|
||||||
|
leaf3 = new Leaf(),
|
||||||
|
leaf4 = new Leaf(),
|
||||||
|
leaf5 = new Leaf(),
|
||||||
|
leaf6 = new Leaf(),
|
||||||
|
leaf7 = new Leaf(),
|
||||||
|
leaf8 = new Leaf(),
|
||||||
|
leaf9 = new Leaf(),
|
||||||
|
leaf10 = new Leaf(),
|
||||||
|
leaf11 = new Leaf(),
|
||||||
|
root = new Node({ children: [leaf1, leaf2, leaf3, leaf4, leaf5, leaf6, leaf7, leaf8, leaf9, leaf10, leaf11] }),
|
||||||
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
|
processor = new jasmineUnderTest.TreeProcessor({
|
||||||
|
tree: root,
|
||||||
|
runnableIds: [root.id],
|
||||||
|
queueRunnerFactory: queueRunner,
|
||||||
|
orderChildren: function(node) {
|
||||||
|
var children = node.children.slice();
|
||||||
|
return children.reverse();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
processor.execute();
|
||||||
|
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||||
|
expect(queueableFns.length).toBe(11);
|
||||||
|
|
||||||
|
queueableFns[0].fn();
|
||||||
|
expect(leaf11.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[1].fn();
|
||||||
|
expect(leaf10.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[2].fn();
|
||||||
|
expect(leaf9.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[3].fn();
|
||||||
|
expect(leaf8.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[4].fn();
|
||||||
|
expect(leaf7.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[5].fn();
|
||||||
|
expect(leaf6.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[6].fn();
|
||||||
|
expect(leaf5.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[7].fn();
|
||||||
|
expect(leaf4.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[8].fn();
|
||||||
|
expect(leaf3.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[9].fn();
|
||||||
|
expect(leaf2.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[10].fn();
|
||||||
|
expect(leaf1.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
describe("j$.util", function() {
|
describe("jasmineUnderTest.util", function() {
|
||||||
describe("isArray_", function() {
|
describe("isArray_", function() {
|
||||||
it("should return true if the argument is an array", function() {
|
it("should return true if the argument is an array", function() {
|
||||||
expect(j$.isArray_([])).toBe(true);
|
expect(jasmineUnderTest.isArray_([])).toBe(true);
|
||||||
expect(j$.isArray_(['a'])).toBe(true);
|
expect(jasmineUnderTest.isArray_(['a'])).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return false if the argument is not an array", function() {
|
it("should return false if the argument is not an array", function() {
|
||||||
expect(j$.isArray_(undefined)).toBe(false);
|
expect(jasmineUnderTest.isArray_(undefined)).toBe(false);
|
||||||
expect(j$.isArray_({})).toBe(false);
|
expect(jasmineUnderTest.isArray_({})).toBe(false);
|
||||||
expect(j$.isArray_(function() {})).toBe(false);
|
expect(jasmineUnderTest.isArray_(function() {})).toBe(false);
|
||||||
expect(j$.isArray_('foo')).toBe(false);
|
expect(jasmineUnderTest.isArray_('foo')).toBe(false);
|
||||||
expect(j$.isArray_(5)).toBe(false);
|
expect(jasmineUnderTest.isArray_(5)).toBe(false);
|
||||||
expect(j$.isArray_(null)).toBe(false);
|
expect(jasmineUnderTest.isArray_(null)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("isUndefined", function() {
|
describe("isUndefined", function() {
|
||||||
it("reports if a variable is defined", function() {
|
it("reports if a variable is defined", function() {
|
||||||
var a;
|
var a;
|
||||||
expect(j$.util.isUndefined(a)).toBe(true);
|
expect(jasmineUnderTest.util.isUndefined(a)).toBe(true);
|
||||||
expect(j$.util.isUndefined(undefined)).toBe(true);
|
expect(jasmineUnderTest.util.isUndefined(undefined)).toBe(true);
|
||||||
|
|
||||||
var undefined = "diz be undefined yo";
|
var undefined = "diz be undefined yo";
|
||||||
expect(j$.util.isUndefined(undefined)).toBe(false);
|
expect(jasmineUnderTest.util.isUndefined(undefined)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,45 +1,52 @@
|
|||||||
describe("Any", function() {
|
describe("Any", function() {
|
||||||
it("matches a string", function() {
|
it("matches a string", function() {
|
||||||
var any = new j$.Any(String);
|
var any = new jasmineUnderTest.Any(String);
|
||||||
|
|
||||||
expect(any.asymmetricMatch("foo")).toBe(true);
|
expect(any.asymmetricMatch("foo")).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("matches a number", function() {
|
it("matches a number", function() {
|
||||||
var any = new j$.Any(Number);
|
var any = new jasmineUnderTest.Any(Number);
|
||||||
|
|
||||||
expect(any.asymmetricMatch(1)).toBe(true);
|
expect(any.asymmetricMatch(1)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("matches a function", function() {
|
it("matches a function", function() {
|
||||||
var any = new j$.Any(Function);
|
var any = new jasmineUnderTest.Any(Function);
|
||||||
|
|
||||||
expect(any.asymmetricMatch(function(){})).toBe(true);
|
expect(any.asymmetricMatch(function(){})).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("matches an Object", function() {
|
it("matches an Object", function() {
|
||||||
var any = new j$.Any(Object);
|
var any = new jasmineUnderTest.Any(Object);
|
||||||
|
|
||||||
expect(any.asymmetricMatch({})).toBe(true);
|
expect(any.asymmetricMatch({})).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("matches a Boolean", function() {
|
it("matches a Boolean", function() {
|
||||||
var any = new j$.Any(Boolean);
|
var any = new jasmineUnderTest.Any(Boolean);
|
||||||
|
|
||||||
expect(any.asymmetricMatch(true)).toBe(true);
|
expect(any.asymmetricMatch(true)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("matches another constructed object", function() {
|
it("matches another constructed object", function() {
|
||||||
var Thing = function() {},
|
var Thing = function() {},
|
||||||
any = new j$.Any(Thing);
|
any = new jasmineUnderTest.Any(Thing);
|
||||||
|
|
||||||
expect(any.asymmetricMatch(new Thing())).toBe(true);
|
expect(any.asymmetricMatch(new Thing())).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("jasmineToString's itself", function() {
|
it("jasmineToString's itself", function() {
|
||||||
var any = new j$.Any(Number);
|
var any = new jasmineUnderTest.Any(Number);
|
||||||
|
|
||||||
expect(any.jasmineToString()).toEqual('<jasmine.any(Number)>');
|
expect(any.jasmineToString()).toEqual('<jasmine.any(Number)>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("when called without an argument", function() {
|
||||||
|
it("tells the user to pass a constructor or use jasmine.anything()", function() {
|
||||||
|
expect(function() {
|
||||||
|
new jasmineUnderTest.Any();
|
||||||
|
}).toThrowError(TypeError, /constructor.*anything/);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,43 +1,43 @@
|
|||||||
describe("Anything", function() {
|
describe("Anything", function() {
|
||||||
it("matches a string", function() {
|
it("matches a string", function() {
|
||||||
var anything = new j$.Anything();
|
var anything = new jasmineUnderTest.Anything();
|
||||||
|
|
||||||
expect(anything.asymmetricMatch('foo')).toBe(true);
|
expect(anything.asymmetricMatch('foo')).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("matches a number", function() {
|
it("matches a number", function() {
|
||||||
var anything = new j$.Anything();
|
var anything = new jasmineUnderTest.Anything();
|
||||||
|
|
||||||
expect(anything.asymmetricMatch(42)).toBe(true);
|
expect(anything.asymmetricMatch(42)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("matches an object", function() {
|
it("matches an object", function() {
|
||||||
var anything = new j$.Anything();
|
var anything = new jasmineUnderTest.Anything();
|
||||||
|
|
||||||
expect(anything.asymmetricMatch({ foo: 'bar' })).toBe(true);
|
expect(anything.asymmetricMatch({ foo: 'bar' })).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("matches an array", function() {
|
it("matches an array", function() {
|
||||||
var anything = new j$.Anything();
|
var anything = new jasmineUnderTest.Anything();
|
||||||
|
|
||||||
expect(anything.asymmetricMatch([1,2,3])).toBe(true);
|
expect(anything.asymmetricMatch([1,2,3])).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("doesn't match undefined", function() {
|
it("doesn't match undefined", function() {
|
||||||
var anything = new j$.Anything();
|
var anything = new jasmineUnderTest.Anything();
|
||||||
|
|
||||||
expect(anything.asymmetricMatch()).toBe(false);
|
expect(anything.asymmetricMatch()).toBe(false);
|
||||||
expect(anything.asymmetricMatch(undefined)).toBe(false);
|
expect(anything.asymmetricMatch(undefined)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("doesn't match null", function() {
|
it("doesn't match null", function() {
|
||||||
var anything = new j$.Anything();
|
var anything = new jasmineUnderTest.Anything();
|
||||||
|
|
||||||
expect(anything.asymmetricMatch(null)).toBe(false);
|
expect(anything.asymmetricMatch(null)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("jasmineToString's itself", function() {
|
it("jasmineToString's itself", function() {
|
||||||
var anything = new j$.Anything();
|
var anything = new jasmineUnderTest.Anything();
|
||||||
|
|
||||||
expect(anything.jasmineToString()).toEqual("<jasmine.anything>");
|
expect(anything.jasmineToString()).toEqual("<jasmine.anything>");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
describe("ArrayContaining", function() {
|
describe("ArrayContaining", function() {
|
||||||
it("matches any actual to an empty array", function() {
|
it("matches any actual to an empty array", function() {
|
||||||
var containing = new j$.ArrayContaining([]);
|
var containing = new jasmineUnderTest.ArrayContaining([]);
|
||||||
|
|
||||||
expect(containing.asymmetricMatch("foo")).toBe(true);
|
expect(containing.asymmetricMatch("foo")).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not work when not passed an array", function() {
|
it("does not work when not passed an array", function() {
|
||||||
var containing = new j$.ArrayContaining("foo");
|
var containing = new jasmineUnderTest.ArrayContaining("foo");
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
containing.asymmetricMatch([]);
|
containing.asymmetricMatch([]);
|
||||||
@@ -14,25 +14,25 @@ describe("ArrayContaining", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("matches when the item is in the actual", function() {
|
it("matches when the item is in the actual", function() {
|
||||||
var containing = new j$.ArrayContaining(["foo"]);
|
var containing = new jasmineUnderTest.ArrayContaining(["foo"]);
|
||||||
|
|
||||||
expect(containing.asymmetricMatch(["foo"])).toBe(true);
|
expect(containing.asymmetricMatch(["foo"])).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("matches when additional items are in the actual", function() {
|
it("matches when additional items are in the actual", function() {
|
||||||
var containing = new j$.ArrayContaining(["foo"]);
|
var containing = new jasmineUnderTest.ArrayContaining(["foo"]);
|
||||||
|
|
||||||
expect(containing.asymmetricMatch(["foo", "bar"])).toBe(true);
|
expect(containing.asymmetricMatch(["foo", "bar"])).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not match when the item is not in the actual", function() {
|
it("does not match when the item is not in the actual", function() {
|
||||||
var containing = new j$.ArrayContaining(["foo"]);
|
var containing = new jasmineUnderTest.ArrayContaining(["foo"]);
|
||||||
|
|
||||||
expect(containing.asymmetricMatch(["bar"])).toBe(false);
|
expect(containing.asymmetricMatch(["bar"])).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("jasmineToStrings itself", function() {
|
it("jasmineToStrings itself", function() {
|
||||||
var containing = new j$.ArrayContaining([]);
|
var containing = new jasmineUnderTest.ArrayContaining([]);
|
||||||
|
|
||||||
expect(containing.jasmineToString()).toMatch("<jasmine.arrayContaining");
|
expect(containing.jasmineToString()).toMatch("<jasmine.arrayContaining");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
describe("ObjectContaining", function() {
|
describe("ObjectContaining", function() {
|
||||||
|
|
||||||
it("matches any actual to an empty object", function() {
|
it("matches any actual to an empty object", function() {
|
||||||
var containing = new j$.ObjectContaining({});
|
var containing = new jasmineUnderTest.ObjectContaining({});
|
||||||
|
|
||||||
expect(containing.asymmetricMatch("foo")).toBe(true);
|
expect(containing.asymmetricMatch("foo")).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not match an empty object actual", function() {
|
it("does not match an empty object actual", function() {
|
||||||
var containing = new j$.ObjectContaining("foo");
|
var containing = new jasmineUnderTest.ObjectContaining("foo");
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
containing.asymmetricMatch({})
|
containing.asymmetricMatch({})
|
||||||
@@ -15,43 +15,43 @@ describe("ObjectContaining", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("matches when the key/value pair is present in the actual", function() {
|
it("matches when the key/value pair is present in the actual", function() {
|
||||||
var containing = new j$.ObjectContaining({foo: "fooVal"});
|
var containing = new jasmineUnderTest.ObjectContaining({foo: "fooVal"});
|
||||||
|
|
||||||
expect(containing.asymmetricMatch({foo: "fooVal", bar: "barVal"})).toBe(true);
|
expect(containing.asymmetricMatch({foo: "fooVal", bar: "barVal"})).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not match when the key/value pair is not present in the actual", function() {
|
it("does not match when the key/value pair is not present in the actual", function() {
|
||||||
var containing = new j$.ObjectContaining({foo: "fooVal"});
|
var containing = new jasmineUnderTest.ObjectContaining({foo: "fooVal"});
|
||||||
|
|
||||||
expect(containing.asymmetricMatch({bar: "barVal", quux: "quuxVal"})).toBe(false);
|
expect(containing.asymmetricMatch({bar: "barVal", quux: "quuxVal"})).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not match when the key is present but the value is different in the actual", function() {
|
it("does not match when the key is present but the value is different in the actual", function() {
|
||||||
var containing = new j$.ObjectContaining({foo: "other"});
|
var containing = new jasmineUnderTest.ObjectContaining({foo: "other"});
|
||||||
|
|
||||||
expect(containing.asymmetricMatch({foo: "fooVal", bar: "barVal"})).toBe(false);
|
expect(containing.asymmetricMatch({foo: "fooVal", bar: "barVal"})).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("jasmineToString's itself", function() {
|
it("jasmineToString's itself", function() {
|
||||||
var containing = new j$.ObjectContaining({});
|
var containing = new jasmineUnderTest.ObjectContaining({});
|
||||||
|
|
||||||
expect(containing.jasmineToString()).toMatch("<jasmine.objectContaining");
|
expect(containing.jasmineToString()).toMatch("<jasmine.objectContaining");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("matches recursively", function() {
|
it("matches recursively", function() {
|
||||||
var containing = new j$.ObjectContaining({one: new j$.ObjectContaining({two: {}})});
|
var containing = new jasmineUnderTest.ObjectContaining({one: new jasmineUnderTest.ObjectContaining({two: {}})});
|
||||||
|
|
||||||
expect(containing.asymmetricMatch({one: {two: {}}})).toBe(true);
|
expect(containing.asymmetricMatch({one: {two: {}}})).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("matches when key is present with undefined value", function() {
|
it("matches when key is present with undefined value", function() {
|
||||||
var containing = new j$.ObjectContaining({ one: undefined });
|
var containing = new jasmineUnderTest.ObjectContaining({ one: undefined });
|
||||||
|
|
||||||
expect(containing.asymmetricMatch({ one: undefined })).toBe(true);
|
expect(containing.asymmetricMatch({ one: undefined })).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not match when key with undefined value is not present", function() {
|
it("does not match when key with undefined value is not present", function() {
|
||||||
var containing = new j$.ObjectContaining({ one: undefined });
|
var containing = new jasmineUnderTest.ObjectContaining({ one: undefined });
|
||||||
|
|
||||||
expect(containing.asymmetricMatch({})).toBe(false);
|
expect(containing.asymmetricMatch({})).toBe(false);
|
||||||
});
|
});
|
||||||
@@ -60,7 +60,7 @@ describe("ObjectContaining", function() {
|
|||||||
// IE 8 doesn't support `definePropery` on non-DOM nodes
|
// IE 8 doesn't support `definePropery` on non-DOM nodes
|
||||||
if (jasmine.getEnv().ieVersion < 9) { return; }
|
if (jasmine.getEnv().ieVersion < 9) { return; }
|
||||||
|
|
||||||
var containing = new j$.ObjectContaining({ foo: "fooVal" });
|
var containing = new jasmineUnderTest.ObjectContaining({ foo: "fooVal" });
|
||||||
|
|
||||||
var definedPropertyObject = {};
|
var definedPropertyObject = {};
|
||||||
Object.defineProperty(definedPropertyObject, "foo", {
|
Object.defineProperty(definedPropertyObject, "foo", {
|
||||||
@@ -70,7 +70,7 @@ describe("ObjectContaining", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("matches prototype properties", function(){
|
it("matches prototype properties", function(){
|
||||||
var containing = new j$.ObjectContaining({ foo: "fooVal" });
|
var containing = new jasmineUnderTest.ObjectContaining({ foo: "fooVal" });
|
||||||
|
|
||||||
var prototypeObject = {foo: "fooVal"};
|
var prototypeObject = {foo: "fooVal"};
|
||||||
var obj;
|
var obj;
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
describe("StringMatching", function() {
|
describe("StringMatching", function() {
|
||||||
it("matches a string against a provided regexp", function() {
|
it("matches a string against a provided regexp", function() {
|
||||||
var matcher = new j$.StringMatching(/foo/);
|
var matcher = new jasmineUnderTest.StringMatching(/foo/);
|
||||||
|
|
||||||
expect(matcher.asymmetricMatch('barfoobaz')).toBe(true);
|
expect(matcher.asymmetricMatch('barfoobaz')).toBe(true);
|
||||||
expect(matcher.asymmetricMatch('barbaz')).toBe(false);
|
expect(matcher.asymmetricMatch('barbaz')).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("matches a string against provided string", function() {
|
it("matches a string against provided string", function() {
|
||||||
var matcher = new j$.StringMatching('foo');
|
var matcher = new jasmineUnderTest.StringMatching('foo');
|
||||||
|
|
||||||
expect(matcher.asymmetricMatch('barfoobaz')).toBe(true);
|
expect(matcher.asymmetricMatch('barfoobaz')).toBe(true);
|
||||||
expect(matcher.asymmetricMatch('barbaz')).toBe(false);
|
expect(matcher.asymmetricMatch('barbaz')).toBe(false);
|
||||||
@@ -15,12 +15,12 @@ describe("StringMatching", function() {
|
|||||||
|
|
||||||
it("raises an Error when the expected is not a String or RegExp", function() {
|
it("raises an Error when the expected is not a String or RegExp", function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
new j$.StringMatching({});
|
new jasmineUnderTest.StringMatching({});
|
||||||
}).toThrowError(/not a String or a RegExp/);
|
}).toThrowError(/not a String or a RegExp/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("jasmineToString's itself", function() {
|
it("jasmineToString's itself", function() {
|
||||||
var matching = new j$.StringMatching(/^foo/);
|
var matching = new jasmineUnderTest.StringMatching(/^foo/);
|
||||||
|
|
||||||
expect(matching.jasmineToString()).toEqual("<jasmine.stringMatching(/^foo/)>");
|
expect(matching.jasmineToString()).toEqual("<jasmine.stringMatching(/^foo/)>");
|
||||||
});
|
});
|
||||||
|
|||||||
13
spec/core/formatErrorMsgSpec.js
Normal file
13
spec/core/formatErrorMsgSpec.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
describe('formatErrorMsg', function () {
|
||||||
|
it('should format an error with a domain', function() {
|
||||||
|
var formator = jasmineUnderTest.formatErrorMsg('api');
|
||||||
|
expect(formator('message')).toBe('api : message');
|
||||||
|
expect(formator('message2')).toBe('api : message2');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should format an error with a domain and usage', function() {
|
||||||
|
var formator = jasmineUnderTest.formatErrorMsg('api', 'with a param');
|
||||||
|
expect(formator('message')).toBe('api : message\nUsage: with a param');
|
||||||
|
expect(formator('message2')).toBe('api : message2\nUsage: with a param');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -3,7 +3,7 @@ describe("Custom Matchers (Integration)", function() {
|
|||||||
var fakeTimer;
|
var fakeTimer;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
env = new j$.Env();
|
env = new jasmineUnderTest.Env();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows adding more matchers local to a spec", function(done) {
|
it("allows adding more matchers local to a spec", function(done) {
|
||||||
@@ -142,7 +142,7 @@ describe("Custom Matchers (Integration)", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var specExpectations = function() {
|
var specExpectations = function() {
|
||||||
expect(argumentSpy).toHaveBeenCalledWith(j$.matchersUtil, [customEqualityFn]);
|
expect(argumentSpy).toHaveBeenCalledWith(jasmineUnderTest.matchersUtil, [customEqualityFn]);
|
||||||
};
|
};
|
||||||
|
|
||||||
env.addReporter({ specDone: specExpectations, jasmineDone: done });
|
env.addReporter({ specDone: specExpectations, jasmineDone: done });
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("Suites execute as expected (no nesting)", function(done) {
|
it("Suites execute as expected (no nesting)", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
calls = [];
|
calls = [];
|
||||||
|
|
||||||
var assertions = function() {
|
var assertions = function() {
|
||||||
@@ -68,7 +68,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("Nested Suites execute as expected", function(done) {
|
it("Nested Suites execute as expected", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
calls = [];
|
calls = [];
|
||||||
|
|
||||||
var assertions = function() {
|
var assertions = function() {
|
||||||
@@ -101,7 +101,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("Multiple top-level Suites execute as expected", function(done) {
|
it("Multiple top-level Suites execute as expected", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
calls = [];
|
calls = [];
|
||||||
|
|
||||||
var assertions = function() {
|
var assertions = function() {
|
||||||
@@ -142,7 +142,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('explicitly fails a spec', function(done) {
|
it('explicitly fails a spec', function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
specDone = jasmine.createSpy('specDone');
|
specDone = jasmine.createSpy('specDone');
|
||||||
|
|
||||||
env.addReporter({
|
env.addReporter({
|
||||||
@@ -204,10 +204,9 @@ describe("Env integration", function() {
|
|||||||
|
|
||||||
|
|
||||||
it("calls associated befores/specs/afters with the same 'this'", function(done) {
|
it("calls associated befores/specs/afters with the same 'this'", function(done) {
|
||||||
var env = new j$.Env();
|
var env = new jasmineUnderTest.Env();
|
||||||
|
|
||||||
env.addReporter({jasmineDone: done});
|
env.addReporter({jasmineDone: done});
|
||||||
|
|
||||||
env.describe("tests", function() {
|
env.describe("tests", function() {
|
||||||
var firstTimeThrough = true, firstSpecContext, secondSpecContext;
|
var firstTimeThrough = true, firstSpecContext, secondSpecContext;
|
||||||
|
|
||||||
@@ -242,7 +241,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("calls associated befores/its/afters with the same 'this' for an async spec", function(done) {
|
it("calls associated befores/its/afters with the same 'this' for an async spec", function(done) {
|
||||||
var env = new j$.Env();
|
var env = new jasmineUnderTest.Env();
|
||||||
|
|
||||||
env.addReporter({jasmineDone: done});
|
env.addReporter({jasmineDone: done});
|
||||||
|
|
||||||
@@ -268,7 +267,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("calls associated beforeAlls/afterAlls only once per suite", function(done) {
|
it("calls associated beforeAlls/afterAlls only once per suite", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
before = jasmine.createSpy('beforeAll'),
|
before = jasmine.createSpy('beforeAll'),
|
||||||
after = jasmine.createSpy('afterAll');
|
after = jasmine.createSpy('afterAll');
|
||||||
|
|
||||||
@@ -300,7 +299,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("calls associated beforeAlls/afterAlls only once per suite for async", function(done) {
|
it("calls associated beforeAlls/afterAlls only once per suite for async", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
before = jasmine.createSpy('beforeAll'),
|
before = jasmine.createSpy('beforeAll'),
|
||||||
after = jasmine.createSpy('afterAll');
|
after = jasmine.createSpy('afterAll');
|
||||||
|
|
||||||
@@ -339,7 +338,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("calls associated beforeAlls/afterAlls with the cascaded 'this'", function(done) {
|
it("calls associated beforeAlls/afterAlls with the cascaded 'this'", function(done) {
|
||||||
var env = new j$.Env();
|
var env = new jasmineUnderTest.Env();
|
||||||
|
|
||||||
env.addReporter({jasmineDone: done});
|
env.addReporter({jasmineDone: done});
|
||||||
|
|
||||||
@@ -393,7 +392,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails all underlying specs when the beforeAll fails", function (done) {
|
it("fails all underlying specs when the beforeAll fails", function (done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone" ]);
|
reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone" ]);
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
@@ -432,7 +431,7 @@ describe("Env integration", function() {
|
|||||||
|
|
||||||
describe('suiteDone reporting', function(){
|
describe('suiteDone reporting', function(){
|
||||||
it("reports when an afterAll fails an expectation", function(done) {
|
it("reports when an afterAll fails an expectation", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
@@ -459,35 +458,35 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("if there are no specs, it still reports correctly", function(done) {
|
it("if there are no specs, it still reports correctly", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
expect(reporter.suiteDone).toHaveFailedExpecationsForRunnable('outer suite', [
|
expect(reporter.suiteDone).toHaveFailedExpecationsForRunnable('outer suite', [
|
||||||
'Expected 1 to equal 2.',
|
'Expected 1 to equal 2.',
|
||||||
'Expected 2 to equal 3.'
|
'Expected 2 to equal 3.'
|
||||||
]);
|
]);
|
||||||
done();
|
done();
|
||||||
});
|
|
||||||
|
|
||||||
env.addReporter(reporter);
|
|
||||||
|
|
||||||
env.describe('outer suite', function() {
|
|
||||||
env.describe('inner suite', function() {
|
|
||||||
env.it('spec', function(){ });
|
|
||||||
});
|
|
||||||
|
|
||||||
env.afterAll(function() {
|
|
||||||
env.expect(1).toEqual(2);
|
|
||||||
env.expect(2).toEqual(3);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
env.execute();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
|
||||||
|
env.describe('outer suite', function() {
|
||||||
|
env.describe('inner suite', function() {
|
||||||
|
env.it('spec', function(){ });
|
||||||
|
});
|
||||||
|
|
||||||
|
env.afterAll(function() {
|
||||||
|
env.expect(1).toEqual(2);
|
||||||
|
env.expect(2).toEqual(3);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
|
||||||
it("reports when afterAll throws an exception", function(done) {
|
it("reports when afterAll throws an exception", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
error = new Error('After All Exception'),
|
error = new Error('After All Exception'),
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
||||||
|
|
||||||
@@ -513,7 +512,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("reports when an async afterAll fails an expectation", function(done) {
|
it("reports when an async afterAll fails an expectation", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
@@ -539,7 +538,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("reports when an async afterAll throws an exception", function(done) {
|
it("reports when an async afterAll throws an exception", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
error = new Error('After All Exception'),
|
error = new Error('After All Exception'),
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
||||||
|
|
||||||
@@ -566,8 +565,55 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('cascades expecatation failures in global beforeAll down to children', function(done) {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
reporter = jasmine.createSpyObj(['specDone', 'jasmineDone']);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function(results) {
|
||||||
|
expect(results.failedExpectations).toEqual([]);
|
||||||
|
expect(reporter.specDone).toHaveFailedExpecationsForRunnable('is a spec', [
|
||||||
|
'Expected 1 to be 0.'
|
||||||
|
]);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.beforeAll(function() {
|
||||||
|
env.expect(1).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
env.it('is a spec', function() {
|
||||||
|
env.expect(true).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reports expectation failures in global afterAll', function(done) {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
reporter = jasmine.createSpyObj(['jasmineDone']);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function(results) {
|
||||||
|
expect(results.failedExpectations).toEqual([jasmine.objectContaining({ message: 'Expected 1 to be 0.' })]);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.afterAll(function() {
|
||||||
|
env.expect(1).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
env.it('is a spec', function() {
|
||||||
|
env.expect(true).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
|
||||||
it("Allows specifying which specs and suites to run", function(done) {
|
it("Allows specifying which specs and suites to run", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
calls = [],
|
calls = [],
|
||||||
suiteCallback = jasmine.createSpy('suite callback'),
|
suiteCallback = jasmine.createSpy('suite callback'),
|
||||||
firstSpec,
|
firstSpec,
|
||||||
@@ -603,7 +649,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('runs before and after all functions for runnables provided to .execute()', function(done) {
|
it('runs before and after all functions for runnables provided to .execute()', function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
calls = [],
|
calls = [],
|
||||||
first_spec,
|
first_spec,
|
||||||
second_spec;
|
second_spec;
|
||||||
@@ -639,7 +685,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("Functions can be spied on and have their calls tracked", function (done) {
|
it("Functions can be spied on and have their calls tracked", function (done) {
|
||||||
var env = new j$.Env();
|
var env = new jasmineUnderTest.Env();
|
||||||
|
|
||||||
var originalFunctionWasCalled = false;
|
var originalFunctionWasCalled = false;
|
||||||
var subject = {
|
var subject = {
|
||||||
@@ -678,8 +724,33 @@ describe("Env integration", function() {
|
|||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can be configured to allow respying on functions', function () {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
foo = {
|
||||||
|
bar: function () {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
env.allowRespy(true);
|
||||||
|
|
||||||
|
env.describe('test suite', function(){
|
||||||
|
env.it('spec 0', function(){
|
||||||
|
env.spyOn(foo,'bar');
|
||||||
|
|
||||||
|
var error = null;
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
|
env.spyOn(foo, 'bar');
|
||||||
|
}).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
|
||||||
it('removes all spies added in a spec after the spec is complete', function(done) {
|
it('removes all spies added in a spec after the spec is complete', function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
originalFoo = function() {},
|
originalFoo = function() {},
|
||||||
testObj = {
|
testObj = {
|
||||||
foo: originalFoo
|
foo: originalFoo
|
||||||
@@ -707,7 +778,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('removes all spies added in a suite after the suite is complete', function(done) {
|
it('removes all spies added in a suite after the suite is complete', function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
originalFoo = function() {},
|
originalFoo = function() {},
|
||||||
testObj = {
|
testObj = {
|
||||||
foo: originalFoo
|
foo: originalFoo
|
||||||
@@ -717,17 +788,17 @@ describe("Env integration", function() {
|
|||||||
env.beforeAll(function() { env.spyOn(testObj, 'foo');})
|
env.beforeAll(function() { env.spyOn(testObj, 'foo');})
|
||||||
|
|
||||||
env.it('spec 0', function() {
|
env.it('spec 0', function() {
|
||||||
expect(j$.isSpy(testObj.foo)).toBe(true);
|
expect(jasmineUnderTest.isSpy(testObj.foo)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
env.it('spec 1', function() {
|
env.it('spec 1', function() {
|
||||||
expect(j$.isSpy(testObj.foo)).toBe(true);
|
expect(jasmineUnderTest.isSpy(testObj.foo)).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.describe('another suite', function() {
|
env.describe('another suite', function() {
|
||||||
env.it('spec 2', function() {
|
env.it('spec 2', function() {
|
||||||
expect(j$.isSpy(testObj.foo)).toBe(false);
|
expect(jasmineUnderTest.isSpy(testObj.foo)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -736,11 +807,36 @@ describe("Env integration", function() {
|
|||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('removes a spy from the top suite after the run is complete', function(done) {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
originalFoo = function() {},
|
||||||
|
testObj = {
|
||||||
|
foo: originalFoo
|
||||||
|
};
|
||||||
|
|
||||||
|
env.beforeAll(function() {
|
||||||
|
env.spyOn(testObj, 'foo');
|
||||||
|
});
|
||||||
|
|
||||||
|
env.it('spec', function() {
|
||||||
|
expect(jasmineUnderTest.isSpy(testObj.foo)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter({
|
||||||
|
jasmineDone: function() {
|
||||||
|
expect(jasmineUnderTest.isSpy(testObj.foo)).toBe(false);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
|
||||||
it("Mock clock can be installed and used in tests", function(done) {
|
it("Mock clock can be installed and used in tests", function(done) {
|
||||||
var globalSetTimeout = jasmine.createSpy('globalSetTimeout'),
|
var globalSetTimeout = jasmine.createSpy('globalSetTimeout'),
|
||||||
delayedFunctionForGlobalClock = jasmine.createSpy('delayedFunctionForGlobalClock'),
|
delayedFunctionForGlobalClock = jasmine.createSpy('delayedFunctionForGlobalClock'),
|
||||||
delayedFunctionForMockClock = jasmine.createSpy('delayedFunctionForMockClock'),
|
delayedFunctionForMockClock = jasmine.createSpy('delayedFunctionForMockClock'),
|
||||||
env = new j$.Env({global: { setTimeout: globalSetTimeout }});
|
env = new jasmineUnderTest.Env({global: { setTimeout: globalSetTimeout }});
|
||||||
|
|
||||||
var assertions = function() {
|
var assertions = function() {
|
||||||
expect(delayedFunctionForMockClock).toHaveBeenCalled();
|
expect(delayedFunctionForMockClock).toHaveBeenCalled();
|
||||||
@@ -770,7 +866,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should run async specs in order, waiting for them to complete", function(done) {
|
it("should run async specs in order, waiting for them to complete", function(done) {
|
||||||
var env = new j$.Env(), mutatedVar;
|
var env = new jasmineUnderTest.Env(), mutatedVar;
|
||||||
|
|
||||||
env.describe("tests", function() {
|
env.describe("tests", function() {
|
||||||
env.beforeEach(function() {
|
env.beforeEach(function() {
|
||||||
@@ -797,17 +893,17 @@ describe("Env integration", function() {
|
|||||||
var originalTimeout;
|
var originalTimeout;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
originalTimeout = j$.DEFAULT_TIMEOUT_INTERVAL;
|
originalTimeout = jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL;
|
||||||
jasmine.clock().install();
|
jasmine.clock().install();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
jasmine.clock().uninstall();
|
jasmine.clock().uninstall();
|
||||||
j$.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should wait a specified interval before failing specs haven't called done yet", function(done) {
|
it("should wait a specified interval before failing specs haven't called done yet", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone" ]);
|
reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone" ]);
|
||||||
|
|
||||||
reporter.specDone.and.callFake(function() {
|
reporter.specDone.and.callFake(function() {
|
||||||
@@ -820,7 +916,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
j$.DEFAULT_TIMEOUT_INTERVAL = 8414;
|
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = 8414;
|
||||||
|
|
||||||
env.it("async spec that doesn't call done", function(underTestCallback) {
|
env.it("async spec that doesn't call done", function(underTestCallback) {
|
||||||
env.expect(true).toBeTruthy();
|
env.expect(true).toBeTruthy();
|
||||||
@@ -831,7 +927,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should wait a specified interval before failing beforeAll's and their associated specs that haven't called done", function(done) {
|
it("should wait a specified interval before failing beforeAll's and their associated specs that haven't called done", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone" ]);
|
reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone" ]);
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
@@ -842,7 +938,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
j$.DEFAULT_TIMEOUT_INTERVAL = 1290;
|
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = 1290;
|
||||||
|
|
||||||
env.beforeAll(function(done) {
|
env.beforeAll(function(done) {
|
||||||
jasmine.clock().tick(1290);
|
jasmine.clock().tick(1290);
|
||||||
@@ -860,7 +956,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should not use the mock clock for asynchronous timeouts", function(){
|
it("should not use the mock clock for asynchronous timeouts", function(){
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone" ]),
|
reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone" ]),
|
||||||
clock = env.clock;
|
clock = env.clock;
|
||||||
|
|
||||||
@@ -870,7 +966,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
j$.DEFAULT_TIMEOUT_INTERVAL = 5;
|
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = 5;
|
||||||
|
|
||||||
env.beforeAll(function() {
|
env.beforeAll(function() {
|
||||||
clock.install();
|
clock.install();
|
||||||
@@ -890,7 +986,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should wait the specified interval before reporting an afterAll that fails to call done", function(done) {
|
it("should wait the specified interval before reporting an afterAll that fails to call done", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
@@ -901,7 +997,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
j$.DEFAULT_TIMEOUT_INTERVAL = 3000;
|
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = 3000;
|
||||||
|
|
||||||
env.describe('my suite', function() {
|
env.describe('my suite', function() {
|
||||||
env.it('my spec', function() {
|
env.it('my spec', function() {
|
||||||
@@ -917,7 +1013,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should wait a custom interval before reporting async functions that fail to call done', function(done) {
|
it('should wait a custom interval before reporting async functions that fail to call done', function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone', 'suiteDone', 'specDone']);
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
@@ -945,7 +1041,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
j$.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||||
|
|
||||||
env.describe('suite', function() {
|
env.describe('suite', function() {
|
||||||
env.describe('beforeAll', function() {
|
env.describe('beforeAll', function() {
|
||||||
@@ -994,7 +1090,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('explicitly fails an async spec', function(done) {
|
it('explicitly fails an async spec', function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
specDone = jasmine.createSpy('specDone');
|
specDone = jasmine.createSpy('specDone');
|
||||||
|
|
||||||
env.addReporter({
|
env.addReporter({
|
||||||
@@ -1067,7 +1163,7 @@ describe("Env integration", function() {
|
|||||||
|
|
||||||
describe('focused tests', function() {
|
describe('focused tests', function() {
|
||||||
it('should only run the focused tests', function(done) {
|
it('should only run the focused tests', function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
calls = [];
|
calls = [];
|
||||||
|
|
||||||
var assertions = function() {
|
var assertions = function() {
|
||||||
@@ -1091,7 +1187,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should only run focused suites', function(){
|
it('should only run focused suites', function(){
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
calls = [];
|
calls = [];
|
||||||
|
|
||||||
var assertions = function() {
|
var assertions = function() {
|
||||||
@@ -1115,10 +1211,82 @@ describe("Env integration", function() {
|
|||||||
|
|
||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should run focused tests inside an xdescribe', function(done) {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||||
|
"jasmineStarted",
|
||||||
|
"jasmineDone",
|
||||||
|
"suiteStarted",
|
||||||
|
"suiteDone",
|
||||||
|
"specStarted",
|
||||||
|
"specDone"
|
||||||
|
]);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
|
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
||||||
|
totalSpecsDefined: 1
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
|
description: 'with a fit spec',
|
||||||
|
status: 'failed'
|
||||||
|
}));
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
|
||||||
|
env.xdescribe("xd suite", function() {
|
||||||
|
env.fit("with a fit spec", function() {
|
||||||
|
env.expect(true).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should run focused suites inside an xdescribe', function(done) {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||||
|
"jasmineStarted",
|
||||||
|
"jasmineDone",
|
||||||
|
"suiteStarted",
|
||||||
|
"suiteDone",
|
||||||
|
"specStarted",
|
||||||
|
"specDone"
|
||||||
|
]);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
|
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
||||||
|
totalSpecsDefined: 1
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
|
description: 'with a spec',
|
||||||
|
status: 'failed'
|
||||||
|
}));
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
|
||||||
|
env.xdescribe("xd suite", function() {
|
||||||
|
env.fdescribe("fd suite", function() {
|
||||||
|
env.it("with a spec", function() {
|
||||||
|
env.expect(true).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should report as expected", function(done) {
|
it("should report as expected", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
reporter = jasmine.createSpyObj('fakeReporter', [
|
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||||
"jasmineStarted",
|
"jasmineStarted",
|
||||||
"jasmineDone",
|
"jasmineDone",
|
||||||
@@ -1188,7 +1356,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should report pending spec messages', function(done) {
|
it('should report pending spec messages', function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
reporter = jasmine.createSpyObj('fakeReporter', [
|
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||||
'specDone',
|
'specDone',
|
||||||
'jasmineDone'
|
'jasmineDone'
|
||||||
@@ -1211,8 +1379,30 @@ describe("Env integration", function() {
|
|||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should report using fallback reporter', function(done) {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||||
|
'specDone',
|
||||||
|
'jasmineDone'
|
||||||
|
]);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
|
expect(reporter.specDone).toHaveBeenCalled();
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.provideFallbackReporter(reporter);
|
||||||
|
|
||||||
|
env.it('will be pending', function() {
|
||||||
|
env.pending('with a message');
|
||||||
|
});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
|
||||||
it('should report xdescribes as expected', function(done) {
|
it('should report xdescribes as expected', function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
reporter = jasmine.createSpyObj('fakeReporter', [
|
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||||
"jasmineStarted",
|
"jasmineStarted",
|
||||||
"jasmineDone",
|
"jasmineDone",
|
||||||
@@ -1227,8 +1417,9 @@ describe("Env integration", function() {
|
|||||||
totalSpecsDefined: 1
|
totalSpecsDefined: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({ status: 'disabled' }));
|
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({ status: 'pending' }));
|
||||||
expect(reporter.suiteDone.calls.count()).toBe(3);
|
expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({ description: 'xd out', status: 'pending' }));
|
||||||
|
expect(reporter.suiteDone.calls.count()).toBe(4);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@@ -1238,8 +1429,10 @@ describe("Env integration", function() {
|
|||||||
env.describe("A Suite", function() {
|
env.describe("A Suite", function() {
|
||||||
env.describe("nested", function() {
|
env.describe("nested", function() {
|
||||||
env.xdescribe("xd out", function() {
|
env.xdescribe("xd out", function() {
|
||||||
env.it("with a spec", function() {
|
env.describe("nested again", function() {
|
||||||
env.expect(true).toBe(false);
|
env.it("with a spec", function() {
|
||||||
|
env.expect(true).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1249,7 +1442,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should be possible to get full name from a spec", function() {
|
it("should be possible to get full name from a spec", function() {
|
||||||
var env = new j$.Env({global: { setTimeout: setTimeout }}),
|
var env = new jasmineUnderTest.Env({global: { setTimeout: setTimeout }}),
|
||||||
topLevelSpec, nestedSpec, doublyNestedSpec;
|
topLevelSpec, nestedSpec, doublyNestedSpec;
|
||||||
|
|
||||||
env.describe("my tests", function() {
|
env.describe("my tests", function() {
|
||||||
@@ -1271,7 +1464,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("Custom equality testers should be per spec", function(done) {
|
it("Custom equality testers should be per spec", function(done) {
|
||||||
var env = new j$.Env({global: { setTimeout: setTimeout }}),
|
var env = new jasmineUnderTest.Env({global: { setTimeout: setTimeout }}),
|
||||||
reporter = jasmine.createSpyObj('fakeReporter', [
|
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||||
"jasmineDone",
|
"jasmineDone",
|
||||||
"specDone"
|
"specDone"
|
||||||
@@ -1304,7 +1497,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("Custom equality testers should be per suite", function(done) {
|
it("Custom equality testers should be per suite", function(done) {
|
||||||
var env = new j$.Env({global: { setTimeout: setTimeout }}),
|
var env = new jasmineUnderTest.Env({global: { setTimeout: setTimeout }}),
|
||||||
reporter = jasmine.createSpyObj('fakeReporter', [
|
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||||
"jasmineDone",
|
"jasmineDone",
|
||||||
"specDone"
|
"specDone"
|
||||||
@@ -1346,7 +1539,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("Custom equality testers for toContain should be per spec", function(done) {
|
it("Custom equality testers for toContain should be per spec", function(done) {
|
||||||
var env = new j$.Env({global: { setTimeout: setTimeout }}),
|
var env = new jasmineUnderTest.Env({global: { setTimeout: setTimeout }}),
|
||||||
reporter = jasmine.createSpyObj('fakeReporter', [
|
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||||
"jasmineDone",
|
"jasmineDone",
|
||||||
"specDone"
|
"specDone"
|
||||||
@@ -1379,7 +1572,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("produces an understandable error message when an 'expect' is used outside of a current spec", function(done) {
|
it("produces an understandable error message when an 'expect' is used outside of a current spec", function(done) {
|
||||||
var env = new j$.Env();
|
var env = new jasmineUnderTest.Env();
|
||||||
|
|
||||||
env.describe("A Suite", function() {
|
env.describe("A Suite", function() {
|
||||||
env.it("an async spec that is actually synchronous", function(underTestCallback) {
|
env.it("an async spec that is actually synchronous", function(underTestCallback) {
|
||||||
@@ -1393,7 +1586,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("Custom equality testers for toContain should be per suite", function(done) {
|
it("Custom equality testers for toContain should be per suite", function(done) {
|
||||||
var env = new j$.Env({global: { setTimeout: setTimeout }}),
|
var env = new jasmineUnderTest.Env({global: { setTimeout: setTimeout }}),
|
||||||
reporter = jasmine.createSpyObj('fakeReporter', [
|
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||||
"jasmineDone",
|
"jasmineDone",
|
||||||
"specDone"
|
"specDone"
|
||||||
@@ -1435,7 +1628,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("Custom matchers should be per spec", function(done) {
|
it("Custom matchers should be per spec", function(done) {
|
||||||
var env = new j$.Env({global: { setTimeout: setTimeout }}),
|
var env = new jasmineUnderTest.Env({global: { setTimeout: setTimeout }}),
|
||||||
matchers = {
|
matchers = {
|
||||||
toFoo: function() {}
|
toFoo: function() {}
|
||||||
};
|
};
|
||||||
@@ -1457,7 +1650,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("Custom matchers should be per suite", function(done) {
|
it("Custom matchers should be per suite", function(done) {
|
||||||
var env = new j$.Env({global: { setTimeout: setTimeout }}),
|
var env = new jasmineUnderTest.Env({global: { setTimeout: setTimeout }}),
|
||||||
matchers = {
|
matchers = {
|
||||||
toFoo: function() {}
|
toFoo: function() {}
|
||||||
};
|
};
|
||||||
@@ -1486,7 +1679,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('throws an exception if you try to create a spy outside of a runnable', function (done) {
|
it('throws an exception if you try to create a spy outside of a runnable', function (done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
obj = {fn: function () {}},
|
obj = {fn: function () {}},
|
||||||
exception;
|
exception;
|
||||||
|
|
||||||
@@ -1509,7 +1702,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('throws an exception if you try to add a matcher outside of a runnable', function (done) {
|
it('throws an exception if you try to add a matcher outside of a runnable', function (done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
obj = {fn: function () {}},
|
obj = {fn: function () {}},
|
||||||
exception;
|
exception;
|
||||||
|
|
||||||
@@ -1532,7 +1725,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('throws an exception if you try to add a custom equality outside of a runnable', function (done) {
|
it('throws an exception if you try to add a custom equality outside of a runnable', function (done) {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
obj = {fn: function () {}},
|
obj = {fn: function () {}},
|
||||||
exception;
|
exception;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ describe("jasmine spec running", function () {
|
|||||||
var env;
|
var env;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
env = new j$.Env();
|
env = new jasmineUnderTest.Env();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should assign spec ids sequentially', function() {
|
it('should assign spec ids sequentially', function() {
|
||||||
@@ -169,7 +169,7 @@ describe("jasmine spec running", function () {
|
|||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should run multiple befores and afters in the order they are declared", function(done) {
|
it("should run multiple befores and afters ordered so functions declared later are treated as more specific", function(done) {
|
||||||
var actions = [];
|
var actions = [];
|
||||||
|
|
||||||
env.beforeEach(function () {
|
env.beforeEach(function () {
|
||||||
@@ -556,15 +556,24 @@ describe("jasmine spec running", function () {
|
|||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: is this useful? It doesn't catch syntax errors
|
it("should recover gracefully when there are errors in describe functions", function(done) {
|
||||||
xit("should recover gracefully when there are errors in describe functions", function() {
|
var specs = [],
|
||||||
var specs = [];
|
reporter = jasmine.createSpyObj(['specDone', 'jasmineDone']);
|
||||||
var superSimpleReporter = new j$.Reporter();
|
|
||||||
superSimpleReporter.reportSpecResults = function(result) {
|
|
||||||
specs.push("Spec: " + result.fullName);
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
reporter.specDone.and.callFake(function(result) {
|
||||||
|
specs.push(result.fullName);
|
||||||
|
});
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
|
expect(specs).toContain('outer1 inner1 should thingy');
|
||||||
|
expect(specs).toContain('outer1 inner1 encountered a declaration exception');
|
||||||
|
expect(specs).toContain('outer1 inner2 should other thingy');
|
||||||
|
expect(specs).toContain('outer1 encountered a declaration exception');
|
||||||
|
expect(specs).toContain('outer2 should xxx');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
env.describe("outer1", function() {
|
env.describe("outer1", function() {
|
||||||
env.describe("inner1", function() {
|
env.describe("inner1", function() {
|
||||||
env.it("should thingy", function() {
|
env.it("should thingy", function() {
|
||||||
@@ -583,8 +592,7 @@ describe("jasmine spec running", function () {
|
|||||||
throw new Error("fake error");
|
throw new Error("fake error");
|
||||||
|
|
||||||
});
|
});
|
||||||
} catch(e) {
|
}).not.toThrow();
|
||||||
}
|
|
||||||
|
|
||||||
env.describe("outer2", function() {
|
env.describe("outer2", function() {
|
||||||
env.it("should xxx", function() {
|
env.it("should xxx", function() {
|
||||||
@@ -592,17 +600,8 @@ describe("jasmine spec running", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.addReporter(superSimpleReporter);
|
env.addReporter(reporter);
|
||||||
env.execute();
|
env.execute();
|
||||||
|
|
||||||
expect(specs.join('')).toMatch(new RegExp(
|
|
||||||
'Spec: outer1 inner1 should thingy.' +
|
|
||||||
'Spec: outer1 inner1 encountered a declaration exception.' +
|
|
||||||
'Spec: outer1 inner2 should other thingy.' +
|
|
||||||
'Spec: outer1 encountered a declaration exception.' +
|
|
||||||
'Spec: outer2 should xxx.'
|
|
||||||
));
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("re-enters suites that have no *Alls", function(done) {
|
it("re-enters suites that have no *Alls", function(done) {
|
||||||
@@ -696,4 +695,103 @@ describe("jasmine spec running", function () {
|
|||||||
env.execute([spec2.id, spec3.id, spec1.id]);
|
env.execute([spec2.id, spec3.id, spec1.id]);
|
||||||
}).toThrowError(/afterAll/);
|
}).toThrowError(/afterAll/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should run the tests in a consistent order when a seed is supplied", function(done) {
|
||||||
|
var actions = [];
|
||||||
|
env.randomizeTests(true);
|
||||||
|
env.seed('123456');
|
||||||
|
|
||||||
|
env.beforeEach(function () {
|
||||||
|
actions.push('topSuite beforeEach');
|
||||||
|
});
|
||||||
|
|
||||||
|
env.afterEach(function () {
|
||||||
|
actions.push('topSuite afterEach');
|
||||||
|
});
|
||||||
|
|
||||||
|
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');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var assertions = function() {
|
||||||
|
var expected = [
|
||||||
|
'topSuite beforeEach',
|
||||||
|
'outer beforeEach',
|
||||||
|
'outer it 2',
|
||||||
|
'outer afterEach',
|
||||||
|
'topSuite afterEach',
|
||||||
|
|
||||||
|
'topSuite beforeEach',
|
||||||
|
'outer beforeEach',
|
||||||
|
'inner 2 beforeEach',
|
||||||
|
'inner 2 it',
|
||||||
|
'inner 2 afterEach',
|
||||||
|
'outer afterEach',
|
||||||
|
'topSuite afterEach',
|
||||||
|
|
||||||
|
'topSuite beforeEach',
|
||||||
|
'outer beforeEach',
|
||||||
|
'inner 1 beforeEach',
|
||||||
|
'inner 1 it',
|
||||||
|
'inner 1 afterEach',
|
||||||
|
'outer afterEach',
|
||||||
|
'topSuite afterEach',
|
||||||
|
|
||||||
|
'topSuite beforeEach',
|
||||||
|
'outer beforeEach',
|
||||||
|
'outer it 1',
|
||||||
|
'outer afterEach',
|
||||||
|
'topSuite afterEach'
|
||||||
|
];
|
||||||
|
expect(actions).toEqual(expected);
|
||||||
|
done();
|
||||||
|
};
|
||||||
|
|
||||||
|
env.addReporter({jasmineDone: assertions});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,61 +1,68 @@
|
|||||||
describe("matchersUtil", function() {
|
describe("matchersUtil", function() {
|
||||||
describe("equals", function() {
|
describe("equals", function() {
|
||||||
it("passes for literals that are triple-equal", function() {
|
it("passes for literals that are triple-equal", function() {
|
||||||
expect(j$.matchersUtil.equals(null, null)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(null, null)).toBe(true);
|
||||||
expect(j$.matchersUtil.equals(void 0, void 0)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(void 0, void 0)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails for things that are not equivalent", function() {
|
it("fails for things that are not equivalent", function() {
|
||||||
expect(j$.matchersUtil.equals({a: "foo"}, 1)).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals({a: "foo"}, 1)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes for Strings that are equivalent", function() {
|
it("passes for Strings that are equivalent", function() {
|
||||||
expect(j$.matchersUtil.equals("foo", "foo")).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals("foo", "foo")).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails for Strings that are not equivalent", function() {
|
it("fails for Strings that are not equivalent", function() {
|
||||||
expect(j$.matchersUtil.equals("foo", "bar")).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals("foo", "bar")).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes for Numbers that are equivalent", function() {
|
it("passes for Numbers that are equivalent", function() {
|
||||||
expect(j$.matchersUtil.equals(123, 123)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(123, 123)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails for Numbers that are not equivalent", function() {
|
it("fails for Numbers that are not equivalent", function() {
|
||||||
expect(j$.matchersUtil.equals(123, 456)).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals(123, 456)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes for Dates that are equivalent", function() {
|
it("passes for Dates that are equivalent", function() {
|
||||||
expect(j$.matchersUtil.equals(new Date("Jan 1, 1970"), new Date("Jan 1, 1970"))).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(new Date("Jan 1, 1970"), new Date("Jan 1, 1970"))).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails for Dates that are not equivalent", function() {
|
it("fails for Dates that are not equivalent", function() {
|
||||||
expect(j$.matchersUtil.equals(new Date("Jan 1, 1970"), new Date("Feb 3, 1991"))).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals(new Date("Jan 1, 1970"), new Date("Feb 3, 1991"))).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes for Booleans that are equivalent", function() {
|
it("passes for Booleans that are equivalent", function() {
|
||||||
expect(j$.matchersUtil.equals(true, true)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(true, true)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails for Booleans that are not equivalent", function() {
|
it("fails for Booleans that are not equivalent", function() {
|
||||||
expect(j$.matchersUtil.equals(true, false)).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals(true, false)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes for RegExps that are equivalent", function() {
|
it("passes for RegExps that are equivalent", function() {
|
||||||
expect(j$.matchersUtil.equals(/foo/, /foo/)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(/foo/, /foo/)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails for RegExps that are not equivalent", function() {
|
it("fails for RegExps that are not equivalent", function() {
|
||||||
expect(j$.matchersUtil.equals(/foo/, /bar/)).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals(/foo/, /bar/)).toBe(false);
|
||||||
expect(j$.matchersUtil.equals(new RegExp("foo", "i"), new RegExp("foo"))).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals(new RegExp("foo", "i"), new RegExp("foo"))).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes for Arrays that are equivalent", function() {
|
it("passes for Arrays that are equivalent", function() {
|
||||||
expect(j$.matchersUtil.equals([1, 2], [1, 2])).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals([1, 2], [1, 2])).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("passes for Arrays that are equivalent, with elements added by changing length", function() {
|
||||||
|
var foo = [];
|
||||||
|
foo.length = 1;
|
||||||
|
|
||||||
|
expect(jasmineUnderTest.matchersUtil.equals(foo, [undefined])).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails for Arrays that are not equivalent", function() {
|
it("fails for Arrays that are not equivalent", function() {
|
||||||
expect(j$.matchersUtil.equals([1, 2], [1, 2, 3])).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals([1, 2], [1, 2, 3])).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails for Arrays whose contents are equivalent, but have differing properties", function() {
|
it("fails for Arrays whose contents are equivalent, but have differing properties", function() {
|
||||||
@@ -65,31 +72,48 @@ describe("matchersUtil", function() {
|
|||||||
one.foo = 'bar';
|
one.foo = 'bar';
|
||||||
two.foo = 'baz';
|
two.foo = 'baz';
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(one, two)).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals(one, two)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("passes for Arrays with equivalent contents and properties", function() {
|
||||||
|
var one = [1,2,3],
|
||||||
|
two = [1,2,3];
|
||||||
|
|
||||||
|
one.foo = 'bar';
|
||||||
|
two.foo = 'bar';
|
||||||
|
|
||||||
|
expect(jasmineUnderTest.matchersUtil.equals(one, two)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes for Errors that are the same type and have the same message", function() {
|
it("passes for Errors that are the same type and have the same message", function() {
|
||||||
expect(j$.matchersUtil.equals(new Error("foo"), new Error("foo"))).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(new Error("foo"), new Error("foo"))).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails for Errors that are the same type and have different messages", function() {
|
it("fails for Errors that are the same type and have different messages", function() {
|
||||||
expect(j$.matchersUtil.equals(new Error("foo"), new Error("bar"))).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals(new Error("foo"), new Error("bar"))).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("fails for objects with different constructors", function() {
|
||||||
|
function One() {}
|
||||||
|
function Two() {}
|
||||||
|
|
||||||
|
expect(jasmineUnderTest.matchersUtil.equals(new One(), new Two())).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes for Objects that are equivalent (simple case)", function() {
|
it("passes for Objects that are equivalent (simple case)", function() {
|
||||||
expect(j$.matchersUtil.equals({a: "foo"}, {a: "foo"})).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals({a: "foo"}, {a: "foo"})).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails for Objects that are not equivalent (simple case)", function() {
|
it("fails for Objects that are not equivalent (simple case)", function() {
|
||||||
expect(j$.matchersUtil.equals({a: "foo"}, {a: "bar"})).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals({a: "foo"}, {a: "bar"})).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes for Objects that are equivalent (deep case)", function() {
|
it("passes for Objects that are equivalent (deep case)", function() {
|
||||||
expect(j$.matchersUtil.equals({a: "foo", b: { c: "bar"}}, {a: "foo", b: { c: "bar"}})).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals({a: "foo", b: { c: "bar"}}, {a: "foo", b: { c: "bar"}})).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails for Objects that are not equivalent (deep case)", function() {
|
it("fails for Objects that are not equivalent (deep case)", function() {
|
||||||
expect(j$.matchersUtil.equals({a: "foo", b: { c: "baz"}}, {a: "foo", b: { c: "bar"}})).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals({a: "foo", b: { c: "baz"}}, {a: "foo", b: { c: "bar"}})).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes for Objects that are equivalent (with cycles)", function() {
|
it("passes for Objects that are equivalent (with cycles)", function() {
|
||||||
@@ -99,7 +123,7 @@ describe("matchersUtil", function() {
|
|||||||
actual.b = actual;
|
actual.b = actual;
|
||||||
expected.b = actual;
|
expected.b = actual;
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(actual, expected)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(actual, expected)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails for Objects that are not equivalent (with cycles)", function() {
|
it("fails for Objects that are not equivalent (with cycles)", function() {
|
||||||
@@ -109,15 +133,15 @@ describe("matchersUtil", function() {
|
|||||||
actual.b = actual;
|
actual.b = actual;
|
||||||
expected.b = actual;
|
expected.b = actual;
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(actual, expected)).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals(actual, expected)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails when comparing an empty object to an empty array (issue #114)", function() {
|
it("fails when comparing an empty object to an empty array (issue #114)", function() {
|
||||||
var emptyObject = {},
|
var emptyObject = {},
|
||||||
emptyArray = [];
|
emptyArray = [];
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(emptyObject, emptyArray)).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals(emptyObject, emptyArray)).toBe(false);
|
||||||
expect(j$.matchersUtil.equals(emptyArray, emptyObject)).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals(emptyArray, emptyObject)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes for equivalent frozen objects (GitHub issue #266)", function() {
|
it("passes for equivalent frozen objects (GitHub issue #266)", function() {
|
||||||
@@ -129,89 +153,115 @@ describe("matchersUtil", function() {
|
|||||||
Object.freeze(a);
|
Object.freeze(a);
|
||||||
Object.freeze(b);
|
Object.freeze(b);
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(a,b)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(a,b)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes for equivalent DOM nodes", function() {
|
describe("when running in a browser", function() {
|
||||||
if (typeof document === 'undefined') {
|
function isNotRunningInBrowser() {
|
||||||
return;
|
return typeof document === 'undefined'
|
||||||
}
|
}
|
||||||
var a = document.createElement("div");
|
|
||||||
a.setAttribute("test-attr", "attr-value")
|
|
||||||
a.appendChild(document.createTextNode('test'));
|
|
||||||
|
|
||||||
var b = document.createElement("div");
|
it("passes for equivalent DOM nodes", function() {
|
||||||
b.setAttribute("test-attr", "attr-value")
|
if (isNotRunningInBrowser()) {
|
||||||
b.appendChild(document.createTextNode('test'));
|
return;
|
||||||
|
}
|
||||||
|
var a = document.createElement("div");
|
||||||
|
a.setAttribute("test-attr", "attr-value");
|
||||||
|
a.appendChild(document.createTextNode('test'));
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(a,b)).toBe(true);
|
var b = document.createElement("div");
|
||||||
|
b.setAttribute("test-attr", "attr-value");
|
||||||
|
b.appendChild(document.createTextNode('test'));
|
||||||
|
|
||||||
|
expect(jasmineUnderTest.matchersUtil.equals(a,b)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("passes for equivalent objects from different frames", function() {
|
||||||
|
if (isNotRunningInBrowser()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// iframe.contentWindow.eval isn't supported in ie8
|
||||||
|
if (jasmine.getEnv().ieVersion < 9) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var iframe = document.createElement('iframe');
|
||||||
|
document.body.appendChild(iframe);
|
||||||
|
iframe.contentWindow.eval('window.testObject = {}');
|
||||||
|
expect(jasmineUnderTest.matchersUtil.equals({}, iframe.contentWindow.testObject)).toBe(true);
|
||||||
|
document.body.removeChild(iframe);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("fails for DOM nodes with different attributes or child nodes", function() {
|
||||||
|
if (isNotRunningInBrowser()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var a = document.createElement("div");
|
||||||
|
a.setAttribute("test-attr", "attr-value")
|
||||||
|
a.appendChild(document.createTextNode('test'));
|
||||||
|
|
||||||
|
var b = document.createElement("div");
|
||||||
|
b.setAttribute("test-attr", "attr-value2")
|
||||||
|
b.appendChild(document.createTextNode('test'));
|
||||||
|
|
||||||
|
expect(jasmineUnderTest.matchersUtil.equals(a,b)).toBe(false);
|
||||||
|
|
||||||
|
b.setAttribute("test-attr", "attr-value");
|
||||||
|
expect(jasmineUnderTest.matchersUtil.equals(a,b)).toBe(true);
|
||||||
|
|
||||||
|
b.appendChild(document.createTextNode('2'));
|
||||||
|
expect(jasmineUnderTest.matchersUtil.equals(a,b)).toBe(false);
|
||||||
|
|
||||||
|
a.appendChild(document.createTextNode('2'));
|
||||||
|
expect(jasmineUnderTest.matchersUtil.equals(a,b)).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails for DOM nodes with different attributes or child nodes", function() {
|
describe("when running in Node", function() {
|
||||||
if (typeof document === 'undefined') {
|
function isNotRunningInNode() {
|
||||||
return;
|
return typeof require !== 'function'
|
||||||
}
|
|
||||||
var a = document.createElement("div");
|
|
||||||
a.setAttribute("test-attr", "attr-value")
|
|
||||||
a.appendChild(document.createTextNode('test'));
|
|
||||||
|
|
||||||
var b = document.createElement("div");
|
|
||||||
b.setAttribute("test-attr", "attr-value2")
|
|
||||||
b.appendChild(document.createTextNode('test'));
|
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(a,b)).toBe(false);
|
|
||||||
|
|
||||||
b.setAttribute("test-attr", "attr-value");
|
|
||||||
expect(j$.matchersUtil.equals(a,b)).toBe(true);
|
|
||||||
|
|
||||||
b.appendChild(document.createTextNode('2'));
|
|
||||||
expect(j$.matchersUtil.equals(a,b)).toBe(false);
|
|
||||||
|
|
||||||
a.appendChild(document.createTextNode('2'));
|
|
||||||
expect(j$.matchersUtil.equals(a,b)).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("passes for equivalent objects from different vm contexts", function() {
|
|
||||||
if (typeof require !== 'function') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var vm = require('vm');
|
|
||||||
var sandbox = {
|
|
||||||
obj: null
|
|
||||||
};
|
|
||||||
vm.runInNewContext('obj = {a: 1, b: 2}', sandbox);
|
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(sandbox.obj, {a: 1, b: 2})).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("passes for equivalent arrays from different vm contexts", function() {
|
|
||||||
if (typeof require !== 'function') {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var vm = require('vm');
|
it("passes for equivalent objects from different vm contexts", function() {
|
||||||
var sandbox = {
|
if (isNotRunningInNode()) {
|
||||||
arr: null
|
return;
|
||||||
};
|
}
|
||||||
vm.runInNewContext('arr = [1, 2]', sandbox);
|
var vm = require('vm');
|
||||||
|
var sandbox = {
|
||||||
|
obj: null
|
||||||
|
};
|
||||||
|
vm.runInNewContext('obj = {a: 1, b: 2}', sandbox);
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(sandbox.arr, [1, 2])).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(sandbox.obj, {a: 1, b: 2})).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("passes for equivalent arrays from different vm contexts", function() {
|
||||||
|
if (isNotRunningInNode()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var vm = require('vm');
|
||||||
|
var sandbox = {
|
||||||
|
arr: null
|
||||||
|
};
|
||||||
|
vm.runInNewContext('arr = [1, 2]', sandbox);
|
||||||
|
|
||||||
|
expect(jasmineUnderTest.matchersUtil.equals(sandbox.arr, [1, 2])).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes when Any is used", function() {
|
it("passes when Any is used", function() {
|
||||||
var number = 3,
|
var number = 3,
|
||||||
anyNumber = new j$.Any(Number);
|
anyNumber = new jasmineUnderTest.Any(Number);
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(number, anyNumber)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(number, anyNumber)).toBe(true);
|
||||||
expect(j$.matchersUtil.equals(anyNumber, number)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(anyNumber, number)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails when Any is compared to something unexpected", function() {
|
it("fails when Any is compared to something unexpected", function() {
|
||||||
var number = 3,
|
var number = 3,
|
||||||
anyString = new j$.Any(String);
|
anyString = new jasmineUnderTest.Any(String);
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(number, anyString)).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals(number, anyString)).toBe(false);
|
||||||
expect(j$.matchersUtil.equals(anyString, number)).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals(anyString, number)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes when ObjectContaining is used", function() {
|
it("passes when ObjectContaining is used", function() {
|
||||||
@@ -219,69 +269,69 @@ describe("matchersUtil", function() {
|
|||||||
foo: 3,
|
foo: 3,
|
||||||
bar: 7
|
bar: 7
|
||||||
},
|
},
|
||||||
containing = new j$.ObjectContaining({foo: 3});
|
containing = new jasmineUnderTest.ObjectContaining({foo: 3});
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(obj, containing)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(obj, containing)).toBe(true);
|
||||||
expect(j$.matchersUtil.equals(containing, obj)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(containing, obj)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes when an asymmetric equality tester returns true", function() {
|
it("passes when an asymmetric equality tester returns true", function() {
|
||||||
var tester = { asymmetricMatch: function(other) { return true; } };
|
var tester = { asymmetricMatch: function(other) { return true; } };
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(false, tester)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(false, tester)).toBe(true);
|
||||||
expect(j$.matchersUtil.equals(tester, false)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(tester, false)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails when an asymmetric equality tester returns false", function() {
|
it("fails when an asymmetric equality tester returns false", function() {
|
||||||
var tester = { asymmetricMatch: function(other) { return false; } };
|
var tester = { asymmetricMatch: function(other) { return false; } };
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(true, tester)).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals(true, tester)).toBe(false);
|
||||||
expect(j$.matchersUtil.equals(tester, true)).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals(tester, true)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes when ArrayContaining is used", function() {
|
it("passes when ArrayContaining is used", function() {
|
||||||
var arr = ["foo", "bar"];
|
var arr = ["foo", "bar"];
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(arr, new j$.ArrayContaining(["bar"]))).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(arr, new jasmineUnderTest.ArrayContaining(["bar"]))).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes when a custom equality matcher returns true", function() {
|
it("passes when a custom equality matcher returns true", function() {
|
||||||
var tester = function(a, b) { return true; };
|
var tester = function(a, b) { return true; };
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(1, 2, [tester])).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(1, 2, [tester])).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes for two empty Objects", function () {
|
it("passes for two empty Objects", function () {
|
||||||
expect(j$.matchersUtil.equals({}, {})).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals({}, {})).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when a custom equality matcher is installed that returns 'undefined'", function () {
|
describe("when a custom equality matcher is installed that returns 'undefined'", function () {
|
||||||
var tester = function(a, b) { return jasmine.undefined; };
|
var tester = function(a, b) { return jasmine.undefined; };
|
||||||
|
|
||||||
it("passes for two empty Objects", function () {
|
it("passes for two empty Objects", function () {
|
||||||
expect(j$.matchersUtil.equals({}, {}, [tester])).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals({}, {}, [tester])).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails for equivalents when a custom equality matcher returns false", function() {
|
it("fails for equivalents when a custom equality matcher returns false", function() {
|
||||||
var tester = function(a, b) { return false; };
|
var tester = function(a, b) { return false; };
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(1, 1, [tester])).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals(1, 1, [tester])).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes for an asymmetric equality tester that returns true when a custom equality tester return false", function() {
|
it("passes for an asymmetric equality tester that returns true when a custom equality tester return false", function() {
|
||||||
var asymmetricTester = { asymmetricMatch: function(other) { return true; } },
|
var asymmetricTester = { asymmetricMatch: function(other) { return true; } },
|
||||||
symmetricTester = function(a, b) { return false; };
|
symmetricTester = function(a, b) { return false; };
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(asymmetricTester, true, [symmetricTester])).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(asymmetricTester, true, [symmetricTester])).toBe(true);
|
||||||
expect(j$.matchersUtil.equals(true, asymmetricTester, [symmetricTester])).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(true, asymmetricTester, [symmetricTester])).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes when an Any is compared to an Any that checks for the same type", function() {
|
it("passes when an Any is compared to an Any that checks for the same type", function() {
|
||||||
var any1 = new j$.Any(Function),
|
var any1 = new jasmineUnderTest.Any(Function),
|
||||||
any2 = new j$.Any(Function);
|
any2 = new jasmineUnderTest.Any(Function);
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(any1, any2)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(any1, any2)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes for null prototype objects with same properties", function () {
|
it("passes for null prototype objects with same properties", function () {
|
||||||
@@ -293,7 +343,7 @@ describe("matchersUtil", function() {
|
|||||||
objA.name = 'test';
|
objA.name = 'test';
|
||||||
objB.name = 'test';
|
objB.name = 'test';
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(objA, objB)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(objA, objB)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails for null prototype objects with different properties", function () {
|
it("fails for null prototype objects with different properties", function () {
|
||||||
@@ -305,44 +355,44 @@ describe("matchersUtil", function() {
|
|||||||
objA.name = 'test';
|
objA.name = 'test';
|
||||||
objB.test = 'name';
|
objB.test = 'name';
|
||||||
|
|
||||||
expect(j$.matchersUtil.equals(objA, objB)).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.equals(objA, objB)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("contains", function() {
|
describe("contains", function() {
|
||||||
it("passes when expected is a substring of actual", function() {
|
it("passes when expected is a substring of actual", function() {
|
||||||
expect(j$.matchersUtil.contains("ABC", "BC")).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.contains("ABC", "BC")).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails when expected is a not substring of actual", function() {
|
it("fails when expected is a not substring of actual", function() {
|
||||||
expect(j$.matchersUtil.contains("ABC", "X")).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.contains("ABC", "X")).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes when expected is an element in an actual array", function() {
|
it("passes when expected is an element in an actual array", function() {
|
||||||
expect(j$.matchersUtil.contains(['foo', 'bar'], 'foo')).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.contains(['foo', 'bar'], 'foo')).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails when expected is not an element in an actual array", function() {
|
it("fails when expected is not an element in an actual array", function() {
|
||||||
expect(j$.matchersUtil.contains(['foo', 'bar'], 'baz')).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.contains(['foo', 'bar'], 'baz')).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes with mixed-element arrays", function() {
|
it("passes with mixed-element arrays", function() {
|
||||||
expect(j$.matchersUtil.contains(["foo", {some: "bar"}], "foo")).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.contains(["foo", {some: "bar"}], "foo")).toBe(true);
|
||||||
expect(j$.matchersUtil.contains(["foo", {some: "bar"}], {some: "bar"})).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.contains(["foo", {some: "bar"}], {some: "bar"})).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("uses custom equality testers if passed in and actual is an Array", function() {
|
it("uses custom equality testers if passed in and actual is an Array", function() {
|
||||||
var customTester = function(a, b) {return true;};
|
var customTester = function(a, b) {return true;};
|
||||||
|
|
||||||
expect(j$.matchersUtil.contains([1, 2], 2, [customTester])).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.contains([1, 2], 2, [customTester])).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails when actual is undefined", function() {
|
it("fails when actual is undefined", function() {
|
||||||
expect(j$.matchersUtil.contains(undefined, 'A')).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.contains(undefined, 'A')).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails when actual is null", function() {
|
it("fails when actual is null", function() {
|
||||||
expect(j$.matchersUtil.contains(null, 'A')).toBe(false);
|
expect(jasmineUnderTest.matchersUtil.contains(null, 'A')).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes with array-like objects", function() {
|
it("passes with array-like objects", function() {
|
||||||
@@ -351,7 +401,7 @@ describe("matchersUtil", function() {
|
|||||||
capturedArgs = arguments;
|
capturedArgs = arguments;
|
||||||
}
|
}
|
||||||
testFunction('foo', 'bar');
|
testFunction('foo', 'bar');
|
||||||
expect(j$.matchersUtil.contains(capturedArgs, 'bar')).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.contains(capturedArgs, 'bar')).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -360,7 +410,7 @@ describe("matchersUtil", function() {
|
|||||||
it("builds an English sentence for a failure case", function() {
|
it("builds an English sentence for a failure case", function() {
|
||||||
var actual = "foo",
|
var actual = "foo",
|
||||||
name = "toBar",
|
name = "toBar",
|
||||||
message = j$.matchersUtil.buildFailureMessage(name, false, actual);
|
message = jasmineUnderTest.matchersUtil.buildFailureMessage(name, false, actual);
|
||||||
|
|
||||||
expect(message).toEqual("Expected 'foo' to bar.");
|
expect(message).toEqual("Expected 'foo' to bar.");
|
||||||
});
|
});
|
||||||
@@ -369,7 +419,7 @@ describe("matchersUtil", function() {
|
|||||||
var actual = "foo",
|
var actual = "foo",
|
||||||
name = "toBar",
|
name = "toBar",
|
||||||
isNot = true,
|
isNot = true,
|
||||||
message = message = j$.matchersUtil.buildFailureMessage(name, isNot, actual);
|
message = message = jasmineUnderTest.matchersUtil.buildFailureMessage(name, isNot, actual);
|
||||||
|
|
||||||
expect(message).toEqual("Expected 'foo' not to bar.");
|
expect(message).toEqual("Expected 'foo' not to bar.");
|
||||||
});
|
});
|
||||||
@@ -377,7 +427,7 @@ describe("matchersUtil", function() {
|
|||||||
it("builds an English sentence for an arbitrary array of expected arguments", function() {
|
it("builds an English sentence for an arbitrary array of expected arguments", function() {
|
||||||
var actual = "foo",
|
var actual = "foo",
|
||||||
name = "toBar",
|
name = "toBar",
|
||||||
message = j$.matchersUtil.buildFailureMessage(name, false, actual, "quux", "corge");
|
message = jasmineUnderTest.matchersUtil.buildFailureMessage(name, false, actual, "quux", "corge");
|
||||||
|
|
||||||
expect(message).toEqual("Expected 'foo' to bar 'quux', 'corge'.");
|
expect(message).toEqual("Expected 'foo' to bar 'quux', 'corge'.");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe("toBeCloseTo", function() {
|
describe("toBeCloseTo", function() {
|
||||||
it("passes when within two decimal places by default", function() {
|
it("passes when within two decimal places by default", function() {
|
||||||
var matcher = j$.matchers.toBeCloseTo(),
|
var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(0, 0);
|
result = matcher.compare(0, 0);
|
||||||
@@ -11,7 +11,7 @@ describe("toBeCloseTo", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails when not within two decimal places by default", function() {
|
it("fails when not within two decimal places by default", function() {
|
||||||
var matcher = j$.matchers.toBeCloseTo(),
|
var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(0, 0.01);
|
result = matcher.compare(0, 0.01);
|
||||||
@@ -19,7 +19,7 @@ describe("toBeCloseTo", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("accepts an optional precision argument", function() {
|
it("accepts an optional precision argument", function() {
|
||||||
var matcher = j$.matchers.toBeCloseTo(),
|
var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(0, 0.1, 0);
|
result = matcher.compare(0, 0.1, 0);
|
||||||
@@ -30,7 +30,7 @@ describe("toBeCloseTo", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("rounds expected values", function() {
|
it("rounds expected values", function() {
|
||||||
var matcher = j$.matchers.toBeCloseTo(),
|
var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(1.23, 1.229);
|
result = matcher.compare(1.23, 1.229);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe("toBeDefined", function() {
|
describe("toBeDefined", function() {
|
||||||
it("matches for defined values", function() {
|
it("matches for defined values", function() {
|
||||||
var matcher = j$.matchers.toBeDefined(),
|
var matcher = jasmineUnderTest.matchers.toBeDefined(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ describe("toBeDefined", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails when matching undefined values", function() {
|
it("fails when matching undefined values", function() {
|
||||||
var matcher = j$.matchers.toBeDefined(),
|
var matcher = jasmineUnderTest.matchers.toBeDefined(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(void 0);
|
result = matcher.compare(void 0);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe("toBeFalsy", function() {
|
describe("toBeFalsy", function() {
|
||||||
it("passes for 'falsy' values", function() {
|
it("passes for 'falsy' values", function() {
|
||||||
var matcher = j$.matchers.toBeFalsy(),
|
var matcher = jasmineUnderTest.matchers.toBeFalsy(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(false);
|
result = matcher.compare(false);
|
||||||
@@ -20,7 +20,7 @@ describe("toBeFalsy", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails for 'truthy' values", function() {
|
it("fails for 'truthy' values", function() {
|
||||||
var matcher = j$.matchers.toBeFalsy(),
|
var matcher = jasmineUnderTest.matchers.toBeFalsy(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(true);
|
result = matcher.compare(true);
|
||||||
|
|||||||
29
spec/core/matchers/toBeGreaterThanOrEqualSpec.js
Normal file
29
spec/core/matchers/toBeGreaterThanOrEqualSpec.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
describe("toBeGreaterThanOrEqual", function() {
|
||||||
|
it("passes when actual >= expected", function() {
|
||||||
|
var matcher = jasmineUnderTest.matchers.toBeGreaterThanOrEqual(),
|
||||||
|
result;
|
||||||
|
|
||||||
|
result = matcher.compare(2, 1);
|
||||||
|
expect(result.pass).toBe(true);
|
||||||
|
|
||||||
|
result = matcher.compare(1, 1);
|
||||||
|
expect(result.pass).toBe(true);
|
||||||
|
|
||||||
|
result = matcher.compare(1.0000001, 1);
|
||||||
|
expect(result.pass).toBe(true);
|
||||||
|
|
||||||
|
result = matcher.compare(1.0, 1.0);
|
||||||
|
expect(result.pass).toBe(true);
|
||||||
|
})
|
||||||
|
|
||||||
|
it("fails when actual < expected", function() {
|
||||||
|
var matcher = jasmineUnderTest.matchers.toBeGreaterThanOrEqual(),
|
||||||
|
result;
|
||||||
|
|
||||||
|
result = matcher.compare(1, 2);
|
||||||
|
expect(result.pass).toBe(false);
|
||||||
|
|
||||||
|
result = matcher.compare(1, 1.0000001);
|
||||||
|
expect(result.pass).toBe(false);
|
||||||
|
})
|
||||||
|
});
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
describe("toBeGreaterThan", function() {
|
describe("toBeGreaterThan", function() {
|
||||||
it("passes when actual > expected", function() {
|
it("passes when actual > expected", function() {
|
||||||
var matcher = j$.matchers.toBeGreaterThan(),
|
var matcher = jasmineUnderTest.matchers.toBeGreaterThan(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(2, 1);
|
result = matcher.compare(2, 1);
|
||||||
@@ -8,7 +8,7 @@ describe("toBeGreaterThan", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails when actual <= expected", function() {
|
it("fails when actual <= expected", function() {
|
||||||
var matcher = j$.matchers.toBeGreaterThan(),
|
var matcher = jasmineUnderTest.matchers.toBeGreaterThan(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(1, 1);
|
result = matcher.compare(1, 1);
|
||||||
|
|||||||
29
spec/core/matchers/toBeLessThanOrEqualSpec.js
Normal file
29
spec/core/matchers/toBeLessThanOrEqualSpec.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
describe("toBeLessThanOrEqual", function() {
|
||||||
|
it("passes when actual <= expected", function() {
|
||||||
|
var matcher = jasmineUnderTest.matchers.toBeLessThanOrEqual(),
|
||||||
|
result;
|
||||||
|
|
||||||
|
result = matcher.compare(1, 2);
|
||||||
|
expect(result.pass).toBe(true);
|
||||||
|
|
||||||
|
result = matcher.compare(1, 1);
|
||||||
|
expect(result.pass).toBe(true);
|
||||||
|
|
||||||
|
result = matcher.compare(1, 1.0000001);
|
||||||
|
expect(result.pass).toBe(true);
|
||||||
|
|
||||||
|
result = matcher.compare(1.0, 1.0);
|
||||||
|
expect(result.pass).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("fails when actual < expected", function() {
|
||||||
|
var matcher = jasmineUnderTest.matchers.toBeLessThanOrEqual(),
|
||||||
|
result;
|
||||||
|
|
||||||
|
result = matcher.compare(2, 1);
|
||||||
|
expect(result.pass).toBe(false);
|
||||||
|
|
||||||
|
result = matcher.compare(1.0000001, 1);
|
||||||
|
expect(result.pass).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
describe("toBeLessThan", function() {
|
describe("toBeLessThan", function() {
|
||||||
it("passes when actual < expected", function() {
|
it("passes when actual < expected", function() {
|
||||||
var matcher = j$.matchers.toBeLessThan(),
|
var matcher = jasmineUnderTest.matchers.toBeLessThan(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(1, 2);
|
result = matcher.compare(1, 2);
|
||||||
@@ -8,7 +8,7 @@ describe("toBeLessThan", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails when actual <= expected", function() {
|
it("fails when actual <= expected", function() {
|
||||||
var matcher = j$.matchers.toBeLessThan(),
|
var matcher = jasmineUnderTest.matchers.toBeLessThan(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(1, 1);
|
result = matcher.compare(1, 1);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe("toBeNaN", function() {
|
describe("toBeNaN", function() {
|
||||||
it("passes for NaN with a custom .not fail", function() {
|
it("passes for NaN with a custom .not fail", function() {
|
||||||
var matcher = j$.matchers.toBeNaN(),
|
var matcher = jasmineUnderTest.matchers.toBeNaN(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(Number.NaN);
|
result = matcher.compare(Number.NaN);
|
||||||
@@ -9,7 +9,7 @@ describe("toBeNaN", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails for anything not a NaN", function() {
|
it("fails for anything not a NaN", function() {
|
||||||
var matcher = j$.matchers.toBeNaN(),
|
var matcher = jasmineUnderTest.matchers.toBeNaN(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(1);
|
result = matcher.compare(1);
|
||||||
@@ -29,7 +29,7 @@ describe("toBeNaN", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("has a custom message on failure", function() {
|
it("has a custom message on failure", function() {
|
||||||
var matcher = j$.matchers.toBeNaN(),
|
var matcher = jasmineUnderTest.matchers.toBeNaN(),
|
||||||
result = matcher.compare(0);
|
result = matcher.compare(0);
|
||||||
|
|
||||||
expect(result.message()).toEqual("Expected 0 to be NaN.");
|
expect(result.message()).toEqual("Expected 0 to be NaN.");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe("toBeNull", function() {
|
describe("toBeNull", function() {
|
||||||
it("passes for null", function() {
|
it("passes for null", function() {
|
||||||
var matcher = j$.matchers.toBeNull(),
|
var matcher = jasmineUnderTest.matchers.toBeNull(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(null);
|
result = matcher.compare(null);
|
||||||
@@ -8,7 +8,7 @@ describe("toBeNull", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails for non-null", function() {
|
it("fails for non-null", function() {
|
||||||
var matcher = j$.matchers.toBeNull(),
|
var matcher = jasmineUnderTest.matchers.toBeNull(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare('foo');
|
result = matcher.compare('foo');
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe("toBe", function() {
|
describe("toBe", function() {
|
||||||
it("passes when actual === expected", function() {
|
it("passes when actual === expected", function() {
|
||||||
var matcher = j$.matchers.toBe(),
|
var matcher = jasmineUnderTest.matchers.toBe(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(1, 1);
|
result = matcher.compare(1, 1);
|
||||||
@@ -8,7 +8,7 @@ describe("toBe", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails when actual !== expected", function() {
|
it("fails when actual !== expected", function() {
|
||||||
var matcher = j$.matchers.toBe(),
|
var matcher = jasmineUnderTest.matchers.toBe(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(1, 2);
|
result = matcher.compare(1, 2);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe("toBeTruthy", function() {
|
describe("toBeTruthy", function() {
|
||||||
it("passes for 'truthy' values", function() {
|
it("passes for 'truthy' values", function() {
|
||||||
var matcher = j$.matchers.toBeTruthy(),
|
var matcher = jasmineUnderTest.matchers.toBeTruthy(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(true);
|
result = matcher.compare(true);
|
||||||
@@ -17,7 +17,7 @@ describe("toBeTruthy", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails for 'falsy' values", function() {
|
it("fails for 'falsy' values", function() {
|
||||||
var matcher = j$.matchers.toBeTruthy(),
|
var matcher = jasmineUnderTest.matchers.toBeTruthy(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(false);
|
result = matcher.compare(false);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe("toBeUndefined", function() {
|
describe("toBeUndefined", function() {
|
||||||
it("passes for undefined values", function() {
|
it("passes for undefined values", function() {
|
||||||
var matcher = j$.matchers.toBeUndefined(),
|
var matcher = jasmineUnderTest.matchers.toBeUndefined(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(void 0);
|
result = matcher.compare(void 0);
|
||||||
@@ -9,7 +9,7 @@ describe("toBeUndefined", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails when matching defined values", function() {
|
it("fails when matching defined values", function() {
|
||||||
var matcher = j$.matchers.toBeUndefined(),
|
var matcher = jasmineUnderTest.matchers.toBeUndefined(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare('foo');
|
result = matcher.compare('foo');
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
describe("toContain", function() {
|
describe("toContain", function() {
|
||||||
it("delegates to j$.matchersUtil.contains", function() {
|
it("delegates to jasmineUnderTest.matchersUtil.contains", function() {
|
||||||
var util = {
|
var util = {
|
||||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toContain(util),
|
matcher = jasmineUnderTest.matchers.toContain(util),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare("ABC", "B");
|
result = matcher.compare("ABC", "B");
|
||||||
@@ -11,12 +11,12 @@ describe("toContain", function() {
|
|||||||
expect(result.pass).toBe(true);
|
expect(result.pass).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("delegates to j$.matchersUtil.contains, passing in equality testers if present", function() {
|
it("delegates to jasmineUnderTest.matchersUtil.contains, passing in equality testers if present", function() {
|
||||||
var util = {
|
var util = {
|
||||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
||||||
},
|
},
|
||||||
customEqualityTesters = ['a', 'b'],
|
customEqualityTesters = ['a', 'b'],
|
||||||
matcher = j$.matchers.toContain(util, customEqualityTesters),
|
matcher = jasmineUnderTest.matchers.toContain(util, customEqualityTesters),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare("ABC", "B");
|
result = matcher.compare("ABC", "B");
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ describe("toEqual", function() {
|
|||||||
var util = {
|
var util = {
|
||||||
equals: jasmine.createSpy('delegated-equals').and.returnValue(true)
|
equals: jasmine.createSpy('delegated-equals').and.returnValue(true)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toEqual(util),
|
matcher = jasmineUnderTest.matchers.toEqual(util),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(1, 1);
|
result = matcher.compare(1, 1);
|
||||||
@@ -17,7 +17,7 @@ describe("toEqual", function() {
|
|||||||
equals: jasmine.createSpy('delegated-equals').and.returnValue(true)
|
equals: jasmine.createSpy('delegated-equals').and.returnValue(true)
|
||||||
},
|
},
|
||||||
customEqualityTesters = ['a', 'b'],
|
customEqualityTesters = ['a', 'b'],
|
||||||
matcher = j$.matchers.toEqual(util, customEqualityTesters),
|
matcher = jasmineUnderTest.matchers.toEqual(util, customEqualityTesters),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(1, 1);
|
result = matcher.compare(1, 1);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
describe("toHaveBeenCalled", function() {
|
describe("toHaveBeenCalled", function() {
|
||||||
it("passes when the actual was called, with a custom .not fail message", function() {
|
it("passes when the actual was called, with a custom .not fail message", function() {
|
||||||
var matcher = j$.matchers.toHaveBeenCalled(),
|
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
|
||||||
calledSpy = j$.createSpy('called-spy'),
|
calledSpy = jasmineUnderTest.createSpy('called-spy'),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
calledSpy();
|
calledSpy();
|
||||||
@@ -12,8 +12,8 @@ describe("toHaveBeenCalled", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails when the actual was not called", function() {
|
it("fails when the actual was not called", function() {
|
||||||
var matcher = j$.matchers.toHaveBeenCalled(),
|
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
|
||||||
uncalledSpy = j$.createSpy('uncalled spy'),
|
uncalledSpy = jasmineUnderTest.createSpy('uncalled spy'),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(uncalledSpy);
|
result = matcher.compare(uncalledSpy);
|
||||||
@@ -21,22 +21,22 @@ describe("toHaveBeenCalled", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("throws an exception when the actual is not a spy", function() {
|
it("throws an exception when the actual is not a spy", function() {
|
||||||
var matcher = j$.matchers.toHaveBeenCalled(),
|
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
|
||||||
fn = function() {};
|
fn = function() {};
|
||||||
|
|
||||||
expect(function() { matcher.compare(fn) }).toThrow(new Error("Expected a spy, but got Function."));
|
expect(function() { matcher.compare(fn) }).toThrowError(Error, /Expected a spy, but got Function./);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("throws an exception when invoked with any arguments", function() {
|
it("throws an exception when invoked with any arguments", function() {
|
||||||
var matcher = j$.matchers.toHaveBeenCalled(),
|
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
|
||||||
spy = j$.createSpy('sample spy');
|
spy = jasmineUnderTest.createSpy('sample spy');
|
||||||
|
|
||||||
expect(function() { matcher.compare(spy, 'foo') }).toThrow(new Error("toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith"));
|
expect(function() { matcher.compare(spy, 'foo') }).toThrowError(Error, /Does not take arguments, use toHaveBeenCalledWith/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has a custom message on failure", function() {
|
it("has a custom message on failure", function() {
|
||||||
var matcher = j$.matchers.toHaveBeenCalled(),
|
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
|
||||||
spy = j$.createSpy('sample-spy'),
|
spy = jasmineUnderTest.createSpy('sample-spy'),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(spy);
|
result = matcher.compare(spy);
|
||||||
|
|||||||
86
spec/core/matchers/toHaveBeenCalledTimesSpec.js
Normal file
86
spec/core/matchers/toHaveBeenCalledTimesSpec.js
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
describe("toHaveBeenCalledTimes", function() {
|
||||||
|
it("passes when the actual 0 matches the expected 0 ", function () {
|
||||||
|
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||||
|
calledSpy = jasmineUnderTest.createSpy('called-spy'),
|
||||||
|
result;
|
||||||
|
result = matcher.compare(calledSpy, 0);
|
||||||
|
expect(result.pass).toBeTruthy();
|
||||||
|
});
|
||||||
|
it("passes when the actual matches the expected", function() {
|
||||||
|
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||||
|
calledSpy = jasmineUnderTest.createSpy('called-spy'),
|
||||||
|
result;
|
||||||
|
calledSpy();
|
||||||
|
|
||||||
|
result = matcher.compare(calledSpy, 1);
|
||||||
|
expect(result.pass).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("fails when expected numbers is not supplied", function(){
|
||||||
|
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||||
|
spy = jasmineUnderTest.createSpy('spy'),
|
||||||
|
result;
|
||||||
|
|
||||||
|
spy();
|
||||||
|
expect(function() {
|
||||||
|
matcher.compare(spy);
|
||||||
|
}).toThrowError(/The expected times failed is a required argument and must be a number./);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("fails when the actual was called less than the expected", function() {
|
||||||
|
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||||
|
uncalledSpy = jasmineUnderTest.createSpy('uncalled spy'),
|
||||||
|
result;
|
||||||
|
|
||||||
|
result = matcher.compare(uncalledSpy, 2);
|
||||||
|
expect(result.pass).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("fails when the actual was called more than expected", function() {
|
||||||
|
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||||
|
uncalledSpy = jasmineUnderTest.createSpy('uncalled spy'),
|
||||||
|
result;
|
||||||
|
|
||||||
|
uncalledSpy();
|
||||||
|
uncalledSpy();
|
||||||
|
|
||||||
|
result = matcher.compare(uncalledSpy, 1);
|
||||||
|
expect(result.pass).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("throws an exception when the actual is not a spy", function() {
|
||||||
|
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||||
|
fn = function() {};
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
|
matcher.compare(fn);
|
||||||
|
}).toThrowError(/Expected a spy, but got Function./);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("has a custom message on failure that tells it was called only once", function() {
|
||||||
|
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||||
|
spy = jasmineUnderTest.createSpy('sample-spy'),
|
||||||
|
result;
|
||||||
|
spy();
|
||||||
|
spy();
|
||||||
|
spy();
|
||||||
|
spy();
|
||||||
|
|
||||||
|
result = matcher.compare(spy, 1);
|
||||||
|
expect(result.message).toEqual('Expected spy sample-spy to have been called once. It was called ' + 4 + ' times.');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("has a custom message on failure that tells how many times it was called", function() {
|
||||||
|
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||||
|
spy = jasmineUnderTest.createSpy('sample-spy'),
|
||||||
|
result;
|
||||||
|
spy();
|
||||||
|
spy();
|
||||||
|
spy();
|
||||||
|
spy();
|
||||||
|
|
||||||
|
result = matcher.compare(spy, 2);
|
||||||
|
expect(result.message).toEqual('Expected spy sample-spy to have been called 2 times. It was called ' + 4 + ' times.');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
describe("toHaveBeenCalledWith", function() {
|
describe("toHaveBeenCalledWith", function() {
|
||||||
|
|
||||||
it("passes when the actual was called with matching parameters", function() {
|
it("passes when the actual was called with matching parameters", function() {
|
||||||
var util = {
|
var util = {
|
||||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toHaveBeenCalledWith(util),
|
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
|
||||||
calledSpy = j$.createSpy('called-spy'),
|
calledSpy = jasmineUnderTest.createSpy('called-spy'),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
calledSpy('a', 'b');
|
calledSpy('a', 'b');
|
||||||
@@ -19,8 +20,8 @@ describe("toHaveBeenCalledWith", function() {
|
|||||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
||||||
},
|
},
|
||||||
customEqualityTesters = [function() { return true; }],
|
customEqualityTesters = [function() { return true; }],
|
||||||
matcher = j$.matchers.toHaveBeenCalledWith(util, customEqualityTesters),
|
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util, customEqualityTesters),
|
||||||
calledSpy = j$.createSpy('called-spy');
|
calledSpy = jasmineUnderTest.createSpy('called-spy');
|
||||||
|
|
||||||
calledSpy('a', 'b');
|
calledSpy('a', 'b');
|
||||||
matcher.compare(calledSpy, 'a', 'b');
|
matcher.compare(calledSpy, 'a', 'b');
|
||||||
@@ -32,8 +33,8 @@ describe("toHaveBeenCalledWith", function() {
|
|||||||
var util = {
|
var util = {
|
||||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(false)
|
contains: jasmine.createSpy('delegated-contains').and.returnValue(false)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toHaveBeenCalledWith(util),
|
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
|
||||||
uncalledSpy = j$.createSpy('uncalled spy'),
|
uncalledSpy = jasmineUnderTest.createSpy('uncalled spy'),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(uncalledSpy);
|
result = matcher.compare(uncalledSpy);
|
||||||
@@ -45,8 +46,8 @@ describe("toHaveBeenCalledWith", function() {
|
|||||||
var util = {
|
var util = {
|
||||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(false)
|
contains: jasmine.createSpy('delegated-contains').and.returnValue(false)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toHaveBeenCalledWith(util),
|
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
|
||||||
calledSpy = j$.createSpy('called spy'),
|
calledSpy = jasmineUnderTest.createSpy('called spy'),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
calledSpy('a');
|
calledSpy('a');
|
||||||
@@ -58,9 +59,9 @@ describe("toHaveBeenCalledWith", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("throws an exception when the actual is not a spy", function() {
|
it("throws an exception when the actual is not a spy", function() {
|
||||||
var matcher = j$.matchers.toHaveBeenCalledWith(),
|
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(),
|
||||||
fn = function() {};
|
fn = function() {};
|
||||||
|
|
||||||
expect(function() { matcher.compare(fn) }).toThrow(new Error("Expected a spy, but got Function."));
|
expect(function() { matcher.compare(fn) }).toThrowError(/Expected a spy, but got Function./);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
describe("toMatch", function() {
|
describe("toMatch", function() {
|
||||||
|
|
||||||
it("passes when RegExps are equivalent", function() {
|
it("passes when RegExps are equivalent", function() {
|
||||||
var matcher = j$.matchers.toMatch(),
|
var matcher = jasmineUnderTest.matchers.toMatch(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(/foo/, /foo/);
|
result = matcher.compare(/foo/, /foo/);
|
||||||
@@ -8,7 +9,7 @@ describe("toMatch", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails when RegExps are not equivalent", function() {
|
it("fails when RegExps are not equivalent", function() {
|
||||||
var matcher = j$.matchers.toMatch(),
|
var matcher = jasmineUnderTest.matchers.toMatch(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(/bar/, /foo/);
|
result = matcher.compare(/bar/, /foo/);
|
||||||
@@ -16,7 +17,7 @@ describe("toMatch", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("passes when the actual matches the expected string as a pattern", function() {
|
it("passes when the actual matches the expected string as a pattern", function() {
|
||||||
var matcher = j$.matchers.toMatch(),
|
var matcher = jasmineUnderTest.matchers.toMatch(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare('foosball', 'foo');
|
result = matcher.compare('foosball', 'foo');
|
||||||
@@ -24,7 +25,7 @@ describe("toMatch", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails when the actual matches the expected string as a pattern", function() {
|
it("fails when the actual matches the expected string as a pattern", function() {
|
||||||
var matcher = j$.matchers.toMatch(),
|
var matcher = jasmineUnderTest.matchers.toMatch(),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare('bar', 'foo');
|
result = matcher.compare('bar', 'foo');
|
||||||
@@ -32,11 +33,11 @@ describe("toMatch", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("throws an Error when the expected is not a String or RegExp", function() {
|
it("throws an Error when the expected is not a String or RegExp", function() {
|
||||||
var matcher = j$.matchers.toMatch();
|
var matcher = jasmineUnderTest.matchers.toMatch();
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
matcher.compare('foo', { bar: 'baz' });
|
matcher.compare('foo', { bar: 'baz' });
|
||||||
}).toThrowError('Expected is not a String or a RegExp');
|
}).toThrowError(/Expected is not a String or a RegExp/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,47 +1,47 @@
|
|||||||
describe("toThrowError", function() {
|
describe("toThrowError", function() {
|
||||||
it("throws an error when the actual is not a function", function() {
|
it("throws an error when the actual is not a function", function() {
|
||||||
var matcher = j$.matchers.toThrowError();
|
var matcher = jasmineUnderTest.matchers.toThrowError();
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
matcher.compare({});
|
matcher.compare({});
|
||||||
}).toThrowError("Actual is not a Function");
|
}).toThrowError(/Actual is not a Function/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("throws an error when the expected is not an Error, string, or RegExp", function() {
|
it("throws an error when the expected is not an Error, string, or RegExp", function() {
|
||||||
var matcher = j$.matchers.toThrowError(),
|
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new Error("foo");
|
throw new Error("foo");
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
matcher.compare(fn, 1);
|
matcher.compare(fn, 1);
|
||||||
}).toThrowError("Expected is not an Error, string, or RegExp.");
|
}).toThrowError(/Expected is not an Error, string, or RegExp./);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("throws an error when the expected error type is not an Error", function() {
|
it("throws an error when the expected error type is not an Error", function() {
|
||||||
var matcher = j$.matchers.toThrowError(),
|
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new Error("foo");
|
throw new Error("foo");
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
matcher.compare(fn, void 0, "foo");
|
matcher.compare(fn, void 0, "foo");
|
||||||
}).toThrowError("Expected error type is not an Error.");
|
}).toThrowError(/Expected error type is not an Error./);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("throws an error when the expected error message is not a string or RegExp", function() {
|
it("throws an error when the expected error message is not a string or RegExp", function() {
|
||||||
var matcher = j$.matchers.toThrowError(),
|
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new Error("foo");
|
throw new Error("foo");
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
matcher.compare(fn, Error, 1);
|
matcher.compare(fn, Error, 1);
|
||||||
}).toThrowError("Expected error message is not a string or RegExp.");
|
}).toThrowError(/Expected error message is not a string or RegExp./);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails if actual does not throw at all", function() {
|
it("fails if actual does not throw at all", function() {
|
||||||
var matcher = j$.matchers.toThrowError(),
|
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
@@ -54,7 +54,7 @@ describe("toThrowError", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails if thrown is not an instanceof Error", function() {
|
it("fails if thrown is not an instanceof Error", function() {
|
||||||
var matcher = j$.matchers.toThrowError(),
|
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw 4;
|
throw 4;
|
||||||
},
|
},
|
||||||
@@ -66,7 +66,7 @@ describe("toThrowError", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails with the correct message if thrown is a falsy value", function() {
|
it("fails with the correct message if thrown is a falsy value", function() {
|
||||||
var matcher = j$.matchers.toThrowError(),
|
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw undefined;
|
throw undefined;
|
||||||
},
|
},
|
||||||
@@ -78,7 +78,7 @@ describe("toThrowError", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("passes if thrown is a type of Error, but there is no expected error", function() {
|
it("passes if thrown is a type of Error, but there is no expected error", function() {
|
||||||
var matcher = j$.matchers.toThrowError(),
|
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new TypeError();
|
throw new TypeError();
|
||||||
},
|
},
|
||||||
@@ -91,7 +91,7 @@ describe("toThrowError", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("passes if thrown is an Error and the expected is the same message", function() {
|
it("passes if thrown is an Error and the expected is the same message", function() {
|
||||||
var matcher = j$.matchers.toThrowError(),
|
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new Error("foo");
|
throw new Error("foo");
|
||||||
},
|
},
|
||||||
@@ -104,7 +104,7 @@ describe("toThrowError", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails if thrown is an Error and the expected is not the same message", function() {
|
it("fails if thrown is an Error and the expected is not the same message", function() {
|
||||||
var matcher = j$.matchers.toThrowError(),
|
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new Error("foo");
|
throw new Error("foo");
|
||||||
},
|
},
|
||||||
@@ -117,7 +117,7 @@ describe("toThrowError", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("passes if thrown is an Error and the expected is a RegExp that matches the message", function() {
|
it("passes if thrown is an Error and the expected is a RegExp that matches the message", function() {
|
||||||
var matcher = j$.matchers.toThrowError(),
|
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new Error("a long message");
|
throw new Error("a long message");
|
||||||
},
|
},
|
||||||
@@ -130,7 +130,7 @@ describe("toThrowError", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails if thrown is an Error and the expected is a RegExp that does not match the message", function() {
|
it("fails if thrown is an Error and the expected is a RegExp that does not match the message", function() {
|
||||||
var matcher = j$.matchers.toThrowError(),
|
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new Error("a long message");
|
throw new Error("a long message");
|
||||||
},
|
},
|
||||||
@@ -146,7 +146,7 @@ describe("toThrowError", function() {
|
|||||||
var util = {
|
var util = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toThrowError(util),
|
matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new Error();
|
throw new Error();
|
||||||
},
|
},
|
||||||
@@ -162,7 +162,7 @@ describe("toThrowError", function() {
|
|||||||
var util = {
|
var util = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toThrowError(util),
|
matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
CustomError = function CustomError(arg) { arg.x },
|
CustomError = function CustomError(arg) { arg.x },
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new CustomError({ x: 1 });
|
throw new CustomError({ x: 1 });
|
||||||
@@ -181,7 +181,7 @@ describe("toThrowError", function() {
|
|||||||
var util = {
|
var util = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toThrowError(util),
|
matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new Error();
|
throw new Error();
|
||||||
},
|
},
|
||||||
@@ -197,7 +197,7 @@ describe("toThrowError", function() {
|
|||||||
var util = {
|
var util = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toThrowError(util),
|
matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new TypeError("foo");
|
throw new TypeError("foo");
|
||||||
},
|
},
|
||||||
@@ -213,7 +213,7 @@ describe("toThrowError", function() {
|
|||||||
var util = {
|
var util = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toThrowError(util),
|
matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
CustomError = function CustomError(arg) { this.message = arg.message },
|
CustomError = function CustomError(arg) { this.message = arg.message },
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new CustomError({message: "foo"});
|
throw new CustomError({message: "foo"});
|
||||||
@@ -232,7 +232,7 @@ describe("toThrowError", function() {
|
|||||||
var util = {
|
var util = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toThrowError(util),
|
matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new TypeError("foo");
|
throw new TypeError("foo");
|
||||||
},
|
},
|
||||||
@@ -248,7 +248,7 @@ describe("toThrowError", function() {
|
|||||||
var util = {
|
var util = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toThrowError(util),
|
matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new TypeError("foo");
|
throw new TypeError("foo");
|
||||||
},
|
},
|
||||||
@@ -264,7 +264,7 @@ describe("toThrowError", function() {
|
|||||||
var util = {
|
var util = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toThrowError(util),
|
matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new TypeError("foo");
|
throw new TypeError("foo");
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
describe("toThrow", function() {
|
describe("toThrow", function() {
|
||||||
|
|
||||||
it("throws an error when the actual is not a function", function() {
|
it("throws an error when the actual is not a function", function() {
|
||||||
var matcher = j$.matchers.toThrow();
|
var matcher = jasmineUnderTest.matchers.toThrow();
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
matcher.compare({});
|
matcher.compare({});
|
||||||
matcherComparator({});
|
matcherComparator({});
|
||||||
}).toThrowError("Actual is not a Function");
|
}).toThrowError(/Actual is not a Function/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails if actual does not throw", function() {
|
it("fails if actual does not throw", function() {
|
||||||
var matcher = j$.matchers.toThrow(),
|
var matcher = jasmineUnderTest.matchers.toThrow(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
@@ -25,7 +26,7 @@ describe("toThrow", function() {
|
|||||||
var util = {
|
var util = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toThrow(util),
|
matcher = jasmineUnderTest.matchers.toThrow(util),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw 5;
|
throw 5;
|
||||||
},
|
},
|
||||||
@@ -38,7 +39,7 @@ describe("toThrow", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("passes even if what is thrown is falsy", function() {
|
it("passes even if what is thrown is falsy", function() {
|
||||||
var matcher = j$.matchers.toThrow(),
|
var matcher = jasmineUnderTest.matchers.toThrow(),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw undefined;
|
throw undefined;
|
||||||
},
|
},
|
||||||
@@ -53,7 +54,7 @@ describe("toThrow", function() {
|
|||||||
var util = {
|
var util = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toThrow(util),
|
matcher = jasmineUnderTest.matchers.toThrow(util),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw 5;
|
throw 5;
|
||||||
},
|
},
|
||||||
@@ -69,7 +70,7 @@ describe("toThrow", function() {
|
|||||||
var util = {
|
var util = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toThrow(util),
|
matcher = jasmineUnderTest.matchers.toThrow(util),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw 5;
|
throw 5;
|
||||||
},
|
},
|
||||||
@@ -85,7 +86,7 @@ describe("toThrow", function() {
|
|||||||
var util = {
|
var util = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toThrow(util),
|
matcher = jasmineUnderTest.matchers.toThrow(util),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw 5;
|
throw 5;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
(function() {
|
(function() {
|
||||||
// By the time onload is called, jasmineRequire will be redefined to point
|
// By the time onload is called, jasmineRequire will be redefined to point
|
||||||
// to the Jasmine source files (and not jasmine.js). So re-require
|
// to the Jasmine source files (and not jasmine.js). So re-require
|
||||||
window.j$ = jasmineRequire.core(jasmineRequire);
|
window.jasmineUnderTest = jasmineRequire.core(jasmineRequire);
|
||||||
jasmineRequire.html(j$);
|
jasmineRequire.html(jasmineUnderTest);
|
||||||
jasmineRequire.console(jasmineRequire, j$);
|
jasmineRequire.console(jasmineRequire, jasmineUnderTest);
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
|
|
||||||
var glob = require("glob");
|
var glob = require("glob");
|
||||||
|
|
||||||
var j$Require = require(path.join(__dirname, "../../src/core/requireCore.js"));
|
var jasmineUnderTestRequire = require(path.join(__dirname, "../../src/core/requireCore.js"));
|
||||||
|
|
||||||
global.getJasmineRequireObj = function () {
|
global.getJasmineRequireObj = function () {
|
||||||
return j$Require;
|
return jasmineUnderTestRequire;
|
||||||
};
|
};
|
||||||
|
|
||||||
function extend(destination, source) {
|
function extend(destination, source) {
|
||||||
@@ -25,9 +25,9 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
extend(j$Require, require(path.join(__dirname,"../../src/console/requireConsole.js")));
|
extend(jasmineUnderTestRequire, require(path.join(__dirname,"../../src/console/requireConsole.js")));
|
||||||
getSourceFiles();
|
getSourceFiles();
|
||||||
global.j$ = j$Require.core(j$Require);
|
global.jasmineUnderTest = jasmineUnderTestRequire.core(jasmineUnderTestRequire);
|
||||||
|
|
||||||
j$Require.console(j$Require, j$);
|
jasmineUnderTestRequire.console(jasmineUnderTestRequire, jasmineUnderTest);
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
describe("New HtmlReporter", function() {
|
describe("New HtmlReporter", function() {
|
||||||
// TODO: Figure out why this isn't rendering...
|
|
||||||
it("builds the initial DOM elements, including the title banner", function() {
|
it("builds the initial DOM elements, including the title banner", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
getContainer = function() { return container; },
|
getContainer = function() { return container; },
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
@@ -14,29 +13,29 @@ describe("New HtmlReporter", function() {
|
|||||||
|
|
||||||
// Main top-level elements
|
// Main top-level elements
|
||||||
expect(container.querySelector("div.jasmine_html-reporter")).toBeTruthy();
|
expect(container.querySelector("div.jasmine_html-reporter")).toBeTruthy();
|
||||||
expect(container.querySelector("div.banner")).toBeTruthy();
|
expect(container.querySelector("div.jasmine-banner")).toBeTruthy();
|
||||||
expect(container.querySelector("div.alert")).toBeTruthy();
|
expect(container.querySelector("div.jasmine-alert")).toBeTruthy();
|
||||||
expect(container.querySelector("div.results")).toBeTruthy();
|
expect(container.querySelector("div.jasmine-results")).toBeTruthy();
|
||||||
|
|
||||||
expect(container.querySelector("ul.symbol-summary")).toBeTruthy();
|
expect(container.querySelector("ul.jasmine-symbol-summary")).toBeTruthy();
|
||||||
|
|
||||||
// title banner
|
// title banner
|
||||||
var banner = container.querySelector(".banner");
|
var banner = container.querySelector(".jasmine-banner");
|
||||||
|
|
||||||
var title = banner.querySelector("a.title");
|
var title = banner.querySelector("a.jasmine-title");
|
||||||
expect(title.getAttribute('href')).toEqual('http://jasmine.github.io/');
|
expect(title.getAttribute('href')).toEqual('http://jasmine.github.io/');
|
||||||
expect(title.getAttribute('target')).toEqual('_blank');
|
expect(title.getAttribute('target')).toEqual('_blank');
|
||||||
|
|
||||||
var version = banner.querySelector(".version"),
|
var version = banner.querySelector(".jasmine-version"),
|
||||||
versionText = 'textContent' in version ? version.textContent : version.innerText;
|
versionText = 'textContent' in version ? version.textContent : version.innerText;
|
||||||
expect(versionText).toEqual(j$.version);
|
expect(versionText).toEqual(jasmineUnderTest.version);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("builds a single reporter even if initialized multiple times", function() {
|
it("builds a single reporter even if initialized multiple times", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
getContainer = function() { return container; },
|
getContainer = function() { return container; },
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
@@ -52,7 +51,7 @@ describe("New HtmlReporter", function() {
|
|||||||
it("starts the timer when jasmine begins", function() {
|
it("starts the timer when jasmine begins", function() {
|
||||||
var env = new jasmine.Env(),
|
var env = new jasmine.Env(),
|
||||||
startTimerSpy = jasmine.createSpy("start-timer-spy"),
|
startTimerSpy = jasmine.createSpy("start-timer-spy"),
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
timer: { start: startTimerSpy }
|
timer: { start: startTimerSpy }
|
||||||
@@ -69,10 +68,10 @@ describe("New HtmlReporter", function() {
|
|||||||
console = { error: function(){} };
|
console = { error: function(){} };
|
||||||
}
|
}
|
||||||
|
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement('div'),
|
container = document.createElement('div'),
|
||||||
getContainer = function() {return container;},
|
getContainer = function() {return container;},
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
@@ -90,15 +89,15 @@ describe("New HtmlReporter", function() {
|
|||||||
failedExpectations: []
|
failedExpectations: []
|
||||||
});
|
});
|
||||||
expect(console.error).toHaveBeenCalledWith("Spec \'Some Name\' has no expectations.");
|
expect(console.error).toHaveBeenCalledWith("Spec \'Some Name\' has no expectations.");
|
||||||
var specEl = container.querySelector('.symbol-summary li');
|
var specEl = container.querySelector('.jasmine-symbol-summary li');
|
||||||
expect(specEl.getAttribute("class")).toEqual("empty");
|
expect(specEl.getAttribute("class")).toEqual("jasmine-empty");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reports the status symbol of a disabled spec", function() {
|
it("reports the status symbol of a disabled spec", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
getContainer = function() { return container; },
|
getContainer = function() { return container; },
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
@@ -108,17 +107,17 @@ describe("New HtmlReporter", function() {
|
|||||||
|
|
||||||
reporter.specDone({id: 789, status: "disabled", fullName: "symbols should have titles", passedExpectations: [], failedExpectations: []});
|
reporter.specDone({id: 789, status: "disabled", fullName: "symbols should have titles", passedExpectations: [], failedExpectations: []});
|
||||||
|
|
||||||
var specEl = container.querySelector('.symbol-summary li');
|
var specEl = container.querySelector('.jasmine-symbol-summary li');
|
||||||
expect(specEl.getAttribute("class")).toEqual("disabled");
|
expect(specEl.getAttribute("class")).toEqual("jasmine-disabled");
|
||||||
expect(specEl.getAttribute("id")).toEqual("spec_789");
|
expect(specEl.getAttribute("id")).toEqual("spec_789");
|
||||||
expect(specEl.getAttribute("title")).toEqual("symbols should have titles");
|
expect(specEl.getAttribute("title")).toEqual("symbols should have titles");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reports the status symbol of a pending spec", function() {
|
it("reports the status symbol of a pending spec", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
getContainer = function() { return container; },
|
getContainer = function() { return container; },
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
@@ -128,16 +127,16 @@ describe("New HtmlReporter", function() {
|
|||||||
|
|
||||||
reporter.specDone({id: 789, status: "pending", passedExpectations: [], failedExpectations: []});
|
reporter.specDone({id: 789, status: "pending", passedExpectations: [], failedExpectations: []});
|
||||||
|
|
||||||
var specEl = container.querySelector('.symbol-summary li');
|
var specEl = container.querySelector('.jasmine-symbol-summary li');
|
||||||
expect(specEl.getAttribute("class")).toEqual("pending");
|
expect(specEl.getAttribute("class")).toEqual("jasmine-pending");
|
||||||
expect(specEl.getAttribute("id")).toEqual("spec_789");
|
expect(specEl.getAttribute("id")).toEqual("spec_789");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reports the status symbol of a passing spec", function() {
|
it("reports the status symbol of a passing spec", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
getContainer = function() { return container; },
|
getContainer = function() { return container; },
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
@@ -147,17 +146,17 @@ describe("New HtmlReporter", function() {
|
|||||||
|
|
||||||
reporter.specDone({id: 123, status: "passed", passedExpectations: [{passed: true}], failedExpectations: []});
|
reporter.specDone({id: 123, status: "passed", passedExpectations: [{passed: true}], failedExpectations: []});
|
||||||
|
|
||||||
var statuses = container.querySelector(".symbol-summary");
|
var statuses = container.querySelector(".jasmine-symbol-summary");
|
||||||
var specEl = statuses.querySelector("li");
|
var specEl = statuses.querySelector("li");
|
||||||
expect(specEl.getAttribute("class")).toEqual("passed");
|
expect(specEl.getAttribute("class")).toEqual("jasmine-passed");
|
||||||
expect(specEl.getAttribute("id")).toEqual("spec_123");
|
expect(specEl.getAttribute("id")).toEqual("spec_123");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reports the status symbol of a failing spec", function() {
|
it("reports the status symbol of a failing spec", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
getContainer = function() { return container; },
|
getContainer = function() { return container; },
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
@@ -173,18 +172,18 @@ describe("New HtmlReporter", function() {
|
|||||||
passedExpectations: []
|
passedExpectations: []
|
||||||
});
|
});
|
||||||
|
|
||||||
var specEl = container.querySelector(".symbol-summary li");
|
var specEl = container.querySelector(".jasmine-symbol-summary li");
|
||||||
expect(specEl.getAttribute("class")).toEqual("failed");
|
expect(specEl.getAttribute("class")).toEqual("jasmine-failed");
|
||||||
expect(specEl.getAttribute("id")).toEqual("spec_345");
|
expect(specEl.getAttribute("id")).toEqual("spec_345");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when there are suite failures", function () {
|
describe("when there are suite failures", function () {
|
||||||
it("displays the exceptions in their own alert bars", function(){
|
it("displays the exceptions in their own alert bars", function(){
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
getContainer = function() { return container; },
|
getContainer = function() { return container; },
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
@@ -196,14 +195,16 @@ describe("New HtmlReporter", function() {
|
|||||||
reporter.jasmineStarted({});
|
reporter.jasmineStarted({});
|
||||||
reporter.suiteDone({ status: 'failed', failedExpectations: [{ message: 'My After All Exception' }] });
|
reporter.suiteDone({ status: 'failed', failedExpectations: [{ message: 'My After All Exception' }] });
|
||||||
reporter.suiteDone({ status: 'failed', failedExpectations: [{ message: 'My Other Exception' }] });
|
reporter.suiteDone({ status: 'failed', failedExpectations: [{ message: 'My Other Exception' }] });
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({ failedExpectations: [{ message: 'Global After All Failure' }, { message: 'Other Global' }] });
|
||||||
|
|
||||||
var alertBars = container.querySelectorAll(".alert .bar");
|
var alertBars = container.querySelectorAll(".jasmine-alert .jasmine-bar");
|
||||||
|
|
||||||
expect(alertBars.length).toEqual(3);
|
expect(alertBars.length).toEqual(5);
|
||||||
expect(alertBars[1].innerHTML).toMatch(/My After All Exception/);
|
expect(alertBars[1].innerHTML).toMatch(/My After All Exception/);
|
||||||
expect(alertBars[1].getAttribute("class")).toEqual('bar errored');
|
expect(alertBars[1].getAttribute("class")).toEqual('jasmine-bar jasmine-errored');
|
||||||
expect(alertBars[2].innerHTML).toMatch(/My Other Exception/);
|
expect(alertBars[2].innerHTML).toMatch(/My Other Exception/);
|
||||||
|
expect(alertBars[3].innerHTML).toMatch(/Global After All Failure/);
|
||||||
|
expect(alertBars[4].innerHTML).toMatch(/Other Global/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -212,10 +213,10 @@ describe("New HtmlReporter", function() {
|
|||||||
if (!window.console) {
|
if (!window.console) {
|
||||||
window.console = { error: function(){} };
|
window.console = { error: function(){} };
|
||||||
}
|
}
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement('div'),
|
container = document.createElement('div'),
|
||||||
getContainer = function() {return container;},
|
getContainer = function() {return container;},
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
@@ -238,7 +239,7 @@ describe("New HtmlReporter", function() {
|
|||||||
reporter.suiteDone({id: 1});
|
reporter.suiteDone({id: 1});
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
var summary = container.querySelector('.summary');
|
var summary = container.querySelector('.jasmine-summary');
|
||||||
var suite = summary.childNodes[0];
|
var suite = summary.childNodes[0];
|
||||||
var specs = suite.childNodes[1];
|
var specs = suite.childNodes[1];
|
||||||
var spec = specs.childNodes[0];
|
var spec = specs.childNodes[0];
|
||||||
@@ -247,11 +248,11 @@ describe("New HtmlReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("reports the run time", function() {
|
it("reports the run time", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
timer = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
timer = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
||||||
getContainer = function() { return container; },
|
getContainer = function() { return container; },
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
@@ -266,15 +267,15 @@ describe("New HtmlReporter", function() {
|
|||||||
timer.elapsed.and.returnValue(100);
|
timer.elapsed.and.returnValue(100);
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone();
|
||||||
|
|
||||||
var duration = container.querySelector(".alert .duration");
|
var duration = container.querySelector(".jasmine-alert .jasmine-duration");
|
||||||
expect(duration.innerHTML).toMatch(/finished in 0.1s/);
|
expect(duration.innerHTML).toMatch(/finished in 0.1s/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reports the suite and spec names with status", function() {
|
it("reports the suite and spec names with status", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
getContainer = function() { return container; },
|
getContainer = function() { return container; },
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
@@ -334,7 +335,7 @@ describe("New HtmlReporter", function() {
|
|||||||
reporter.suiteDone({id: 1});
|
reporter.suiteDone({id: 1});
|
||||||
|
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
var summary = container.querySelector(".summary");
|
var summary = container.querySelector(".jasmine-summary");
|
||||||
|
|
||||||
expect(summary.childNodes.length).toEqual(1);
|
expect(summary.childNodes.length).toEqual(1);
|
||||||
|
|
||||||
@@ -346,7 +347,7 @@ describe("New HtmlReporter", function() {
|
|||||||
var node = outerSuite.childNodes[i];
|
var node = outerSuite.childNodes[i];
|
||||||
classes.push(node.getAttribute("class"));
|
classes.push(node.getAttribute("class"));
|
||||||
}
|
}
|
||||||
expect(classes).toEqual(["suite-detail", "specs", "suite", "specs"]);
|
expect(classes).toEqual(["jasmine-suite-detail", "jasmine-specs", "jasmine-suite", "jasmine-specs"]);
|
||||||
|
|
||||||
var suiteDetail = outerSuite.childNodes[0];
|
var suiteDetail = outerSuite.childNodes[0];
|
||||||
var suiteLink = suiteDetail.childNodes[0];
|
var suiteLink = suiteDetail.childNodes[0];
|
||||||
@@ -355,7 +356,7 @@ describe("New HtmlReporter", function() {
|
|||||||
|
|
||||||
var specs = outerSuite.childNodes[1];
|
var specs = outerSuite.childNodes[1];
|
||||||
var spec = specs.childNodes[0];
|
var spec = specs.childNodes[0];
|
||||||
expect(spec.getAttribute("class")).toEqual("passed");
|
expect(spec.getAttribute("class")).toEqual("jasmine-passed");
|
||||||
expect(spec.getAttribute("id")).toEqual("spec-123");
|
expect(spec.getAttribute("id")).toEqual("spec-123");
|
||||||
|
|
||||||
var specLink = spec.childNodes[0];
|
var specLink = spec.childNodes[0];
|
||||||
@@ -365,12 +366,12 @@ describe("New HtmlReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("has an options menu", function() {
|
it("has an options menu", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
getContainer = function() {
|
getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
},
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() {
|
createElement: function() {
|
||||||
@@ -384,28 +385,28 @@ describe("New HtmlReporter", function() {
|
|||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
var trigger = container.querySelector('.run-options .trigger'),
|
var trigger = container.querySelector('.jasmine-run-options .jasmine-trigger'),
|
||||||
payload = container.querySelector('.run-options .payload');
|
payload = container.querySelector('.jasmine-run-options .jasmine-payload');
|
||||||
|
|
||||||
expect(payload.className).not.toContain('open');
|
expect(payload.className).not.toContain('jasmine-open');
|
||||||
|
|
||||||
trigger.onclick();
|
trigger.onclick();
|
||||||
|
|
||||||
expect(payload.className).toContain('open');
|
expect(payload.className).toContain('jasmine-open');
|
||||||
|
|
||||||
trigger.onclick();
|
trigger.onclick();
|
||||||
|
|
||||||
expect(payload.className).not.toContain('open');
|
expect(payload.className).not.toContain('jasmine-open');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("UI for raising/catching exceptions", function() {
|
describe("UI for raising/catching exceptions", function() {
|
||||||
it("should be unchecked if the env is catching", function() {
|
it("should be unchecked if the env is catching", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
getContainer = function() {
|
getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
},
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() {
|
createElement: function() {
|
||||||
@@ -419,17 +420,17 @@ describe("New HtmlReporter", function() {
|
|||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
var raisingExceptionsUI = container.querySelector(".raise");
|
var raisingExceptionsUI = container.querySelector(".jasmine-raise");
|
||||||
expect(raisingExceptionsUI.checked).toBe(false);
|
expect(raisingExceptionsUI.checked).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be checked if the env is not catching", function() {
|
it("should be checked if the env is not catching", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
getContainer = function() {
|
getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
},
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() {
|
createElement: function() {
|
||||||
@@ -444,18 +445,18 @@ describe("New HtmlReporter", function() {
|
|||||||
env.catchExceptions(false);
|
env.catchExceptions(false);
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
var raisingExceptionsUI = container.querySelector(".raise");
|
var raisingExceptionsUI = container.querySelector(".jasmine-raise");
|
||||||
expect(raisingExceptionsUI.checked).toBe(true);
|
expect(raisingExceptionsUI.checked).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should affect the query param for catching exceptions", function() {
|
it("should affect the query param for catching exceptions", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
exceptionsClickHandler = jasmine.createSpy("raise exceptions checked"),
|
exceptionsClickHandler = jasmine.createSpy("raise exceptions checked"),
|
||||||
getContainer = function() {
|
getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
},
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
onRaiseExceptionsClick: exceptionsClickHandler,
|
onRaiseExceptionsClick: exceptionsClickHandler,
|
||||||
@@ -470,7 +471,7 @@ describe("New HtmlReporter", function() {
|
|||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
var input = container.querySelector(".raise");
|
var input = container.querySelector(".jasmine-raise");
|
||||||
input.click();
|
input.click();
|
||||||
expect(exceptionsClickHandler).toHaveBeenCalled();
|
expect(exceptionsClickHandler).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@@ -478,12 +479,12 @@ describe("New HtmlReporter", function() {
|
|||||||
|
|
||||||
describe("UI for throwing errors on expectation failures", function() {
|
describe("UI for throwing errors on expectation failures", function() {
|
||||||
it("should be unchecked if not throwing", function() {
|
it("should be unchecked if not throwing", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
getContainer = function() {
|
getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
},
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() {
|
createElement: function() {
|
||||||
@@ -497,17 +498,17 @@ describe("New HtmlReporter", function() {
|
|||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
var throwingExpectationsUI = container.querySelector(".throw");
|
var throwingExpectationsUI = container.querySelector(".jasmine-throw");
|
||||||
expect(throwingExpectationsUI.checked).toBe(false);
|
expect(throwingExpectationsUI.checked).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be checked if throwing", function() {
|
it("should be checked if throwing", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
getContainer = function() {
|
getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
},
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() {
|
createElement: function() {
|
||||||
@@ -523,18 +524,18 @@ describe("New HtmlReporter", function() {
|
|||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
var throwingExpectationsUI = container.querySelector(".throw");
|
var throwingExpectationsUI = container.querySelector(".jasmine-throw");
|
||||||
expect(throwingExpectationsUI.checked).toBe(true);
|
expect(throwingExpectationsUI.checked).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should affect the query param for throw expectation failures", function() {
|
it("should affect the query param for throw expectation failures", function() {
|
||||||
var env = new j$.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
throwingExceptionHandler = jasmine.createSpy('throwingExceptions'),
|
throwingExceptionHandler = jasmine.createSpy('throwingExceptions'),
|
||||||
getContainer = function() {
|
getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
},
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
onThrowExpectationsClick: throwingExceptionHandler,
|
onThrowExpectationsClick: throwingExceptionHandler,
|
||||||
@@ -549,19 +550,190 @@ describe("New HtmlReporter", function() {
|
|||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
var throwingExpectationsUI = container.querySelector(".throw");
|
var throwingExpectationsUI = container.querySelector(".jasmine-throw");
|
||||||
throwingExpectationsUI.click();
|
throwingExpectationsUI.click();
|
||||||
|
|
||||||
expect(throwingExceptionHandler).toHaveBeenCalled();
|
expect(throwingExceptionHandler).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("UI for running tests in random order", function() {
|
||||||
|
it("should be unchecked if not randomizing", function() {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
container = document.createElement("div"),
|
||||||
|
getContainer = function() {
|
||||||
|
return container;
|
||||||
|
},
|
||||||
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
|
env: env,
|
||||||
|
getContainer: getContainer,
|
||||||
|
createElement: function() {
|
||||||
|
return document.createElement.apply(document, arguments);
|
||||||
|
},
|
||||||
|
createTextNode: function() {
|
||||||
|
return document.createTextNode.apply(document, arguments);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
reporter.initialize();
|
||||||
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
|
var randomUI = container.querySelector(".jasmine-random");
|
||||||
|
expect(randomUI.checked).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should be checked if randomizing", function() {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
container = document.createElement("div"),
|
||||||
|
getContainer = function() {
|
||||||
|
return container;
|
||||||
|
},
|
||||||
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
|
env: env,
|
||||||
|
getContainer: getContainer,
|
||||||
|
createElement: function() {
|
||||||
|
return document.createElement.apply(document, arguments);
|
||||||
|
},
|
||||||
|
createTextNode: function() {
|
||||||
|
return document.createTextNode.apply(document, arguments);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
env.randomizeTests(true);
|
||||||
|
reporter.initialize();
|
||||||
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
|
var randomUI = container.querySelector(".jasmine-random");
|
||||||
|
expect(randomUI.checked).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should affect the query param for random tests", function() {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
container = document.createElement("div"),
|
||||||
|
randomHandler = jasmine.createSpy('randomHandler'),
|
||||||
|
getContainer = function() {
|
||||||
|
return container;
|
||||||
|
},
|
||||||
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
|
env: env,
|
||||||
|
getContainer: getContainer,
|
||||||
|
onRandomClick: randomHandler,
|
||||||
|
createElement: function() {
|
||||||
|
return document.createElement.apply(document, arguments);
|
||||||
|
},
|
||||||
|
createTextNode: function() {
|
||||||
|
return document.createTextNode.apply(document, arguments);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
reporter.initialize();
|
||||||
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
|
var randomUI = container.querySelector(".jasmine-random");
|
||||||
|
randomUI.click();
|
||||||
|
|
||||||
|
expect(randomHandler).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show the seed bar if randomizing", function() {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
container = document.createElement("div"),
|
||||||
|
getContainer = function() {
|
||||||
|
return container;
|
||||||
|
},
|
||||||
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
|
env: env,
|
||||||
|
getContainer: getContainer,
|
||||||
|
createElement: function() {
|
||||||
|
return document.createElement.apply(document, arguments);
|
||||||
|
},
|
||||||
|
createTextNode: function() {
|
||||||
|
return document.createTextNode.apply(document, arguments);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
reporter.initialize();
|
||||||
|
reporter.jasmineDone({
|
||||||
|
order: {
|
||||||
|
random: true,
|
||||||
|
seed: '424242'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var seedBar = container.querySelector(".jasmine-seed-bar");
|
||||||
|
var seedBarText = 'textContent' in seedBar ? seedBar.textContent : seedBar.innerText;
|
||||||
|
expect(seedBarText).toBe(', randomized with seed 424242');
|
||||||
|
var seedLink = container.querySelector(".jasmine-seed-bar a");
|
||||||
|
expect(seedLink.getAttribute('href')).toBe('?seed=424242');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not show the current seed bar if not randomizing", function() {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
container = document.createElement("div"),
|
||||||
|
getContainer = function() {
|
||||||
|
return container;
|
||||||
|
},
|
||||||
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
|
env: env,
|
||||||
|
getContainer: getContainer,
|
||||||
|
createElement: function() {
|
||||||
|
return document.createElement.apply(document, arguments);
|
||||||
|
},
|
||||||
|
createTextNode: function() {
|
||||||
|
return document.createTextNode.apply(document, arguments);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
reporter.initialize();
|
||||||
|
reporter.jasmineDone();
|
||||||
|
|
||||||
|
var seedBar = container.querySelector(".jasmine-seed-bar");
|
||||||
|
expect(seedBar).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should include the random query param in the jasmine-skipped link when randomizing", function(){
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
container = document.createElement("div"),
|
||||||
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
|
env: env,
|
||||||
|
getContainer: function() { return container; },
|
||||||
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
|
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||||
|
});
|
||||||
|
|
||||||
|
reporter.initialize();
|
||||||
|
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
||||||
|
reporter.jasmineDone({ order: { random: true } });
|
||||||
|
|
||||||
|
var skippedLink = container.querySelector(".jasmine-skipped a");
|
||||||
|
expect(skippedLink.getAttribute('href')).toEqual('?random=true');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not include the random query param in the jasmine-skipped link when not randomizing", function(){
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
container = document.createElement("div"),
|
||||||
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
|
env: env,
|
||||||
|
getContainer: function() { return container; },
|
||||||
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
|
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||||
|
});
|
||||||
|
|
||||||
|
reporter.initialize();
|
||||||
|
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
||||||
|
reporter.jasmineDone();
|
||||||
|
|
||||||
|
var skippedLink = container.querySelector(".jasmine-skipped a");
|
||||||
|
expect(skippedLink.getAttribute('href')).toEqual('?');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("shows a message if no specs are run", function(){
|
it("shows a message if no specs are run", function(){
|
||||||
var env, container, reporter;
|
var env, container, reporter;
|
||||||
env = new j$.Env();
|
env = new jasmineUnderTest.Env();
|
||||||
container = document.createElement("div");
|
container = document.createElement("div");
|
||||||
var getContainer = function() { return container; },
|
var getContainer = function() { return container; },
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
@@ -572,18 +744,18 @@ describe("New HtmlReporter", function() {
|
|||||||
reporter.jasmineStarted({});
|
reporter.jasmineStarted({});
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
var alertBars = container.querySelectorAll(".alert .bar");
|
var alertBars = container.querySelectorAll(".jasmine-alert .jasmine-bar");
|
||||||
expect(alertBars[0].getAttribute('class')).toMatch(/skipped/);
|
expect(alertBars[0].getAttribute('class')).toMatch(/jasmine-skipped/);
|
||||||
expect(alertBars[0].innerHTML).toMatch(/No specs found/);
|
expect(alertBars[0].innerHTML).toMatch(/No specs found/);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("and all specs pass", function() {
|
describe("and all specs pass", function() {
|
||||||
var env, container, reporter;
|
var env, container, reporter;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
env = new j$.Env();
|
env = new jasmineUnderTest.Env();
|
||||||
container = document.createElement("div");
|
container = document.createElement("div");
|
||||||
var getContainer = function() { return container; },
|
var getContainer = function() { return container; },
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
@@ -612,21 +784,21 @@ describe("New HtmlReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("reports the specs counts", function() {
|
it("reports the specs counts", function() {
|
||||||
var alertBars = container.querySelectorAll(".alert .bar");
|
var alertBars = container.querySelectorAll(".jasmine-alert .jasmine-bar");
|
||||||
|
|
||||||
expect(alertBars.length).toEqual(1);
|
expect(alertBars.length).toEqual(1);
|
||||||
expect(alertBars[0].getAttribute('class')).toMatch(/passed/);
|
expect(alertBars[0].getAttribute('class')).toMatch(/jasmine-passed/);
|
||||||
expect(alertBars[0].innerHTML).toMatch(/2 specs, 0 failures/);
|
expect(alertBars[0].innerHTML).toMatch(/2 specs, 0 failures/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reports no failure details", function() {
|
it("reports no failure details", function() {
|
||||||
var specFailure = container.querySelector(".failures");
|
var specFailure = container.querySelector(".jasmine-failures");
|
||||||
|
|
||||||
expect(specFailure.childNodes.length).toEqual(0);
|
expect(specFailure.childNodes.length).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reports no pending specs", function() {
|
it("reports no pending specs", function() {
|
||||||
var alertBar = container.querySelector(".alert .bar");
|
var alertBar = container.querySelector(".jasmine-alert .jasmine-bar");
|
||||||
|
|
||||||
expect(alertBar.innerHTML).not.toMatch(/pending spec[s]/);
|
expect(alertBar.innerHTML).not.toMatch(/pending spec[s]/);
|
||||||
});
|
});
|
||||||
@@ -635,10 +807,10 @@ describe("New HtmlReporter", function() {
|
|||||||
describe("and there are pending specs", function() {
|
describe("and there are pending specs", function() {
|
||||||
var env, container, reporter;
|
var env, container, reporter;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
env = new j$.Env();
|
env = new jasmineUnderTest.Env();
|
||||||
container = document.createElement("div");
|
container = document.createElement("div");
|
||||||
var getContainer = function() { return container; };
|
var getContainer = function() { return container; };
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
@@ -662,19 +834,19 @@ describe("New HtmlReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("reports the pending specs count", function() {
|
it("reports the pending specs count", function() {
|
||||||
var alertBar = container.querySelector(".alert .bar");
|
var alertBar = container.querySelector(".jasmine-alert .jasmine-bar");
|
||||||
|
|
||||||
expect(alertBar.innerHTML).toMatch(/1 spec, 0 failures, 1 pending spec/);
|
expect(alertBar.innerHTML).toMatch(/1 spec, 0 failures, 1 pending spec/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reports no failure details", function() {
|
it("reports no failure details", function() {
|
||||||
var specFailure = container.querySelector(".failures");
|
var specFailure = container.querySelector(".jasmine-failures");
|
||||||
|
|
||||||
expect(specFailure.childNodes.length).toEqual(0);
|
expect(specFailure.childNodes.length).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("displays the custom pending reason", function() {
|
it("displays the custom pending reason", function() {
|
||||||
var pendingDetails = container.querySelector(".summary .pending");
|
var pendingDetails = container.querySelector(".jasmine-summary .jasmine-pending");
|
||||||
|
|
||||||
expect(pendingDetails.innerHTML).toContain("my custom pending reason");
|
expect(pendingDetails.innerHTML).toContain("my custom pending reason");
|
||||||
});
|
});
|
||||||
@@ -684,10 +856,10 @@ describe("New HtmlReporter", function() {
|
|||||||
var env, container, reporter;
|
var env, container, reporter;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
env = new j$.Env();
|
env = new jasmineUnderTest.Env();
|
||||||
container = document.createElement("div");
|
container = document.createElement("div");
|
||||||
var getContainer = function() { return container; }
|
var getContainer = function() { return container; }
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
@@ -721,37 +893,37 @@ describe("New HtmlReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("reports the specs counts", function() {
|
it("reports the specs counts", function() {
|
||||||
var alertBar = container.querySelector(".alert .bar");
|
var alertBar = container.querySelector(".jasmine-alert .jasmine-bar");
|
||||||
|
|
||||||
expect(alertBar.getAttribute('class')).toMatch(/failed/);
|
expect(alertBar.getAttribute('class')).toMatch(/jasmine-failed/);
|
||||||
expect(alertBar.innerHTML).toMatch(/2 specs, 1 failure/);
|
expect(alertBar.innerHTML).toMatch(/2 specs, 1 failure/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reports failure messages and stack traces", function() {
|
it("reports failure messages and stack traces", function() {
|
||||||
var specFailures = container.querySelector(".failures");
|
var specFailures = container.querySelector(".jasmine-failures");
|
||||||
|
|
||||||
var failure = specFailures.childNodes[0];
|
var failure = specFailures.childNodes[0];
|
||||||
expect(failure.getAttribute("class")).toMatch(/failed/);
|
expect(failure.getAttribute("class")).toMatch(/jasmine-failed/);
|
||||||
expect(failure.getAttribute("class")).toMatch(/spec-detail/);
|
expect(failure.getAttribute("class")).toMatch(/jasmine-spec-detail/);
|
||||||
|
|
||||||
var specDiv = failure.childNodes[0];
|
var specDiv = failure.childNodes[0];
|
||||||
expect(specDiv.getAttribute("class")).toEqual("description");
|
expect(specDiv.getAttribute("class")).toEqual("jasmine-description");
|
||||||
|
|
||||||
var specLink = specDiv.childNodes[0];
|
var specLink = specDiv.childNodes[0];
|
||||||
expect(specLink.getAttribute("title")).toEqual("a suite with a failing spec");
|
expect(specLink.getAttribute("title")).toEqual("a suite with a failing spec");
|
||||||
expect(specLink.getAttribute("href")).toEqual("?foo=bar&spec=a suite with a failing spec");
|
expect(specLink.getAttribute("href")).toEqual("?foo=bar&spec=a suite with a failing spec");
|
||||||
|
|
||||||
var message = failure.childNodes[1].childNodes[0];
|
var message = failure.childNodes[1].childNodes[0];
|
||||||
expect(message.getAttribute("class")).toEqual("result-message");
|
expect(message.getAttribute("class")).toEqual("jasmine-result-message");
|
||||||
expect(message.innerHTML).toEqual("a failure message");
|
expect(message.innerHTML).toEqual("a failure message");
|
||||||
|
|
||||||
var stackTrace = failure.childNodes[1].childNodes[1];
|
var stackTrace = failure.childNodes[1].childNodes[1];
|
||||||
expect(stackTrace.getAttribute("class")).toEqual("stack-trace");
|
expect(stackTrace.getAttribute("class")).toEqual("jasmine-stack-trace");
|
||||||
expect(stackTrace.innerHTML).toEqual("a stack trace");
|
expect(stackTrace.innerHTML).toEqual("a stack trace");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows switching between failure details and the spec summary", function() {
|
it("allows switching between failure details and the spec summary", function() {
|
||||||
var menuBar = container.querySelectorAll(".bar")[1];
|
var menuBar = container.querySelectorAll(".jasmine-bar")[1];
|
||||||
|
|
||||||
expect(menuBar.getAttribute("class")).not.toMatch(/hidden/);
|
expect(menuBar.getAttribute("class")).not.toMatch(/hidden/);
|
||||||
|
|
||||||
@@ -762,7 +934,7 @@ describe("New HtmlReporter", function() {
|
|||||||
|
|
||||||
it("sets the reporter to 'Failures List' mode", function() {
|
it("sets the reporter to 'Failures List' mode", function() {
|
||||||
var reporterNode = container.querySelector(".jasmine_html-reporter");
|
var reporterNode = container.querySelector(".jasmine_html-reporter");
|
||||||
expect(reporterNode.getAttribute("class")).toMatch("failure-list");
|
expect(reporterNode.getAttribute("class")).toMatch("jasmine-failure-list");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
describe("j$.HtmlSpecFilter", function() {
|
describe("jasmineUnderTest.HtmlSpecFilter", function() {
|
||||||
|
|
||||||
it("should match when no string is provided", function() {
|
it("should match when no string is provided", function() {
|
||||||
var specFilter = new j$.HtmlSpecFilter();
|
var specFilter = new jasmineUnderTest.HtmlSpecFilter();
|
||||||
|
|
||||||
expect(specFilter.matches("foo")).toBe(true);
|
expect(specFilter.matches("foo")).toBe(true);
|
||||||
expect(specFilter.matches("*bar")).toBe(true);
|
expect(specFilter.matches("*bar")).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should only match the provided string", function() {
|
it("should only match the provided string", function() {
|
||||||
var specFilter = new j$.HtmlSpecFilter({
|
var specFilter = new jasmineUnderTest.HtmlSpecFilter({
|
||||||
filterString: function() { return "foo"; }
|
filterString: function() { return "foo"; }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ describe("MatchersSpec - HTML Dependent", function () {
|
|||||||
var env, spec;
|
var env, spec;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
env = new j$.Env();
|
env = new jasmineUnderTest.Env();
|
||||||
|
|
||||||
var suite = env.describe("suite", function() {
|
var suite = env.describe("suite", function() {
|
||||||
spec = env.it("spec", function() {
|
spec = env.it("spec", function() {
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
describe("j$.pp (HTML Dependent)", function () {
|
describe("jasmineUnderTest.pp (HTML Dependent)", function () {
|
||||||
it("should stringify HTML nodes properly", function() {
|
it("should stringify HTML nodes properly", function() {
|
||||||
var sampleNode = document.createElement('div');
|
var sampleNode = document.createElement('div');
|
||||||
sampleNode.innerHTML = 'foo<b>bar</b>';
|
sampleNode.innerHTML = 'foo<b>bar</b>';
|
||||||
expect(j$.pp(sampleNode)).toEqual("HTMLNode");
|
expect(jasmineUnderTest.pp(sampleNode)).toEqual("HTMLNode");
|
||||||
expect(j$.pp({foo: sampleNode})).toEqual("Object({ foo: HTMLNode })");
|
expect(jasmineUnderTest.pp({foo: sampleNode})).toEqual("Object({ foo: HTMLNode })");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should print Firefox's wrapped native objects correctly", function() {
|
it("should print Firefox's wrapped native objects correctly", function() {
|
||||||
if(jasmine.getEnv().firefoxVersion) {
|
if(jasmine.getEnv().firefoxVersion) {
|
||||||
try { new CustomEvent(); } catch(e) { var err = e; };
|
try { new CustomEvent(); } catch(e) { var err = e; };
|
||||||
expect(j$.pp(err)).toMatch(/Not enough arguments/);
|
expect(jasmineUnderTest.pp(err)).toMatch(/Not enough arguments/);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ describe("QueryString", function() {
|
|||||||
var windowLocation = {
|
var windowLocation = {
|
||||||
search: ""
|
search: ""
|
||||||
},
|
},
|
||||||
queryString = new j$.QueryString({
|
queryString = new jasmineUnderTest.QueryString({
|
||||||
getWindowLocation: function() { return windowLocation }
|
getWindowLocation: function() { return windowLocation }
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ describe("QueryString", function() {
|
|||||||
var windowLocation = {
|
var windowLocation = {
|
||||||
search: "?foo=bar"
|
search: "?foo=bar"
|
||||||
},
|
},
|
||||||
queryString = new j$.QueryString({
|
queryString = new jasmineUnderTest.QueryString({
|
||||||
getWindowLocation: function() { return windowLocation }
|
getWindowLocation: function() { return windowLocation }
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ describe("QueryString", function() {
|
|||||||
var windowLocation = {
|
var windowLocation = {
|
||||||
search: "?foo=bar"
|
search: "?foo=bar"
|
||||||
},
|
},
|
||||||
queryString = new j$.QueryString({
|
queryString = new jasmineUnderTest.QueryString({
|
||||||
getWindowLocation: function() { return windowLocation }
|
getWindowLocation: function() { return windowLocation }
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ describe("QueryString", function() {
|
|||||||
var windowLocation = {
|
var windowLocation = {
|
||||||
search: "?baz=quux%20corge"
|
search: "?baz=quux%20corge"
|
||||||
},
|
},
|
||||||
queryString = new j$.QueryString({
|
queryString = new jasmineUnderTest.QueryString({
|
||||||
getWindowLocation: function() { return windowLocation }
|
getWindowLocation: function() { return windowLocation }
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ describe("QueryString", function() {
|
|||||||
var windowLocation = {
|
var windowLocation = {
|
||||||
search: ""
|
search: ""
|
||||||
},
|
},
|
||||||
queryString = new j$.QueryString({
|
queryString = new jasmineUnderTest.QueryString({
|
||||||
getWindowLocation: function() { return windowLocation }
|
getWindowLocation: function() { return windowLocation }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ describe("ResultsNode", function() {
|
|||||||
id: 123,
|
id: 123,
|
||||||
message: "foo"
|
message: "foo"
|
||||||
},
|
},
|
||||||
node = new j$.ResultsNode(fakeResult, "suite", null);
|
node = new jasmineUnderTest.ResultsNode(fakeResult, "suite", null);
|
||||||
|
|
||||||
expect(node.result).toBe(fakeResult);
|
expect(node.result).toBe(fakeResult);
|
||||||
expect(node.type).toEqual("suite");
|
expect(node.type).toEqual("suite");
|
||||||
@@ -19,7 +19,7 @@ describe("ResultsNode", function() {
|
|||||||
id: 456,
|
id: 456,
|
||||||
message: "bar"
|
message: "bar"
|
||||||
},
|
},
|
||||||
node = new j$.ResultsNode(fakeResult, "suite", null);
|
node = new jasmineUnderTest.ResultsNode(fakeResult, "suite", null);
|
||||||
|
|
||||||
node.addChild(fakeChildResult, "spec");
|
node.addChild(fakeChildResult, "spec");
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ describe("ResultsNode", function() {
|
|||||||
id: 456,
|
id: 456,
|
||||||
message: "bar"
|
message: "bar"
|
||||||
},
|
},
|
||||||
node = new j$.ResultsNode(fakeResult, "suite", null);
|
node = new jasmineUnderTest.ResultsNode(fakeResult, "suite", null);
|
||||||
|
|
||||||
node.addChild(fakeChildResult, "spec");
|
node.addChild(fakeChildResult, "spec");
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ describe("ResultsNode", function() {
|
|||||||
id: 456,
|
id: 456,
|
||||||
message: "bar"
|
message: "bar"
|
||||||
},
|
},
|
||||||
node = new j$.ResultsNode(fakeResult, "suite", null);
|
node = new jasmineUnderTest.ResultsNode(fakeResult, "suite", null);
|
||||||
|
|
||||||
node.addChild(fakeChildResult, "spec");
|
node.addChild(fakeChildResult, "spec");
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
use_sauce: <%= ENV['USE_SAUCE'] %>
|
use_sauce: <%= ENV['USE_SAUCE'] %>
|
||||||
browser: <%= ENV['JASMINE_BROWSER'] %>
|
browser: <%= ENV['JASMINE_BROWSER'] %>
|
||||||
sauce:
|
sauce:
|
||||||
|
sauce_connect_path: "/Users/gregg/Downloads/sc-4.3.11-osx/bin/sc"
|
||||||
name: jasmine-core <%= Time.now.to_s %>
|
name: jasmine-core <%= Time.now.to_s %>
|
||||||
username: <%= ENV['SAUCE_USERNAME'] %>
|
username: <%= ENV['SAUCE_USERNAME'] %>
|
||||||
access_key: <%= ENV['SAUCE_ACCESS_KEY'] %>
|
access_key: <%= ENV['SAUCE_ACCESS_KEY'] %>
|
||||||
@@ -11,6 +12,6 @@ sauce:
|
|||||||
- CI
|
- CI
|
||||||
tunnel_identifier: <%= ENV['TRAVIS_JOB_NUMBER'] ? %Q("#{ENV['TRAVIS_JOB_NUMBER']}") : nil %>
|
tunnel_identifier: <%= ENV['TRAVIS_JOB_NUMBER'] ? %Q("#{ENV['TRAVIS_JOB_NUMBER']}") : nil %>
|
||||||
os: <%= ENV['SAUCE_OS'] %>
|
os: <%= ENV['SAUCE_OS'] %>
|
||||||
browser_version: <%= ENV['SAUCE_BROWSER_VERSION'] %>
|
browser_version: "<%= ENV['SAUCE_BROWSER_VERSION'] %>"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,195 +0,0 @@
|
|||||||
var fs = require('fs');
|
|
||||||
var util = require('util');
|
|
||||||
var path = require('path');
|
|
||||||
|
|
||||||
// boot code for jasmine
|
|
||||||
var jasmineRequire = require('../lib/jasmine-core/jasmine.js');
|
|
||||||
var jasmine = jasmineRequire.core(jasmineRequire);
|
|
||||||
|
|
||||||
var consoleFns = require('../lib/console/console.js');
|
|
||||||
extend(jasmineRequire, consoleFns);
|
|
||||||
jasmineRequire.console(jasmineRequire, jasmine);
|
|
||||||
|
|
||||||
var env = jasmine.getEnv();
|
|
||||||
|
|
||||||
var jasmineInterface = {
|
|
||||||
describe: function(description, specDefinitions) {
|
|
||||||
return env.describe(description, specDefinitions);
|
|
||||||
},
|
|
||||||
|
|
||||||
xdescribe: function(description, specDefinitions) {
|
|
||||||
return env.xdescribe(description, specDefinitions);
|
|
||||||
},
|
|
||||||
|
|
||||||
it: function(desc, func) {
|
|
||||||
return env.it(desc, func);
|
|
||||||
},
|
|
||||||
|
|
||||||
xit: function(desc, func) {
|
|
||||||
return env.xit(desc, func);
|
|
||||||
},
|
|
||||||
|
|
||||||
beforeEach: function(beforeEachFunction) {
|
|
||||||
return env.beforeEach(beforeEachFunction);
|
|
||||||
},
|
|
||||||
|
|
||||||
afterEach: function(afterEachFunction) {
|
|
||||||
return env.afterEach(afterEachFunction);
|
|
||||||
},
|
|
||||||
|
|
||||||
expect: function(actual) {
|
|
||||||
return env.expect(actual);
|
|
||||||
},
|
|
||||||
|
|
||||||
spyOn: function(obj, methodName) {
|
|
||||||
return env.spyOn(obj, methodName);
|
|
||||||
},
|
|
||||||
|
|
||||||
jsApiReporter: new jasmine.JsApiReporter({
|
|
||||||
timer: new jasmine.Timer()
|
|
||||||
}),
|
|
||||||
|
|
||||||
beforeAll: function(beforeAllFunction) {
|
|
||||||
return env.beforeAll(beforeAllFunction);
|
|
||||||
},
|
|
||||||
|
|
||||||
afterAll: function(afterAllFunction) {
|
|
||||||
return env.afterAll(afterAllFunction);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
extend(global, jasmineInterface);
|
|
||||||
|
|
||||||
function extend(destination, source) {
|
|
||||||
for (var property in source) destination[property] = source[property];
|
|
||||||
return destination;
|
|
||||||
}
|
|
||||||
|
|
||||||
jasmine.addCustomEqualityTester = function(tester) {
|
|
||||||
env.addCustomEqualityTester(tester);
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.addMatchers = function(matchers) {
|
|
||||||
return env.addMatchers(matchers);
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.clock = function() {
|
|
||||||
return env.clock;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Jasmine "runner"
|
|
||||||
function executeSpecs(specs, done, isVerbose, showColors) {
|
|
||||||
global.jasmine = jasmine;
|
|
||||||
|
|
||||||
for (var i = 0; i < specs.length; i++) {
|
|
||||||
var filename = specs[i];
|
|
||||||
require(filename.replace(/\.\w+$/, ""));
|
|
||||||
}
|
|
||||||
|
|
||||||
var env = jasmine.getEnv();
|
|
||||||
var consoleReporter = new jasmine.ConsoleReporter({
|
|
||||||
print: util.print,
|
|
||||||
onComplete: done,
|
|
||||||
showColors: showColors,
|
|
||||||
timer: new jasmine.Timer()
|
|
||||||
});
|
|
||||||
|
|
||||||
env.addReporter(consoleReporter);
|
|
||||||
env.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFiles(dir, matcher) {
|
|
||||||
var allFiles = [];
|
|
||||||
|
|
||||||
if (fs.statSync(dir).isFile() && dir.match(matcher)) {
|
|
||||||
allFiles.push(dir);
|
|
||||||
} else {
|
|
||||||
var files = fs.readdirSync(dir);
|
|
||||||
for (var i = 0, len = files.length; i < len; ++i) {
|
|
||||||
var filename = dir + '/' + files[i];
|
|
||||||
if (fs.statSync(filename).isFile() && filename.match(matcher)) {
|
|
||||||
allFiles.push(filename);
|
|
||||||
} else if (fs.statSync(filename).isDirectory()) {
|
|
||||||
var subfiles = getFiles(filename);
|
|
||||||
subfiles.forEach(function(result) {
|
|
||||||
allFiles.push(result);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return allFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSpecFiles(dir) {
|
|
||||||
return getFiles(dir, new RegExp("Spec.js$"));
|
|
||||||
}
|
|
||||||
|
|
||||||
var j$require = (function() {
|
|
||||||
var exported = {},
|
|
||||||
j$req;
|
|
||||||
|
|
||||||
global.getJasmineRequireObj = getJasmineRequireObj;
|
|
||||||
|
|
||||||
j$req = require(__dirname + "/../src/core/requireCore.js");
|
|
||||||
extend(j$req, require(__dirname + "/../src/console/requireConsole.js"));
|
|
||||||
|
|
||||||
var srcFiles = getFiles(__dirname + "/../src/core");
|
|
||||||
srcFiles.push(__dirname + "/../src/version.js");
|
|
||||||
srcFiles.push(__dirname + "/../src/console/ConsoleReporter.js");
|
|
||||||
|
|
||||||
for (var i = 0; i < srcFiles.length; i++) {
|
|
||||||
require(srcFiles[i]);
|
|
||||||
}
|
|
||||||
extend(j$req, exported);
|
|
||||||
|
|
||||||
delete global.getJasmineRequireObj;
|
|
||||||
|
|
||||||
return j$req;
|
|
||||||
|
|
||||||
function getJasmineRequireObj() {
|
|
||||||
return exported;
|
|
||||||
}
|
|
||||||
}());
|
|
||||||
|
|
||||||
j$ = j$require.core(j$require);
|
|
||||||
j$require.console(j$require, j$);
|
|
||||||
|
|
||||||
// options from command line
|
|
||||||
var isVerbose = false;
|
|
||||||
var showColors = true;
|
|
||||||
var perfSuite = false;
|
|
||||||
|
|
||||||
process.argv.forEach(function(arg) {
|
|
||||||
switch (arg) {
|
|
||||||
case '--color':
|
|
||||||
showColors = true;
|
|
||||||
break;
|
|
||||||
case '--noColor':
|
|
||||||
showColors = false;
|
|
||||||
break;
|
|
||||||
case '--verbose':
|
|
||||||
isVerbose = true;
|
|
||||||
break;
|
|
||||||
case '--perf':
|
|
||||||
perfSuite = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
specs = [];
|
|
||||||
|
|
||||||
if (perfSuite) {
|
|
||||||
specs = getFiles(__dirname + '/performance', new RegExp("test.js$"));
|
|
||||||
} else {
|
|
||||||
var consoleSpecs = getSpecFiles(__dirname + "/console"),
|
|
||||||
coreSpecs = getSpecFiles(__dirname + "/core"),
|
|
||||||
specs = consoleSpecs.concat(coreSpecs);
|
|
||||||
}
|
|
||||||
|
|
||||||
executeSpecs(specs, function(passed) {
|
|
||||||
if (passed) {
|
|
||||||
process.exit(0);
|
|
||||||
} else {
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
}, isVerbose, showColors);
|
|
||||||
@@ -5,9 +5,9 @@ describe('npm package', function() {
|
|||||||
|
|
||||||
beforeAll(function() {
|
beforeAll(function() {
|
||||||
var shell = require('shelljs'),
|
var shell = require('shelljs'),
|
||||||
pack = shell.exec('npm pack', { silent: true });
|
pack = shell.exec('npm pack', { silent: true});
|
||||||
|
|
||||||
this.tarball = pack.output.split('\n')[0];
|
this.tarball = pack.stdout.split('\n')[0];
|
||||||
this.tmpDir = temp.mkdirSync(); // automatically deleted on exit
|
this.tmpDir = temp.mkdirSync(); // automatically deleted on exit
|
||||||
|
|
||||||
var untar = shell.exec('tar -xzf ' + this.tarball + ' -C ' + this.tmpDir, { silent: true });
|
var untar = shell.exec('tar -xzf ' + this.tarball + ' -C ' + this.tmpDir, { silent: true });
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ describe('Printing a big object', function(){
|
|||||||
|
|
||||||
it('takes a resonable amount of time', function(){
|
it('takes a resonable amount of time', function(){
|
||||||
bigObject = generateObject(0);
|
bigObject = generateObject(0);
|
||||||
expect(j$.pp(bigObject)).toMatch(/cycle/);
|
expect(jasmineUnderTest.pp(bigObject)).toMatch(/cycle/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,5 +5,6 @@
|
|||||||
],
|
],
|
||||||
"helper_files": [
|
"helper_files": [
|
||||||
"helpers/nodeDefineJasmineUnderTest.js"
|
"helpers/nodeDefineJasmineUnderTest.js"
|
||||||
]
|
],
|
||||||
|
"random": true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,3 +7,4 @@ helpers:
|
|||||||
spec_files:
|
spec_files:
|
||||||
- 'performance/performance_test.js'
|
- 'performance/performance_test.js'
|
||||||
spec_dir: spec
|
spec_dir: spec
|
||||||
|
random: true
|
||||||
|
|||||||
@@ -7,5 +7,6 @@
|
|||||||
],
|
],
|
||||||
"helpers": [
|
"helpers": [
|
||||||
"helpers/nodeDefineJasmineUnderTest.js"
|
"helpers/nodeDefineJasmineUnderTest.js"
|
||||||
]
|
],
|
||||||
|
"random": true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,5 +22,6 @@ spec_files:
|
|||||||
- '**/*[Ss]pec.js'
|
- '**/*[Ss]pec.js'
|
||||||
- '!npmPackage/**/*'
|
- '!npmPackage/**/*'
|
||||||
spec_dir: spec
|
spec_dir: spec
|
||||||
|
random: true
|
||||||
|
spec_helper: spec/support/jasmine_helper.rb
|
||||||
|
|
||||||
|
|||||||
3
spec/support/jasmine_helper.rb
Normal file
3
spec/support/jasmine_helper.rb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Jasmine.configure do |config|
|
||||||
|
config.prevent_phantom_js_auto_install = true
|
||||||
|
end
|
||||||
@@ -1,9 +1,26 @@
|
|||||||
getJasmineRequireObj().CallTracker = function() {
|
getJasmineRequireObj().CallTracker = function(j$) {
|
||||||
|
|
||||||
function CallTracker() {
|
function CallTracker() {
|
||||||
var calls = [];
|
var calls = [];
|
||||||
|
var opts = {};
|
||||||
|
|
||||||
|
function argCloner(context) {
|
||||||
|
var clonedArgs = [];
|
||||||
|
var argsAsArray = j$.util.argsToArray(context.args);
|
||||||
|
for(var i = 0; i < argsAsArray.length; i++) {
|
||||||
|
if(Object.prototype.toString.apply(argsAsArray[i]).match(/^\[object/)) {
|
||||||
|
clonedArgs.push(j$.util.clone(argsAsArray[i]));
|
||||||
|
} else {
|
||||||
|
clonedArgs.push(argsAsArray[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
context.args = clonedArgs;
|
||||||
|
}
|
||||||
|
|
||||||
this.track = function(context) {
|
this.track = function(context) {
|
||||||
|
if(opts.cloneArgs) {
|
||||||
|
argCloner(context);
|
||||||
|
}
|
||||||
calls.push(context);
|
calls.push(context);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -44,6 +61,11 @@ getJasmineRequireObj().CallTracker = function() {
|
|||||||
this.reset = function() {
|
this.reset = function() {
|
||||||
calls = [];
|
calls = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.saveArgumentsByValue = function() {
|
||||||
|
opts.cloneArgs = true;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return CallTracker;
|
return CallTracker;
|
||||||
|
|||||||
@@ -82,8 +82,7 @@ getJasmineRequireObj().Clock = function() {
|
|||||||
|
|
||||||
self.tick = function(millis) {
|
self.tick = function(millis) {
|
||||||
if (installed) {
|
if (installed) {
|
||||||
mockDate.tick(millis);
|
delayedFunctionScheduler.tick(millis, function(millis) { mockDate.tick(millis); });
|
||||||
delayedFunctionScheduler.tick(millis);
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Mock clock is not installed, use jasmine.clock().install()');
|
throw new Error('Mock clock is not installed, use jasmine.clock().install()');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
|||||||
var currentTime = 0;
|
var currentTime = 0;
|
||||||
var delayedFnCount = 0;
|
var delayedFnCount = 0;
|
||||||
|
|
||||||
self.tick = function(millis) {
|
self.tick = function(millis, tickDate) {
|
||||||
millis = millis || 0;
|
millis = millis || 0;
|
||||||
var endTime = currentTime + millis;
|
var endTime = currentTime + millis;
|
||||||
|
|
||||||
runScheduledFunctions(endTime);
|
runScheduledFunctions(endTime, tickDate);
|
||||||
currentTime = endTime;
|
currentTime = endTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -113,13 +113,18 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function runScheduledFunctions(endTime) {
|
function runScheduledFunctions(endTime, tickDate) {
|
||||||
|
tickDate = tickDate || function() {};
|
||||||
if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
|
if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
|
||||||
|
tickDate(endTime - currentTime);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
currentTime = scheduledLookup.shift();
|
var newCurrentTime = scheduledLookup.shift();
|
||||||
|
tickDate(newCurrentTime - currentTime);
|
||||||
|
|
||||||
|
currentTime = newCurrentTime;
|
||||||
|
|
||||||
var funcsToRun = scheduledFunctions[currentTime];
|
var funcsToRun = scheduledFunctions[currentTime];
|
||||||
delete scheduledFunctions[currentTime];
|
delete scheduledFunctions[currentTime];
|
||||||
@@ -138,6 +143,11 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
|||||||
// scheduled in a funcToRun from forcing an extra iteration
|
// scheduled in a funcToRun from forcing an extra iteration
|
||||||
currentTime !== endTime &&
|
currentTime !== endTime &&
|
||||||
scheduledLookup[0] <= endTime);
|
scheduledLookup[0] <= endTime);
|
||||||
|
|
||||||
|
// ran out of functions to call, but still time left on the clock
|
||||||
|
if (currentTime !== endTime) {
|
||||||
|
tickDate(endTime - currentTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user