Compare commits

...

247 Commits

Author SHA1 Message Date
Davis W. Frank
227698f5fa Updating source and standalone distribution to 2.0.1 2014-07-21 12:36:24 -07:00
Davis W. Frank
ff1fa6a893 Updating version to 2.0.1 2014-07-21 12:35:34 -07:00
Davis W. Frank
ba1f8bc036 Merge branch 'master' of https://github.com/pivotal/jasmine 2014-07-21 12:33:42 -07:00
Davis W. Frank
a5be51f912 First cut at 2.0.1 release notes 2014-07-21 12:33:39 -07:00
Rajan Agaskar
d64ed6ebe9 Merge pull request #632 from kissrobber/bug_fix
Fixes incorrect use of signature args

- Not currently an issue, since always called with '2', but could break unexpectedly if argSlice is used without reading the body.
2014-07-21 06:46:05 -07:00
kissrobber
062dc6b15a fix a potential bug 2014-07-21 00:35:33 +09:00
slackersoft
33641578e6 update release doc to use github releases 2014-07-18 14:27:18 -07:00
slackersoft
a1c109ea17 Contains is explicitly false if actual is undefined or null
Fix #627
2014-07-18 13:18:22 -07:00
slackersoft
62212bbfa4 use released jasmine selenium runner 2014-07-18 13:07:11 -07:00
Rajan Agaskar
6a89d084f4 Merge pull request #621 from bengrunfeld/docs-installation
Add installation instructions to README
2014-07-07 12:56:32 -07:00
bengrunfeld
013c4f725f Add Ruby Gem and Python Egg to docs 2014-07-07 10:11:13 -06:00
bengrunfeld
c064488192 Add installation instructions to README 2014-07-07 09:37:44 -06:00
Sheel Choksi
f20df57607 Keeping jasmine_selenium_runner in Gemfile only for now 2014-06-28 18:09:41 -07:00
Sheel Choksi
48f7a5f17b Point to head of jasmine_selenium_runner
jasmine_selenium_runner on master now has a fix for printing circular
objects which is needed since Jasmine has some circular objects that are
included now that we return passedExpectations (but was a bug with
    failedExpectations anyways)
2014-06-28 17:59:29 -07:00
Sheel Choksi
f7ff47706c Remove 'empty' as an option as a spec result
- Having the 'empty' state for a spec result can be considered a
breaking change to the reporter interface
- Instead, we determine if a spec has no expectations using the added
key of 'passedExpectations' in combination of the 'failedExpectations'
to determine that there a spec is 'empty'

[fixes #73741032]
2014-06-27 23:50:28 -07:00
Alex Treppass
5f34be446c keeping track of passed expectations 2014-06-27 22:34:05 -07:00
Sheel Choksi
e1e49e8292 Bumping built distribution 2014-06-27 22:19:44 -07:00
Lee Penkman
eb1bd25445 namespace html-reporter -> jasmine_html-reporter 2014-06-22 21:47:46 -07:00
Lee Penkman
aac6968ed8 Stop Jasmine's CSS affecting the style of the body tag
[fixes #600]
2014-06-22 21:47:07 -07:00
Sheel Choksi
7d93541c09 Throw a more specific error when 'expect' is used without a currentSpec
If an async test has timed-out, there could still be some expectations
that are scheduled to run after the fact in which case curerntSpec will
be null. Rather than the type error that would result, we now indicate
that 'expect' was used at an unexpected time.

This also helps cases where an 'expect' is being used at a top-level,
showing an error message in the console for this case as well.

[fixes #602]
2014-06-06 23:49:58 -07:00
Drew Freyling
29aad761d9 Smushed with PNG Gauntlet. 2014-06-06 23:09:08 -07:00
Sheel Choksi
7d3de92cef Merge pull request #594 from plukevdh/reporter-reset
HTML Reporter reset previous DOM when re-initialized
2014-06-06 22:59:52 -07:00
Sheel Choksi
13e0dd27c9 Narrow down raise exceptions query selector
Finding by any input tag is a little bit broad [#605]
2014-06-06 22:20:18 -07:00
Sheel Choksi
fc6603e99f Merge pull request #580 from pablofiu/detailedGeneralWorkflow
added detailed steps on how to contribute coding
2014-06-02 23:04:35 -07:00
Luke van der Hoeven
07cce0b1d1 clear prior test results on multiple inits 2014-05-23 15:59:56 -04:00
Luke van der Hoeven
6750559211 failing spec for multiple inits 2014-05-23 15:58:09 -04:00
Pablo Alejandro Fiumara
0419780682 added detailed steps on how to contribute coding 2014-04-25 01:18:38 -03:00
Sheel Choksi
00c8e37257 Pass through custom equality testers in toHaveBeenCalledWith [fixes #536] 2014-03-26 22:19:03 -07:00
Christopher Amavisca and Davis W Frank
e53b487017 - Add a main entry point for the jasmine-core npm
- jasmine-core can now self test with the jasmine-npm
- Add node examples files
- Add node_boot.js for node environment
- Move jasmine-core npm packaging to .npmignore
- removing src_dir and src_files from jasmine.json b/c jasmine-npm does not support requiring source files automatically.
2014-03-21 17:21:52 -07:00
Sheel Choksi
ed5cd6ba2c Merge pull request #550 from slothmonster/fix-copyright-year
Fix outdated copyright year (update to 2014)

[skip ci]
2014-03-16 18:36:21 -07:00
Greg Cobb and Luan Santos
213a6023fd Add package.json to egg to get correct version number
[#67556148][#551]
2014-03-14 10:51:26 -07:00
Adam Deibert
7d220fcd1b Fix outdated copyright year (update to 2014) 2014-03-14 01:42:39 -07:00
Greg Cobb and Luan Santos
c1382c77b4 Enable bundler cache 2014-03-12 13:46:25 -07:00
Greg Cobb and Luan Santos
311263a3df Fix build in IE8 (IE8 doesn't support Object.freeze) 2014-03-12 13:45:46 -07:00
mikemoraned
33e4f5efbe Allow users to set the maximum length of array that the pretty-printer
will print out.

Currently, jasmine's pretty printer will iterate over an entire array,
formatting every element recursively. For very large arrays, this can
crash the page, or cause a 'slow script' warning.

This commit exposes a 'MAX_PRETTY_PRINT_ARRAY_LENGTH' option. If an
array larger than this is encountered, recursion will stop and the
array length will be printed instead e.g. "Array[20000000]".

The 'MAX_PRETTY_PRINT_ARRAY_LENGTH' option defaults to 100. This is
length of array will not kill your browser, but will allow you
to see big arrays, if you can stomach the output.
2014-03-12 12:16:01 -07:00
Greg Cobb and Luan Santos
367d3dcf66 Rebuild distribution 2014-03-12 11:51:49 -07:00
Greg Cobb and Luan Santos
21de44a204 Remove space between key and colon when pretty printing objects
[#4005255]
2014-03-12 11:47:47 -07:00
Greg Cobb and Luan Santos
c9e37a2a1c Refactor prettyPrinter to work with immutable objects
[#50766813][#266]
2014-03-12 11:41:18 -07:00
Davis W. Frank
9e927af56e Merge pull request #548 from pivotal/python
Create jasmine-core python egg
2014-03-11 14:05:45 -07:00
Greg Cobb
fc173e9a5e Add logo image to readme 2014-03-11 13:54:47 -07:00
Greg Cobb
62a7f64659 Update readme with correct code climate link 2014-03-11 13:49:51 -07:00
Greg Cobb and Luan Santos
3e739e4bc9 Create jasmine-core python egg 2014-03-11 13:40:28 -07:00
Greg Cobb and Luan Santos
ba6f99423f Add jasmine logo image to html runner
[#3984585]
2014-03-10 17:16:31 -07:00
Christopher Amavisca, Greg Cobb and Luan Santos
3a5672cd33 Show message if no specs are found in console reporter
[#12784235]
2014-03-10 12:00:49 -07:00
Christopher Amavisca, Greg Cobb and Luan Santos
af4cc76e2a Show message if no specs are found
[#12784235]
2014-03-10 11:23:27 -07:00
Christopher Amavisca, Greg Cobb and Luan Santos
1922514f2d Specs without expectations should be alerted to the user
- Add console.error to the HtmlReporter when there is a spec without any expectation
- Change the spec's link text and color to include a warning
- Create a status for specs to label them as "empty"
- console is not accessible to IE unless you have developer tools open,
  so protect against that by mocking console.

[#59424794]
2014-03-10 11:19:07 -07:00
slackersoft
71dbffeaef Merge branch 'recursive-containing' of https://github.com/cbandy/jasmine into cbandy-recursive-containing 2014-03-05 21:01:34 -08:00
Rajan Agaskar
9c6d03d3ac README.md: Add link to Jasmine 2.0 release notes
- To help people upgrading find a list of what they'll need to change.
2014-03-05 11:31:39 -08:00
Chris Bandy
47884032ad Fix ObjectContaining to match recursively
matchersUtil.equals() does not expect a matcher as its first argument,
so send the "actual" value first and the "expected" value second.
2014-03-02 11:42:37 -06:00
slackersoft
d7053612f5 Build distribution to include MockDate
- Forgot to do this when merging the pull request
- Also fix quotes for string to match jshint rules
2014-03-01 13:18:15 -08:00
Christopher Amavisca and Sheel Choksi
9d1e92f5e2 Clean up more remnants of dev_boot 2014-02-27 18:02:14 -08:00
Elana Koren and Gregg Van Hove
eebba2ecca Support browsers that don't supply a Date.now()
- install the mockDate by calling `mockDate` on `clock` instead of
  passing an argument to `clock.install()`

[Finishes #66606132] Closes #361
2014-02-27 11:55:25 -08:00
Elana Koren and Gregg Van Hove
627a262085 Merge branch 'mock-date' of https://github.com/jalopez/jasmine into jalopez-mock-date 2014-02-27 10:03:35 -08:00
Christopher Amavisca and Sheel Choksi
305bd73142 Instead of dev boot use a custom helper to defined j$ 2014-02-26 17:35:10 -08:00
Elana Koren and Gregg Van Hove
fb853ad5b5 Don't include jasmine_selenium_runner from github, now that it's
published to rubygems

[finish #66472672]
2014-02-26 15:30:17 -08:00
Greg Cobb and Sheel Choksi
640f94a1bd Don't allow calling the same done callback multiple times
[finishes #62585700][fixes #523]
2014-02-25 18:06:30 -08:00
Greg Cobb and Sheel Choksi
5aac3e3292 Refactor Spec and QueueRunner [#62585700]
- QueueRunner now responsible for timing out async specs instead of
   Spec
 - Make sure only spec functions are timeoutable and not suites (due to
   the refactor)
2014-02-25 18:06:30 -08:00
Charles Hansen and Gregg Van Hove
84160ff51d revert to old version of checking the docs 2014-02-25 11:28:02 -08:00
Charles Hansen and Gregg Van Hove
e972bac80d No longer try to push to github, we'll update jasmine in docs manually 2014-02-25 10:58:59 -08:00
Charles Hansen and Gregg Van Hove
455b6bade8 bundle install in docs repo 2014-02-25 10:56:41 -08:00
Charles Hansen and Gregg Van Hove
23c0e379e0 update edge docs when changes are made to jasmine 2014-02-25 10:42:59 -08:00
Robin Böhm
31d71ac22f add single quote check to jshint and fix src files for that
[fixes #522]
2014-02-24 16:28:16 -08:00
Greg Cobb and Sheel Choksi
095b02ad83 Follow redirects when trying to connect to sauce 2014-02-24 16:13:25 -08:00
Greg Cobb and Sheel Choksi
98c258a659 Bump built distribution [#503][finishes #66350898] 2014-02-24 15:47:34 -08:00
Michal Mocny
85fa148f18 Support running jasmine within CSP (remove eval)
[fixes #503]
2014-02-24 15:44:11 -08:00
Sheel Choksi
76ca5ef6d4 Allow matcher custom failure messages to be a function
By deferring the evaluation of these messages, we can avoid the
expensive creation of them when in the majority use case (tests are
    passing) they are not needed.

These failure messages were causing performance problems with larger
objects needed to be pretty printed as discussed in #520 and brought up
by @rdy.

[fixes #65925900][fixes #520]
2014-02-18 20:05:30 -08:00
Sheel Choksi
46d2c43da1 Revert "Use default failure message for toBeNaN"
Forgot that NaN has special casing that it needs a custom error message
for

This reverts commit b6c03a34e7.
2014-02-18 19:14:16 -08:00
Sheel Choksi
b6c03a34e7 Use default failure message for toBeNaN
It is providing the same functionality by default without a custom error message
2014-02-17 22:45:54 -08:00
Sheel Choksi
4ddf316388 Add in default rake task 2014-02-16 14:57:14 -08:00
Sheel Choksi
a8cbef3123 More color blind friendly CSS from @dleppik
Updating the passing and failing colors in HTML reporter to
help red/green color blind users using the colors suggested by @dleppik

Console reporter still likely needs similar changes but there's less
options there

[#463, #509, finishes #60613086]
2014-02-16 14:56:18 -08:00
Sheel Choksi
a937d8d74f Merge pull request #521 from robinboehm/load-grunt-tasks
use load-grunt-tasks
2014-02-16 14:53:07 -08:00
Robin Böhm
2fc2802809 use load-grunt-tasks 2014-02-16 22:13:53 +01:00
Sheel Choksi
7cf899a4ea Special case printing -0
Use the 1/x trick to determine if a value is -0 and special case the
printing of it.

[closes #496]
2014-02-09 14:14:33 -08:00
Sheel Choksi
83c0ea7f91 Fix error message in jasmine.any
The expected any 'class' was not being included in the error message
due to accessing the wrong property
2014-02-09 14:06:47 -08:00
Sheel Choksi
289c8313d1 Short spec to document why we close over Date and ensure cross-browser compatibility
[closes #506]
2014-02-09 12:20:03 -08:00
tcorral
b5775aec4f Allow stub or spy Date object safely using a closure to get a clean copy
[closes #506]
2014-02-09 12:20:03 -08:00
Davis W. Frank
21b01f4a5d Whitespace Markdown fix 2014-01-24 09:32:20 -08:00
Davis W. Frank
71faeea7b0 First attempt at publishing an npm 2014-01-24 09:31:38 -08:00
Sheel Choksi
de7d005b3d Break out quick start guide on newline
[skip ci]
2014-01-19 14:21:21 -08:00
Sheel Choksi
7acf5d4220 Add in link to quick start of Jasmine, closes #498
[skip ci]
2014-01-19 14:16:00 -08:00
slackersoft
2a8b5a30b6 Use \d7 instead of plain 'x' for more square appearance
[finishes #48434179]
2014-01-18 17:33:57 -10:00
Sheel Choksi
9c7ba43ebd Clean up a bunch of spec global variable leaks
Also some formatting changes to highlight when using one 'var' with comma operator
2014-01-18 14:17:14 -08:00
Sheel Choksi
8ca08ff999 Run Object.create(null) spec on all browsers not IE 8
IE 8 doesn't support Object.create so there shouldn't be a need to run this spec in IE 8
2014-01-18 13:12:07 -08:00
slackersoft
15aa3ecb5d Better support in pretty printer when an object has null prototype
- Fixes #500
2014-01-17 19:56:43 -10:00
Davis W. Frank
2670bb40a7 Get rid of freeze property for now - it's not adding value. 2014-01-10 10:23:14 -08:00
Sheel Choksi
c8ffa6000b Reproducing change made in #479 that was made to build distribution instead of src
It was lost when I rebuilt the distribution
2014-01-09 22:14:04 -08:00
Sheel Choksi
06a553503d Better failure message when something is thrown that's not an error
Change from 'undefined : undefined' to '<thing that was thrown> thrown'

Pointed out by @charleshansen
2014-01-09 22:10:40 -08:00
Sheel Choksi
aab4808410 Bump built distribution 2014-01-09 22:07:59 -08:00
Sheel Choksi
b525313cdb Make the check for pending spec exception work for values that don't have toString 2014-01-04 23:11:20 -08:00
Sheel Choksi
f576395620 Bump built distribution copyright's for 2014 2014-01-04 23:11:20 -08:00
Sheel Choksi
b161e9e3df Merge pull request #486 from nextmat/link_fix
Update link at top of README
2014-01-01 20:00:18 -08:00
Matt Sanders
94ecb998bb Update link at top of README
Allows access to Jasmine 2.0 docs
2013-12-27 00:29:35 -07:00
Davis W. Frank
38daa43c7e Merge pull request #479 from shprink/fix_jasmine_html
force query selector to seek within the html-reporter element
2013-12-19 09:42:15 -08:00
Davis W. Frank
9fb9c12066 Merge pull request #478 from shprink/adding_netbeans_to_gitignore
adding netbeans project folder to the gitignore list
2013-12-19 09:37:19 -08:00
shprink
de2fb225b0 adding netbeans project folder to the gitignore list 2013-12-19 10:20:49 +01:00
shprink
4f4ae086aa force query selector to seek within the html-reporter element 2013-12-19 10:19:02 +01:00
Sheel Choksi
8510bdd947 Update mailing list link
It seems that Github was interpreting it as a repository link. Made it an explicit mailto instead.
2013-12-17 18:37:10 -08:00
Sheel Choksi
66bd8c7825 Adding older standalone zips from downloads page to our dist folder 2013-12-17 12:19:53 -08:00
Christopher Jobst and Sheel Choksi
a736e664ea Remove the old RC standalone distributions. 2013-12-16 15:49:27 -08:00
Christopher Jobst and Sheel Choksi
812b14d000 Update README and remove rc release notes
RC release notes have been merged into release_notes/20.md
2013-12-16 12:42:17 -08:00
Christopher Jobst and Sheel Choksi
a2a8b5dde2 Create a 2.0 distribution 2013-12-16 12:33:34 -08:00
Christopher Jobst
78bed99ba3 Add in 2.0 release notes 2013-12-16 11:17:51 -08:00
Sheel Choksi
f9191d7b0d Merge pull request #473 from pimterry/callTrackingTests
Refactored the createSpy tests, to add unit tests for its part of call tracking
2013-12-07 16:57:57 -08:00
pimterry
83a692d5a8 Use the correct Jasmine version in the spy integration tests 2013-12-07 22:16:24 +00:00
pimterry
14a8c2ca09 Move spy integration tests out of the unit test suite 2013-12-07 20:52:02 +00:00
pimterry
b2e8de7bcd Mock callTracker in spy tests for better test isolation 2013-12-07 20:43:38 +00:00
pimterry
1d98a23b14 Add tests for call tracking in createSpy 2013-12-07 20:27:08 +00:00
Sheel Choksi
16ffd3b3fb Fix up specs that failed when maximumSpecCallbackDepth is set to 1 2013-11-22 23:04:42 -08:00
Sheel Choksi
6bc87ad223 Merge pull request #466 from
maciej-filip-sz:DelayedFunctionScheduler-patch

Sets and executes timeouts set during a tick.
2013-11-17 17:17:31 -08:00
Maciej Filip Szkodziński
555d328cf2 Moved last currentTime assignment to tick. 2013-11-17 17:14:29 -08:00
Maciej Filip Szkodziński
c78fba4b13 Sets and executes timeouts set during a tick.
All timeouts and intervals set during a tick were being scheduled to run
at delay + end-of-tick, instead of delay + time-of-outer-timeout.

Scheduled run-at times were shifted because currentTime was being
incremented before executing scheduled functions.

Additionally, the execute loop was iterating over a functions-to-run
array, created from scheduledFunctions before starting. Any changes to
scheduledFunctions were being ignored during the tick, and the next tick
would ignore any functions which should have been executed in the past.

The commit is a rewrite of DelayedFunctionScheduler, preserving the
public interface. Execution of scheduled functions updates currentTime
on each iteration, and each time takes the functions with the lowest
runAtMillis from the schedule, if they aren't higher than endTime.
2013-11-17 17:14:29 -08:00
Sheel Choksi
8a6d7828c6 Make all async functions be subject to the timeout
[finishes #60798058]
2013-11-14 23:01:43 -08:00
Sheel Choksi
c888b0c1b8 Slight refactoring of clearing timeouts when an exception is thrown 2013-11-14 20:48:28 -08:00
Sheel Choksi
72e9851217 Bumping built distribution 2013-11-14 18:16:32 -08:00
Sheel Choksi
7ee5073921 Fix bad merge 2013-11-11 21:01:36 -08:00
Sheel Choksi
614a18453e Rename Spec's queueRunner to more accurately be a queueRunnerFactory 2013-11-11 20:53:13 -08:00
Rajan Agaskar
916f889c01 Merge pull request #462 from tidoust/clear-timeout-async
Clears timeout timer even when async spec throws an exception
2013-11-07 09:40:43 -08:00
François Daoust
4a7b79ad0d Regression spec added for timeout timer in an async spec
The spec ensures that the timeout timer is properly cleared out
even when the async spec throws an exception.
2013-11-07 16:08:41 +01:00
François Daoust
775e2ff0a9 Clears timeout timer even when async spec throws an exception
When an async spec throws a (sync) exception for some reason, the
exception was correctly caught and reported by Jasmine but the timeout
timer continued to run in the background.

For instance, running the (rather stupid) example below would report
the exception immediately but would also make the process loop for 5s
(and report the exception depending on the reported being used).

describe('exception', function () {
  it('is caught but timer continues to run', function (done) {
    throw new Error('Oh no!');
  });
});

This happened because the timout timer is set in Spec while the
"try... catch" block is in the queue runner. The "callDone" function
of "timeoutable" that resets the timer was thus not called.

The commit simply introduces a "try... catch" block within the
`timeoutable` function to ensure that "callDone" gets called even
when an exception is thrown.
2013-11-07 14:51:46 +01:00
Sheel Choksi
1b6725ec25 Updating Spec#getFullName spec to work in IE 8
Forgot that the pretty printer is not functional in IE 8, which
subsequently brings down toHaveBeenCalledWith
2013-11-04 21:59:06 -08:00
Sheel Choksi
952eb59707 Change test for how a spy gets its full name
- Removes another TODO
- A spec uses its full name as soon as it is created (for the result
    object) and so it needed to be tested differently
2013-11-04 21:38:01 -08:00
Sheel Choksi
de6a305b44 Move the various integration specs into their own folder
- There is now an integration folder inside of spec/core
- Killed the TODOs about moving around integration specs
2013-11-03 16:48:35 -08:00
Sheel Choksi
8513201fa3 Add in missing repository field to package.json
Removes the following warning when doing a `npm install`: 'npm WARN
package.json jasmine-core@2.0.0-rc5 No repository field.'
2013-11-02 18:28:53 -07:00
JR and Sheel Choksi
6e07dccb68 Make getGlobal() work in strict mode
Slight modifications to implementation in pull #437
2013-11-01 11:06:57 -07:00
JR and Sheel Choksi
fcc50cc6f4 Rename Release.markdown to be more consistently named 2013-10-31 14:27:30 -07:00
Sheel Choksi
9e8466ba2b Merge pull request #458 from jsoref/readme
Rename README for consistency
2013-10-31 14:24:43 -07:00
Kristóf Marussy
4350045d61 Replaced deprecated octal literal with hexadecimal
Octal literals are deprecated in JavaScript 1.5 and Gjs were generating
warnings because of them.
2013-10-31 14:03:06 -07:00
Rajan Agaskar
666e9c341e Merge pull request #460 from jsoref/releasenotes
Improving Release note text
2013-10-30 20:52:30 -07:00
Josh Soref
5830d9f86b Improving Release note text 2013-10-30 23:14:57 -04:00
August Toman-Yih and Sheel Choksi
ea888e4c03 Fix triple/tripple spelling error 2013-10-30 17:30:25 -07:00
Josh Soref
c7e3ca6c8a Spelling: Fix spelling errors
* equal
* existence
* expectation
* expected
* intend
* message
* report
* singular
2013-10-30 20:12:05 -04:00
Josh Soref
06db4a8583 Rename README for consistency 2013-10-30 10:31:15 -04:00
Rajan Agaskar and Sheel Choksi
a2debf60b6 Use jasmine.addMatchers instead of reaching through jasmine.Expectation [finishes #59518946] 2013-10-29 18:35:17 -07:00
Sheel Choksi
04c7db9259 Update built distribution to include latest 2.0.0-rc5 fixes 2013-10-29 17:40:15 -07:00
Sheel Choksi
8585ef69a5 Update clock not installed message to reflect current boot installation process 2013-10-29 17:33:51 -07:00
Sheel Choksi
cb5aea1fcf Fix builds by working around browser timing functions not being successfully overridden 2013-10-29 17:32:04 -07:00
Sheel Choksi
966f76b481 Add in missing clock uninstall 2013-10-29 17:28:41 -07:00
Sheel Choksi
40e3020fdc Build distribution for 2.0.0-rc5 and associated standalone distribution 2013-10-29 14:03:02 -07:00
Sheel Choksi
69549a6ff3 Add in 2.0.0-rc5 release notes 2013-10-29 14:03:01 -07:00
Sheel Choksi
a03fad8911 Move built console.js into lib and include in standalone distribution
[finishes #59679110]
2013-10-29 14:03:01 -07:00
Sheel Choksi
61993cf1fc Expose Jasmine's topSuite [finishes #59774024] 2013-10-29 11:27:12 -07:00
Kyriacos Souroullas and Sheel Choksi
cd9d5284cd Matchers can have a negativeCompare
- Passing in a 'negativeCompare' will cause that function to be used when it is a 'not' assertion
- Otherwise, the reversal of the compare's result will be used instead

[finishes #59703824]
2013-10-28 17:13:18 -07:00
Kyriacos Souroullas and Sheel Choksi
e346e7dcc1 Revert removal of compare nesting
Since we want the user to be able to pass a negative comparison function, the extra layer of wrapping is now needed
2013-10-28 17:13:09 -07:00
Davis W. Frank
dd8a455f91 Adding Code Climate badge to README 2013-10-25 12:25:27 -07:00
Davis W. Frank
9e149d1e0f Move node dev deps forward, add .jshintrc to support latest grunt-contrib-jshint and Code Climate score 2013-10-25 12:23:57 -07:00
Sheel Choksi and Tim Jarratt
797984f173 Add newlines to end of files 2013-10-25 10:57:43 -07:00
Sheel Choksi and Tim Jarratt
29c5c127e5 Refactor Suite.addSpec and .addSuite to .addChild 2013-10-25 10:52:31 -07:00
Sheel Choksi and Tim Jarratt
26581b4c91 Rename Suite.children_ to .children
Also removed some unit tests that were brittle, and already tested by
better, more round-trip tests.
2013-10-25 10:25:50 -07:00
Javier López Pardo
3186b24a66 add acceptance tests for mock clock with date 2013-10-25 14:59:07 +02:00
Javier López Pardo
81b822fea9 Add specs for mock date 2013-10-25 14:41:32 +02:00
Javier López Pardo
fb8bede8ea Add FakeDate object 2013-10-25 13:25:09 +02:00
Davis W. Frank
243ff80196 Fixing global leak for 'timer' 2013-10-24 17:17:05 -07:00
Davis W. Frank
284bb0b608 Giving Sheel his due 2013-10-24 16:55:51 -07:00
Sheel Choksi
6453ed656b Suites just have children instead of separating into specs/suites 2013-10-24 16:35:00 -07:00
Sheel Choksi
a1a948b8df Remove completeCallback from suite as its unused 2013-10-24 16:34:34 -07:00
Sheel Choksi
7a4876ecfa Also move function to determine whether specs should catch exceptions into closure 2013-10-24 16:24:55 -07:00
Sheel Choksi
d9ece1f14f Remove version/versionString and currentRunner
- Instead of version/versionString, jasmine.version should be sufficient
- currentRunner was exposing Jasmine's internal top level suite
2013-10-24 15:42:46 -07:00
Sheel Choksi
f1613ce77c Move additional methods from Env prototype to env closure
- Users can no longer spelunk the spec tree from topSuite
- Users no longer have access to currentSuite/currentSpec
- Other miscellaneous (arguably less useful) methods have also been tucked
away into the closure, like suiteFactory
2013-10-24 15:28:01 -07:00
Sheel Choksi
a3424ea265 Remove addCustomEqualityTester and addMatchers from global
These functions are available on the jasmine namespace
2013-10-24 14:00:05 -07:00
Sheel Choksi
ab0b2b783c Move next spec/next suite ids into closure
No longer exposing these from the environment
2013-10-24 13:43:04 -07:00
Sheel Choksi
d0aff9ed02 Use toThrowError instead of toThrow in places where we are expecting an error 2013-10-24 12:15:17 -07:00
Sheel Choksi
a309117758 Remove TODO: should be easier to load polyfill for timeout functions as Jasmine does not get references to these functions until boot.js is loaded 2013-10-24 11:58:21 -07:00
Sheel Choksi
0c6e590a93 A spec without expectations is considered passing
- Specs are passing by default unless told otherwise
- Getting the result.status of a spec before the spec has run is now
  undefined instead of pending

[finishes #59422744]
2013-10-24 11:34:42 -07:00
Sheel Choksi
d06da150de Stop passing in queryString to HTMLReporter, it is unused 2013-10-23 11:06:42 -07:00
Sheel Choksi
39d7ebf28e Remove an extra layer of wrapping for matchers/custom matchers
Helps reduce how nested custom matchers have to be for users as well as
Jasmine internal matchers

[#59161378]
2013-10-20 22:21:56 -07:00
Sheel Choksi
5f429fcb37 Re-enable CustomMatchersSpec and update for current version of custom matchers 2013-10-20 21:58:16 -07:00
Sheel Choksi
b6eb9a4d5e Remove now unused updateInterval that was being set in specs 2013-10-20 17:12:40 -07:00
Sheel Choksi
fdb7df812c Improve error message when a spec doesn't call the async callback within the default time interval 2013-10-19 21:18:06 -07:00
Davis W. Frank
81299860aa Merge pull request #450 from slackersoft/manualClockUninstall
Env no longer automatically uninstalls the clock after each spec
2013-10-18 15:51:10 -07:00
slackersoft
ca6fa6f711 Env no longer automatically uninstalls the clock after each spec
- Behaves more like how we want plugins to behave

[#58281436]
2013-10-16 18:39:03 -07:00
Davis W. Frank
5aaafed4d8 Move clock from global to jasmine; provide a function to access the clock. 2013-10-10 16:24:58 -07:00
Davis W. Frank
c28c124f58 removed addMatchers from the global. This should have been in previous commit 2013-10-10 14:11:44 -07:00
Davis W. Frank
f0a1adb61c Continuing boot change with docs 2013-10-10 12:00:46 -07:00
Davis W. Frank
5ff2aecab8 Moving a documented-up boot.js from the website back into core 2013-10-10 11:59:59 -07:00
Davis W. Frank
8ca8197b4c Make exposure of addMatchers and addCustomEqualityTesters be on jasmine instead of inconsistent. 2013-10-10 11:32:21 -07:00
Davis W. Frank
55716723b5 Adding Compass as a dev dependency in order to build HTMLreporter CSS 2013-10-10 11:27:40 -07:00
Davis W. Frank
3973cc5a71 Merge pull request #443 from kryger/patch-1
Fixed broken link to contributing guide
2013-10-08 07:48:53 -07:00
Lukasz Kryger
95af58ade6 Fixed broken link to contributing guide 2013-10-08 11:33:55 +01:00
slackersoft
6641d64305 Make addCustomEqualityTester available on jasmine global
- User shouldn't have to `jasmine.getEnv()` to add one

[#54582648]
2013-10-06 11:32:38 -07:00
slackersoft
7c1fcd7bb5 Regenerate jasmine.js for QueueRunner fix 2013-10-06 11:32:19 -07:00
slackersoft
e91d0341a4 Revert "Make addCustomEqualityTester available on jasmine global"
Oops, this made it on global object, not `jasmnie`

This reverts commit 144ff174f6.
2013-10-06 11:11:46 -07:00
slackersoft
144ff174f6 Make addCustomEqualityTester available on jasmine global
- User shouldn't have to `jasmine.getEnv()` to add one
2013-10-06 11:05:35 -07:00
Gregg Van Hove and Tim Jarratt
af4bfa8bc4 Env should use the "public" QueueRunner interface 2013-10-04 17:04:22 -07:00
Gregg Van Hove and Tim Jarratt
620e3f5992 Run docs tests under phantomjs 2013-10-04 13:32:56 -07:00
Gregg Van Hove and Tim Jarratt
ea76a30d85 Update standalone distributions
[#30296755]
2013-10-04 12:28:27 -07:00
Gregg Van Hove and Tim Jarratt
adde1b4a5b Doc js files from jasmine.github.io should be part of CI build
[Finish #50572569]
2013-10-04 12:10:38 -07:00
Gregg Van Hove and Tim Jarratt
07e7ad2314 Update jasmine_favicon.png
Using the new image from google drive. It's 32x32px but browsers should
be able to downsize that to 16x16 if they need to

[Finish #57170588]
2013-10-04 10:55:01 -07:00
Davis W. Frank
706180ad01 2.0 rc3 release notes 2013-10-03 16:36:08 -07:00
Davis W. Frank
547c9cfde9 Adding Anchorman back in as a dependency 2013-10-03 16:35:56 -07:00
Gregg Van Hove and Tim Jarratt
d3ec12e62a buildStandaloneDist should also build jasmine.js 2013-10-03 15:28:42 -07:00
Gregg Van Hove and Tim Jarratt
749c15fe07 Bump version to rc3 in jasmine.js 2013-10-03 15:28:26 -07:00
Gregg Van Hove and Tim Jarratt
7e071547f5 Custom matchers fail to behave as expected
If they return false, that should be respected.

Submitted via @tjgrathwell

[Finish #58184156]
close #434
2013-10-03 15:13:27 -07:00
Gregg Van Hove
6354ee17e5 Merge pull request #439 from tjarratt/pull_request_travis
Don't try to use SauceLabs on pull request builds
2013-10-03 12:32:32 -07:00
Gregg Van Hove and Tim Jarratt
255a50baee Update contribution guidelines for pull requests
[Finish #45961121]
2013-10-03 12:30:07 -07:00
Tim Jarratt
520a8c85a2 Don't bother trying to still use firefox 2013-10-03 12:07:57 -07:00
Gregg Van Hove and Tim Jarratt
6de355544f Make firefox with Sauce explicitly the default test
Apparently Travis-ci will create a default test separate from your
matrix includes and this resulted in some testrun duplication.
2013-10-03 11:44:48 -07:00
Gregg Van Hove and Tim Jarratt
95572fb314 Don't try to use SauceLabs on pull request builds 2013-10-03 11:24:57 -07:00
Gregg Van Hove and Tim Jarratt
18e1ab93ea Release for rc3 2013-10-03 09:55:36 -07:00
Davis W. Frank
0c4113e167 Quick fix - Spec needs j$ at execute time 2013-10-02 22:45:33 -07:00
Gregg Van Hove and Tim Jarratt
a563e67015 Move selenium_runner.yml to spec/javascripts/support
- The selenium runner gem should support configurable path as the main
  gem does so we don't need to do this. This workaround is kind of
  gross.
2013-10-02 16:48:13 -07:00
Gregg Van Hove and Tim Jarratt
fab489851e Fix paths for node specs
[#58126010]
2013-10-02 16:41:07 -07:00
Gregg Van Hove and Tim Jarratt
1c19b8e38a Move spec files back out of spec/javascripts
- Jasmine gem allows us to specify a path to jasmine.yml via ENV

[finish #58126010]
2013-10-02 16:32:35 -07:00
Gregg Van Hove and Tim Jarratt
fc258b3d36 Make it easy to copy the title of failing specs
[finish #58121820]
2013-10-02 15:14:41 -07:00
Mike Stay
ffa6138d75 Make getGlobal() work in strict mode
An update of fb3e1acb09

ES5 strict mode does not promote an undefined 'this' to the global object.  The only way to get the global object in strict mode is to say 'this' while in the global scope.
2013-10-02 12:38:25 -06:00
Gregg Van Hove and Tim Jarratt
51dd66a4cc Turn the exceptions spec back on, it still works 2013-10-02 10:24:24 -07:00
Gregg Van Hove and Tim Jarratt
37a3135d6a cleanup whitespace 2013-10-01 16:30:17 -07:00
Gregg Van Hove and Tim Jarratt
cb8ba74937 Don't add periods to the full name of a spec
- Breaks links for spec filters
- Looks strange if users add their own

[fix #58043244] fix #427
2013-10-01 16:28:33 -07:00
Gregg Van Hove and Tim Jarratt
70fb0f0ed5 Update Firefox pretty print test
At some point, firefox changed the exception message.
2013-09-30 15:43:44 -07:00
Sheel Choksi
15889494c5 Update node suites to not rely on previous accidental global j$ and create its own 2013-09-29 14:59:58 -07:00
Sheel Choksi
da33c7823e Add missing var in front of j$ to avoid polluting global namespace
Users should only have 'jasmine' in global namespace, j$ should be
fully internal unless developing for jasmine

As brought up by Morten Maxild
2013-09-29 14:46:55 -07:00
Gregg Van Hove
04e1d8420e Ensure tunnel_identifier is properly quoted for travis builds 2013-09-25 14:24:57 -07:00
Gregg Van Hove and Rajan Agaskar
19b2472761 Really make tunnel_identifier a string.
yay.
2013-09-25 11:24:41 -07:00
Gregg Van Hove and Rajan Agaskar
1fc614ad19 Tunnel identifier must be a string
- Travis provides a float.
2013-09-25 11:03:45 -07:00
Gregg Van Hove and Rajan Agaskar
84692f545c Use jasmine_selenium_runner to run specs via Sauce 2013-09-25 10:45:53 -07:00
Gregg Van Hove and Rajan Agaskar
5017d1a4f1 Make rake jasmine:ci run specs correctly.
- Will replace rake core_specs.
- Remove obsolete dependencies & files -- most of these were for build tasks we
  are no longer using. Notably, rspec and spec_helper were deleted.
2013-09-25 10:11:02 -07:00
Gregg Van Hove and Rajan Agaskar
963cd5e850 Make rake dev dependency 2013-09-24 11:31:21 -07:00
Gregg Van Hove and Rajan Agaskar
527394068e Update specs to use new HTTP Runner interface. 2013-09-24 11:30:50 -07:00
Gregg Van Hove and Rajan Agaskar
5e279a1393 Remove unnecessary Jasmine.configure. 2013-09-20 11:16:40 -07:00
Gregg Van Hove and Rajan Agaskar
8f0f0a607e update self test to work with gem runner interface 2013-09-20 11:09:35 -07:00
Gregg Van Hove and Rajan Agaskar
4891d578e3 Set default rake task 2013-09-19 10:15:15 -07:00
Sheel Choksi
efc384c6d6 Allow Env to take optional spec/suite ids when asked to execute 2013-09-17 19:55:49 -07:00
Sheel Choksi
d60786a06c More clearly differentiate between spec and suite ids 2013-09-17 19:55:48 -07:00
Sheel Choksi
66010d01ec Give reporting symbols a little bit more height
Ensures they don't appear cut off when in the last row
2013-09-16 21:05:24 -07:00
Sheel Choksi
1619067ddd Merge pull request #428 from tjgrathwell/htmlreporter-inline-block-dots
Change HTMLReporter symbols to be inline-block instead of floated
2013-09-16 20:55:49 -07:00
Travis Grathwell
79a75f5bdb HTMLReporter symbols are inline-block rather than floated
On a very large test suite (8000 specs), a significant amount
of time is spent just drawing the spec dots. Some sort of
worse-than-linear artifact that summons itself only when you
have 8000 floated elements trying to hang out together.

This performance penalty is not seen with inline-block.

In Chrome 29:
  Floated dots: 16.795s
  Inline-block dots: 2.774s

Setting the dots to 'display: none;' takes about the same time
as the inline-block figure, so this is probably a low enough bound
(no need for chunked rendering or who knows what).
2013-09-10 19:46:51 -07:00
Sheel Choksi
7158e048a6 Update Jasmine CSS build process
- Update compass configuration to build jasmine.scss into lib
- Remove src/html/jasmine.css (since jasmine.scss builds directly into
    lib now)
- Bump lib/jasmine-core/jasmine.css to be latest from scss
2013-09-09 21:41:24 -07:00
Sheel Choksi
f8f064d12d Update jasmine-performance.yml
Get it back into working condition and more similar to jasmine.yml
2013-09-09 21:41:24 -07:00
Sheel Choksi
8ac085c103 Use jasmine.DEFAULT_TIMEOUT_INTERVAL for async timeout
Allows a user to specify their desired timeout interval for async specs
and change it on a per spec basis (for particularly slow specs, for example).

As pointed out by @Eric-Wright in #422. [finishes #55996798]
2013-09-08 21:41:45 -07:00
Sheel Choksi
03dfea967c Remove unused jasmine.DEFAULT_UPDATE_INTERVAL 2013-09-08 14:18:34 -07:00
Sheel Choksi
f463e1f7aa Consistent 'this' between befores/it/afters
Change the 'this' user functions are called with to be an empty object
instead of the QueueRunner so that if the user puts properties on it,
        they won't conflict.

Also, changes async specs to be called with a proper 'this', as pointed
out by @Eric-Wright in #419 and #420.

[finishes #56030080]
2013-09-07 18:28:03 -07:00
Sheel Choksi
4bff199c2a Rename a spy's callReturn and callThrow
.and.callReturn is now .and.returnValue
.and.callThrow is now .and.throwError

[finishes #56281634]
2013-09-06 21:55:14 -07:00
Sheel Choksi
e3f0389ac2 Change andThrow to always throw an Error
If an error is passed in, it is thrown, otherwise the argument passed
in is wrapped in an Error

[finishes #50607615][closes #372]
2013-09-05 23:05:45 -07:00
Sheel Choksi
be0f7b4117 EnvSpec for timing out async spec fix
Spec still can't work for maximumSpecCallbackDepth = 1 until further
mock clock enhancements. Fixes the specs running twice issue caused by
the previous commit.
2013-09-02 21:48:44 -07:00
Sheel Choksi
edb46a6f7c Fix spec in EnvSpec.js for specs that hang
This spec would hang when maximumSpecCallbackDepth was set to 1
[Fixes #54168730]
2013-09-02 20:39:37 -07:00
Sheel Choksi
a442acb8aa Mock Clock now correctly schedules delayed functions during a 'tick' 2013-09-02 18:50:17 -07:00
Davis W. Frank
fc409f39a1 Workaround and bug exposure for IE8 and PrettyPrinter, which doesn't work well when trying to pretty print the native timer functions on IE. Make Jasmine's suite green and call out for a fix once we re-write the pretty printer. [Finishes #54168708] 2013-09-01 15:38:14 -07:00
Davis W. Frank
ba55cb5e38 Mock clock now less intrusive, replacing global timer funcions only when clock is installed. [Fixes #54168708] 2013-08-27 22:46:01 -07:00
Davis W. Frank
2d4f398dd6 Merge branch 'master' of https://github.com/pivotal/jasmine 2013-08-27 22:43:06 -07:00
Sheel Choksi
5ba6e51e1c Restore custom failure messages for toHaveBeenCalledWith
As pointed out by @tjgrathwell
2013-08-26 23:24:43 -07:00
Davis W. Frank
ba43e37356 Updating GOALS doc after rc2 2013-08-06 08:04:37 -07:00
Sheel Choksi
0f42f2709a Update PrettyPrinter to better check for an Object
Includes test case to fix FF as suggested by @ondras
Fixes #409
2013-08-03 11:49:20 -07:00
Sheel Choksi
4c4317b80e Update BrowserFlags to include Firefox
- DRYs up the browser checking code
- Adds in Firefox as another flag
- Makes it possible to do checks like `if (env.ieVersion)` to target all
IE versions
2013-08-03 11:45:13 -07:00
Davis W. Frank
b4bb99dfdf Merge pull request #410 from martyhines/fix-broken-link
Updated contribute.markdown links
2013-07-31 07:54:42 -07:00
martyhines
d721418490 Updated contribute.markdown links 2013-07-31 10:40:28 -04:00
Davis W. Frank
45fd8df861 Adding ignores for latest RVM/RbEnv convention 2013-07-30 08:08:24 -07:00
Davis W. Frank
0e800ee243 Rename to GitHub convention; Makes this doc available during pull request creation 2013-07-30 08:07:22 -07:00
Davis W. Frank
8a8cc03dea Add release notes & GitHub releases instructions 2013-07-28 20:59:57 -07:00
151 changed files with 5053 additions and 3234 deletions

8
.gitignore vendored
View File

@@ -5,6 +5,8 @@ site/
.bundle/
.pairs
.rvmrc
.ruby-gemset
.ruby-version
*.gem
.bundle
tags
@@ -13,4 +15,10 @@ pkg/*
.sass-cache/*
src/html/.sass-cache/*
node_modules/
*.pyc
sauce_connect.log
*.swp
build/
*.egg-info/
dist/*.tar.gz
nbproject/

9
.jshintrc Normal file
View File

@@ -0,0 +1,9 @@
{
"bitwise": true,
"curly": true,
"immed": true,
"newcap": true,
"trailing": true,
"loopfunc": true,
"quotmark": "single"
}

23
.npmignore Normal file
View File

@@ -0,0 +1,23 @@
dist/
grunt/
images/
node_modules
release_notes/
spec/
src/
Gemfile
Gemfile.lock
Rakefile
jasmine-core.gemspec
.rspec
.travis.yml
.jshintrc
.gitignore
*.sh
Gruntfile.js
lib/jasmine-core/boot/
lib/jasmine-core/boot.js
lib/jasmine-core/spec
lib/jasmine-core/*.css
lib/jasmine-core/jasmine-html.js
lib/jasmine-core/version.rb

View File

@@ -1,12 +1,16 @@
---
script: $TEST_COMMAND
language: ruby
cache: bundler
rvm: 1.9.3
env:
global:
- USE_SAUCE=true
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
- TEST_COMMAND="bash travis-core-script.sh"
- JASMINE_BROWSER="firefox"
- SAUCE_OS="Linux"
- SAUCE_BROWSER_VERSION=''
- secure: WSPWhlnC4mWSnSPquX+m1/BCu5ch5NygkaHuM2Nea7lD8oS3XLX8QncZZAsQ4lnNfqoDDuBOizG0AESiqNvE4y6x5qvLLTS6q+ce255ZEMZ71TBdZgDEEvGMEjOPPsVXiXyTQOP1lwOPlrbZvaPgWV7e11KIBab6DfFcQpnvDgo=
- secure: SW7CJhZnwaNT749Gdnhvqb5rbXlAOsygUAzh9qhtyvbqXKkmJdBIEsO01YF6pbju1X2twE9JvWCOxeZju43NgQChJlPsGbjY2j3k/TdQeTAJesQe2K7ytwghunI30gjEovtRH0T3w1EmcKPH8yj5eBIcB2OYoJHx8KEC7e68q1g=
matrix:
@@ -14,34 +18,34 @@ matrix:
- env:
- USE_SAUCE=false
- TEST_COMMAND="bash travis-node-script.sh"
- env:
- JASMINE_BROWSER="firefox"
- SAUCE_PLATFORM="Linux"
- SAUCE_VERSION=''
- env:
- JASMINE_BROWSER="safari"
- SAUCE_PLATFORM="OS X 10.8"
- SAUCE_VERSION=6
- env:
- JASMINE_BROWSER="safari"
- SAUCE_PLATFORM="OS X 10.6"
- SAUCE_VERSION=5
- env:
- SAUCE_OS="OS X 10.8"
- SAUCE_BROWSER_VERSION=6
- env:
- JASMINE_BROWSER="safari"
- SAUCE_OS="OS X 10.6"
- SAUCE_BROWSER_VERSION=5
- env:
- JASMINE_BROWSER="internet explorer"
- SAUCE_PLATFORM="Windows 8"
- SAUCE_VERSION=10
- env:
- SAUCE_OS="Windows 8"
- SAUCE_BROWSER_VERSION=10
- env:
- JASMINE_BROWSER="internet explorer"
- SAUCE_PLATFORM="Windows 7"
- SAUCE_VERSION=9
- env:
- SAUCE_OS="Windows 7"
- SAUCE_BROWSER_VERSION=9
- env:
- JASMINE_BROWSER="internet explorer"
- SAUCE_PLATFORM="Windows 7"
- SAUCE_VERSION=8
- env:
- SAUCE_OS="Windows 7"
- SAUCE_BROWSER_VERSION=8
- env:
- JASMINE_BROWSER="chrome"
- SAUCE_PLATFORM="Linux"
- SAUCE_VERSION=''
- env:
- SAUCE_OS="Linux"
- SAUCE_BROWSER_VERSION=''
- env:
- JASMINE_BROWSER="phantomjs"
- USE_SAUCE=false
- env:
- USE_SAUCE=false
- JASMINE_BROWSER="phantomjs"
- TEST_COMMAND="bash travis-docs-script.sh"

View File

@@ -7,6 +7,11 @@ We welcome your contributions - Thanks for helping make Jasmine a better project
Please submit pull requests via feature branches using the semi-standard workflow of:
1. Fork it
1. Clone your fork: (`git clone git@github.com:yourUserName/jasmine.git`)
1. Change directory: (`cd jasmine`)
1. Asign original repository to a remote named 'upstream': (`git remote add
upstream https://github.com/pivotal/jasmine.git`)
1. Pull in changes not present in your local repository: (`git fetch upstream`)
1. Create your feature branch (`git checkout -b my-new-feature`)
1. Commit your changes (`git commit -am 'Add some feature'`)
1. Push to the branch (`git push origin my-new-feature`)
@@ -107,5 +112,10 @@ Jasmine uses Node.js with a custom runner to test outside of a browser.
1. Ensure JSHint is green with `grunt jsHint`
1. Build `jasmine.js` with `grunt buildDistribution` and run all specs again - this ensures that your changes self-test well
## Submitting a Pull Request
1. Revert your changes to `jasmine.js` and `jasmine-html.js`
* We do this because `jasmine.js` and `jasmine-html.js` are auto-generated (as you've seen in the previous steps) and accepting multiple pull requests when this auto-generated file changes causes lots of headaches.
1. When we accept your pull request, we will generate these files as a separate commit and merge the entire branch into master.
Note that we use Travis for Continuous Integration. We only accept green pull requests.

View File

@@ -20,8 +20,6 @@
* 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
* Spies
* break these out into their own tests/file
* Remove isA functions:
* isArray_ - used in matchers and spies
* isString_
@@ -33,11 +31,6 @@
* 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?
* Matchers improvements
* unit testable DONE
* better equality (from Underscore) DONE
* refactor equals function so that it just loops & recurses over a list of fns (custom and built-in) - 2.1?
* addCustomMatchers doesn't explode stack
* Pretty printing
* move away from pretty printer and to a JSON.stringify implementation?
* jasmineToString vs. custom toString ?
@@ -47,6 +40,16 @@
* 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

View File

@@ -1,7 +1,6 @@
source 'https://rubygems.org'
gem "rake"
gem "jasmine", :git => 'https://github.com/pivotal/jasmine-gem.git'
#gem "jasmine", path: "/Users/pivotal/workspace/jasmine-gem"
# gem "jasmine", path: "/Users/pivotal/workspace/jasmine-gem"
unless ENV["TRAVIS"]
group :debug do
gem 'debugger'
@@ -9,3 +8,5 @@ unless ENV["TRAVIS"]
end
gemspec
gem "anchorman"

View File

@@ -10,10 +10,7 @@ module.exports = function(grunt) {
compress: require('./grunt/config/compress.js')
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-compress');
require('load-grunt-tasks')(grunt);
grunt.loadTasks('grunt/tasks');
@@ -37,12 +34,20 @@ module.exports = function(grunt) {
]
);
var spec = require('./grunt/tasks/spec.js');
grunt.registerTask("execSpecsInNode",
"Run Jasmine core specs in Node.js",
spec.execSpecsInNode
"Run Jasmine core specs in Node.js",
function() {
var exitInfo = require("shelljs").exec("node_modules/.bin/jasmine");
if (exitInfo.code !== 0) {
grunt.fail.fatal("Specs Failed", exitInfo.code);
}
}
);
grunt.registerTask("execSpecsInNode:performance",
"Run Jasmine performance specs in Node.js",
function() {
require("shelljs").exec("node_modules/.bin/jasmine JASMINE_CONFIG_PATH=spec/support/jasmine-performance.json");
}
);
};

5
MANIFEST.in Normal file
View File

@@ -0,0 +1,5 @@
recursive-include . *.py
include lib/jasmine-core/*.js
include lib/jasmine-core/*.css
include images/*.png
include package.json

View File

@@ -1,4 +1,4 @@
Copyright (c) 2008-2011 Pivotal Labs
Copyright (c) 2008-2014 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

View File

@@ -1,27 +0,0 @@
<a name="README">[Jasmine](http://pivotal.github.com/jasmine/)</a> [![Build Status](https://travis-ci.org/pivotal/jasmine.png?branch=master)](https://travis-ci.org/pivotal/jasmine)
=======
**A JavaScript Testing Framework**
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://pivotal.github.com/jasmine/](http://pivotal.github.com/jasmine/)
## Contributing
Please read the [contributors' guide](https://github.com/pivotal/jasmine/blob/master/Contribute.markdown)
## Support
* Search past discussions: [http://groups.google.com/group/jasmine-js](http://groups.google.com/group/jasmine-js)
* Send an email to the list: [jasmine-js@googlegroups.com](jasmine-js@googlegroups.com)
* View the project backlog at Pivotal Tracker: [http://www.pivotaltracker.com/projects/10606](http://www.pivotaltracker.com/projects/10606)
* Follow us on Twitter: [@JasmineBDD](http://twitter.com/JasmineBDD)
## Maintainers
* [Davis W. Frank](mailto:dwfrank@pivotallabs.com), Pivotal Labs
* [Rajan Agaskar](mailto:rajan@pivotallabs.com), Pivotal Labs
* [Christian Williams](mailto:antixian666@gmail.com), Square
Copyright (c) 2008-2013 Pivotal Labs. This software is licensed under the MIT License.

64
README.md Normal file
View File

@@ -0,0 +1,64 @@
<a name="README">[<img src="https://rawgithub.com/pivotal/jasmine/master/images/jasmine-horizontal.svg" width="400px" />](http://jasmine.github.io)</a>
[![Build Status](https://travis-ci.org/pivotal/jasmine.png?branch=master)](https://travis-ci.org/pivotal/jasmine) [![Code Climate](https://codeclimate.com/github/pivotal/jasmine.png)](https://codeclimate.com/github/pivotal/jasmine)
=======
**A JavaScript Testing Framework**
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/)
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/pivotal/jasmine/blob/v2.0.0/release_notes/20.md) for a list of what's new (including breaking interface changes).
## Contributing
Please read the [contributors' guide](https://github.com/pivotal/jasmine/blob/master/CONTRIBUTING.md)
## Installation
To install Jasmine on your local box:
* Clone Jasmine - `git clone https://github.com/pivotal/jasmine.git`
* 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`
* Change directory - `cd my-project/jasmine`
* Unzip the dist - `unzip jasmine-standalone-2.0.0.zip`
Add the following to your HTML file:
<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-html.js"></script>
<script type="text/javascript" src="jasmine/lib/jasmine-2.0.0/boot.js"></script>
For the Jasmine Ruby Gem:<br>
[https://github.com/pivotal/jasmine-gem](https://github.com/pivotal/jasmine-gem)
For the Jasmine Python Egg:<br>
[https://github.com/pivotal/jasmine-py](https://github.com/pivotal/jasmine-py)
## Support
* Search past discussions: [http://groups.google.com/group/jasmine-js](http://groups.google.com/group/jasmine-js)
* Send an email to the list: [jasmine-js@googlegroups.com](mailto:jasmine-js@googlegroups.com)
* View the project backlog at Pivotal Tracker: [http://www.pivotaltracker.com/projects/10606](http://www.pivotaltracker.com/projects/10606)
* Follow us on Twitter: [@JasmineBDD](http://twitter.com/JasmineBDD)
## Maintainers
* [Davis W. Frank](mailto:dwfrank@pivotallabs.com), Pivotal Labs
* [Rajan Agaskar](mailto:rajan@pivotallabs.com), Pivotal Labs
* [Sheel Choksi](mailto:schoksi@pivotallabs.com), Pivotal Labs
### Maintainers Emeritus
* [Christian Williams](mailto:antixian666@gmail.com), Square
Copyright (c) 2008-2014 Pivotal Labs. This software is licensed under the MIT License.

View File

@@ -3,7 +3,7 @@
## Development
___Jasmine Core Maintainers Only___
Follow the instructions in `Contribute.markdown` during development.
Follow the instructions in `CONTRIBUTING.md` during development.
### Git Rules
@@ -20,7 +20,7 @@ The current version lives in the file `/package.json`. This file should be set t
This version is used by both `jasmine.js` and the `jasmine-core` Ruby gem.
Note that Jasmine should *not* use the "patch" version number. Let downstream projects rev their patch versions as needed, keeping their major and minor version numbers in sync with Jasmine core.
### Update the Github Pages (as needed)
___Note: This is going to change right after 2.0___
@@ -33,15 +33,34 @@ If you want to submit changes to this repo and aren't a Pivotal Labs employee, y
When ready to release - specs are all green and the stories are done:
1. Update the release notes in `release_notes` - use the Anchorman gem to generate the markdown file and edit accordingly
1. Update the version in `package.json` to a release candidate
1. Update any links or top-level landing page for the Github Pages
### Build standalone distribution
1. Build the standalone distribution with `grunt buildStandaloneDist`
1. Make sure you add the new ZIP file to git
1. Should we still do this? Given we want to use guthub releases...
### Release the Python egg
1. `python setup.py register sdist upload` You will need pypi credentials to upload the egg.
### Release the Ruby gem
1. Copy version to the Ruby gem with `grunt build:copyVersionToGem`
1. __NOTE__: You will likely need to point to a local jasmine gem in order to run tests locally. _Do not_ push this version of the Gemfile.
1. __NOTE__: You will likely need to push a new jasmine gem with a dependent version right after this release.
1. Push these changes to GitHub and verify that this SHA is green
1. `rake release` - tags the repo with the version, builds the `jasmine-core` gem, pushes the gem to Rubygems.org. In order to release you will have to ensure you have rubygems creds locally.
### Finally
1. Visit the [Releases page for Jasmine](https://github.com/pivotal/jasmine/releases), find the tag just pushed.
1. Paste in a link to the correct release notes for this release. The link should reference the blob and tag correctly, and the markdown file for the notes.
1. If it is a pre-release, mark it as such.
1. Attach the standalone zipfile
There should be a post to Pivotal Labs blog and a tweet to that link.

View File

@@ -2,38 +2,17 @@ require "bundler"
Bundler::GemHelper.install_tasks
require "json"
require "jasmine"
Dir["#{File.dirname(__FILE__)}/tasks/**/*.rb"].each do |file|
require file
end
# TODO: Is there better way to invoke this using Jasmine gem???
task :core_spec do
exec "ruby spec/jasmine_self_test_spec.rb"
unless ENV["JASMINE_BROWSER"] == 'phantomjs'
require "jasmine_selenium_runner"
end
load "jasmine/tasks/jasmine.rake"
namespace :jasmine do
task :server do
port = ENV['JASMINE_PORT'] || 8888
jasmine_yml = ENV['JASMINE_YML'] || 'jasmine.yml'
Jasmine.load_configuration_from_yaml(File.join(Dir.pwd, 'spec', jasmine_yml))
config = Jasmine.config
server = Jasmine::Server.new(port, Jasmine::Application.app(config))
server.start
puts "your tests are here:"
puts " http://localhost:#{port}/"
end
desc "Copy examples from Jasmine JS to the gem"
task :copy_examples_to_gem do
require "fileutils"
# copy jasmine's example tree into our generator templates dir
FileUtils.rm_r('generators/jasmine/templates/jasmine-example', :force => true)
FileUtils.cp_r(File.join(Jasmine::Core.path, 'example'), 'generators/jasmine/templates/jasmine-example', :preserve => true)
task :set_env do
ENV['JASMINE_CONFIG_PATH'] ||= 'spec/support/jasmine.yml'
end
end
desc "Run specs via server"
task :jasmine => ['jasmine:server']
task "jasmine:configure" => "jasmine:set_env"
task :default => "jasmine:ci"

BIN
dist/jasmine-standalone-1.0.0.zip vendored Normal file

Binary file not shown.

BIN
dist/jasmine-standalone-1.1.0.zip vendored Normal file

Binary file not shown.

BIN
dist/jasmine-standalone-1.2.0.zip vendored Normal file

Binary file not shown.

BIN
dist/jasmine-standalone-1.3.0.zip vendored Normal file

Binary file not shown.

BIN
dist/jasmine-standalone-1.3.1.zip vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
dist/jasmine-standalone-2.0.0.zip vendored Normal file

Binary file not shown.

BIN
dist/jasmine-standalone-2.0.1.zip vendored Normal file

Binary file not shown.

View File

@@ -1,10 +1,10 @@
module.exports = {
jasmine: {
options: {
cssDir: 'src/html',
cssDir: 'lib/jasmine-core/',
sassDir: 'src/html',
outputStyle: 'compact',
lineComments: false
noLineComments: true,
}
}
};
};

View File

@@ -1,7 +1,8 @@
var standaloneLibDir = "lib/jasmine-" + jasmineVersion;
function root(path) { return "./" + path; }
function lib(path) { return root("lib/jasmine-core/" + path); }
function libJasmineCore(path) { return root("lib/jasmine-core/" + path); }
function libConsole() { return "lib/console/" }
function dist(path) { return root("dist/" + path); }
module.exports = {
@@ -26,13 +27,21 @@ module.exports = {
],
dest: standaloneLibDir,
expand: true,
cwd: lib("")
cwd: libJasmineCore("")
},
{
src: [
"console.js"
],
dest: standaloneLibDir,
expand: true,
cwd: libConsole()
},
{
src: [ "boot.js" ],
dest: standaloneLibDir,
expand: true,
cwd: lib("boot")
cwd: libJasmineCore("boot")
},
{
src: [ "SpecRunner.html" ],
@@ -44,13 +53,13 @@ module.exports = {
src: [ "*.js" ],
dest: "src",
expand: true,
cwd: lib("example/src/")
cwd: libJasmineCore("example/src/")
},
{
src: [ "*.js" ],
dest: "spec",
expand: true,
cwd: lib("example/spec/")
cwd: libJasmineCore("example/spec/")
}
]
}

View File

@@ -39,12 +39,16 @@ module.exports = {
src: ['lib/jasmine-core/boot/boot.js'],
dest: 'lib/jasmine-core/boot.js'
},
nodeBoot: {
src: ['lib/jasmine-core/boot/node_boot.js'],
dest: 'lib/jasmine-core/node_boot.js'
},
console: {
src: [
'src/console/requireConsole.js',
'src/console/ConsoleReporter.js'
],
dest: 'src/console/console.js'
dest: 'lib/console/console.js'
},
options: {
banner: license(),
@@ -54,4 +58,4 @@ module.exports = {
}
}
}
};
};

View File

@@ -5,13 +5,7 @@ module.exports = {
'lib/jasmine-core/jasmine.js'
],
options: {
/* While it's possible that we could be considering unwanted prototype methods, mostly
* we're doing this because the objects are being used as maps.
*/
forin: false,
/* We're fine with functions defined inside loops (setTimeout functions, etc) */
loopfunc: true
jshintrc: '.jshintrc'
},
all: ['src/**/*.js']
};
};

View File

@@ -1,7 +1,7 @@
var grunt = require("grunt");
function standaloneTmpDir(path) { return "dist/tmp/" + path; }
grunt.registerTask("build:compileSpecRunner",
"Processes the spec runner template and writes to a tmp file",
function() {
@@ -23,6 +23,7 @@ grunt.registerTask("build:cleanSpecRunner",
grunt.registerTask("buildStandaloneDist",
"Builds a standalone distribution",
[
"buildDistribution",
"build:compileSpecRunner",
"compress:standalone",
"build:cleanSpecRunner"

View File

@@ -1,11 +0,0 @@
var shell = require('shelljs');
var grunt = require('grunt');
module.exports = {
execSpecsInNode: function() {
var exit_code = shell.exec("node spec/node_suite.js --color=true").code;
if (exit_code !== 0) {
grunt.fail.fatal("Specs Failed", exit_code);
}
}
};

0
images/__init__.py Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="681.96252"
height="187.5"
id="svg2"
xml:space="preserve"><metadata
id="metadata8"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
id="defs6"><clipPath
id="clipPath18"><path
d="M 0,1500 0,0 l 5455.74,0 0,1500 L 0,1500 z"
inkscape:connector-curvature="0"
id="path20" /></clipPath></defs><g
transform="matrix(1.25,0,0,-1.25,0,187.5)"
id="g10"><g
transform="scale(0.1,0.1)"
id="g12"><g
id="g14"><g
clip-path="url(#clipPath18)"
id="g16"><path
d="m 1544,599.434 c 0.92,-40.352 25.68,-81.602 71.53,-81.602 27.51,0 47.68,12.832 61.44,35.754 12.83,22.93 12.83,56.852 12.83,82.527 l 0,329.184 -71.52,0 0,104.543 266.83,0 0,-104.543 -70.6,0 0,-344.77 c 0,-58.691 -3.68,-104.531 -44.93,-152.218 -36.68,-42.18 -96.28,-66.02 -153.14,-66.02 -117.37,0 -207.24,77.941 -202.64,197.145 l 130.2,0"
inkscape:connector-curvature="0"
id="path22"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 2301.4,662.695 c 0,80.703 -66.94,145.813 -147.63,145.813 -83.44,0 -147.63,-68.781 -147.63,-151.301 0,-79.785 66.94,-145.801 145.8,-145.801 84.35,0 149.46,67.852 149.46,151.289 z m -1.83,-181.547 c -35.77,-54.097 -93.53,-78.859 -157.72,-78.859 -140.3,0 -251.24,116.449 -251.24,254.918 0,142.129 113.7,260.41 256.74,260.41 63.27,0 118.29,-29.336 152.22,-82.523 l 0,69.687 175.14,0 0,-104.527 -61.44,0 0,-280.598 61.44,0 0,-104.527 -175.14,0 0,66.019"
inkscape:connector-curvature="0"
id="path24"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 2622.33,557.258 c 3.67,-44.016 33.01,-73.348 78.86,-73.348 33.93,0 66.93,23.824 66.93,60.504 0,48.606 -45.84,56.856 -83.44,66.941 -85.28,22.004 -178.81,48.606 -178.81,155.879 0,93.536 78.86,147.633 165.98,147.633 44,0 83.43,-9.176 110.94,-44.008 l 0,33.922 82.53,0 0,-132.965 -108.21,0 c -1.83,34.856 -28.42,57.774 -63.26,57.774 -30.26,0 -62.35,-17.422 -62.35,-51.348 0,-45.847 44.93,-55.93 80.69,-64.18 88.02,-20.175 182.47,-47.695 182.47,-157.734 0,-99.027 -83.44,-154.039 -175.13,-154.039 -49.53,0 -94.46,15.582 -126.55,53.18 l 0,-40.34 -85.27,0 0,142.129 114.62,0"
inkscape:connector-curvature="0"
id="path26"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 2988.18,800.254 -63.26,0 0,104.527 165.05,0 0,-73.355 c 31.18,51.347 78.86,85.277 141.21,85.277 67.85,0 124.71,-41.258 152.21,-102.699 26.6,62.351 92.62,102.699 160.47,102.699 53.19,0 105.46,-22 141.21,-62.351 38.52,-44.938 38.52,-93.532 38.52,-149.457 l 0,-185.239 63.27,0 0,-104.527 -238.42,0 0,104.527 63.28,0 0,157.715 c 0,32.102 0,60.527 -14.67,88.957 -18.34,26.582 -48.61,40.344 -79.77,40.344 -30.26,0 -63.28,-12.844 -82.53,-36.672 -22.93,-29.355 -22.93,-56.863 -22.93,-92.629 l 0,-157.715 63.27,0 0,-104.527 -238.41,0 0,104.527 63.28,0 0,150.383 c 0,29.348 0,66.023 -14.67,91.699 -15.59,29.336 -47.69,44.934 -80.7,44.934 -31.18,0 -57.77,-11.008 -77.94,-35.774 -24.77,-30.253 -26.6,-62.343 -26.6,-99.941 l 0,-151.301 63.27,0 0,-104.527 -238.4,0 0,104.527 63.26,0 0,280.598"
inkscape:connector-curvature="0"
id="path28"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 3998.66,951.547 -111.87,0 0,118.293 111.87,0 0,-118.293 z m 0,-431.891 63.27,0 0,-104.527 -239.33,0 0,104.527 64.19,0 0,280.598 -63.27,0 0,104.527 175.14,0 0,-385.125"
inkscape:connector-curvature="0"
id="path30"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 4159.12,800.254 -63.27,0 0,104.527 175.14,0 0,-69.687 c 29.35,54.101 84.36,80.699 144.87,80.699 53.19,0 105.45,-22.016 141.22,-60.527 40.34,-44.934 41.26,-88.032 41.26,-143.957 l 0,-191.653 63.27,0 0,-104.527 -238.4,0 0,104.527 63.26,0 0,158.637 c 0,30.262 0,61.434 -19.26,88.035 -20.17,26.582 -53.18,39.414 -86.19,39.414 -33.93,0 -68.77,-13.75 -88.94,-41.25 -21.09,-27.5 -21.09,-69.687 -21.09,-102.707 l 0,-142.129 63.26,0 0,-104.527 -238.4,0 0,104.527 63.27,0 0,280.598"
inkscape:connector-curvature="0"
id="path32"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 5082.48,703.965 c -19.24,70.605 -81.6,115.547 -154.04,115.547 -66.04,0 -129.3,-51.348 -143.05,-115.547 l 297.09,0 z m 85.27,-144.883 c -38.51,-93.523 -129.27,-156.793 -231.05,-156.793 -143.07,0 -257.68,111.871 -257.68,255.836 0,144.883 109.12,261.328 254.91,261.328 67.87,0 135.72,-30.258 183.39,-78.863 48.62,-51.344 68.79,-113.695 68.79,-183.383 l -3.67,-39.434 -396.13,0 c 14.67,-67.863 77.03,-117.363 146.72,-117.363 48.59,0 90.76,18.328 118.28,58.672 l 116.44,0"
inkscape:connector-curvature="0"
id="path34"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 690.895,850.703 90.75,0 22.543,31.035 0,243.122 -135.829,0 0,-243.141 22.536,-31.016"
inkscape:connector-curvature="0"
id="path36"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 632.395,742.258 28.039,86.304 -22.551,31.04 -231.223,75.128 -41.976,-129.183 231.257,-75.137 36.454,11.848"
inkscape:connector-curvature="0"
id="path38"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 717.449,653.105 -73.41,53.36 -36.488,-11.875 -142.903,-196.692 109.883,-79.828 142.918,196.703 0,38.332"
inkscape:connector-curvature="0"
id="path40"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 828.52,706.465 -73.426,-53.34 0.011,-38.359 L 898.004,418.07 1007.9,497.898 864.973,694.609 828.52,706.465"
inkscape:connector-curvature="0"
id="path42"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 812.086,828.586 28.055,-86.32 36.484,-11.836 231.225,75.117 -41.97,129.183 -231.239,-75.14 -22.555,-31.004"
inkscape:connector-curvature="0"
id="path44"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 736.301,1335.88 c -323.047,0 -585.875,-262.78 -585.875,-585.782 0,-323.118 262.828,-585.977 585.875,-585.977 323.019,0 585.809,262.859 585.809,585.977 0,323.002 -262.79,585.782 -585.809,585.782 l 0,0 z m 0,-118.61 c 257.972,0 467.189,-209.13 467.189,-467.172 0,-258.129 -209.217,-467.348 -467.189,-467.348 -258.074,0 -467.254,209.219 -467.254,467.348 0,258.042 209.18,467.172 467.254,467.172"
inkscape:connector-curvature="0"
id="path46"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 1091.13,619.883 -175.771,57.121 11.629,35.808 175.762,-57.121 -11.62,-35.808"
inkscape:connector-curvature="0"
id="path48"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="M 866.957,902.074 836.5,924.199 945.121,1073.73 975.586,1051.61 866.957,902.074"
inkscape:connector-curvature="0"
id="path50"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="M 607.465,903.445 498.855,1052.97 529.32,1075.1 637.93,925.566 607.465,903.445"
inkscape:connector-curvature="0"
id="path52"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 380.688,622.129 -11.626,35.801 175.758,57.09 11.621,-35.801 -175.753,-57.09"
inkscape:connector-curvature="0"
id="path54"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 716.289,376.59 37.6406,0 0,184.816 -37.6406,0 0,-184.816 z"
inkscape:connector-curvature="0"
id="path56"
style="fill:#8a4182;fill-opacity:1;fill-rule:nonzero;stroke:none" /></g></g></g></g></svg>

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 905 B

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -16,12 +16,8 @@ Gem::Specification.new do |s|
s.files = Dir.glob("./lib/**/*") + Dir.glob("./lib/jasmine-core/spec/**/*.js")
s.require_paths = ["lib"]
s.add_development_dependency "json_pure", ">= 1.4.3"
s.add_development_dependency "sass"
s.add_development_dependency "compass"
s.add_development_dependency "rspec"
s.add_development_dependency "fuubar"
s.add_development_dependency "awesome_print"
s.add_development_dependency "nokogiri"
s.add_development_dependency "rake"
s.add_development_dependency "sauce-connect"
s.add_development_dependency "compass"
s.add_development_dependency "jasmine_selenium_runner", ">= 0.2.0"
end

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2008-2013 Pivotal Labs
Copyright (c) 2008-2014 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -21,7 +21,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
function getJasmineRequireObj() {
if (typeof module !== "undefined" && module.exports) {
if (typeof module !== 'undefined' && module.exports) {
return exports;
} else {
window.jasmineRequire = window.jasmineRequire || {};
@@ -50,17 +50,17 @@ getJasmineRequireObj().ConsoleReporter = function() {
failedSpecs = [],
pendingCount,
ansi = {
green: '\033[32m',
red: '\033[31m',
yellow: '\033[33m',
none: '\033[0m'
green: '\x1B[32m',
red: '\x1B[31m',
yellow: '\x1B[33m',
none: '\x1B[0m'
};
this.jasmineStarted = function() {
specCount = 0;
failureCount = 0;
pendingCount = 0;
print("Started");
print('Started');
printNewline();
timer.start();
};
@@ -71,19 +71,24 @@ getJasmineRequireObj().ConsoleReporter = function() {
specFailureDetails(failedSpecs[i]);
}
printNewline();
var specCounts = specCount + " " + plural("spec", specCount) + ", " +
failureCount + " " + plural("failure", failureCount);
if(specCount > 0) {
printNewline();
if (pendingCount) {
specCounts += ", " + pendingCount + " pending " + plural("spec", pendingCount);
var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' +
failureCount + ' ' + plural('failure', failureCount);
if (pendingCount) {
specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount);
}
print(specCounts);
} else {
print('No specs found');
}
print(specCounts);
printNewline();
var seconds = timer.elapsed() / 1000;
print("Finished in " + seconds + " " + plural("second", seconds));
print('Finished in ' + seconds + ' ' + plural('second', seconds));
printNewline();
@@ -93,28 +98,28 @@ getJasmineRequireObj().ConsoleReporter = function() {
this.specDone = function(result) {
specCount++;
if (result.status == "pending") {
if (result.status == 'pending') {
pendingCount++;
print(colored("yellow", "*"));
print(colored('yellow', '*'));
return;
}
if (result.status == "passed") {
print(colored("green", '.'));
if (result.status == 'passed') {
print(colored('green', '.'));
return;
}
if (result.status == "failed") {
if (result.status == 'failed') {
failureCount++;
failedSpecs.push(result);
print(colored("red", 'F'));
print(colored('red', 'F'));
}
};
return this;
function printNewline() {
print("\n");
print('\n');
}
function colored(color, str) {
@@ -122,7 +127,7 @@ getJasmineRequireObj().ConsoleReporter = function() {
}
function plural(str, count) {
return count == 1 ? str : str + "s";
return count == 1 ? str : str + 's';
}
function repeat(thing, times) {
@@ -134,12 +139,12 @@ getJasmineRequireObj().ConsoleReporter = function() {
}
function indent(str, spaces) {
var lines = (str || '').split("\n");
var lines = (str || '').split('\n');
var newArr = [];
for (var i = 0; i < lines.length; i++) {
newArr.push(repeat(" ", spaces).join("") + lines[i]);
newArr.push(repeat(' ', spaces).join('') + lines[i]);
}
return newArr.join("\n");
return newArr.join('\n');
}
function specFailureDetails(result) {

2
lib/jasmine-core.js Normal file
View File

@@ -0,0 +1,2 @@
module.exports = require("./jasmine-core/jasmine.js");
module.exports.boot = require('./jasmine-core/node_boot.js');

View File

@@ -6,7 +6,7 @@ module Jasmine
end
def js_files
(["jasmine.js"] + Dir.glob(File.join(path, "*.js"))).map { |f| File.basename(f) }.uniq - boot_files
(["jasmine.js"] + Dir.glob(File.join(path, "*.js"))).map { |f| File.basename(f) }.uniq - boot_files - node_boot_files
end
SPEC_TYPES = ["core", "html", "node"]
@@ -27,8 +27,12 @@ module Jasmine
["boot.js"]
end
def node_boot_files
["node_boot.js"]
end
def boot_dir
File.join(path, 'boot')
path
end
def spec_files(type)

View File

@@ -0,0 +1 @@
from .core import Core

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2008-2013 Pivotal Labs
Copyright (c) 2008-2014 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -20,13 +20,40 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Jasmine boot.js for browser runners - exposes external/global interface, builds the Jasmine environment and executes it.
/**
Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
[jasmine-gem]: http://github.com/pivotal/jasmine-gem
*/
(function() {
/**
* ## Require &amp; Instantiate
*
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
*/
window.jasmine = jasmineRequire.core(jasmineRequire);
/**
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
*/
jasmineRequire.html(jasmine);
/**
* Create the Jasmine environment. This is used to run all specs in a project.
*/
var env = jasmine.getEnv();
/**
* ## The Global Interface
*
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
*/
var jasmineInterface = {
describe: function(description, specDefinitions) {
return env.describe(description, specDefinitions);
@@ -60,41 +87,64 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
return env.pending();
},
addMatchers: function(matchers) {
return env.addMatchers(matchers);
},
spyOn: function(obj, methodName) {
return env.spyOn(obj, methodName);
},
clock: env.clock,
setTimeout: env.clock.setTimeout,
clearTimeout: env.clock.clearTimeout,
setInterval: env.clock.setInterval,
clearInterval: env.clock.clearInterval,
jsApiReporter: new jasmine.JsApiReporter({
timer: new jasmine.Timer()
})
};
/**
* Add all of the Jasmine global/public interface to the proper global, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
*/
if (typeof window == "undefined" && typeof exports == "object") {
extend(exports, jasmineInterface);
} else {
extend(window, jasmineInterface);
}
/**
* Expose the interface for adding custom equality testers.
*/
jasmine.addCustomEqualityTester = function(tester) {
env.addCustomEqualityTester(tester);
};
/**
* Expose the interface for adding custom expectation matchers
*/
jasmine.addMatchers = function(matchers) {
return env.addMatchers(matchers);
};
/**
* Expose the mock interface for the JavaScript timeout functions
*/
jasmine.clock = function() {
return env.clock;
};
/**
* ## Runner Parameters
*
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
*/
var queryString = new jasmine.QueryString({
getWindowLocation: function() { return window.location; }
});
// TODO: move all of catching to raise so we don't break our brains
var catchingExceptions = queryString.getParam("catch");
env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
/**
* ## 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).
*/
var htmlReporter = new jasmine.HtmlReporter({
env: env,
queryString: queryString,
onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
getContainer: function() { return document.body; },
createElement: function() { return document.createElement.apply(document, arguments); },
@@ -102,9 +152,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
timer: new jasmine.Timer()
});
/**
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
*/
env.addReporter(jasmineInterface.jsApiReporter);
env.addReporter(htmlReporter);
/**
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
*/
var specFilter = new jasmine.HtmlSpecFilter({
filterString: function() { return queryString.getParam("spec"); }
});
@@ -113,6 +169,19 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
return specFilter.matches(spec.getFullName());
};
/**
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
*/
window.setTimeout = window.setTimeout;
window.setInterval = window.setInterval;
window.clearTimeout = window.clearTimeout;
window.clearInterval = window.clearInterval;
/**
* ## Execution
*
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
*/
var currentWindowOnload = window.onload;
window.onload = function() {
@@ -123,6 +192,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
env.execute();
};
/**
* Helper function for readability above.
*/
function extend(destination, source) {
for (var property in source) destination[property] = source[property];
return destination;

View File

@@ -1,10 +1,37 @@
// Jasmine boot.js for browser runners - exposes external/global interface, builds the Jasmine environment and executes it.
/**
Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
[jasmine-gem]: http://github.com/pivotal/jasmine-gem
*/
(function() {
/**
* ## Require &amp; Instantiate
*
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
*/
window.jasmine = jasmineRequire.core(jasmineRequire);
/**
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
*/
jasmineRequire.html(jasmine);
/**
* Create the Jasmine environment. This is used to run all specs in a project.
*/
var env = jasmine.getEnv();
/**
* ## The Global Interface
*
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
*/
var jasmineInterface = {
describe: function(description, specDefinitions) {
return env.describe(description, specDefinitions);
@@ -38,41 +65,64 @@
return env.pending();
},
addMatchers: function(matchers) {
return env.addMatchers(matchers);
},
spyOn: function(obj, methodName) {
return env.spyOn(obj, methodName);
},
clock: env.clock,
setTimeout: env.clock.setTimeout,
clearTimeout: env.clock.clearTimeout,
setInterval: env.clock.setInterval,
clearInterval: env.clock.clearInterval,
jsApiReporter: new jasmine.JsApiReporter({
timer: new jasmine.Timer()
})
};
/**
* Add all of the Jasmine global/public interface to the proper global, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
*/
if (typeof window == "undefined" && typeof exports == "object") {
extend(exports, jasmineInterface);
} else {
extend(window, jasmineInterface);
}
/**
* Expose the interface for adding custom equality testers.
*/
jasmine.addCustomEqualityTester = function(tester) {
env.addCustomEqualityTester(tester);
};
/**
* Expose the interface for adding custom expectation matchers
*/
jasmine.addMatchers = function(matchers) {
return env.addMatchers(matchers);
};
/**
* Expose the mock interface for the JavaScript timeout functions
*/
jasmine.clock = function() {
return env.clock;
};
/**
* ## Runner Parameters
*
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
*/
var queryString = new jasmine.QueryString({
getWindowLocation: function() { return window.location; }
});
// TODO: move all of catching to raise so we don't break our brains
var catchingExceptions = queryString.getParam("catch");
env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
/**
* ## 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).
*/
var htmlReporter = new jasmine.HtmlReporter({
env: env,
queryString: queryString,
onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
getContainer: function() { return document.body; },
createElement: function() { return document.createElement.apply(document, arguments); },
@@ -80,9 +130,15 @@
timer: new jasmine.Timer()
});
/**
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
*/
env.addReporter(jasmineInterface.jsApiReporter);
env.addReporter(htmlReporter);
/**
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
*/
var specFilter = new jasmine.HtmlSpecFilter({
filterString: function() { return queryString.getParam("spec"); }
});
@@ -91,6 +147,19 @@
return specFilter.matches(spec.getFullName());
};
/**
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
*/
window.setTimeout = window.setTimeout;
window.setInterval = window.setInterval;
window.clearTimeout = window.clearTimeout;
window.clearInterval = window.clearInterval;
/**
* ## Execution
*
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
*/
var currentWindowOnload = window.onload;
window.onload = function() {
@@ -101,6 +170,9 @@
env.execute();
};
/**
* Helper function for readability above.
*/
function extend(destination, source) {
for (var property in source) destination[property] = source[property];
return destination;

View File

@@ -0,0 +1,71 @@
module.exports = function(jasmineRequire) {
var jasmine = jasmineRequire.core(jasmineRequire);
var consoleFns = require('../console/console.js');
consoleFns.console(consoleFns, 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()
}),
jasmine: jasmine
};
extend(global, jasmineInterface);
jasmine.addCustomEqualityTester = function(tester) {
env.addCustomEqualityTester(tester);
};
jasmine.addMatchers = function(matchers) {
return env.addMatchers(matchers);
};
jasmine.clock = function() {
return env.clock;
};
function extend(destination, source) {
for (var property in source) destination[property] = source[property];
return destination;
}
return jasmine;
};

60
lib/jasmine-core/core.py Normal file
View File

@@ -0,0 +1,60 @@
import pkg_resources
try:
from collections import OrderedDict
except ImportError:
from ordereddict import OrderedDict
class Core(object):
@classmethod
def js_package(cls):
return __package__
@classmethod
def css_package(cls):
return __package__
@classmethod
def image_package(cls):
return __package__ + ".images"
@classmethod
def js_files(cls):
js_files = sorted(list(filter(lambda x: '.js' in x, pkg_resources.resource_listdir(cls.js_package(), '.'))))
# jasmine.js needs to be first
js_files.insert(0, 'jasmine.js')
# boot needs to be last
js_files.remove('boot.js')
js_files.append('boot.js')
return cls._uniq(js_files)
@classmethod
def css_files(cls):
return cls._uniq(sorted(filter(lambda x: '.css' in x, pkg_resources.resource_listdir(cls.css_package(), '.'))))
@classmethod
def favicon(cls):
return 'jasmine_favicon.png'
@classmethod
def _uniq(self, items, idfun=None):
# order preserving
if idfun is None:
def idfun(x): return x
seen = {}
result = []
for item in items:
marker = idfun(item)
# in old Python versions:
# if seen.has_key(marker)
# but in new ones:
if marker in seen:
continue
seen[marker] = 1
result.append(item)
return result

View File

@@ -0,0 +1,60 @@
describe("Player", function() {
var Player = require('../../jasmine_examples/Player.js');
var Song = require('../../jasmine_examples/Song.js');
var player;
var song;
beforeEach(function() {
player = new Player();
song = new Song();
});
it("should be able to play a Song", function() {
player.play(song);
expect(player.currentlyPlayingSong).toEqual(song);
//demonstrates use of custom matcher
expect(player).toBePlaying(song);
});
describe("when song has been paused", function() {
beforeEach(function() {
player.play(song);
player.pause();
});
it("should indicate that the song is currently paused", function() {
expect(player.isPlaying).toBeFalsy();
// demonstrates use of 'not' with a custom matcher
expect(player).not.toBePlaying(song);
});
it("should be possible to resume", function() {
player.resume();
expect(player.isPlaying).toBeTruthy();
expect(player.currentlyPlayingSong).toEqual(song);
});
});
// demonstrates use of spies to intercept and test method calls
it("tells the current song if the user has made it a favorite", function() {
spyOn(song, 'persistFavoriteStatus');
player.play(song);
player.makeFavorite();
expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);
});
//demonstrates use of expected exceptions
describe("#resume", function() {
it("should throw an exception if song is already playing", function() {
player.play(song);
expect(function() {
player.resume();
}).toThrowError("song is already playing");
});
});
});

View File

@@ -0,0 +1,15 @@
beforeEach(function () {
jasmine.addMatchers({
toBePlaying: function () {
return {
compare: function (actual, expected) {
var player = actual;
return {
pass: player.currentlyPlayingSong === expected && player.isPlaying
}
}
};
}
});
});

View File

@@ -0,0 +1,24 @@
function Player() {
}
Player.prototype.play = function(song) {
this.currentlyPlayingSong = song;
this.isPlaying = true;
};
Player.prototype.pause = function() {
this.isPlaying = false;
};
Player.prototype.resume = function() {
if (this.isPlaying) {
throw new Error("song is already playing");
}
this.isPlaying = true;
};
Player.prototype.makeFavorite = function() {
this.currentlyPlayingSong.persistFavoriteStatus(true);
};
module.exports = Player;

View File

@@ -0,0 +1,9 @@
function Song() {
}
Song.prototype.persistFavoriteStatus = function(value) {
// something complicated
throw new Error("not yet implemented");
};
module.exports = Song;

View File

@@ -1,15 +1,15 @@
beforeEach(function () {
jasmine.Expectation.addMatchers({
toBePlaying: function () {
return {
compare: function (actual, expected) {
var player = actual;
jasmine.addMatchers({
toBePlaying: function () {
return {
compare: function (actual, expected) {
var player = actual;
return {
pass: player.currentlyPlayingSong === expected && player.isPlaying
}
}
};
return {
pass: player.currentlyPlayingSong === expected && player.isPlaying
}
}
});
};
}
});
});

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2008-2013 Pivotal Labs
Copyright (c) 2008-2014 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -26,11 +26,12 @@ jasmineRequire.html = function(j$) {
j$.QueryString = jasmineRequire.QueryString();
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
};
jasmineRequire.HtmlReporter = function(j$) {
var noopTimer = {
start: function(){},
elapsed: function(){ return 0; }
start: function() {},
elapsed: function() { return 0; }
};
function HtmlReporter(options) {
@@ -48,20 +49,21 @@ jasmineRequire.HtmlReporter = function(j$) {
symbols;
this.initialize = function() {
htmlReporterMain = createDom("div", {className: "html-reporter"},
createDom("div", {className: "banner"},
createDom("span", {className: "title"}, "Jasmine"),
createDom("span", {className: "version"}, j$.version)
clearPrior();
htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'},
createDom('div', {className: 'banner'},
createDom('a', {className: 'title', href: 'http://jasmine.github.io/', target: '_blank'}),
createDom('span', {className: 'version'}, j$.version)
),
createDom("ul", {className: "symbol-summary"}),
createDom("div", {className: "alert"}),
createDom("div", {className: "results"},
createDom("div", {className: "failures"})
createDom('ul', {className: 'symbol-summary'}),
createDom('div', {className: 'alert'}),
createDom('div', {className: 'results'},
createDom('div', {className: 'failures'})
)
);
getContainer().appendChild(htmlReporterMain);
symbols = find(".symbol-summary");
symbols = find('.symbol-summary');
};
var totalSpecsDefined;
@@ -70,13 +72,13 @@ jasmineRequire.HtmlReporter = function(j$) {
timer.start();
};
var summary = createDom("div", {className: "summary"});
var summary = createDom('div', {className: 'summary'});
var topResults = new j$.ResultsNode({}, "", null),
var topResults = new j$.ResultsNode({}, '', null),
currentParent = topResults;
this.suiteStarted = function(result) {
currentParent.addChild(result, "suite");
currentParent.addChild(result, 'suite');
currentParent = currentParent.last();
};
@@ -89,79 +91,94 @@ jasmineRequire.HtmlReporter = function(j$) {
};
this.specStarted = function(result) {
currentParent.addChild(result, "spec");
currentParent.addChild(result, 'spec');
};
var failures = [];
this.specDone = function(result) {
if (result.status != "disabled") {
if(noExpectations(result) && console && console.error) {
console.error('Spec \'' + result.fullName + '\' has no expectations.');
}
if (result.status != 'disabled') {
specsExecuted++;
}
symbols.appendChild(createDom("li", {
className: result.status,
id: "spec_" + result.id,
title: result.fullName}
symbols.appendChild(createDom('li', {
className: noExpectations(result) ? 'empty' : result.status,
id: 'spec_' + result.id,
title: result.fullName
}
));
if (result.status == "failed") {
if (result.status == 'failed') {
failureCount++;
var failure =
createDom("div", {className: "spec-detail failed"},
createDom("a", {className: "description", title: result.fullName, href: specHref(result)}, result.fullName),
createDom("div", {className: "messages"})
createDom('div', {className: 'spec-detail failed'},
createDom('div', {className: 'description'},
createDom('a', {title: result.fullName, href: specHref(result)}, result.fullName)
),
createDom('div', {className: 'messages'})
);
var messages = failure.childNodes[1];
for (var i = 0; i < result.failedExpectations.length; i++) {
var expectation = result.failedExpectations[i];
messages.appendChild(createDom("div", {className: "result-message"}, expectation.message));
messages.appendChild(createDom("div", {className: "stack-trace"}, expectation.stack));
messages.appendChild(createDom('div', {className: 'result-message'}, expectation.message));
messages.appendChild(createDom('div', {className: 'stack-trace'}, expectation.stack));
}
failures.push(failure);
}
if (result.status == "pending") {
if (result.status == 'pending') {
pendingSpecCount++;
}
};
this.jasmineDone = function() {
var banner = find(".banner");
banner.appendChild(createDom("span", {className: "duration"}, "finished in " + timer.elapsed() / 1000 + "s"));
var banner = find('.banner');
banner.appendChild(createDom('span', {className: 'duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
var alert = find(".alert");
var alert = find('.alert');
alert.appendChild(createDom("span", { className: "exceptions" },
createDom("label", { className: "label", 'for': "raise-exceptions" }, "raise exceptions"),
createDom("input", {
className: "raise",
id: "raise-exceptions",
type: "checkbox"
alert.appendChild(createDom('span', { className: 'exceptions' },
createDom('label', { className: 'label', 'for': 'raise-exceptions' }, 'raise exceptions'),
createDom('input', {
className: 'raise',
id: 'raise-exceptions',
type: 'checkbox'
})
));
var checkbox = find("input");
var checkbox = find('#raise-exceptions');
checkbox.checked = !env.catchingExceptions();
checkbox.onclick = onRaiseExceptionsClick;
if (specsExecuted < totalSpecsDefined) {
var skippedMessage = "Ran " + specsExecuted + " of " + totalSpecsDefined + " specs - run all";
var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
alert.appendChild(
createDom("span", {className: "bar skipped"},
createDom("a", {href: "?", title: "Run all specs"}, skippedMessage)
createDom('span', {className: 'bar skipped'},
createDom('a', {href: '?', title: 'Run all specs'}, skippedMessage)
)
);
}
var statusBarMessage = "" + pluralize("spec", specsExecuted) + ", " + pluralize("failure", failureCount);
if (pendingSpecCount) { statusBarMessage += ", " + pluralize("pending spec", pendingSpecCount); }
var statusBarMessage = '';
var statusBarClassName = 'bar ';
var statusBarClassName = "bar " + ((failureCount > 0) ? "failed" : "passed");
alert.appendChild(createDom("span", {className: statusBarClassName}, statusBarMessage));
if (totalSpecsDefined > 0) {
statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
statusBarClassName += (failureCount > 0) ? 'failed' : 'passed';
} else {
statusBarClassName += 'skipped';
statusBarMessage += 'No specs found';
}
var results = find(".results");
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage));
var results = find('.results');
results.appendChild(summary);
summaryList(topResults, summary);
@@ -170,27 +187,31 @@ jasmineRequire.HtmlReporter = function(j$) {
var specListNode;
for (var i = 0; i < resultsTree.children.length; i++) {
var resultNode = resultsTree.children[i];
if (resultNode.type == "suite") {
var suiteListNode = createDom("ul", {className: "suite", id: "suite-" + resultNode.result.id},
createDom("li", {className: "suite-detail"},
createDom("a", {href: specHref(resultNode.result)}, resultNode.result.description)
if (resultNode.type == 'suite') {
var suiteListNode = createDom('ul', {className: 'suite', id: 'suite-' + resultNode.result.id},
createDom('li', {className: 'suite-detail'},
createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description)
)
);
summaryList(resultNode, suiteListNode);
domParent.appendChild(suiteListNode);
}
if (resultNode.type == "spec") {
if (domParent.getAttribute("class") != "specs") {
specListNode = createDom("ul", {className: "specs"});
if (resultNode.type == 'spec') {
if (domParent.getAttribute('class') != 'specs') {
specListNode = createDom('ul', {className: 'specs'});
domParent.appendChild(specListNode);
}
var specDescription = resultNode.result.description;
if(noExpectations(resultNode.result)) {
specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription;
}
specListNode.appendChild(
createDom("li", {
createDom('li', {
className: resultNode.result.status,
id: "spec-" + resultNode.result.id
id: 'spec-' + resultNode.result.id
},
createDom("a", {href: specHref(resultNode.result)}, resultNode.result.description)
createDom('a', {href: specHref(resultNode.result)}, specDescription)
)
);
}
@@ -199,24 +220,24 @@ jasmineRequire.HtmlReporter = function(j$) {
if (failures.length) {
alert.appendChild(
createDom('span', {className: "menu bar spec-list"},
createDom("span", {}, "Spec List | "),
createDom('a', {className: "failures-menu", href: "#"}, "Failures")));
createDom('span', {className: 'menu bar spec-list'},
createDom('span', {}, 'Spec List | '),
createDom('a', {className: 'failures-menu', href: '#'}, 'Failures')));
alert.appendChild(
createDom('span', {className: "menu bar failure-list"},
createDom('a', {className: "spec-list-menu", href: "#"}, "Spec List"),
createDom("span", {}, " | Failures ")));
createDom('span', {className: 'menu bar failure-list'},
createDom('a', {className: 'spec-list-menu', href: '#'}, 'Spec List'),
createDom('span', {}, ' | Failures ')));
find(".failures-menu").onclick = function() {
find('.failures-menu').onclick = function() {
setMenuModeTo('failure-list');
};
find(".spec-list-menu").onclick = function() {
find('.spec-list-menu').onclick = function() {
setMenuModeTo('spec-list');
};
setMenuModeTo('failure-list');
var failureNode = find(".failures");
var failureNode = find('.failures');
for (var i = 0; i < failures.length; i++) {
failureNode.appendChild(failures[i]);
}
@@ -226,7 +247,16 @@ jasmineRequire.HtmlReporter = function(j$) {
return this;
function find(selector) {
return getContainer().querySelector(selector);
return getContainer().querySelector('.jasmine_html-reporter ' + selector);
}
function clearPrior() {
// return the reporter
var oldReporter = find('');
if(oldReporter) {
getContainer().removeChild(oldReporter);
}
}
function createDom(type, attrs, childrenVarArgs) {
@@ -245,7 +275,7 @@ jasmineRequire.HtmlReporter = function(j$) {
}
for (var attr in attrs) {
if (attr == "className") {
if (attr == 'className') {
el[attr] = attrs[attr];
} else {
el.setAttribute(attr, attrs[attr]);
@@ -256,17 +286,22 @@ jasmineRequire.HtmlReporter = function(j$) {
}
function pluralize(singular, count) {
var word = (count == 1 ? singular : singular + "s");
var word = (count == 1 ? singular : singular + 's');
return "" + count + " " + word;
return '' + count + ' ' + word;
}
function specHref(result) {
return "?spec=" + encodeURIComponent(result.fullName);
return '?spec=' + encodeURIComponent(result.fullName);
}
function setMenuModeTo(mode) {
htmlReporterMain.setAttribute("class", "html-reporter " + mode);
htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode);
}
function noExpectations(result) {
return (result.failedExpectations.length + result.passedExpectations.length) === 0 &&
result.status === 'passed';
}
}
@@ -275,7 +310,7 @@ jasmineRequire.HtmlReporter = function(j$) {
jasmineRequire.HtmlSpecFilter = function() {
function HtmlSpecFilter(options) {
var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
var filterPattern = new RegExp(filterString);
this.matches = function(specName) {
@@ -305,6 +340,7 @@ jasmineRequire.ResultsNode = function() {
return ResultsNode;
};
jasmineRequire.QueryString = function() {
function QueryString(options) {
@@ -323,9 +359,9 @@ jasmineRequire.QueryString = function() {
function toQueryString(paramMap) {
var qStrPairs = [];
for (var prop in paramMap) {
qStrPairs.push(encodeURIComponent(prop) + "=" + encodeURIComponent(paramMap[prop]));
qStrPairs.push(encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop]));
}
return "?" + qStrPairs.join('&');
return '?' + qStrPairs.join('&');
}
function queryStringToParamMap() {
@@ -338,7 +374,7 @@ jasmineRequire.QueryString = function() {
for (var i = 0; i < params.length; i++) {
var p = params[i].split('=');
var value = decodeURIComponent(p[1]);
if (value === "true" || value === "false") {
if (value === 'true' || value === 'false') {
value = JSON.parse(value);
}
paramMap[decodeURIComponent(p[0])] = value;

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,93 @@
/*
Copyright (c) 2008-2014 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
module.exports = function(jasmineRequire) {
var jasmine = jasmineRequire.core(jasmineRequire);
var consoleFns = require('../console/console.js');
consoleFns.console(consoleFns, 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()
}),
jasmine: jasmine
};
extend(global, jasmineInterface);
jasmine.addCustomEqualityTester = function(tester) {
env.addCustomEqualityTester(tester);
};
jasmine.addMatchers = function(matchers) {
return env.addMatchers(matchers);
};
jasmine.clock = function() {
return env.clock;
};
function extend(destination, source) {
for (var property in source) destination[property] = source[property];
return destination;
}
return jasmine;
};

View File

@@ -4,6 +4,6 @@
#
module Jasmine
module Core
VERSION = "2.0.0.rc2"
VERSION = "2.0.1"
end
end

View File

@@ -1,13 +1,23 @@
{
"name": "jasmine-core",
"license": "MIT",
"version": "2.0.0-rc2",
"version": "2.0.1",
"repository": {
"type": "git",
"url": "https://github.com/pivotal/jasmine.git"
},
"description": "Official packaging of Jasmine's core files for use by Node.js projects.",
"homepage": "http://jasmine.github.io",
"main": "./lib/jasmine-core.js",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.2.0",
"grunt-contrib-concat": "~0.1.3",
"grunt-contrib-compass": "~0.1.3",
"grunt-contrib-compress": "~0.4.1",
"shelljs": "~0.1.2"
"grunt-contrib-jshint": "~0.7.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-compass": "~0.6.0",
"grunt-contrib-compress": "~0.5.2",
"shelljs": "~0.1.4",
"glob": "~3.2.9",
"jasmine": "https://github.com/pivotal/jasmine-npm/archive/master.tar.gz",
"load-grunt-tasks": "^0.4.0"
}
}

70
release_notes/2.0.1.md Normal file
View File

@@ -0,0 +1,70 @@
# Jasmine Core 2.0.1 Release Notes
## Summary
This release is for small bug fixes and enhancements ahead of a real-soon-now 2.1.
## Changes
### Features
* NodeJS is now supported with a jasmine-core npm
* [Support browsers that don't supply a `Date.now()` by having a `mockDate` object](http://www.pivotaltracker.com/story/66606132) - Closes #361
* [Show message if no specs where loaded](http://www.pivotaltracker.com/story/12784235)
* When using `jasmine.any`, the `class` will now be included in the error message
* Reporters now receive the number of passed expectations in a spec
* Use default failure message for `toBeNaN`
* Use the latest `jasmine_selenium_runner` so we use the fix for printing objects with cycles
* Add jasmine logo image to HTML runner
* Stop Jasmine's CSS affecting the style of the body tag - Closes #600
* Standardized location of the standalone distributions - they now live in the repo in `/dist` as well as on the Releases page
### Bugs
* Don't allow calling the same done callback multiple times - Fixes #523
* [Remove 'empty' as an option as a spec result](http://www.pivotaltracker.com/story/73741032) as this was a breaking change
* Instead, we determine if a spec has no expectations using the added
key of `passedExpectations` in combination of the `failedExpectations`
to determine that there a spec is 'empty'
* Fix build in IE8 (IE8 doesn't support `Object.freeze`)
* Fix `ObjectContaining` to match recursively
### Documentation
* Update release doc to use GitHub releases
* Add installation instructions to README - Merges #621
* Add Ruby Gem and Python Egg to docs
* Add detailed steps on how to contribute - Merges #580 from @pablofiu
## Pull Requests and Issues
* Contains is explicitly false if actual is `undefined` or `null` - Fixes #627
* namespace `html-reporter` -> `jasmine_html-reporter` - Fixes #600
* Throw a more specific error when `expect` is used without a `currentSpec` - Fixes #602
* Reduced size of logo with PNG Gauntlet - Merges #588
* HTML Reporter resets previous DOM when re-initialized - Merges #594 from @plukevdh
* Narrow down raise exceptions query selector; Finding by any input tag is a little bit broad - Closes #605
* Pass through custom equality testers in toHaveBeenCalledWith - Fixes #536
* Fix outdated copyright year (update to 2014) - Merges #550 from @slothmonster
* [Add package.json to Python egg to get correct version number](http://www.pivotaltracker.com/story/67556148) - Fixes #551
* Allow users to set the maximum length of array that the pretty-printer
will print out - Fixes #323 @mikemoraned and #374 @futuraprime
* `matchersUtil.equals()`` does not expect a matcher as its first argument,
so send the "actual" value first and the "expected" value second. - Merges #538 from @cbandy
* Add single quote check to `jshint` and fix src files for that - Closes #522
* Remove an `eval` in order to support running jasmine within CSP - Closes #503
* Allow matcher custom failure messages to be a function - Closes #520
* More color blind friendly CSS from @dleppik - Closes #463 &amp; #509
* Use `load-grunt-tasks` Merges #521 from @robinboehm
* Special case printing `-0` - Closes #496
* Allow stub or spy Date object safely using a closure to get a clean copy - Closes #506
* [Use `\d7` instead of plain 'x' for more square appearance](http://www.pivotaltracker.com/story/48434179)
* Better support in pretty printer when an object has null prototype - Fixes #500
* Update link at top of README to improve access to Jasmine 2.0 docs - Merges #486 from @nextmat
* Force query selector to seek within the html-reporter element - Merges #479 from @shprink
* Netbeans files are in gitignore - Merges #478 from @shprink
------
_Release Notes generated with [Anchorman](http://github.com/infews/anchorman)_

179
release_notes/20.md Normal file
View File

@@ -0,0 +1,179 @@
# Jasmine Core 2.0 Release Notes
## Summary
These notes are for Jasmine Core 2.0.
## Breaking Changes
The [`introduction.js`][intro] page covers the current syntax, highlighting the changes. Here are the known interface changes that are not backwards compatible with 1.x.
* New syntax for asynchronous specs
* New syntax for spies
* New interface for reporters
* Better Equality testing
* Replaced custom matchers for ease of use
* Change to `toThrow` matcher
* Clock now remains installed when a spec finishes
* More Jasmine internal variables/functions have been moved into closures
### New syntax for asynchronous specs
Similar to [Mocha][mocha], Jasmine `before`s, `spec`s, and `after`s can take an optional `done` callback in order to force asynchronous tests. The next function, whether it's a `before`, `spec` or `after`, will wait until this function is called or until a timeout is reached.
### New syntax for spies
Spies have a slightly modified syntax. The idea came from a desire to preserve any of the properties on a spied-upon function and some better testing patterns.
### New interface for reporters
The reporter interface has been **replaced**. The callbacks are different and more consistent. The objects passed in should only provide what is needed to report results. This enforces an interface to result data so custom reporters will be less coupled to the Jasmine implementation. The Jasmine reporter API now includes a slot for a `timer` object.
### Better Equality testing
We removed the previous equality code and are now using new code for testing equality. We started with [Underscore.js][underscore]'s `isEqual`, refactored a bit and added some additional tests.
### Replaced custom matchers for ease of use
The interface for adding custom matchers has been **replaced**. It has always been possible to add custom matchers, but the API was barely documented and difficult to test. We've changed how matchers are added and tested. Jasmine adds its own matchers by the same mechanism that custom matchers use. Dogfooding FTW.
### Change to `toThrow` matcher
We've changed the behavior of the `toThrow` matcher, moving some functionality to the `toThrowError` matcher. This should allow more of the requested use cases.
### Clock now remains installed when a spec finishes
After installing the Jasmine Clock, it will stay installed until `uninstall` is called -- clearing up any ambiguity for when those timing functions will revert to using the global clock object.
## More Jasmine internal variables/functions have been moved into closures
Certain variables/functions like a function to get the next spec id have been moved into closures, making the Jasmine interface cleaner.
## Other Changes
* Massive refactoring and better testing
* Environment setup now in `boot.js`
* Development and Build moved to Grunt
* Changes to how Jasmine is loaded
* Changes to how Jasmine is tested
* Better node.js support
* Better Continuous Integration Environment at Travis
* Support matrix updated
* Removed JsDoc Pages
* Adding Code Climate for JavaScript
## Massive refactoring and better testing
This is the biggest set of changes. We've touched nearly every file and every object. We've merged objects together and factored out code. We styled the code more consistently. We've improved nearly every test.
In general, Jasmine is made of smaller, more-loosely-coupled objects, unit-tested with explicit dependencies injected. This made tests easier to read, write, and maintain. We know this has made Jasmine development easier for the core team. We expect (and hope) this makes it easier for the community to extend Jasmine and provide pull requests that make more sense the first time out.
## Environment setup now in `boot.js`
Instantiation and setup of the Jasmine environment, including building reporters, exposing the "global" functions, and executing tests has moved into its own file: `boot.js`. This should make it easier to add custom reporters, configure some objects, or just in general change how you use Jasmine from the outside.
For example, during development, Jasmine uses its own `devboot.js` to load itself twice - once from `jasmine.js` and once from the source directories.
## Development and Build moved to Grunt
We've moved away from Ruby and embraced [Node.js][node] and [Grunt.js][grunt] for the various command line tasks during development. Yes, it's a just a different set of dependencies. But it's less code for the team to maintain - it turns out that JavaScript tools are pretty good at building JavaScript projects. This will make it easier for the community to make sure contributions work in browsers and in Node.js before submitting Pull Requests. There is more detail in the [Contributor's Guide][contrib].
## Changes to how Jasmine is loaded
We did not want to add new run-time dependencies, yet we needed to be cleaner when loading Jasmine. So we wrote a custom "require" scheme that works in Node.js and in browsers. This only affects pull requests which add files - please be careful in these cases. Again, the [Contributor's Guide][contrib] should help.
## Changes to how Jasmine is tested with Jasmine
Writing a custom require system helped enforce self-testing - the built `jasmine.js` testing Jasmine from the source directories. Overall this has improved the stability of the code. When you look at Jasmine's tests, you'll see both `jasmine` and `j$` used. The former, `jasmine`, will always be used to test the code from source, which is loaded into the reference `j$`. Please adhere to this pattern when writing tests for contributions.
## Better node.js support
`Node.js` is now officially a first-class citizen. For a long time we've made sure tests were green in Node before releasing. But it is now officially part of Jasmine's CI build at [Travis][travis]. For the curious, the [`node_suite.js`][node_suite], is essentially a `boot.js` for Node. An official `npm` is coming.
## Better Continuous Integration Environment at Travis
The [CI build at Travis][travis_jasmine] now runs the core specs in a build matrix across browsers. It's far from complete on the operating system matrix, but you will see that Jasmine runs against: Firefox, Chrome, Safari 5, Safari 6, [Phantom.js][phantom], [Node.js][node], and IE versions 8, 9, and 10. Big thanks to [SauceLabs][sauce] for their support of open source projects. We will happily take pull requests for additional OS/Browser combos within the matrix.
## Support Matrix Updated
We're dropping support for IE < 8. [Jasmine 1.x][jasmine_downloads] remains for projects that need to support older browsers.
## Removed JsDoc Pages
Comments in code are lies waiting to happen. Jasmine's JsDoc comments were no exception. The comments were out of date, the generated pages were even more out of date, and frankly they were not helpful. So they're gone.
Last year saw the posting of the [`introduction.js`][intro] page to document the real, practical interface for projects to use. This page has received a lot of positive feedback so expect more pages like this one.
## Adding Code Climate for JavaScript
We are running Code Climate for Jasmine. We have some work to do here but it's helping us easily find code hotspots.
## Pull Requests and Issues
The following Pull Requests were merged:
* ObjectContaining wrong filed value error message #[394](https://github.com/pivotal/jasmine/issues/394) from albertandrejev
* Removed unnecessary parameter from `suiteFactory()` call #[397](https://github.com/pivotal/jasmine/issues/397) from valera-rozuvan
* `jasmine.Any` supports `Boolean` #[392](https://github.com/pivotal/jasmine/issues/392) from albertandrejev
* Reporters get execution time #[30](https://github.com/pivotal/jasmine/issues/30)
* `toThrow` matchers handle falsy exceptions #[317](https://github.com/pivotal/jasmine/issues/371)
* Removed deprecated `jasmine.Matchers.pp` #[363](https://github.com/pivotal/jasmine/issues/363) from robinboehm
* Fix for Clock ticking to default to 0 #[340](https://github.com/pivotal/jasmine/issues/340) from Caio Cunha
* Whitespace failures should be easier to understand #[332](https://github.com/pivotal/jasmine/issues/332) from bjornblomqvist
* Fix for more markdown-y image for Build status #[329](https://github.com/pivotal/jasmine/issues/329) from sunliwen
* UTF-8 encoding fixes #[333](https://github.com/pivotal/jasmine/issues/333) from bjornblomqvist
* Replaced deprecated octal literal with hexadecimal from kris7t
* Make getGlobal() work in strict mode from metaweta
* Clears timeout timer even when async spec throws an exception from tidoust
* Timeouts scheduled within a delayed function are correctly scheduled and executed from maciej-filip-sz
### Bug Fixes
* Improved the performance of the HTML output with a CSS change #[428](https://github.com/pivotal/jasmine/issues/428) - Thanks @tjgrathwell
* Removed an accidental global pollution of `j$` as a reference to Jasmine. Thanks to Morten Maxild from the mailing list
* There is now a consistent `this` between `beforeEach`, `it` and `afterEach` for a spec
* A spy's strategy now has properties `returnValue` and `throwError` because they are better names
* Make it easy to copy the title of failing specs from the HTML output
* Don't add periods to the full name of a spec fix #[427](https://github.com/pivotal/jasmine/issues/427)
* Allow Env to take optional spec/suite ids when asked to `execute`
* [Mock clock now less intrusive, replacing global timer functions only when clock is installed](http://www.pivotaltracker.com/story/54168708)
* Restore custom failure messages for `toHaveBeenCalledWith`
* Jasmine global object has a addCustomEqualityTester and addMatchers (no longer directly on global)
* Fixed a global leak of `timer`
* Remove currentRunner from Env (users can use topSuite from Env instead)
* [Specs without expectations are now considered passing](http://www.pivotaltracker.com/story/59422744)
* Improve error message when a spec does not call the async callback within the default time interval
* Allow passing a negativeCompare in a custom matcher for more custom implementations when `.not` is called
* Update favicon to be higher resolution
* Make all async functions be subject to the timeout
There were several other pull requests that either had already been fixed, or were good starting points for the various changes above. Thank you for all of the hard work to keep Jasmine awesome.
## Other Bugs and Features
There were a few small changes and fixes that didn't fit into any of the above categories:
* HTML Reporter refactored for simplicity and performance
* Default character encoding on the HTML runner page is UTF-8
* [Escape special regex characters from the spec param](http://www.pivotaltracker.com/story/52731407)
* Favicon returns
* [Clock supports `eval`'d strings as functions](http://www.pivotaltracker.com/story/40853563)
* There should always be stack traces on failures
* Removed references to unused `jasmine.VERBOSE`
* Removed references to unused `jasmine.XmlHttpRequest`
[mocha]: http://visionmedia.github.io/mocha/
[underscore]: http://underscorejs.org/
[grunt]: http://gruntjs.com
[node]: http://nodejs.org
[phantom]: http://phantomjs.org
[jasmine_downloads]: https://github.com/pivotal/jasmine/downloads
[contrib]: https://github.com/pivotal/jasmine/blob/master/CONTRIBUTING.md
[travis]: http://travis-ci.org
[travis_jasmine]: http://travis-ci.org/jasmine
[sauce]: http://saucelabs.com
[node_suite]: https://github.com/pivotal/jasmine/blob/master/spec/node_suite.js
[intro]: http://jasmine.github.io/2.0/introduction.html
------
_Release Notes generated with [Anchorman](http://github.com/infews/anchorman)_

View File

@@ -1,138 +0,0 @@
# Jasmine Core 2.0 Release Notes
## Summary
These notes are for RC1 of Jasmine Core 2.0.
## Breaking Changes
These changes have breaking interface changes and are not backwards compatible with 1.x.
* New syntax for asynchronous specs
* New syntax for spies
* New interface for reporters
* Better Equality testing
* Easier custom matchers
* Change to `toThrow` matcher
### New syntax for asynchronous specs
Similar to [Mocha][mocha], Jasmine befores, specs, and afters can take an optional "done" callback in order to force asynchronous tests. The next function, whether it's a before, spec or after, will wait until this function is called or if a timeout is reached.
### New syntax for spies
Spies have a slightly modified syntax. The ideas came from a desire to preserve any of the properties on a spied-upon function and some better testing patterns.
### New interface for reporters
The reporter interface has changed. The callbacks are different and more consistent. The objects passed in should only provide what is needed to report results. This enforces an interface to result data so custom reporters will be less coupled to Jasmine implementation. The full suite execution time is also reported.
### Better Equality testing
We have tossed the previous equality code and are now using new code for testing equality. We started with [Underscore.js][underscore]'s `isEqual`, refactored a bit and added some additional tests.
### Easier custom matchers
Custom matchers have always been possible, but this was barely documented and clunky to test. We've changed how matchers are added and tested. Jasmine adds its own matchers by the same mechanism that as custom matchers use. Dogfooding FTW.
### Change to `toThrow` matcher
We've changed the behavior of the `toThrow` matcher, moving some functionality to the `toThrowError` matcher. This should allow more of the requested use cases.
## Other Changes
* Massive refactoring and better testing
* Environment setup now in `boot.js`
* Development & Build moved to Grunt
* Change in how Jasmine is loaded
* Change in how Jasmine is tested
* Better node.js support
* Better Continuous Integration Environment at Travis
* Support matrix updated
* Removed JsDoc Pages
## Massive refactoring and better testing
This is the biggest set of changes. We've touched nearly every file and every object. We've slammed objects back together and pulled out new extractions. We've made the code more consistently styled. We've improved the tests nearly everywhere.
In general, Jasmine is made of smaller, more-loosely-coupled objects, unit-tested with explicit dependencies injected. This made tests easier to write, read, and maintain. We know this has made Jasmine development easier for the core team. We expect (and hope) this makes it easier for the community to extend Jasmine and provide pull requests that make more sense the first time out.
## Environment setup now in `boot.js`
Instantiation and setup of the Jasmine environment, including building reporters, exposing the "global" functions, and executing tests has moved into its own file: `boot.js`. This should make it easier to add custom reporters, configure some objects, or just in general change how you use Jasmine from the outside.
For example, during development, Jasmine uses it's own `devboot.js` to load itself twice - once from `jasmine.js` and once from the source directories.
## Development & Build moved to Grunt
We've moved away from Ruby and embraced Node.js and [Grunt.js][grunt] for the various command line tasks during development. Yes, it's a just a different set of dependencies. But it's less code for the team to maintain - it turns out that JavaScript tools are pretty good at building JavaScript projects. This will make it easier for the community to make sure contributions work in browser and in Node.js before submitting Pull Requests. There is more detail in the [Contributor's Guide][contrib].
## Change in how Jasmine is loaded
We did not want to add new run-time dependencies, yet we needed to be cleaner when loading Jasmine. So we wrote a custom "require" scheme that works in Node.js and in browsers. This only affects pull requests that add files - please be careful in these cases. Again, the [Contributor's Guide][contrib] should help.
## Change in how Jasmine is tested with Jasmine
Writing a custom require system helped enforce self-testing - the built `jasmine.js` testing Jasmine from the source directories. Overall this has improved the stability of the code. When you look at Jasmine's tests, you'll see both `jasmine` and `j$` used. The former, `jasmine`, will always be used to test the code from source, which is loaded into the reference `j$`. Please adhere to this pattern when writing tests for contributions.
## Better node.js support
Node.js is now officially a first-class citizen. For a long time we've made sure tests were green in Node before releasing. But it is now officially part of Jasmine's CI build at [Travis][travis]. For the curious, the [`node_suite.js`][node_suite], is essentially a `boot.js` for Node. An official npm is coming.
## Better Continuous Integration Environment at Travis
The [CI build at Travis][travis_jasmine] now runs the core specs in a build matrix across browsers. It's far from complete on the operating system matrix, but you will see that Jasmine runs against: Firefox, Chrome, Safari 5, Safari 6, Phantom.js, Node.js, and IE versions 8, 9, and 10. Big thanks to [SauceLabs][sauce] for their support of open source projects. We will happily take pull requests for additional OS/Browser combos within the matrix.
## Support Matrix Updated
We're dropping support for IE < 8. Jasmine 1.x remains for projects supporting earlier versions of browsers.
## Removed JsDoc Pages
Comments in code are lies waiting to happen. Jasmine's JsDoc comments were no exception. The comments were out of date, the generated pages were even more out of date, and frankly they were not helpful. So they're gone.
Last year saw the posting of the [`introduction.js`][intro] page to document the real, practical interface for projects to use. This page has received a lot of positive feedback so expect more pages like this one.
## Pull Requests & Issues
The following Pull Requests were merged:
* ObjectContaining wrong filed value error message #[394](https://github.com/pivotal/jasmine/issues/394) from albertandrejev
* Removed unnecessary parameter from `suiteFactory()` call #[397](https://github.com/pivotal/jasmine/issues/397) from valera-rozuvan
* `jasmine.Any` supports `Boolean` #[392](https://github.com/pivotal/jasmine/issues/392) from albertandrejev
* Reporters get execution time #[30](https://github.com/pivotal/jasmine/issues/30)
* `toThrow` matchers handle falsy exceptions #[317](https://github.com/pivotal/jasmine/issues/371)
* Removed deprecated `jasmine.Matchers.pp` #[363](https://github.com/pivotal/jasmine/issues/363) from robinboehm
* Fix for Clock ticking to default to 0 #[340](https://github.com/pivotal/jasmine/issues/340) from Caio Cunha
* Whitespace failures should be easier to understand #[332](https://github.com/pivotal/jasmine/issues/332) from bjornblomqvist
* Fix for more markdown-y image for Build status #[329](https://github.com/pivotal/jasmine/issues/329) from sunliwen
* UTF-8 encoding fixes #[333](https://github.com/pivotal/jasmine/issues/333) from bjornblomqvist
There were several other pull requests that either had already been fixed, or were good starting points for the various changes above. Thank you for all of the hard work to keep Jasmine awesome.
## Other Bugs & Features
There were a few small changes and fixes that didn't fit into any of the above categories:
* HTML Reporter refactored for simplicity and performance
* Default character encoding on the HTML runner page is UTF-8
* [Escape special regex characters from the spec param](http://www.pivotaltracker.com/story/52731407)
* Favicon returns
* [Clock supports `eval`'d strings as functions](http://www.pivotaltracker.com/story/40853563)
* There should always be stack traces on failures
* Removed references to unused `jasmine.VERBOSE`
* Removed references to unused `jasmine.XmlHttpRequest`
------
_Release Notes generated with [Anchorman](http://github.com/infews/anchorman)_
[mocha]: http://visionmedia.github.io/mocha/
[underscore]: http://underscorejs.org/
[grunt]: http://gruntjs.com
[contrib]: https://github.com/pivotal/jasmine/blob/master/Contribute.markdown
[travis]: http://travis-ci.org
[travis_jasmine]: http://travis-ci.org/jasmine
[sauce]: http://saucelabs.com
[node_suite]: https://github.com/pivotal/jasmine/blob/master/spec/node_suite.js
[intro]: http://pivotal.github.com/jasmine/

1
requirements.txt Normal file
View File

@@ -0,0 +1 @@
ordereddict==1.1

47
setup.py Normal file
View File

@@ -0,0 +1,47 @@
from setuptools import setup, find_packages, os
import json
with open('package.json') as packageFile:
version = json.load(packageFile)['version']
setup(
name="jasmine-core",
version=version,
url="http://pivotal.github.io/jasmine/",
author="Pivotal Labs",
author_email="jasmine-js@googlegroups.com",
description=('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.'),
license='MIT',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Software Development :: Build Tools',
'Topic :: Software Development :: Quality Assurance',
'Topic :: Software Development :: Testing',
],
packages=['jasmine_core', 'jasmine_core.images'],
package_dir={'jasmine_core': 'lib/jasmine-core', 'jasmine_core.images': 'images'},
package_data={'jasmine_core': ['*.js', '*.css'], 'jasmine_core.images': ['*.png']},
include_package_data=True,
install_requires=['glob2>=0.4.1', 'ordereddict==1.1']
)

View File

@@ -80,7 +80,19 @@ describe("ConsoleReporter", function() {
expect(out.getOutput()).toEqual("*");
});
it("reports a summary when done (singluar spec and time)", function() {
it("alerts user if there are no specs", function(){
var reporter = new j$.ConsoleReporter({
print: out.print
});
reporter.jasmineStarted();
out.clear();
reporter.jasmineDone();
expect(out.getOutput()).toMatch(/No specs found/);
});
it("reports a summary when done (singular spec and time)", function() {
var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
reporter = new j$.ConsoleReporter({
print: out.print,
@@ -90,7 +102,7 @@ describe("ConsoleReporter", function() {
reporter.jasmineStarted();
reporter.specDone({status: "passed"});
timerSpy.elapsed.and.callReturn(1000);
timerSpy.elapsed.and.returnValue(1000);
out.clear();
reporter.jasmineDone();
@@ -127,7 +139,7 @@ describe("ConsoleReporter", function() {
out.clear();
timerSpy.elapsed.and.callReturn(100);
timerSpy.elapsed.and.returnValue(100);
reporter.jasmineDone();
@@ -198,7 +210,7 @@ describe("ConsoleReporter", function() {
reporter.specDone({status: "passed"});
expect(out.getOutput()).toEqual("\033[32m.\033[0m");
expect(out.getOutput()).toEqual("\x1B[32m.\x1B[0m");
});
it("does not report a disabled spec", function() {
@@ -220,7 +232,7 @@ describe("ConsoleReporter", function() {
reporter.specDone({status: 'failed'});
expect(out.getOutput()).toEqual("\033[31mF\033[0m");
expect(out.getOutput()).toEqual("\x1B[31mF\x1B[0m");
});
});
});

View File

@@ -40,6 +40,7 @@ describe("Any", function() {
var any = new j$.Any(Number);
expect(any.jasmineToString()).toMatch('<jasmine.any');
expect(any.jasmineToString()).toMatch('Number');
});
});
});

View File

@@ -1,41 +1,148 @@
describe("Clock", function() {
it("calls the global setTimeout directly if Clock is not installed", function() {
var setTimeout = jasmine.createSpy('setTimeout'),
delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['scheduleFunction']),
global = { setTimeout: setTimeout },
delayedFn = jasmine.createSpy('delayedFn'),
clock = new j$.Clock(global, delayedFunctionScheduler);
it("does not replace setTimeout until it is installed", function() {
var fakeSetTimeout = jasmine.createSpy("global setTimeout"),
fakeGlobal = { setTimeout: fakeSetTimeout },
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction"]),
delayedFn = jasmine.createSpy("delayedFn"),
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
clock.setTimeout(delayedFn, 0);
fakeGlobal.setTimeout(delayedFn, 0);
expect(fakeSetTimeout).toHaveBeenCalledWith(delayedFn, 0);
expect(delayedFunctionScheduler.scheduleFunction).not.toHaveBeenCalled();
expect(setTimeout).toHaveBeenCalledWith(delayedFn, 0);
fakeSetTimeout.calls.reset();
clock.install();
fakeGlobal.setTimeout(delayedFn, 0);
expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalled();
expect(fakeSetTimeout).not.toHaveBeenCalled();
});
it("schedules the delayed function with the fake timer", function() {
var setTimeout = jasmine.createSpy('setTimeout'),
it("does not replace clearTimeout until it is installed", function() {
var fakeClearTimeout = jasmine.createSpy("global cleartimeout"),
fakeGlobal = { clearTimeout: fakeClearTimeout },
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["removeFunctionWithId"]),
delayedFn = jasmine.createSpy("delayedFn"),
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
fakeGlobal.clearTimeout("foo");
expect(fakeClearTimeout).toHaveBeenCalledWith("foo");
expect(delayedFunctionScheduler.removeFunctionWithId).not.toHaveBeenCalled();
fakeClearTimeout.calls.reset();
clock.install();
fakeGlobal.clearTimeout("foo");
expect(delayedFunctionScheduler.removeFunctionWithId).toHaveBeenCalled();
expect(fakeClearTimeout).not.toHaveBeenCalled();
});
it("does not replace setInterval until it is installed", function() {
var fakeSetInterval = jasmine.createSpy("global setInterval"),
fakeGlobal = { setInterval: fakeSetInterval },
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction"]),
delayedFn = jasmine.createSpy("delayedFn"),
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
fakeGlobal.setInterval(delayedFn, 0);
expect(fakeSetInterval).toHaveBeenCalledWith(delayedFn, 0);
expect(delayedFunctionScheduler.scheduleFunction).not.toHaveBeenCalled();
fakeSetInterval.calls.reset();
clock.install();
fakeGlobal.setInterval(delayedFn, 0);
expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalled();
expect(fakeSetInterval).not.toHaveBeenCalled();
});
it("does not replace clearInterval until it is installed", function() {
var fakeClearInterval = jasmine.createSpy("global clearinterval"),
fakeGlobal = { clearInterval: fakeClearInterval },
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["removeFunctionWithId"]),
delayedFn = jasmine.createSpy("delayedFn"),
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
fakeGlobal.clearInterval("foo");
expect(fakeClearInterval).toHaveBeenCalledWith("foo");
expect(delayedFunctionScheduler.removeFunctionWithId).not.toHaveBeenCalled();
fakeClearInterval.calls.reset();
clock.install();
fakeGlobal.clearInterval("foo");
expect(delayedFunctionScheduler.removeFunctionWithId).toHaveBeenCalled();
expect(fakeClearInterval).not.toHaveBeenCalled();
});
it("replaces the global timer functions on uninstall", function() {
var fakeSetTimeout = jasmine.createSpy("global setTimeout"),
fakeClearTimeout = jasmine.createSpy("global clearTimeout"),
fakeSetInterval = jasmine.createSpy("global setInterval"),
fakeClearInterval = jasmine.createSpy("global clearInterval"),
fakeGlobal = {
setTimeout: fakeSetTimeout,
clearTimeout: fakeClearTimeout,
setInterval: fakeSetInterval,
clearInterval: fakeClearInterval
},
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction", "reset"]),
delayedFn = jasmine.createSpy("delayedFn"),
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
clock.install();
clock.uninstall();
fakeGlobal.setTimeout(delayedFn, 0);
fakeGlobal.clearTimeout("foo");
fakeGlobal.setInterval(delayedFn, 10);
fakeGlobal.clearInterval("bar");
expect(fakeSetTimeout).toHaveBeenCalledWith(delayedFn, 0);
expect(fakeClearTimeout).toHaveBeenCalledWith("foo");
expect(fakeSetInterval).toHaveBeenCalledWith(delayedFn, 10);
expect(fakeClearInterval).toHaveBeenCalledWith("bar");
expect(delayedFunctionScheduler.scheduleFunction).not.toHaveBeenCalled();
});
it("schedules the delayed function (via setTimeout) with the fake timer", function() {
var fakeSetTimeout = jasmine.createSpy('setTimeout'),
scheduleFunction = jasmine.createSpy('scheduleFunction'),
delayedFunctionScheduler = {scheduleFunction: scheduleFunction},
global = { setTimeout: setTimeout },
delayedFunctionScheduler = { scheduleFunction: scheduleFunction },
fakeGlobal = { setTimeout: fakeSetTimeout },
delayedFn = jasmine.createSpy('delayedFn'),
clock = new j$.Clock(global, delayedFunctionScheduler);
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
clock.install();
clock.setTimeout(delayedFn, 0, 'a', 'b');
expect(setTimeout).not.toHaveBeenCalled();
expect(fakeSetTimeout).not.toHaveBeenCalled();
expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalledWith(delayedFn, 0, ['a', 'b']);
});
it("returns an id for the delayed function", function() {
var setTimeout = jasmine.createSpy('setTimeout'),
var fakeSetTimeout = jasmine.createSpy('setTimeout'),
scheduleId = 123,
scheduleFunction = jasmine.createSpy('scheduleFunction').and.callReturn(scheduleId),
scheduleFunction = jasmine.createSpy('scheduleFunction').and.returnValue(scheduleId),
delayedFunctionScheduler = {scheduleFunction: scheduleFunction},
global = { setTimeout: setTimeout },
fakeGlobal = { setTimeout: fakeSetTimeout },
delayedFn = jasmine.createSpy('delayedFn'),
clock = new j$.Clock(global, delayedFunctionScheduler),
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate),
timeoutId;
clock.install();
@@ -44,67 +151,46 @@ describe("Clock", function() {
expect(timeoutId).toEqual(123);
});
it("calls the global clearTimeout directly if Clock is not installed", function() {
var clearTimeout = jasmine.createSpy('clearTimeout'),
delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['clearTimeout']),
global = { clearTimeout: clearTimeout },
clock = new j$.Clock(global, delayedFunctionScheduler);
clock.clearTimeout(123);
expect(clearTimeout).toHaveBeenCalledWith(123);
});
it("clears the scheduled function with the scheduler", function() {
var clearTimeout = jasmine.createSpy('clearTimeout'),
var fakeClearTimeout = jasmine.createSpy('clearTimeout'),
delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['removeFunctionWithId']),
global = { setTimeout: clearTimeout },
fakeGlobal = { setTimeout: fakeClearTimeout },
delayedFn = jasmine.createSpy('delayedFn'),
clock = new j$.Clock(global, delayedFunctionScheduler);
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
clock.install();
clock.clearTimeout(123);
expect(clearTimeout).not.toHaveBeenCalled();
expect(fakeClearTimeout).not.toHaveBeenCalled();
expect(delayedFunctionScheduler.removeFunctionWithId).toHaveBeenCalledWith(123);
});
it("calls the global setInterval directly if Clock is not installed", function() {
var setInterval = jasmine.createSpy('setInterval'),
delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['scheduleFunction']),
global = { setInterval: setInterval },
delayedFn = jasmine.createSpy('delayedFn'),
clock = new j$.Clock(global, delayedFunctionScheduler);
clock.setInterval(delayedFn, 0);
expect(delayedFunctionScheduler.scheduleFunction).not.toHaveBeenCalled();
expect(setInterval).toHaveBeenCalledWith(delayedFn, 0);
});
it("schedules the delayed function with the fake timer", function() {
var setInterval = jasmine.createSpy('setInterval'),
var fakeSetInterval = jasmine.createSpy('setInterval'),
scheduleFunction = jasmine.createSpy('scheduleFunction'),
delayedFunctionScheduler = {scheduleFunction: scheduleFunction},
global = { setInterval: setInterval },
fakeGlobal = { setInterval: fakeSetInterval },
delayedFn = jasmine.createSpy('delayedFn'),
clock = new j$.Clock(global, delayedFunctionScheduler);
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
clock.install();
clock.setInterval(delayedFn, 0, 'a', 'b');
expect(setInterval).not.toHaveBeenCalled();
expect(fakeSetInterval).not.toHaveBeenCalled();
expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalledWith(delayedFn, 0, ['a', 'b'], true);
});
it("returns an id for the delayed function", function() {
var setInterval = jasmine.createSpy('setInterval'),
var fakeSetInterval = jasmine.createSpy('setInterval'),
scheduleId = 123,
scheduleFunction = jasmine.createSpy('scheduleFunction').and.callReturn(scheduleId),
scheduleFunction = jasmine.createSpy('scheduleFunction').and.returnValue(scheduleId),
delayedFunctionScheduler = {scheduleFunction: scheduleFunction},
global = { setInterval: setInterval },
fakeGlobal = { setInterval: fakeSetInterval },
delayedFn = jasmine.createSpy('delayedFn'),
clock = new j$.Clock(global, delayedFunctionScheduler),
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate),
intervalId;
clock.install();
@@ -113,23 +199,13 @@ describe("Clock", function() {
expect(intervalId).toEqual(123);
});
it("calls the global clearInterval directly if Clock is not installed", function() {
var clearInterval = jasmine.createSpy('clearInterval'),
delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['clearInterval']),
global = { clearInterval: clearInterval },
clock = new j$.Clock(global, delayedFunctionScheduler);
clock.clearInterval(123);
expect(clearInterval).toHaveBeenCalledWith(123);
});
it("clears the scheduled function with the scheduler", function() {
var clearInterval = jasmine.createSpy('clearInterval'),
delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['removeFunctionWithId']),
global = { setInterval: clearInterval },
fakeGlobal = { setInterval: clearInterval },
delayedFn = jasmine.createSpy('delayedFn'),
clock = new j$.Clock(global, delayedFunctionScheduler);
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
clock.install();
clock.clearInterval(123);
@@ -145,53 +221,21 @@ describe("Clock", function() {
}).toThrow();
});
it("can be uninstalled", function() {
var setTimeout = jasmine.createSpy('setTimeout'),
setInterval = jasmine.createSpy('setInterval'),
delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['scheduleFunction', 'tick', 'reset']),
global = { setTimeout: setTimeout, setInterval: setInterval },
delayedFn = jasmine.createSpy('delayedFn'),
clock = new j$.Clock(global, delayedFunctionScheduler);
clock.install();
clock.setTimeout(delayedFn, 0);
expect(setTimeout).not.toHaveBeenCalled();
clock.setInterval(delayedFn, 0);
expect(setInterval).not.toHaveBeenCalled();
expect(function() {
clock.tick(0);
}).not.toThrow();
clock.uninstall();
expect(delayedFunctionScheduler.reset).toHaveBeenCalled();
clock.setTimeout(delayedFn, 0);
expect(setTimeout).toHaveBeenCalled();
clock.setInterval(delayedFn, 0);
expect(setInterval).toHaveBeenCalled();
expect(function() {
clock.tick(0);
}).toThrow();
});
it("on IE < 9, fails if extra args are passed to fake clock", function() {
//fail, because this would break in IE9.
var setTimeout = jasmine.createSpy('setTimeout'),
setInterval = jasmine.createSpy('setInterval'),
delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['scheduleFunction']),
fn = jasmine.createSpy('fn'),
global = { setTimeout: setTimeout, setInterval: setInterval },
clock = new j$.Clock(global, delayedFunctionScheduler);
var fakeSetTimeout = jasmine.createSpy('setTimeout'),
fakeSetInterval = jasmine.createSpy('setInterval'),
delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['scheduleFunction']),
fn = jasmine.createSpy('fn'),
fakeGlobal = {
setTimeout: fakeSetTimeout,
setInterval: fakeSetInterval
},
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
setTimeout.apply = null;
setInterval.apply = null;
fakeSetTimeout.apply = null;
fakeSetInterval.apply = null;
clock.install();
@@ -217,12 +261,13 @@ describe("Clock (acceptance)", function() {
delayedFn3 = jasmine.createSpy('delayedFn3'),
recurring1 = jasmine.createSpy('recurring1'),
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
clock = new j$.Clock({setTimeout: setTimeout}, delayedFunctionScheduler);
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
clock = new j$.Clock({setTimeout: setTimeout}, delayedFunctionScheduler, mockDate);
clock.install();
clock.setTimeout(delayedFn1, 0, 'some', 'arg');
var intervalId = clock.setInterval(recurring1, 50, 'some', 'other', 'args');
clock.setTimeout(delayedFn1, 0);
var intervalId = clock.setInterval(recurring1, 50);
clock.setTimeout(delayedFn2, 100);
clock.setTimeout(delayedFn3, 200);
@@ -232,13 +277,13 @@ describe("Clock (acceptance)", function() {
clock.tick(0);
expect(delayedFn1).toHaveBeenCalledWith('some', 'arg');
expect(delayedFn1).toHaveBeenCalled();
expect(delayedFn2).not.toHaveBeenCalled();
expect(delayedFn3).not.toHaveBeenCalled();
clock.tick(50);
expect(recurring1).toHaveBeenCalledWith('some', 'other', 'args');
expect(recurring1).toHaveBeenCalled();
expect(recurring1.calls.count()).toBe(1);
expect(delayedFn2).not.toHaveBeenCalled();
expect(delayedFn3).not.toHaveBeenCalled();
@@ -263,7 +308,8 @@ describe("Clock (acceptance)", function() {
it("can clear a previously set timeout", function() {
var clearedFn = jasmine.createSpy('clearedFn'),
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler),
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler, mockDate),
timeoutId;
clock.install();
@@ -280,7 +326,8 @@ describe("Clock (acceptance)", function() {
it("correctly schedules functions after the Clock has advanced", function() {
var delayedFn1 = jasmine.createSpy('delayedFn1'),
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
clock = new j$.Clock({setTimeout: function(){}}, delayedFunctionScheduler);
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler, mockDate);
clock.install();
@@ -292,23 +339,107 @@ describe("Clock (acceptance)", function() {
expect(delayedFn1).toHaveBeenCalled();
});
it("calls the global clearTimeout correctly when not installed", function () {
var delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['clearTimeout']),
global = jasmine.getGlobal(),
clock = new j$.Clock(global, delayedFunctionScheduler);
it("correctly schedules functions while the Clock is advancing", function() {
var delayedFn1 = jasmine.createSpy('delayedFn1'),
delayedFn2 = jasmine.createSpy('delayedFn2'),
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler, mockDate);
expect(function() {
clock.clearTimeout(123)
}).not.toThrow();
delayedFn1.and.callFake(function() { clock.setTimeout(delayedFn2, 0); });
clock.install();
clock.setTimeout(delayedFn1, 5);
clock.tick(5);
expect(delayedFn1).toHaveBeenCalled();
expect(delayedFn2).not.toHaveBeenCalled();
clock.tick();
expect(delayedFn2).toHaveBeenCalled();
});
it("calls the global clearTimeout correctly when not installed", function () {
var delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['clearTimeout']),
global = jasmine.getGlobal(),
clock = new j$.Clock(global, delayedFunctionScheduler);
it("correctly calls functions scheduled while the Clock is advancing", function() {
var delayedFn1 = jasmine.createSpy('delayedFn1'),
delayedFn2 = jasmine.createSpy('delayedFn2'),
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler, mockDate);
expect(function() {
clock.clearInterval(123)
}).not.toThrow();
delayedFn1.and.callFake(function() { clock.setTimeout(delayedFn2, 1); });
clock.install();
clock.setTimeout(delayedFn1, 5);
clock.tick(6);
expect(delayedFn1).toHaveBeenCalled();
expect(delayedFn2).toHaveBeenCalled();
});
it("does not mock the Date object by default", function() {
var delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
global = {Date: Date},
mockDate = new j$.MockDate(global),
clock = new j$.Clock({setTimeout: setTimeout}, delayedFunctionScheduler, mockDate);
clock.install();
expect(global.Date).toEqual(Date);
var now = new global.Date().getTime();
clock.tick(50);
expect(new global.Date().getTime() - now).not.toEqual(50);
});
it("mocks the Date object and sets it to current time", function() {
var delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
global = {Date: Date},
mockDate = new j$.MockDate(global),
clock = new j$.Clock({setTimeout: setTimeout}, delayedFunctionScheduler, mockDate);
clock.install().mockDate();
var now = new global.Date().getTime();
clock.tick(50);
expect(new global.Date().getTime() - now).toEqual(50);
var timeoutDate = 0;
clock.setTimeout(function() {
timeoutDate = new global.Date().getTime();
}, 100);
clock.tick(100);
expect(timeoutDate - now).toEqual(150);
});
it("mocks the Date object and sets it to a given time", function() {
var delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
global = {Date: Date},
mockDate = new j$.MockDate(global),
clock = new j$.Clock({setTimeout: setTimeout}, delayedFunctionScheduler, mockDate),
baseTime = new Date(2013, 9, 23);
clock.install().mockDate(baseTime);
var now = new global.Date().getTime();
expect(now).toEqual(baseTime.getTime());
clock.tick(50);
expect(new global.Date().getTime()).toEqual(baseTime.getTime() + 50);
var timeoutDate = 0;
clock.setTimeout(function() {
timeoutDate = new global.Date().getTime();
}, 100);
clock.tick(100);
expect(timeoutDate).toEqual(baseTime.getTime() + 150);
});
});

View File

@@ -1,96 +0,0 @@
////TODO: matchers should be add-able to the env, not to the spec.
//describe("Custom Matchers", function() {
// var env;
// var fakeTimer;
//
// beforeEach(function() {
// env = new jasmine.Env();
// env.updateInterval = 0;
// });
//
// it("should be easy to add more matchers local to a spec, suite, etc.", function() {
// var spec1, spec2, spec1Matcher, spec2Matcher;
// var suite = env.describe('some suite', function() {
// env.beforeEach(function() {
// this.addMatchers({
// matcherForSuite: function(expected) {
// this.message = "matcherForSuite: actual: " + this.actual + "; expected: " + expected;
// return true;
// }
// });
// });
//
// spec1 = env.it('spec with an expectation').runs(function () {
// this.addMatchers({
// matcherForSpec: function(expected) {
// this.message = "matcherForSpec: actual: " + this.actual + "; expected: " + expected;
// return true;
// }
// });
// spec1Matcher = this.expect("xxx");
// });
//
// spec2 = env.it('spec with failing expectation').runs(function () {
// spec2Matcher = this.expect("yyy");
// });
// });
//
// suite.execute();
//
// spec1Matcher.matcherForSuite("expected");
// expect(spec1Matcher.message).toEqual("matcherForSuite: actual: xxx; expected: expected");
// spec1Matcher.matcherForSpec("expected");
// expect(spec1Matcher.message).toEqual("matcherForSpec: actual: xxx; expected: expected");
//
// spec2Matcher.matcherForSuite("expected");
// expect(spec2Matcher.message).toEqual("matcherForSuite: actual: yyy; expected: expected");
// expect(spec2Matcher.matcherForSpec).toBe(jasmine.undefined);
// });
//
// it("should generate messages with the same rules as for regular matchers when this.report() is not called", function() {
// var spec;
// var suite = env.describe('some suite', function() {
// spec = env.it('spec with an expectation').runs(function () {
// this.addMatchers({
// toBeTrue: function() {
// return this.actual === true;
// }
// });
// this.expect(true).toBeTrue();
// this.expect(false).toBeTrue();
// });
// });
//
// suite.execute();
//
// var results = spec.results().getItems();
// expect(results[0].message).toEqual("Passed.");
// expect(results[1].message).toEqual("Expected false to be true.");
// });
//
// it("should pass args", function() {
// var matcherCallArgs = [];
// var spec;
// var suite = env.describe('some suite', function() {
// spec = env.it('spec with an expectation').runs(function () {
// this.addMatchers({
// toBeTrue: function() {
// matcherCallArgs.push(jasmine.util.argsToArray(arguments));
// return this.actual === true;
// }
// });
// this.expect(true).toBeTrue();
// this.expect(false).toBeTrue('arg');
// this.expect(true).toBeTrue('arg1', 'arg2');
// });
// });
//
// suite.execute();
// var results = spec.results().getItems();
// expect(results[0].expected).toEqual(jasmine.undefined);
// expect(results[1].expected).toEqual('arg');
// expect(results[2].expected).toEqual(['arg1', 'arg2']);
//
// expect(matcherCallArgs).toEqual([[], ['arg'], ['arg1', 'arg2']]);
// });
//});

View File

@@ -14,7 +14,7 @@ describe("DelayedFunctionScheduler", function() {
it("schedules a string for later execution", function() {
var scheduler = new j$.DelayedFunctionScheduler(),
strfn = "horrible = true;";
strfn = "horrible = true;";
scheduler.scheduleFunction(strfn, 0);
@@ -175,5 +175,72 @@ describe("DelayedFunctionScheduler", function() {
expect(fn).toHaveBeenCalled();
});
it("schedules a function for later execution during a tick", function () {
var scheduler = new j$.DelayedFunctionScheduler(),
fn = jasmine.createSpy('fn'),
fnDelay = 10;
scheduler.scheduleFunction(function () {
scheduler.scheduleFunction(fn, fnDelay);
}, 0);
expect(fn).not.toHaveBeenCalled();
scheduler.tick(fnDelay);
expect(fn).toHaveBeenCalled();
});
it("#removeFunctionWithId removes a previously scheduled function with a given id during a tick", function () {
var scheduler = new j$.DelayedFunctionScheduler(),
fn = jasmine.createSpy('fn'),
fnDelay = 10,
timeoutKey;
scheduler.scheduleFunction(function () {
scheduler.removeFunctionWithId(timeoutKey);
}, 0);
timeoutKey = scheduler.scheduleFunction(fn, fnDelay);
expect(fn).not.toHaveBeenCalled();
scheduler.tick(fnDelay);
expect(fn).not.toHaveBeenCalled();
});
it("executes recurring functions interleaved with regular functions and functions scheduled during a tick in the correct order", function () {
var scheduler = new j$.DelayedFunctionScheduler(),
fn = jasmine.createSpy('fn'),
recurringCallCount = 0,
recurring = jasmine.createSpy('recurring').and.callFake(function() {
recurringCallCount++;
if (recurringCallCount < 5) {
expect(fn).not.toHaveBeenCalled();
}
}),
innerFn = jasmine.createSpy('innerFn').and.callFake(function() {
expect(recurring.calls.count()).toBe(4);
expect(fn).not.toHaveBeenCalled();
}),
scheduling = jasmine.createSpy('scheduling').and.callFake(function() {
expect(recurring.calls.count()).toBe(3);
expect(fn).not.toHaveBeenCalled();
scheduler.scheduleFunction(innerFn, 10); // 41ms absolute
});
scheduler.scheduleFunction(recurring, 10, [], true);
scheduler.scheduleFunction(fn, 50);
scheduler.scheduleFunction(scheduling, 31);
scheduler.tick(60);
expect(recurring).toHaveBeenCalled();
expect(recurring.calls.count()).toBe(6);
expect(fn).toHaveBeenCalled();
expect(scheduling).toHaveBeenCalled();
expect(innerFn).toHaveBeenCalled();
});
});

View File

@@ -3,46 +3,23 @@ describe("Env", function() {
var env;
beforeEach(function() {
env = new j$.Env();
env.updateInterval = 0;
});
describe('ids', function() {
it('nextSpecId should return consecutive integers, starting at 0', function() {
expect(env.nextSpecId()).toEqual(0);
expect(env.nextSpecId()).toEqual(1);
expect(env.nextSpecId()).toEqual(2);
});
});
describe("reporting", function() {
var fakeReporter;
beforeEach(function() {
fakeReporter = jasmine.createSpyObj("fakeReporter", ["jasmineStarted"]);
});
it("should allow reporters to be registered", function() {
env.addReporter(fakeReporter);
env.reporter.jasmineStarted();
expect(fakeReporter.jasmineStarted).toHaveBeenCalled();
});
});
it('removes all spies when env is executed', function(done) {
originalFoo = function() {},
testObj = {
foo: originalFoo
},
firstSpec = jasmine.createSpy('firstSpec').and.callFake(function() {
env.spyOn(testObj, 'foo');
}),
secondSpec = jasmine.createSpy('secondSpec').and.callFake(function() {
expect(testObj.foo).toBe(originalFoo);
});
env.describe('test suite', function() {
env.it('spec 0', firstSpec);
env.it('spec 1', secondSpec);
});
var originalFoo = function() {},
testObj = {
foo: originalFoo
},
firstSpec = jasmine.createSpy('firstSpec').and.callFake(function() {
env.spyOn(testObj, 'foo');
}),
secondSpec = jasmine.createSpy('secondSpec').and.callFake(function() {
expect(testObj.foo).toBe(originalFoo);
});
env.describe('test suite', function() {
env.it('spec 0', firstSpec);
env.it('spec 1', secondSpec);
});
var assertions = function() {
expect(firstSpec).toHaveBeenCalled();
@@ -56,13 +33,13 @@ describe("Env", function() {
});
describe("#spyOn", function() {
it("checks for the existance of the object", function() {
it("checks for the existence of the object", function() {
expect(function() {
env.spyOn(void 0, 'pants');
}).toThrowError(/could not find an object/);
});
it("checks for the existance of the method", function() {
it("checks for the existence of the method", function() {
var subject = {};
expect(function() {
@@ -84,41 +61,9 @@ describe("Env", function() {
var originalFunctionWasCalled = false;
var subject = { spiedFunc: function() { originalFunctionWasCalled = true; } };
originalFunc = subject.spiedFunc;
var spy = env.spyOn(subject, 'spiedFunc');
expect(subject.spiedFunc).toEqual(spy);
expect(subject.spiedFunc.calls.any()).toEqual(false);
expect(subject.spiedFunc.calls.count()).toEqual(0);
subject.spiedFunc('foo');
expect(subject.spiedFunc.calls.any()).toEqual(true);
expect(subject.spiedFunc.calls.count()).toEqual(1);
expect(subject.spiedFunc.calls.mostRecent().args).toEqual(['foo']);
expect(subject.spiedFunc.calls.mostRecent().object).toEqual(subject);
expect(originalFunctionWasCalled).toEqual(false);
subject.spiedFunc('bar');
expect(subject.spiedFunc.calls.count()).toEqual(2);
expect(subject.spiedFunc.calls.mostRecent().args).toEqual(['bar']);
});
});
describe("#catchException", function() {
it("returns true if the exception is a pending spec exception", function() {
env.catchExceptions(false);
expect(env.catchException(new Error(j$.Spec.pendingSpecExceptionMessage))).toBe(true);
});
it("returns false if the exception is not a pending spec exception and not catching exceptions", function() {
env.catchExceptions(false);
expect(env.catchException(new Error("external error"))).toBe(false);
expect(env.catchException(new Error(j$.Spec.pendingSpecExceptionMessage))).toBe(true);
});
});
@@ -130,382 +75,11 @@ describe("Env", function() {
});
});
});
// TODO: move these into a separate file
describe("Env integration", function() {
it("Suites execute as expected (no nesting)", function(done) {
var env = new j$.Env(),
calls = [];
var assertions = function() {
expect(calls).toEqual([
"with a spec",
"and another spec"
]);
done();
};
env.addReporter({ jasmineDone: assertions});
env.describe("A Suite", function() {
env.it("with a spec", function() {
calls.push("with a spec");
});
env.it("and another spec", function() {
calls.push("and another spec");
});
describe("#topSuite", function() {
it("returns the Jasmine top suite for users to traverse the spec tree", function() {
var suite = env.topSuite();
expect(suite.description).toEqual('Jasmine__TopLevel__Suite');
});
env.execute();
});
it("Nested Suites execute as expected", function(done) {
var env = new j$.Env(),
calls = [];
var assertions = function() {
expect(calls).toEqual([
'an outer spec',
'an inner spec',
'another inner spec'
]);
done();
};
env.addReporter({ jasmineDone: assertions });
env.describe("Outer suite", function() {
env.it("an outer spec", function() {
calls.push('an outer spec')
});
env.describe("Inner suite", function() {
env.it("an inner spec", function() {
calls.push('an inner spec');
});
env.it("another inner spec", function() {
calls.push('another inner spec');
});
});
});
env.execute();
});
it("Multiple top-level Suites execute as expected", function(done) {
var env = new j$.Env(),
calls = [];
var assertions = function() {
expect(calls).toEqual([
'an outer spec',
'an inner spec',
'another inner spec',
'a 2nd outer spec'
]);
done();
};
env.addReporter({ jasmineDone: assertions });
env.describe("Outer suite", function() {
env.it("an outer spec", function() {
calls.push('an outer spec')
});
env.describe("Inner suite", function() {
env.it("an inner spec", function() {
calls.push('an inner spec');
});
env.it("another inner spec", function() {
calls.push('another inner spec');
});
});
});
env.describe("Another outer suite", function() {
env.it("a 2nd outer spec", function() {
calls.push('a 2nd outer spec')
});
});
env.execute();
});
it("Mock clock can be installed and used in tests", function(done) {
var globalSetTimeout = jasmine.createSpy('globalSetTimeout'),
delayedFunctionForGlobalClock = jasmine.createSpy('delayedFunctionForGlobalClock'),
delayedFunctionForMockClock = jasmine.createSpy('delayedFunctionForMockClock'),
env = new j$.Env({global: { setTimeout: globalSetTimeout }});
var assertions = function() {
expect(delayedFunctionForMockClock).toHaveBeenCalled();
expect(globalSetTimeout).toHaveBeenCalledWith(delayedFunctionForGlobalClock, 100);
done();
};
env.addReporter({ jasmineDone: assertions });
env.describe("tests", function() {
env.it("test with mock clock", function() {
env.clock.install();
env.clock.setTimeout(delayedFunctionForMockClock, 100);
env.clock.tick(100);
});
env.it("test without mock clock", function() {
env.clock.setTimeout(delayedFunctionForGlobalClock, 100);
});
});
expect(globalSetTimeout).not.toHaveBeenCalled();
expect(delayedFunctionForMockClock).not.toHaveBeenCalled();
env.execute();
});
it("should run async specs in order, waiting for them to complete", function(done) {
var env = new j$.Env(), mutatedVar;
env.describe("tests", function() {
env.beforeEach(function() {
mutatedVar = 2;
});
env.it("async spec", function(underTestCallback) {
setTimeout(function() {
expect(mutatedVar).toEqual(2);
underTestCallback();
done();
}, 0);
});
env.it("after async spec", function() {
mutatedVar = 3;
});
});
env.execute();
});
describe("with a mock clock", function() {
beforeEach(function() {
jasmine.getEnv().clock.install();
});
afterEach(function() {
jasmine.getEnv().clock.uninstall();
});
it("should not hang on async specs that forget to call done()", function(done) {
var env = new j$.Env(),
reporter = jasmine.createSpyObj('fakeReporter', [
"jasmineStarted",
"jasmineDone",
"suiteStarted",
"suiteDone",
"specStarted",
"specDone"
]);
env.addReporter(reporter);
env.describe("tests", function() {
env.it("async spec that will hang", function(underTestCallback) {
env.expect(true).toBeTruthy();
});
env.it("after async spec", function() {
env.expect(true).toBeTruthy();
});
});
env.execute();
reporter.jasmineDone.and.callFake(function() {
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
totalSpecsDefined: 2
});
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({status: 'passed'}));
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({status: 'failed'}));
done();
});
jasmine.getEnv().clock.tick(60001);
});
});
// TODO: something is wrong with this spec
it("should report as expected", function(done) {
var env = new j$.Env(),
reporter = jasmine.createSpyObj('fakeReporter', [
"jasmineStarted",
"jasmineDone",
"suiteStarted",
"suiteDone",
"specStarted",
"specDone"
]);
reporter.jasmineDone.and.callFake(function() {
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
totalSpecsDefined: 3
});
var suiteResult = reporter.suiteStarted.calls.first().args[0];
expect(suiteResult.description).toEqual("A Suite");
expect(reporter.jasmineDone).toHaveBeenCalled();
done();
});
env.addReporter(reporter);
env.describe("A Suite", function() {
env.it("with a top level spec", function() {
env.expect(true).toBe(true);
});
env.describe("with a nested suite", function() {
env.xit("with a pending spec", function() {
env.expect(true).toBe(true);
});
env.it("with a spec", function() {
env.expect(true).toBe(false);
});
});
});
env.execute();
});
it("should be possible to get full name from a spec", function() {
var env = new j$.Env({global: { setTimeout: setTimeout }}),
topLevelSpec, nestedSpec, doublyNestedSpec;
env.describe("my tests", function() {
topLevelSpec = env.it("are sometimes top level", function() {
});
env.describe("are sometimes", function() {
nestedSpec = env.it("singly nested", function() {
});
env.describe("even", function() {
doublyNestedSpec = env.it("doubly nested", function() {
});
});
});
});
expect(topLevelSpec.getFullName()).toBe("my tests are sometimes top level.");
expect(nestedSpec.getFullName()).toBe("my tests are sometimes singly nested.");
expect(doublyNestedSpec.getFullName()).toBe("my tests are sometimes even doubly nested.");
});
it("Custom equality testers should be per spec", function(done) {
var env = new j$.Env({global: { setTimeout: setTimeout }}),
reporter = jasmine.createSpyObj('fakeReproter', [
"jasmineStarted",
"jasmineDone",
"suiteStarted",
"suiteDone",
"specStarted",
"specDone"
]);
reporter.jasmineDone.and.callFake(function() {
var firstSpecResult = reporter.specDone.calls.first().args[0],
secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
expect(firstSpecResult.status).toEqual("passed");
expect(secondSpecResult.status).toEqual("failed");
done();
});
env.addReporter(reporter);
env.describe("testing custom equality testers", function() {
env.it("with a custom tester", function() {
env.addCustomEqualityTester(function(a, b) { return true; });
env.expect("a").toEqual("b");
});
env.it("without a custom tester", function() {
env.expect("a").toEqual("b");
});
});
env.execute();
});
it("Custom matchers should be per spec", function() {
var env = new j$.Env({global: { setTimeout: setTimeout }}),
matchers = {
toFoo: function() {}
},
reporter = jasmine.createSpyObj('fakeReproter', [
"jasmineStarted",
"jasmineDone",
"suiteStarted",
"suiteDone",
"specStarted",
"specDone"
]);
env.addReporter(reporter);
env.describe("testing custom matchers", function() {
env.it("with a custom matcher", function() {
env.addMatchers(matchers);
expect(env.expect().toFoo).toBeDefined();
});
env.it("without a custom matcher", function() {
expect(env.expect().toFoo).toBeUndefined();
});
});
env.execute();
});
it("Custom equality testers for toContain should be per spec", function(done) {
var env = new j$.Env({global: { setTimeout: setTimeout }}),
reporter = jasmine.createSpyObj('fakeReproter', [
"jasmineStarted",
"jasmineDone",
"suiteStarted",
"suiteDone",
"specStarted",
"specDone"
]);
reporter.jasmineDone.and.callFake(function() {
var firstSpecResult = reporter.specDone.calls.first().args[0],
secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
expect(firstSpecResult.status).toEqual("passed");
expect(secondSpecResult.status).toEqual("failed");
done();
});
env.addReporter(reporter);
env.describe("testing custom equality testers", function() {
env.it("with a custom tester", function() {
env.addCustomEqualityTester(function(a, b) { return true; });
env.expect(["a"]).toContain("b");
});
env.it("without a custom tester", function() {
env.expect("a").toContain("b");
});
});
env.execute();
});
});

View File

@@ -35,7 +35,14 @@ describe("ExceptionFormatter", function() {
message = exceptionFormatter.message(sampleV8);
expect(message).toEqual('A Classic Mistake: you got your foo in my bar');
});
it("formats thrown exceptions that aren't errors", function() {
var thrown = "crazy error",
exceptionFormatter = new j$.ExceptionFormatter(),
message = exceptionFormatter.message(thrown);
expect(message).toEqual("crazy error thrown");
});
});

View File

@@ -1,64 +1,68 @@
xdescribe('Exceptions:', function() {
describe('Exceptions:', function() {
var env;
beforeEach(function() {
env = new j$.Env();
env.updateInterval = 0;
});
describe('with break on exception', function() {
it('should not catch the exception', function() {
env.catchExceptions(false);
var suite = env.describe('suite for break on exceptions', function() {
env.describe('suite for break on exceptions', function() {
env.it('should break when an exception is thrown', function() {
throw new Error('I should hit a breakpoint!');
});
});
var runner = env.currentRunner();
var dont_change = 'I will never change!';
var spy = jasmine.createSpy('spy');
try {
suite.execute();
dont_change = 'oops I changed';
env.execute();
spy();
}
catch (e) {}
expect(dont_change).toEqual('I will never change!');
expect(spy).not.toHaveBeenCalled();
});
});
describe("with catch on exception", function() {
it('should handle exceptions thrown, but continue', function() {
var ranSecondTest = false,
suite = env.describe('Suite for handles exceptions', function () {
it('should handle exceptions thrown, but continue', function(done) {
var secondTest = jasmine.createSpy('second test');
env.describe('Suite for handles exceptions', function () {
env.it('should be a test that fails because it throws an exception', function() {
throw new Error();
});
env.it('should be a passing test that runs after exceptions are thrown from a async test', function() {
ranSecondTest = true;
});
env.it('should be a passing test that runs after exceptions are thrown from a async test', secondTest);
});
suite.execute();
expect(ranSecondTest).toBe(true);
var expectations = function() {
expect(secondTest).toHaveBeenCalled();
done();
};
env.addReporter({ jasmineDone: expectations });
env.execute();
});
it("should handle exceptions thrown directly in top-level describe blocks and continue", function () {
var ranSecondDescribe = false, suite, suite2, runner = env.currentRunner();
suite = env.describe("a suite that throws an exception", function () {
it("should handle exceptions thrown directly in top-level describe blocks and continue", function(done) {
var secondDescribe = jasmine.createSpy("second describe");
env.describe("a suite that throws an exception", function () {
env.it("is a test that should pass", function () {
this.expect(true).toEqual(true);
});
throw new Error("top level error");
});
suite2 = env.describe("a suite that doesn't throw an exception", function () {
ranSecondDescribe = true;
});
env.describe("a suite that doesn't throw an exception", secondDescribe);
runner.execute();
expect(ranSecondDescribe).toBe(true);
var expectations = function() {
expect(secondDescribe).toHaveBeenCalled();
done();
};
env.addReporter({ jasmineDone: expectations });
env.execute();
});
});
});

View File

@@ -9,14 +9,14 @@ describe("buildExpectationResult", function() {
expect(result.message).toBe('Passed.');
});
it("message returns the message for failing expecations", function() {
it("message returns the message for failing expectations", function() {
var result = j$.buildExpectationResult({passed: false, message: 'some-value'});
expect(result.message).toBe('some-value');
});
it("delegates message formatting to the provided formatter if there was an Error", function() {
var fakeError = {message: 'foo'},
messageFormatter = jasmine.createSpy("exception message formatter").and.callReturn(fakeError.message);
messageFormatter = jasmine.createSpy("exception message formatter").and.returnValue(fakeError.message);
var result = j$.buildExpectationResult(
{
@@ -31,7 +31,7 @@ describe("buildExpectationResult", function() {
it("delegates stack formatting to the provided formatter if there was an Error", function() {
var fakeError = {stack: 'foo'},
stackFormatter = jasmine.createSpy("stack formatter").and.callReturn(fakeError.stack);
stackFormatter = jasmine.createSpy("stack formatter").and.returnValue(fakeError.stack);
var result = j$.buildExpectationResult(
{

View File

@@ -46,7 +46,7 @@ describe("Expectation", function() {
expect(expectation.toFoo).toBeUndefined();
});
it("Factory builds an expectaion/negative expectation", function() {
it("Factory builds an expectation/negative expectation", function() {
var builtExpectation = j$.Expectation.Factory();
expect(builtExpectation instanceof j$.Expectation).toBe(true);
@@ -56,7 +56,7 @@ describe("Expectation", function() {
it("wraps matchers's compare functions, passing in matcher dependencies", function() {
var fakeCompare = function() { return { pass: true }; },
matcherFactory = jasmine.createSpy("matcher").and.callReturn({ compare: fakeCompare }),
matcherFactory = jasmine.createSpy("matcher").and.returnValue({ compare: fakeCompare }),
matchers = {
toFoo: matcherFactory
},
@@ -80,7 +80,7 @@ describe("Expectation", function() {
});
it("wraps matchers's compare functions, passing the actual and expected", function() {
var fakeCompare = jasmine.createSpy('fake-compare').and.callReturn({pass: true}),
var fakeCompare = jasmine.createSpy('fake-compare').and.returnValue({pass: true}),
matchers = {
toFoo: function() {
return {
@@ -193,6 +193,40 @@ describe("Expectation", function() {
j$.Expectation.addMatchers(matchers);
expectation = new j$.Expectation({
actual: "an actual",
addExpectationResult: addExpectationResult
});
expectation.toFoo("hello");
expect(addExpectationResult).toHaveBeenCalledWith(false, {
matcherName: "toFoo",
passed: false,
expected: "hello",
actual: "an actual",
message: "I am a custom message"
});
});
it("reports a failing result with a custom fail message function to the spec when the comparison fails", function() {
var matchers = {
toFoo: function() {
return {
compare: function() {
return {
pass: false,
message: function() { return "I am a custom message"; }
};
}
};
}
},
addExpectationResult = jasmine.createSpy("addExpectationResult"),
expectation;
j$.Expectation.addMatchers(matchers);
expectation = new j$.Expectation({
matchers: matchers,
actual: "an actual",
@@ -254,7 +288,7 @@ describe("Expectation", function() {
}
},
util = {
buildFailureMessage: function() { return "default messge"; }
buildFailureMessage: function() { return "default message"; }
},
addExpectationResult = jasmine.createSpy("addExpectationResult"),
actual = "an actual",
@@ -277,7 +311,7 @@ describe("Expectation", function() {
passed: false,
expected: "hello",
actual: actual,
message: "default messge"
message: "default message"
});
});
@@ -317,4 +351,77 @@ describe("Expectation", function() {
message: "I am a custom message"
});
});
});
it("reports a passing result to the spec when the 'not' comparison passes, given a negativeCompare", function() {
var matchers = {
toFoo: function() {
return {
compare: function() { return { pass: true }; },
negativeCompare: function() { return { pass: true }; }
};
}
},
addExpectationResult = jasmine.createSpy("addExpectationResult"),
actual = "an actual",
expectation;
j$.Expectation.addMatchers(matchers);
expectation = new j$.Expectation({
matchers: matchers,
actual: "an actual",
addExpectationResult: addExpectationResult,
isNot: true
});
expectation.toFoo("hello");
expect(addExpectationResult).toHaveBeenCalledWith(true, {
matcherName: "toFoo",
passed: true,
expected: "hello",
actual: actual,
message: ""
});
});
it("reports a failing result and a custom fail message to the spec when the 'not' comparison fails, given a negativeCompare", function() {
var matchers = {
toFoo: function() {
return {
compare: function() { return { pass: true }; },
negativeCompare: function() {
return {
pass: false,
message: "I'm a custom message"
};
}
};
}
},
addExpectationResult = jasmine.createSpy("addExpectationResult"),
actual = "an actual",
expectation;
j$.Expectation.addMatchers(matchers);
expectation = new j$.Expectation({
matchers: matchers,
actual: "an actual",
addExpectationResult: addExpectationResult,
isNot: true
});
expectation.toFoo("hello");
expect(addExpectationResult).toHaveBeenCalledWith(false, {
matcherName: "toFoo",
passed: false,
expected: "hello",
actual: actual,
message: "I'm a custom message"
});
});
});

View File

@@ -6,7 +6,6 @@ xdescribe('JsApiReporter (integration specs)', function() {
beforeEach(function() {
env = new j$.Env();
env.updateInterval = 0;
suite = env.describe("top-level suite", function() {
spec1 = env.it("spec 1", function() {
@@ -196,7 +195,7 @@ describe("JsApiReporter", function() {
timer: timerSpy
});
timerSpy.elapsed.and.callReturn(1000);
timerSpy.elapsed.and.returnValue(1000);
reporter.jasmineDone();
expect(reporter.executionTime()).toEqual(1000);
});

179
spec/core/MockDateSpec.js Normal file
View File

@@ -0,0 +1,179 @@
describe("FakeDate", function() {
it("does not fail if no global date is found", function() {
var fakeGlobal = {},
mockDate = new j$.MockDate(fakeGlobal);
expect(function() {
mockDate.install();
mockDate.tick(0);
mockDate.uninstall();
}).not.toThrow();
});
it("replaces the global Date when it is installed", function() {
var globalDate = jasmine.createSpy("global Date").and.callFake(function() {
return {
getTime: function() {}
}
}),
fakeGlobal = { Date: globalDate },
mockDate = new j$.MockDate(fakeGlobal);
expect(fakeGlobal.Date).toEqual(globalDate);
mockDate.install();
expect(fakeGlobal.Date).not.toEqual(globalDate);
});
it("replaces the global Date on uninstall", function() {
var globalDate = jasmine.createSpy("global Date").and.callFake(function() {
return {
getTime: function() {}
}
}),
fakeGlobal = { Date: globalDate },
mockDate = new j$.MockDate(fakeGlobal);
mockDate.install();
mockDate.uninstall();
expect(fakeGlobal.Date).toEqual(globalDate);
});
it("takes the current time as the base when installing without parameters", function() {
var globalDate = jasmine.createSpy("global Date").and.callFake(function() {
return {
getTime: function() {
return 1000;
}
}
}),
fakeGlobal = { Date: globalDate },
mockDate = new j$.MockDate(fakeGlobal);
mockDate.install();
globalDate.calls.reset();
new fakeGlobal.Date();
expect(globalDate).toHaveBeenCalledWith(1000);
});
it("can accept a date as time base when installing", function() {
var fakeGlobal = { Date: Date },
mockDate = new j$.MockDate(fakeGlobal),
baseDate = new Date();
spyOn(baseDate, 'getTime').and.returnValue(123);
mockDate.install(baseDate);
expect(new fakeGlobal.Date().getTime()).toEqual(123);
});
it("makes real dates", function() {
var fakeGlobal = { Date: Date },
mockDate = new j$.MockDate(fakeGlobal);
mockDate.install();
expect(new fakeGlobal.Date()).toEqual(jasmine.any(Date));
});
it("fakes current time when using Date.now()", function() {
var globalDate = jasmine.createSpy("global Date").and.callFake(function() {
return {
getTime: function() {
return 1000;
}
}
}),
fakeGlobal = { Date: globalDate };
globalDate.now = function() {};
var mockDate = new j$.MockDate(fakeGlobal);
mockDate.install();
expect(fakeGlobal.Date.now()).toEqual(1000);
});
it("does not stub Date.now() if it doesn't already exist", function() {
var globalDate = jasmine.createSpy("global Date").and.callFake(function() {
return {
getTime: function() {
return 1000;
}
}
}),
fakeGlobal = { Date: globalDate },
mockDate = new j$.MockDate(fakeGlobal);
mockDate.install();
expect(fakeGlobal.Date.now).toThrowError("Browser does not support Date.now()");
});
it("makes time passes using tick", function() {
var globalDate = jasmine.createSpy("global Date").and.callFake(function() {
return {
getTime: function() {
return 1000;
}
}
}),
fakeGlobal = { Date: globalDate };
globalDate.now = function() {};
var mockDate = new j$.MockDate(fakeGlobal);
mockDate.install();
mockDate.tick(100);
expect(fakeGlobal.Date.now()).toEqual(1100);
mockDate.tick(1000);
expect(fakeGlobal.Date.now()).toEqual(2100);
});
it("allows to increase 0 milliseconds using tick", function() {
var globalDate = jasmine.createSpy("global Date").and.callFake(function() {
return {
getTime: function() {
return 1000;
}
}
}),
fakeGlobal = { Date: globalDate };
globalDate.now = function() {};
var mockDate = new j$.MockDate(fakeGlobal);
mockDate.install();
mockDate.tick(0);
expect(fakeGlobal.Date.now()).toEqual(1000);
mockDate.tick();
expect(fakeGlobal.Date.now()).toEqual(1000);
});
it("allows to create a Date in a different time than the mocked time", function() {
var fakeGlobal = { Date: Date },
mockDate = new j$.MockDate(fakeGlobal),
baseDate = new Date(2013, 9, 23, 0, 0, 0, 0);
mockDate.install(baseDate);
var otherDate = new fakeGlobal.Date(2013, 9, 23, 0, 0, 1, 0);
expect(otherDate.getTime()).not.toEqual(baseDate.getTime());
});
it("copies all Date properties to the mocked date", function() {
var fakeGlobal = { Date: Date },
mockDate = new j$.MockDate(fakeGlobal);
mockDate.install();
expect(fakeGlobal.Date.UTC(2013, 9, 23)).toEqual(Date.UTC(2013, 9, 23));
});
});

View File

@@ -61,4 +61,10 @@ describe("ObjectContaining", function() {
expect(containing.jasmineToString()).toMatch("<jasmine.objectContaining");
});
});
it("matches recursively", function() {
var containing = new j$.ObjectContaining({one: new j$.ObjectContaining({two: {}})});
expect(containing.jasmineMatches({one: {two: {}}})).toBe(true);
});
});

View File

@@ -11,6 +11,7 @@ describe("j$.pp", function () {
expect(j$.pp(jasmine.undefined)).toEqual("undefined");
expect(j$.pp(3)).toEqual("3");
expect(j$.pp(-3.14)).toEqual("-3.14");
expect(j$.pp(-0)).toEqual("-0");
});
it("should stringify arrays properly", function() {
@@ -26,10 +27,10 @@ describe("j$.pp", function () {
});
it("should stringify objects properly", function() {
expect(j$.pp({foo: 'bar'})).toEqual("{ foo : 'bar' }");
expect(j$.pp({foo:'bar', baz:3, nullValue: null, undefinedValue: jasmine.undefined})).toEqual("{ foo : 'bar', baz : 3, nullValue : null, undefinedValue : undefined }");
expect(j$.pp({foo: 'bar'})).toEqual("{ foo: 'bar' }");
expect(j$.pp({foo:'bar', baz:3, nullValue: null, undefinedValue: jasmine.undefined})).toEqual("{ foo: 'bar', baz: 3, nullValue: null, undefinedValue: undefined }");
expect(j$.pp({foo: function () {
}, bar: [1, 2, 3]})).toEqual("{ foo : Function, bar : [ 1, 2, 3 ] }");
}, bar: [1, 2, 3]})).toEqual("{ foo: Function, bar: [ 1, 2, 3 ] }");
});
it("should not include inherited properties when stringifying an object", function() {
@@ -37,7 +38,7 @@ describe("j$.pp", function () {
SomeClass.prototype.foo = "inherited foo";
var instance = new SomeClass();
instance.bar = "my own bar";
expect(j$.pp(instance)).toEqual("{ bar : 'my own bar' }");
expect(j$.pp(instance)).toEqual("{ bar: 'my own bar' }");
});
it("should not recurse objects and arrays more deeply than j$.MAX_PRETTY_PRINT_DEPTH", function() {
@@ -47,21 +48,42 @@ describe("j$.pp", function () {
try {
j$.MAX_PRETTY_PRINT_DEPTH = 2;
expect(j$.pp(nestedObject)).toEqual("{ level1 : { level2 : Object } }");
expect(j$.pp(nestedObject)).toEqual("{ level1: { level2: Object } }");
expect(j$.pp(nestedArray)).toEqual("[ 1, [ 2, Array ] ]");
j$.MAX_PRETTY_PRINT_DEPTH = 3;
expect(j$.pp(nestedObject)).toEqual("{ level1 : { level2 : { level3 : Object } } }");
expect(j$.pp(nestedObject)).toEqual("{ level1: { level2: { level3: Object } } }");
expect(j$.pp(nestedArray)).toEqual("[ 1, [ 2, [ 3, Array ] ] ]");
j$.MAX_PRETTY_PRINT_DEPTH = 4;
expect(j$.pp(nestedObject)).toEqual("{ level1 : { level2 : { level3 : { level4 : 'leaf' } } } }");
expect(j$.pp(nestedObject)).toEqual("{ level1: { level2: { level3: { level4: 'leaf' } } } }");
expect(j$.pp(nestedArray)).toEqual("[ 1, [ 2, [ 3, [ 4, 'leaf' ] ] ] ]");
} finally {
j$.MAX_PRETTY_PRINT_DEPTH = originalMaxDepth;
}
});
it("should stringify immutable circular objects", function(){
if(Object.freeze){
var frozenObject = {foo: {bar: 'baz'}};
frozenObject.circular = frozenObject;
frozenObject = Object.freeze(frozenObject);
expect(j$.pp(frozenObject)).toEqual("{ foo: { bar: 'baz' }, circular: <circular reference: Object> }");
}
});
it("should truncate arrays that are longer than j$.MAX_PRETTY_PRINT_ARRAY_LENGTH", function() {
var originalMaxLength = j$.MAX_PRETTY_PRINT_ARRAY_LENGTH;
var array = [1, 2, 3];
try {
j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
expect(j$.pp(array)).toEqual("[ 1, 2, ... ]");
} finally {
j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxLength;
}
});
it("should stringify RegExp objects properly", function() {
expect(j$.pp(/x|y|z/)).toEqual("/x|y|z/");
});
@@ -69,7 +91,7 @@ describe("j$.pp", function () {
it("should indicate circular object references", function() {
var sampleValue = {foo: 'hello'};
sampleValue.nested = sampleValue;
expect(j$.pp(sampleValue)).toEqual("{ foo : 'hello', nested : <circular reference: Object> }");
expect(j$.pp(sampleValue)).toEqual("{ foo: 'hello', nested: <circular reference: Object> }");
});
it("should indicate getters on objects as such", function() {
@@ -81,10 +103,10 @@ describe("j$.pp", function () {
});
}
if (sampleValue.__defineGetter__) {
expect(j$.pp(sampleValue)).toEqual("{ id : 1, calculatedValue : <getter> }");
expect(j$.pp(sampleValue)).toEqual("{ id: 1, calculatedValue: <getter> }");
}
else {
expect(j$.pp(sampleValue)).toEqual("{ id : 1 }");
expect(j$.pp(sampleValue)).toEqual("{ id: 1 }");
}
});
@@ -121,5 +143,14 @@ describe("j$.pp", function () {
expect(j$.pp(obj)).toEqual("strung");
});
it("should handle objects with null prototype", function() {
if (jasmine.getEnv().ieVersion < 9) { return; }
var obj = Object.create(null);
obj.foo = 'bar';
expect(j$.pp(obj)).toEqual("{ foo: 'bar' }");
});
});

View File

@@ -19,60 +19,185 @@ describe("QueueRunner", function() {
expect(calls).toEqual(['fn1', 'fn2']);
});
it("supports asynchronous functions, only advancing to next function after a done() callback", function() {
//TODO: it would be nice if spy arity could match the fake, so we could do something like:
//createSpy('asyncfn').and.callFake(function(done) {});
var onComplete = jasmine.createSpy('onComplete'),
beforeCallback = jasmine.createSpy('beforeCallback'),
fnCallback = jasmine.createSpy('fnCallback'),
afterCallback = jasmine.createSpy('afterCallback'),
fn1 = function(done) {
beforeCallback();
setTimeout(function() {
done()
}, 100);
},
fn2 = function(done) {
fnCallback();
setTimeout(function() {
done()
}, 100);
},
fn3 = function(done) {
afterCallback();
setTimeout(function() {
done()
}, 100);
},
queueRunner = new j$.QueueRunner({
fns: [fn1, fn2, fn3],
onComplete: onComplete
});
clock.install();
it("calls each function with a consistent 'this'-- an empty object", function() {
var fn1 = jasmine.createSpy('fn1'),
fn2 = jasmine.createSpy('fn2'),
fn3 = function(done) { asyncContext = this; done(); },
queueRunner = new j$.QueueRunner({
fns: [fn1, fn2, fn3]
}),
asyncContext;
queueRunner.execute();
expect(beforeCallback).toHaveBeenCalled();
expect(fnCallback).not.toHaveBeenCalled();
expect(afterCallback).not.toHaveBeenCalled();
expect(onComplete).not.toHaveBeenCalled();
var context = fn1.calls.first().object;
expect(context).toEqual({});
expect(fn2.calls.first().object).toBe(context);
expect(asyncContext).toBe(context);
});
clock.tick(100);
describe("with an asynchronous function", function() {
beforeEach(function() {
jasmine.clock().install();
});
expect(fnCallback).toHaveBeenCalled();
expect(afterCallback).not.toHaveBeenCalled();
expect(onComplete).not.toHaveBeenCalled();
afterEach(function() {
jasmine.clock().uninstall();
});
clock.tick(100);
it("supports asynchronous functions, only advancing to next function after a done() callback", function() {
//TODO: it would be nice if spy arity could match the fake, so we could do something like:
//createSpy('asyncfn').and.callFake(function(done) {});
expect(afterCallback).toHaveBeenCalled();
expect(onComplete).not.toHaveBeenCalled();
var onComplete = jasmine.createSpy('onComplete'),
beforeCallback = jasmine.createSpy('beforeCallback'),
fnCallback = jasmine.createSpy('fnCallback'),
afterCallback = jasmine.createSpy('afterCallback'),
fn1 = function(done) {
beforeCallback();
setTimeout(done, 100);
},
fn2 = function(done) {
fnCallback();
setTimeout(done, 100);
},
fn3 = function(done) {
afterCallback();
setTimeout(done, 100);
},
queueRunner = new j$.QueueRunner({
fns: [fn1, fn2, fn3],
onComplete: onComplete
});
clock.tick(100);
queueRunner.execute();
expect(onComplete).toHaveBeenCalled();
expect(beforeCallback).toHaveBeenCalled();
expect(fnCallback).not.toHaveBeenCalled();
expect(afterCallback).not.toHaveBeenCalled();
expect(onComplete).not.toHaveBeenCalled();
jasmine.clock().tick(100);
expect(fnCallback).toHaveBeenCalled();
expect(afterCallback).not.toHaveBeenCalled();
expect(onComplete).not.toHaveBeenCalled();
jasmine.clock().tick(100);
expect(afterCallback).toHaveBeenCalled();
expect(onComplete).not.toHaveBeenCalled();
jasmine.clock().tick(100);
expect(onComplete).toHaveBeenCalled();
});
it("sets a timeout if requested for asynchronous functions so they don't go on forever", function() {
var beforeFn = function(done) { },
fn = jasmine.createSpy('fn'),
onComplete = jasmine.createSpy('onComplete'),
onException = jasmine.createSpy('onException'),
queueRunner = new j$.QueueRunner({
fns: [beforeFn, fn],
onComplete: onComplete,
onException: onException,
enforceTimeout: function() { return true; }
});
queueRunner.execute();
expect(fn).not.toHaveBeenCalled();
jasmine.clock().tick(j$.DEFAULT_TIMEOUT_INTERVAL);
expect(onException).toHaveBeenCalledWith(jasmine.any(Error));
expect(fn).toHaveBeenCalled();
expect(onComplete).toHaveBeenCalled();
});
it("by default does not set a timeout for asynchronous functions", function() {
var beforeFn = function(done) { },
fn = jasmine.createSpy('fn'),
onComplete = jasmine.createSpy('onComplete'),
onException = jasmine.createSpy('onException'),
queueRunner = new j$.QueueRunner({
fns: [beforeFn, fn],
onComplete: onComplete,
onException: onException,
});
queueRunner.execute();
expect(fn).not.toHaveBeenCalled();
jasmine.clock().tick(j$.DEFAULT_TIMEOUT_INTERVAL);
expect(onException).not.toHaveBeenCalled();
expect(fn).not.toHaveBeenCalled();
expect(onComplete).not.toHaveBeenCalled();
});
it("clears the timeout when an async function throws an exception, to prevent additional onException calls", function() {
var fn = function(done) { throw new Error("error!"); },
onComplete = jasmine.createSpy('onComplete'),
onException = jasmine.createSpy('onException'),
queueRunner = new j$.QueueRunner({
fns: [fn],
onComplete: onComplete,
onException: onException
});
queueRunner.execute();
expect(onComplete).toHaveBeenCalled();
expect(onException).toHaveBeenCalled();
jasmine.clock().tick(j$.DEFAULT_TIMEOUT_INTERVAL);
expect(onException.calls.count()).toEqual(1);
});
it("clears the timeout when the done callback is called", function() {
var fn = function(done) { done(); },
onComplete = jasmine.createSpy('onComplete'),
onException = jasmine.createSpy('onException'),
queueRunner = new j$.QueueRunner({
fns: [fn],
onComplete: onComplete,
onException: onException
});
queueRunner.execute();
expect(onComplete).toHaveBeenCalled();
jasmine.clock().tick(j$.DEFAULT_TIMEOUT_INTERVAL);
expect(onException).not.toHaveBeenCalled();
});
it("only moves to the next spec the first time you call done", function() {
var fn = function(done) {done(); done();},
nextFn = jasmine.createSpy('nextFn');
queueRunner = new j$.QueueRunner({
fns: [fn, nextFn]
});
queueRunner.execute();
expect(nextFn.calls.count()).toEqual(1);
});
it("does not move to the next spec if done is called after an exception has ended the spec", function() {
var fn = function(done) {
setTimeout(done, 1);
throw new Error('error!');
},
nextFn = jasmine.createSpy('nextFn');
queueRunner = new j$.QueueRunner({
fns: [fn, nextFn]
});
queueRunner.execute();
jasmine.clock().tick(1);
expect(nextFn.calls.count()).toEqual(1);
});
});
it("calls an exception handler when an exception is thrown in a fn", function() {
@@ -99,16 +224,15 @@ describe("QueueRunner", function() {
catchException: function(e) { return false; }
});
expect(function() { queueRunner.execute(); }).toThrow();
expect(queueRunner.execute).toThrow();
});
it("continues running the functions even after an exception is thrown in an async spec", function() {
var fn = function(done) { throw new Error("error"); },
nextFn = jasmine.createSpy("nextFunction");
queueRunner = new j$.QueueRunner({
fns: [fn, nextFn]
});
nextFn = jasmine.createSpy("nextFunction"),
queueRunner = new j$.QueueRunner({
fns: [fn, nextFn]
});
queueRunner.execute();
expect(nextFn).toHaveBeenCalled();

View File

@@ -37,4 +37,4 @@ describe("ReportDispatcher", function() {
dispatcher.foo(123, 456);
}).not.toThrow();
});
});
});

View File

@@ -20,13 +20,17 @@ describe("Spec", function() {
expect(j$.Spec.isPendingSpecException(e)).toBe(false);
});
it("#isPendingSpecException returns false for thrown values that don't have toString", function() {
expect(j$.Spec.isPendingSpecException(void 0)).toBe(false);
});
it("delegates execution to a QueueRunner", function() {
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
spec = new j$.Spec({
description: 'my test',
id: 'some-id',
fn: function() {},
queueRunner: fakeQueueRunner
queueRunnerFactory: fakeQueueRunner
});
spec.execute();
@@ -36,19 +40,23 @@ describe("Spec", function() {
it("should call the start callback on execution", function() {
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
beforesWereCalled = false,
startCallback = jasmine.createSpy('startCallback'),
spec = new j$.Spec({
id: 123,
description: 'foo bar',
fn: function() {},
onStart: startCallback,
queueRunner: fakeQueueRunner
queueRunnerFactory: fakeQueueRunner
});
spec.execute();
expect(startCallback).toHaveBeenCalledWith(spec);
// TODO: due to some issue with the Pretty Printer, this line fails, but the other two pass.
// This means toHaveBeenCalledWith on IE8 will always be broken.
// expect(startCallback).toHaveBeenCalledWith(spec);
expect(startCallback).toHaveBeenCalled();
expect(startCallback.calls.first().object).toEqual(spec);
});
it("should call the start callback on execution but before any befores are called", function() {
@@ -65,7 +73,7 @@ describe("Spec", function() {
}]
},
onStart: startCallback,
queueRunner: fakeQueueRunner
queueRunnerFactory: fakeQueueRunner
});
spec.execute();
@@ -89,7 +97,7 @@ describe("Spec", function() {
afterFns: function() {
return [after]
},
queueRunner: fakeQueueRunner
queueRunnerFactory: fakeQueueRunner
});
spec.execute();
@@ -107,7 +115,7 @@ describe("Spec", function() {
onStart: startCallback,
fn: null,
resultCallback: resultCallback,
queueRunner: fakeQueueRunner
queueRunnerFactory: fakeQueueRunner
});
@@ -123,7 +131,7 @@ describe("Spec", function() {
onStart:startCallback,
fn: specBody,
resultCallback: resultCallback,
queueRunner: fakeQueueRunner
queueRunnerFactory: fakeQueueRunner
});
spec.disable();
@@ -150,7 +158,7 @@ describe("Spec", function() {
getSpecName: function() {
return "a suite with a spec"
},
queueRunner: fakeQueueRunner
queueRunnerFactory: fakeQueueRunner
});
spec.pend();
@@ -167,7 +175,8 @@ describe("Spec", function() {
status: 'pending',
description: 'with a spec',
fullName: 'a suite with a spec',
failedExpectations: []
failedExpectations: [],
passedExpectations: []
});
});
@@ -177,7 +186,7 @@ describe("Spec", function() {
fn: function() {},
catchExceptions: function() { return false; },
resultCallback: function() {},
queueRunner: function(attrs) { attrs.onComplete(); }
queueRunnerFactory: function(attrs) { attrs.onComplete(); }
});
spec.execute(done);
@@ -185,18 +194,9 @@ describe("Spec", function() {
expect(done).toHaveBeenCalled();
});
it("#status returns pending by default", function() {
var spec = new j$.Spec({fn: jasmine.createSpy("spec body")});
expect(spec.status()).toEqual('pending');
});
it("#status returns pending if no expectations were encountered", function() {
var specBody = jasmine.createSpy("spec body"),
spec = new j$.Spec({fn: specBody});
spec.execute();
expect(spec.status()).toEqual('pending');
it("#status returns passing by default", function(){
var spec = new j$.Spec({ fn: function () {} });
expect(spec.status()).toBe("passed");
});
it("#status returns passed if all expectations in the spec have passed", function() {
@@ -212,19 +212,35 @@ describe("Spec", function() {
expect(spec.status()).toBe('failed');
});
it("keeps track of passed and failed expectations", function() {
var resultCallback = jasmine.createSpy('resultCallback'),
spec = new j$.Spec({
fn: jasmine.createSpy("spec body"),
expectationResultFactory: function (data) { return data; },
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
resultCallback: resultCallback
});
spec.addExpectationResult(true, 'expectation1');
spec.addExpectationResult(false, 'expectation2');
spec.execute();
expect(resultCallback.calls.first().args[0].passedExpectations).toEqual(['expectation1']);
expect(resultCallback.calls.first().args[0].failedExpectations).toEqual(['expectation2']);
});
it("can return its full name", function() {
var spec;
spec = new j$.Spec({
getSpecName: function(passedVal) {
// expect(passedVal).toBe(spec); TODO: a exec time, spec is undefined WTF?
return 'expected val';
}
var specNameSpy = jasmine.createSpy('specNameSpy').and.returnValue('expected val');
var spec = new j$.Spec({
getSpecName: specNameSpy
});
expect(spec.getFullName()).toBe('expected val');
expect(specNameSpy.calls.mostRecent().args[0].id).toEqual(spec.id);
});
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() {
var fakeQueueRunner = function(opts) {
opts.onException(new Error(j$.Spec.pendingSpecExceptionMessage));
@@ -233,7 +249,7 @@ describe("Spec", function() {
description: 'my test',
id: 'some-id',
fn: function() { },
queueRunner: fakeQueueRunner
queueRunnerFactory: fakeQueueRunner
});
spec.execute();

View File

@@ -14,7 +14,7 @@ describe('Spies', function () {
expect(spy.bob).toEqual("test");
});
it("warns the user that we indend to overwrite an existing property", function() {
it("warns the user that we intend to overwrite an existing property", function() {
TestClass.prototype.someFunction.and = "turkey";
expect(function() {
@@ -28,6 +28,25 @@ describe('Spies', function () {
expect(spy.and).toEqual(jasmine.any(j$.SpyStrategy));
expect(spy.calls).toEqual(jasmine.any(j$.CallTracker));
});
it("tracks the argument of calls", function () {
var spy = j$.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
var trackSpy = spyOn(spy.calls, "track");
spy("arg");
expect(trackSpy.calls.mostRecent().args[0].args).toEqual(["arg"]);
});
it("tracks the context of calls", function () {
var spy = j$.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
var trackSpy = spyOn(spy.calls, "track");
var contextObject = { spyMethod: spy };
contextObject.spyMethod();
expect(trackSpy.calls.mostRecent().args[0].object).toEqual(contextObject);
});
});
describe("createSpyObj", function() {

View File

@@ -22,7 +22,7 @@ describe("SpyStrategy", 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.callReturn(42),
var originalFn = jasmine.createSpy("original").and.returnValue(42),
spyStrategy = new j$.SpyStrategy({fn: originalFn}),
returnValue;
@@ -39,7 +39,7 @@ describe("SpyStrategy", function() {
spyStrategy = new j$.SpyStrategy({fn: originalFn}),
returnValue;
spyStrategy.callReturn(17);
spyStrategy.returnValue(17);
returnValue = spyStrategy.exec();
expect(originalFn).not.toHaveBeenCalled();
@@ -50,15 +50,25 @@ describe("SpyStrategy", function() {
var originalFn = jasmine.createSpy("original"),
spyStrategy = new j$.SpyStrategy({fn: originalFn});
spyStrategy.callThrow("bar");
spyStrategy.throwError(new TypeError("bar"));
expect(function() { spyStrategy.exec(); }).toThrow("bar");
expect(function() { spyStrategy.exec(); }).toThrowError(TypeError, "bar");
expect(originalFn).not.toHaveBeenCalled();
});
it("allows a non-Error to be thrown, wrapping it into an exception when executed", function() {
var originalFn = jasmine.createSpy("original"),
spyStrategy = new j$.SpyStrategy({fn: originalFn});
spyStrategy.throwError("bar");
expect(function() { spyStrategy.exec(); }).toThrowError(Error, "bar");
expect(originalFn).not.toHaveBeenCalled();
});
it("allows a fake function to be called instead", function() {
var originalFn = jasmine.createSpy("original"),
fakeFn = jasmine.createSpy("fake").and.callReturn(67),
fakeFn = jasmine.createSpy("fake").and.returnValue(67),
spyStrategy = new j$.SpyStrategy({fn: originalFn}),
returnValue;
@@ -71,7 +81,7 @@ describe("SpyStrategy", function() {
it("allows a return to plan stubbing after another strategy", function() {
var originalFn = jasmine.createSpy("original"),
fakeFn = jasmine.createSpy("fake").and.callReturn(67),
fakeFn = jasmine.createSpy("fake").and.returnValue(67),
spyStrategy = new j$.SpyStrategy({fn: originalFn}),
returnValue;
@@ -89,12 +99,12 @@ describe("SpyStrategy", function() {
it("returns the spy after changing the strategy", function(){
var spy = {},
spyFn = jasmine.createSpy('spyFn').and.callReturn(spy),
spyFn = jasmine.createSpy('spyFn').and.returnValue(spy),
spyStrategy = new j$.SpyStrategy({getSpy: spyFn});
expect(spyStrategy.callThrough()).toBe(spy);
expect(spyStrategy.callReturn()).toBe(spy);
expect(spyStrategy.callThrow()).toBe(spy);
expect(spyStrategy.returnValue()).toBe(spy);
expect(spyStrategy.throwError()).toBe(spy);
expect(spyStrategy.callFake()).toBe(spy);
expect(spyStrategy.stub()).toBe(spy);
});

View File

@@ -67,54 +67,6 @@ describe("Suite", function() {
expect(suite.afterFns).toEqual([innerAfter, outerAfter]);
});
it("adds specs", function() {
var env = new j$.Env(),
fakeQueue = {
add: jasmine.createSpy()
},
suite = new j$.Suite({
env: env,
description: "I am a suite",
queueFactory: function() {
return fakeQueue
}
}),
fakeSpec = {};
expect(suite.specs.length).toEqual(0);
suite.addSpec(fakeSpec);
expect(suite.specs.length).toEqual(1);
});
it("adds suites", function() {
var env = new j$.Env(),
fakeQueue = {
add: jasmine.createSpy()
},
suite = new j$.Suite({
env: env,
description: "I am a suite",
queueFactory: function() {
return fakeQueue
}
}),
anotherSuite = new j$.Suite({
env: env,
description: "I am another suite",
queueFactory: function() {
return fakeQueue
}
});
expect(suite.suites.length).toEqual(0);
suite.addSuite(anotherSuite);
expect(suite.suites.length).toEqual(1);
});
it("can be disabled", function() {
var env = new j$.Env(),
fakeQueueRunner = jasmine.createSpy('fake queue runner'),
@@ -154,8 +106,8 @@ describe("Suite", function() {
spyOn(suite, "execute");
parentSuite.addSpec(fakeSpec1);
parentSuite.addSuite(suite);
parentSuite.addChild(fakeSpec1);
parentSuite.addChild(suite);
parentSuite.execute(parentSuiteDone);

View File

@@ -3,11 +3,29 @@ describe("Timer", function() {
var fakeNow = jasmine.createSpy('fake Date.now'),
timer = new j$.Timer({now: fakeNow});
fakeNow.and.callReturn(100);
fakeNow.and.returnValue(100);
timer.start();
fakeNow.and.callReturn(200);
fakeNow.and.returnValue(200);
expect(timer.elapsed()).toEqual(100);
});
describe("when date is stubbed, perhaps by other testing helpers", function() {
var origDate = Date;
beforeEach(function() {
Date = jasmine.createSpy('date spy');
});
afterEach(function() {
Date = origDate;
});
it("does not throw even though Date was taken away", function() {
var timer = new j$.Timer();
expect(timer.start).not.toThrow();
expect(timer.elapsed()).toEqual(jasmine.any(Number));
});
});
});

View File

@@ -0,0 +1,149 @@
describe("Custom Matchers (Integration)", function() {
var env;
var fakeTimer;
beforeEach(function() {
env = new j$.Env();
});
it("allows adding more matchers local to a spec", function(done) {
env.it('spec defining a custom matcher', function() {
env.addMatchers({
matcherForSpec: function() {
return {
compare: function(actual, expected) {
return { pass: false, message: "matcherForSpec: actual: " + actual + "; expected: " + expected };
}
}
}
});
env.expect("zzz").matcherForSpec("yyy");
});
env.it("spec without custom matcher defined", function() {
expect(env.expect("zzz").matcherForSpec).toBeUndefined();
});
var specDoneSpy = jasmine.createSpy("specDoneSpy");
var expectations = function() {
var firstSpecResult = specDoneSpy.calls.first().args[0];
expect(firstSpecResult.status).toEqual("failed");
expect(firstSpecResult.failedExpectations[0].message).toEqual("matcherForSpec: actual: zzz; expected: yyy");
done();
};
env.addReporter({ specDone:specDoneSpy, jasmineDone: expectations});
env.execute();
});
it("passes the spec if the custom matcher passes", function(done) {
env.addMatchers({
toBeReal: function() {
return { compare: function() { return { pass: true }; } };
}
});
env.it("spec using custom matcher", function() {
env.expect(true).toBeReal();
});
var specExpectations = function(result) {
expect(result.status).toEqual('passed');
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
});
it("uses the negative compare function for a negative comparison, if provided", function(done) {
env.addMatchers({
toBeReal: function() {
return {
compare: function() { return { pass: true }; },
negativeCompare: function() { return { pass: true }; }
};
}
});
env.it("spec with custom negative comparison matcher", function() {
env.expect(true).not.toBeReal();
});
var specExpectations = function(result) {
expect(result.status).toEqual('passed');
}
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
});
it("generates messages with the same rules as built in matchers absent a custom message", function(done) {
env.addMatchers({
toBeReal: function() {
return {
compare: function() {
return { pass: false };
}
}
}
});
env.it('spec with an expectation', function() {
env.expect("a").toBeReal();
});
var specExpectations = function(result) {
expect(result.failedExpectations[0].message).toEqual("Expected 'a' to be real.");
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
});
it("passes the expected and actual arguments to the comparison function", function(done) {
var argumentSpy = jasmine.createSpy("argument spy").and.returnValue({ pass: true });
env.addMatchers({
toBeReal: function() {
return { compare: argumentSpy };
}
});
env.it('spec with an expectation', function () {
env.expect(true).toBeReal();
env.expect(true).toBeReal("arg");
env.expect(true).toBeReal("arg1", "arg2");
});
var specExpectations = function() {
expect(argumentSpy).toHaveBeenCalledWith(true);
expect(argumentSpy).toHaveBeenCalledWith(true, "arg");
expect(argumentSpy).toHaveBeenCalledWith(true, "arg1", "arg2");
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
});
it("passes the jasmine utility and current equality matchers to the expectation factory", function(done) {
var matcherFactory = function() { return { compare: function() { return {pass: true}; }}; },
argumentSpy = jasmine.createSpy("argument spy").and.returnValue(matcherFactory),
customEqualityFn = function() { return true; };
env.addCustomEqualityTester(customEqualityFn);
env.addMatchers({
toBeReal: argumentSpy
});
env.it("spec with expectation", function() {
env.expect(true).toBeReal();
});
var specExpectations = function() {
expect(argumentSpy).toHaveBeenCalledWith(j$.matchersUtil, [customEqualityFn]);
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
});
});

View File

@@ -0,0 +1,506 @@
describe("Env integration", function() {
it("Suites execute as expected (no nesting)", function(done) {
var env = new j$.Env(),
calls = [];
var assertions = function() {
expect(calls).toEqual([
"with a spec",
"and another spec"
]);
done();
};
env.addReporter({ jasmineDone: assertions});
env.describe("A Suite", function() {
env.it("with a spec", function() {
calls.push("with a spec");
});
env.it("and another spec", function() {
calls.push("and another spec");
});
});
env.execute();
});
it("Nested Suites execute as expected", function(done) {
var env = new j$.Env(),
calls = [];
var assertions = function() {
expect(calls).toEqual([
'an outer spec',
'an inner spec',
'another inner spec'
]);
done();
};
env.addReporter({ jasmineDone: assertions });
env.describe("Outer suite", function() {
env.it("an outer spec", function() {
calls.push('an outer spec')
});
env.describe("Inner suite", function() {
env.it("an inner spec", function() {
calls.push('an inner spec');
});
env.it("another inner spec", function() {
calls.push('another inner spec');
});
});
});
env.execute();
});
it("Multiple top-level Suites execute as expected", function(done) {
var env = new j$.Env(),
calls = [];
var assertions = function() {
expect(calls).toEqual([
'an outer spec',
'an inner spec',
'another inner spec',
'a 2nd outer spec'
]);
done();
};
env.addReporter({ jasmineDone: assertions });
env.describe("Outer suite", function() {
env.it("an outer spec", function() {
calls.push('an outer spec')
});
env.describe("Inner suite", function() {
env.it("an inner spec", function() {
calls.push('an inner spec');
});
env.it("another inner spec", function() {
calls.push('another inner spec');
});
});
});
env.describe("Another outer suite", function() {
env.it("a 2nd outer spec", function() {
calls.push('a 2nd outer spec')
});
});
env.execute();
});
it("calls associated befores/specs/afters with the same 'this'", function(done) {
var env = new j$.Env();
env.addReporter({jasmineDone: done});
env.describe("tests", function() {
var firstTimeThrough = true, firstSpecContext, secondSpecContext;
env.beforeEach(function() {
if (firstTimeThrough) {
firstSpecContext = this;
} else {
secondSpecContext = this;
}
expect(this).toEqual({});
});
env.it("sync spec", function() {
expect(this).toBe(firstSpecContext);
});
env.it("another sync spec", function() {
expect(this).toBe(secondSpecContext);
});
env.afterEach(function() {
if (firstTimeThrough) {
expect(this).toBe(firstSpecContext);
firstTimeThrough = false;
} else {
expect(this).toBe(secondSpecContext);
}
});
});
env.execute();
});
it("calls associated befores/its/afters with the same 'this' for an async spec", function(done) {
var env = new j$.Env();
env.addReporter({jasmineDone: done});
env.describe("with an async spec", function() {
var specContext;
env.beforeEach(function() {
specContext = this;
expect(this).toEqual({});
});
env.it("sync spec", function(underTestCallback) {
expect(this).toBe(specContext);
underTestCallback();
});
env.afterEach(function() {
expect(this).toBe(specContext);
});
});
env.execute();
});
it("Allows specifying which specs and suites to run", function(done) {
var env = new j$.Env(),
calls = [],
suiteCallback = jasmine.createSpy('suite callback'),
firstSpec,
secondSuite;
var assertions = function() {
expect(calls).toEqual([
'third spec',
'first spec'
]);
expect(suiteCallback).toHaveBeenCalled();
done();
};
env.addReporter({jasmineDone: assertions, suiteDone: suiteCallback});
env.describe("first suite", function() {
firstSpec = env.it("first spec", function() {
calls.push('first spec');
});
env.it("second spec", function() {
calls.push('second spec');
});
});
secondSuite = env.describe("second suite", function() {
env.it("third spec", function() {
calls.push('third spec');
});
});
env.execute([secondSuite.id, firstSpec.id]);
});
it("Functions can be spied on and have their calls tracked", function () {
var env = new j$.Env();
var originalFunctionWasCalled = false;
var subject = { spiedFunc: function() { originalFunctionWasCalled = true; } };
var spy = env.spyOn(subject, 'spiedFunc');
expect(subject.spiedFunc).toEqual(spy);
expect(subject.spiedFunc.calls.any()).toEqual(false);
expect(subject.spiedFunc.calls.count()).toEqual(0);
subject.spiedFunc('foo');
expect(subject.spiedFunc.calls.any()).toEqual(true);
expect(subject.spiedFunc.calls.count()).toEqual(1);
expect(subject.spiedFunc.calls.mostRecent().args).toEqual(['foo']);
expect(subject.spiedFunc.calls.mostRecent().object).toEqual(subject);
expect(originalFunctionWasCalled).toEqual(false);
subject.spiedFunc('bar');
expect(subject.spiedFunc.calls.count()).toEqual(2);
expect(subject.spiedFunc.calls.mostRecent().args).toEqual(['bar']);
});
it("Mock clock can be installed and used in tests", function(done) {
var globalSetTimeout = jasmine.createSpy('globalSetTimeout'),
delayedFunctionForGlobalClock = jasmine.createSpy('delayedFunctionForGlobalClock'),
delayedFunctionForMockClock = jasmine.createSpy('delayedFunctionForMockClock'),
env = new j$.Env({global: { setTimeout: globalSetTimeout }});
var assertions = function() {
expect(delayedFunctionForMockClock).toHaveBeenCalled();
expect(globalSetTimeout).toHaveBeenCalledWith(delayedFunctionForGlobalClock, 100);
done();
};
env.addReporter({ jasmineDone: assertions });
env.describe("tests", function() {
env.it("test with mock clock", function() {
env.clock.install();
env.clock.setTimeout(delayedFunctionForMockClock, 100);
env.clock.tick(100);
env.clock.uninstall();
});
env.it("test without mock clock", function() {
env.clock.setTimeout(delayedFunctionForGlobalClock, 100);
});
});
expect(globalSetTimeout).not.toHaveBeenCalled();
expect(delayedFunctionForMockClock).not.toHaveBeenCalled();
env.execute();
});
it("should run async specs in order, waiting for them to complete", function(done) {
var env = new j$.Env(), mutatedVar;
env.describe("tests", function() {
env.beforeEach(function() {
mutatedVar = 2;
});
env.it("async spec", function(underTestCallback) {
setTimeout(function() {
expect(mutatedVar).toEqual(2);
underTestCallback();
done();
}, 0);
});
env.it("after async spec", function() {
mutatedVar = 3;
});
});
env.execute();
});
describe("with a mock clock", function() {
var originalTimeout;
beforeEach(function() {
originalTimeout = j$.DEFAULT_TIMEOUT_INTERVAL;
jasmine.getEnv().clock.install();
});
afterEach(function() {
jasmine.getEnv().clock.uninstall();
j$.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
});
it("should wait a specified interval before failing specs haven't called done yet", function(done) {
var env = new j$.Env(),
reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone" ]);
reporter.specDone.and.callFake(function() {
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({status: 'failed'}));
});
reporter.jasmineDone.and.callFake(function() {
expect(reporter.jasmineDone.calls.count()).toEqual(1);
done();
});
env.addReporter(reporter);
j$.DEFAULT_TIMEOUT_INTERVAL = 8414;
env.it("async spec that doesn't call done", function(underTestCallback) {
env.expect(true).toBeTruthy();
jasmine.getEnv().clock.tick(8416);
});
env.execute();
});
});
// TODO: something is wrong with this spec
it("should report as expected", function(done) {
var env = new j$.Env(),
reporter = jasmine.createSpyObj('fakeReporter', [
"jasmineStarted",
"jasmineDone",
"suiteStarted",
"suiteDone",
"specStarted",
"specDone"
]);
reporter.jasmineDone.and.callFake(function() {
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
totalSpecsDefined: 3
});
var suiteResult = reporter.suiteStarted.calls.first().args[0];
expect(suiteResult.description).toEqual("A Suite");
done();
});
env.addReporter(reporter);
env.describe("A Suite", function() {
env.it("with a top level spec", function() {
env.expect(true).toBe(true);
});
env.describe("with a nested suite", function() {
env.xit("with a pending spec", function() {
env.expect(true).toBe(true);
});
env.it("with a spec", function() {
env.expect(true).toBe(false);
});
});
});
env.execute();
});
it("should be possible to get full name from a spec", function() {
var env = new j$.Env({global: { setTimeout: setTimeout }}),
topLevelSpec, nestedSpec, doublyNestedSpec;
env.describe("my tests", function() {
topLevelSpec = env.it("are sometimes top level", function() {
});
env.describe("are sometimes", function() {
nestedSpec = env.it("singly nested", function() {
});
env.describe("even", function() {
doublyNestedSpec = env.it("doubly nested", function() {
});
});
});
});
expect(topLevelSpec.getFullName()).toBe("my tests are sometimes top level");
expect(nestedSpec.getFullName()).toBe("my tests are sometimes singly nested");
expect(doublyNestedSpec.getFullName()).toBe("my tests are sometimes even doubly nested");
});
it("Custom equality testers should be per spec", function(done) {
var env = new j$.Env({global: { setTimeout: setTimeout }}),
reporter = jasmine.createSpyObj('fakeReporter', [
"jasmineStarted",
"jasmineDone",
"suiteStarted",
"suiteDone",
"specStarted",
"specDone"
]);
reporter.jasmineDone.and.callFake(function() {
var firstSpecResult = reporter.specDone.calls.first().args[0],
secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
expect(firstSpecResult.status).toEqual("passed");
expect(secondSpecResult.status).toEqual("failed");
done();
});
env.addReporter(reporter);
env.describe("testing custom equality testers", function() {
env.it("with a custom tester", function() {
env.addCustomEqualityTester(function(a, b) { return true; });
env.expect("a").toEqual("b");
});
env.it("without a custom tester", function() {
env.expect("a").toEqual("b");
});
});
env.execute();
});
it("Custom matchers should be per spec", function() {
var env = new j$.Env({global: { setTimeout: setTimeout }}),
matchers = {
toFoo: function() {}
},
reporter = jasmine.createSpyObj('fakeReporter', [
"jasmineStarted",
"jasmineDone",
"suiteStarted",
"suiteDone",
"specStarted",
"specDone"
]);
env.addReporter(reporter);
env.describe("testing custom matchers", function() {
env.it("with a custom matcher", function() {
env.addMatchers(matchers);
expect(env.expect().toFoo).toBeDefined();
});
env.it("without a custom matcher", function() {
expect(env.expect().toFoo).toBeUndefined();
});
});
env.execute();
});
it("Custom equality testers for toContain should be per spec", function(done) {
var env = new j$.Env({global: { setTimeout: setTimeout }}),
reporter = jasmine.createSpyObj('fakeReporter', [
"jasmineStarted",
"jasmineDone",
"suiteStarted",
"suiteDone",
"specStarted",
"specDone"
]);
reporter.jasmineDone.and.callFake(function() {
var firstSpecResult = reporter.specDone.calls.first().args[0],
secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
expect(firstSpecResult.status).toEqual("passed");
expect(secondSpecResult.status).toEqual("failed");
done();
});
env.addReporter(reporter);
env.describe("testing custom equality testers", function() {
env.it("with a custom tester", function() {
env.addCustomEqualityTester(function(a, b) { return true; });
env.expect(["a"]).toContain("b");
});
env.it("without a custom tester", function() {
env.expect("a").toContain("b");
});
});
env.execute();
});
it("produces an understandable error message when an 'expect' is used outside of a current spec", function(done) {
var env = new j$.Env();
env.describe("A Suite", function() {
env.it("an async spec that is actually synchronous", function(underTestCallback) {
underTestCallback();
expect(function() { env.expect('a').toEqual('a'); }).toThrowError(/'expect' was used when there was no current spec/);
done();
});
});
env.execute();
});
});

View File

@@ -1,11 +1,9 @@
// TODO: This should really be part of the Env Integration Spec
describe("jasmine spec running", function () {
var env;
var fakeTimer;
beforeEach(function() {
env = new j$.Env();
env.updateInterval = 0;
});
it('should assign spec ids sequentially', function() {
@@ -25,11 +23,11 @@ describe("jasmine spec running", function () {
});
});
expect(it0.id).toEqual(0);
expect(it1.id).toEqual(1);
expect(it2.id).toEqual(2);
expect(it3.id).toEqual(3);
expect(it4.id).toEqual(4);
expect(it0.id).toEqual('spec0');
expect(it1.id).toEqual('spec1');
expect(it2.id).toEqual('spec2');
expect(it3.id).toEqual('spec3');
expect(it4.id).toEqual('spec4');
});
it('nested suites', function (done) {
@@ -305,4 +303,4 @@ describe("jasmine spec running", function () {
));
});
});
});

View File

@@ -1,6 +1,6 @@
describe("matchersUtil", function() {
describe("equals", function() {
it("passes for literals that are threequal", function() {
it("passes for literals that are triple-equal", function() {
expect(j$.matchersUtil.equals(null, null)).toBe(true);
expect(j$.matchersUtil.equals(void 0, void 0)).toBe(true);
});
@@ -153,10 +153,22 @@ describe("matchersUtil", function() {
expect(j$.matchersUtil.equals(1, 2, [tester])).toBe(true);
});
it("passes for two empty Objects", function () {
expect(j$.matchersUtil.equals({}, {})).toBe(true);
});
describe("when a custom equality matcher is installed that returns 'undefined'", function () {
var tester = function(a, b) { return jasmine.undefined; };
it("passes for two empty Objects", function () {
expect(j$.matchersUtil.equals({}, {}, [tester])).toBe(true);
});
});
it("fails for equivalents when a custom equality matcher returns false", function() {
var tester = function(a, b) { return false; };
expect(j$.matchersUtil.equals(1, 2, [tester])).toBe(false);
expect(j$.matchersUtil.equals(1, 1, [tester])).toBe(false);
});
});
@@ -187,6 +199,14 @@ describe("matchersUtil", function() {
expect(j$.matchersUtil.contains([1, 2], 2, [customTester])).toBe(true);
});
it("fails when actual is undefined", function() {
expect(j$.matchersUtil.contains(undefined, 'A')).toBe(false);
});
it("fails when actual is null", function() {
expect(j$.matchersUtil.contains(null, 'A')).toBe(false);
});
});
describe("buildMessage", function() {

View File

@@ -8,7 +8,8 @@ describe("toBeGreaterThan", function() {
});
it("fails when actual <= expected", function() {
var matcher = j$.matchers.toBeGreaterThan();
var matcher = j$.matchers.toBeGreaterThan(),
result;
result = matcher.compare(1, 1);
expect(result.pass).toBe(false);

View File

@@ -9,7 +9,8 @@ describe("toBeNaN", function() {
});
it("fails for anything not a NaN", function() {
var matcher = j$.matchers.toBeNaN();
var matcher = j$.matchers.toBeNaN(),
result;
result = matcher.compare(1);
expect(result.pass).toBe(false);
@@ -31,6 +32,6 @@ describe("toBeNaN", function() {
var matcher = j$.matchers.toBeNaN(),
result = matcher.compare(0);
expect(result.message).toEqual("Expected 0 to be NaN.");
expect(result.message()).toEqual("Expected 0 to be NaN.");
});
});

View File

@@ -9,7 +9,8 @@ describe("toBeUndefined", function() {
});
it("fails when matching defined values", function() {
var matcher = j$.matchers.toBeUndefined();
var matcher = j$.matchers.toBeUndefined(),
result;
result = matcher.compare('foo');
expect(result.pass).toBe(false);

View File

@@ -1,9 +1,10 @@
describe("toContain", function() {
it("delegates to j$.matchersUtil.contains", function() {
var util = {
contains: jasmine.createSpy('delegated-contains').and.callReturn(true)
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
},
matcher = j$.matchers.toContain(util);
matcher = j$.matchers.toContain(util),
result;
result = matcher.compare("ABC", "B");
expect(util.contains).toHaveBeenCalledWith("ABC", "B", []);
@@ -12,10 +13,11 @@ describe("toContain", function() {
it("delegates to j$.matchersUtil.contains, passing in equality testers if present", function() {
var util = {
contains: jasmine.createSpy('delegated-contains').and.callReturn(true)
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
},
customEqualityTesters = ['a', 'b'],
matcher = j$.matchers.toContain(util, customEqualityTesters);
matcher = j$.matchers.toContain(util, customEqualityTesters),
result;
result = matcher.compare("ABC", "B");
expect(util.contains).toHaveBeenCalledWith("ABC", "B", ['a', 'b']);

View File

@@ -1,7 +1,7 @@
describe("toEqual", function() {
it("delegates to equals function", function() {
var util = {
equals: jasmine.createSpy('delegated-equals').and.callReturn(true)
equals: jasmine.createSpy('delegated-equals').and.returnValue(true)
},
matcher = j$.matchers.toEqual(util),
result;
@@ -14,7 +14,7 @@ describe("toEqual", function() {
it("delegates custom equality testers, if present", function() {
var util = {
equals: jasmine.createSpy('delegated-equals').and.callReturn(true)
equals: jasmine.createSpy('delegated-equals').and.returnValue(true)
},
customEqualityTesters = ['a', 'b'],
matcher = j$.matchers.toEqual(util, customEqualityTesters),

View File

@@ -13,7 +13,8 @@ describe("toHaveBeenCalled", function() {
it("fails when the actual was not called", function() {
var matcher = j$.matchers.toHaveBeenCalled(),
uncalledSpy = j$.createSpy('uncalled spy');
uncalledSpy = j$.createSpy('uncalled spy'),
result;
result = matcher.compare(uncalledSpy);
expect(result.pass).toBe(false);

View File

@@ -1,7 +1,7 @@
describe("toHaveBeenCalledWith", function() {
it("passes when the actual was called with matching parameters", function() {
var util = {
contains: jasmine.createSpy('delegated-contains').and.callReturn(true)
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
},
matcher = j$.matchers.toHaveBeenCalledWith(util),
calledSpy = j$.createSpy('called-spy'),
@@ -11,11 +11,26 @@ describe("toHaveBeenCalledWith", function() {
result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(true);
expect(result.message()).toEqual("Expected spy called-spy not to have been called with [ 'a', 'b' ] but it was.");
});
it("passes through the custom equality testers", function() {
var util = {
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
},
customEqualityTesters = [function() { return true; }],
matcher = j$.matchers.toHaveBeenCalledWith(util, customEqualityTesters),
calledSpy = j$.createSpy('called-spy');
calledSpy('a', 'b');
matcher.compare(calledSpy, 'a', 'b');
expect(util.contains).toHaveBeenCalledWith([['a', 'b']], ['a', 'b'], customEqualityTesters);
});
it("fails when the actual was not called", function() {
var util = {
contains: jasmine.createSpy('delegated-contains').and.callReturn(false)
contains: jasmine.createSpy('delegated-contains').and.returnValue(false)
},
matcher = j$.matchers.toHaveBeenCalledWith(util),
uncalledSpy = j$.createSpy('uncalled spy'),
@@ -23,20 +38,23 @@ describe("toHaveBeenCalledWith", function() {
result = matcher.compare(uncalledSpy);
expect(result.pass).toBe(false);
expect(result.message()).toEqual("Expected spy uncalled spy to have been called with [ ] but it was never called.");
});
it("fails when the actual was called with different parameters", function() {
var util = {
contains: jasmine.createSpy('delegated-contains').and.callReturn(false)
contains: jasmine.createSpy('delegated-contains').and.returnValue(false)
},
matcher = j$.matchers.toHaveBeenCalledWith(util),
calledSpy = j$.createSpy('called spy'),
result;
calledSpy('a');
calledSpy('c', 'd');
result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(false);
expect(result.message()).toEqual("Expected spy called spy to have been called with [ 'a', 'b' ] but actual calls were [ 'a' ], [ 'c', 'd' ].");
});
it("throws an exception when the actual is not a spy", function() {
@@ -45,13 +63,4 @@ describe("toHaveBeenCalledWith", function() {
expect(function() { matcher.compare(fn) }).toThrow(new Error("Expected a spy, but got Function."));
});
it("has a custom message on failure", function() {
var matcher = j$.matchers.toHaveBeenCalledWith(),
spy = j$.createSpy('sample-spy'),
messages = matcher.message(spy);
expect(messages.affirmative).toEqual("Expected spy sample-spy to have been called.")
expect(messages.negative).toEqual("Expected spy sample-spy not to have been called.")
});
});

View File

@@ -4,7 +4,7 @@ describe("toThrowError", function() {
expect(function() {
matcher.compare({});
}).toThrow(new Error("Actual is not a Function")); // TODO: this needs to change for self-test
}).toThrowError("Actual is not a Function");
});
it("throws an error when the expected is not an Error, string, or RegExp", function() {
@@ -15,7 +15,7 @@ describe("toThrowError", function() {
expect(function() {
matcher.compare(fn, 1);
}).toThrow(new Error("Expected is not an Error, string, or RegExp.")); // TODO: this needs to change for self-test
}).toThrowError("Expected is not an Error, string, or RegExp.");
});
it("throws an error when the expected error type is not an Error", function() {
@@ -26,7 +26,7 @@ describe("toThrowError", function() {
expect(function() {
matcher.compare(fn, void 0, "foo");
}).toThrow(new Error("Expected error type is not an Error.")); // TODO: this needs to change for self-test
}).toThrowError("Expected error type is not an Error.");
});
it("throws an error when the expected error message is not a string or RegExp", function() {
@@ -37,7 +37,7 @@ describe("toThrowError", function() {
expect(function() {
matcher.compare(fn, Error, 1);
}).toThrow(new Error("Expected error message is not a string or RegExp.")); // TODO: this needs to change for self-test
}).toThrowError("Expected error message is not a string or RegExp.");
});
it("fails if actual does not throw at all", function() {
@@ -62,7 +62,7 @@ describe("toThrowError", function() {
result = matcher.compare(fn);
expect(result.pass).toBe(false);
expect(result.message).toEqual("Expected function to throw an Error, but it threw 4.");
expect(result.message()).toEqual("Expected function to throw an Error, but it threw 4.");
});
it("fails with the correct message if thrown is a falsy value", function() {
@@ -74,7 +74,7 @@ describe("toThrowError", function() {
result = matcher.compare(fn);
expect(result.pass).toBe(false);
expect(result.message).toEqual("Expected function to throw an Error, but it threw undefined.");
expect(result.message()).toEqual("Expected function to throw an Error, but it threw undefined.");
});
it("passes if thrown is a type of Error, but there is no expected error", function() {
@@ -100,7 +100,7 @@ describe("toThrowError", function() {
result = matcher.compare(fn, "foo");
expect(result.pass).toBe(true);
expect(result.message).toEqual("Expected function not to throw an exception with message 'foo'.");
expect(result.message()).toEqual("Expected function not to throw an exception with message 'foo'.");
});
it("fails if thrown is an Error and the expected is not the same message", function() {
@@ -113,7 +113,7 @@ describe("toThrowError", function() {
result = matcher.compare(fn, "bar");
expect(result.pass).toBe(false);
expect(result.message).toEqual("Expected function to throw an exception with message 'bar', but it threw an exception with message 'foo'.");
expect(result.message()).toEqual("Expected function to throw an exception with message 'bar', but it threw an exception with message 'foo'.");
});
it("passes if thrown is an Error and the expected is a RegExp that matches the message", function() {
@@ -126,7 +126,7 @@ describe("toThrowError", function() {
result = matcher.compare(fn, /long/);
expect(result.pass).toBe(true);
expect(result.message).toEqual("Expected function not to throw an exception with a message matching /long/.");
expect(result.message()).toEqual("Expected function not to throw an exception with a message matching /long/.");
});
it("fails if thrown is an Error and the expected is a RegExp that does not match the message", function() {
@@ -139,12 +139,12 @@ describe("toThrowError", function() {
result = matcher.compare(fn, /foo/);
expect(result.pass).toBe(false);
expect(result.message).toEqual("Expected function to throw an exception with a message matching /foo/, but it threw an exception with message 'a long message'.");
expect(result.message()).toEqual("Expected function to throw an exception with a message matching /foo/, but it threw an exception with message 'a long message'.");
});
it("passes if thrown is an Error and the expected the same Error", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.callReturn(true)
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
},
matcher = j$.matchers.toThrowError(util),
fn = function() {
@@ -160,7 +160,7 @@ describe("toThrowError", function() {
it("passes if thrown is a custom error that takes arguments and the expected is the same error", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.callReturn(true)
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
},
matcher = j$.matchers.toThrowError(util),
CustomError = function CustomError(arg) { arg.x },
@@ -180,7 +180,7 @@ describe("toThrowError", function() {
it("fails if thrown is an Error and the expected is a different Error", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.callReturn(false)
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
},
matcher = j$.matchers.toThrowError(util),
fn = function() {
@@ -196,7 +196,7 @@ describe("toThrowError", function() {
it("passes if thrown is a type of Error and it is equal to the expected Error and message", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.callReturn(true)
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
},
matcher = j$.matchers.toThrowError(util),
fn = function() {
@@ -207,12 +207,12 @@ describe("toThrowError", function() {
result = matcher.compare(fn, TypeError, "foo");
expect(result.pass).toBe(true);
expect(result.message).toEqual("Expected function not to throw TypeError with message \"foo\".");
expect(result.message()).toEqual("Expected function not to throw TypeError with message 'foo'.");
});
it("passes if thrown is a custom error that takes arguments and it is equal to the expected custom error and message", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.callReturn(true)
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
},
matcher = j$.matchers.toThrowError(util),
CustomError = function CustomError(arg) { this.message = arg.message },
@@ -227,12 +227,12 @@ describe("toThrowError", function() {
result = matcher.compare(fn, CustomError, "foo");
expect(result.pass).toBe(true);
expect(result.message).toEqual("Expected function not to throw CustomError with message \"foo\".");
expect(result.message()).toEqual("Expected function not to throw CustomError with message 'foo'.");
});
it("fails if thrown is a type of Error and the expected is a different Error", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.callReturn(false)
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
},
matcher = j$.matchers.toThrowError(util),
fn = function() {
@@ -243,12 +243,12 @@ describe("toThrowError", function() {
result = matcher.compare(fn, TypeError, "bar");
expect(result.pass).toBe(false);
expect(result.message).toEqual("Expected function to throw TypeError with message \"bar\", but it threw TypeError with message \"foo\".");
expect(result.message()).toEqual("Expected function to throw TypeError with message 'bar', but it threw TypeError with message 'foo'.");
});
it("passes if thrown is a type of Error and has the same type as the expected Error and the message matches the exepcted message", function() {
it("passes if thrown is a type of Error and has the same type as the expected Error and the message matches the expected message", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.callReturn(true)
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
},
matcher = j$.matchers.toThrowError(util),
fn = function() {
@@ -259,12 +259,12 @@ describe("toThrowError", function() {
result = matcher.compare(fn, TypeError, /foo/);
expect(result.pass).toBe(true);
expect(result.message).toEqual("Expected function not to throw TypeError with message matching /foo/.");
expect(result.message()).toEqual("Expected function not to throw TypeError with message matching /foo/.");
});
it("fails if thrown is a type of Error and the expected is a different Error", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.callReturn(false)
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
},
matcher = j$.matchers.toThrowError(util),
fn = function() {
@@ -275,6 +275,6 @@ describe("toThrowError", function() {
result = matcher.compare(fn, TypeError, /bar/);
expect(result.pass).toBe(false);
expect(result.message).toEqual("Expected function to throw TypeError with message matching /bar/, but it threw TypeError with message \"foo\".");
expect(result.message()).toEqual("Expected function to throw TypeError with message matching /bar/, but it threw TypeError with message 'foo'.");
});
});

View File

@@ -4,7 +4,8 @@ describe("toThrow", function() {
expect(function() {
matcher.compare({});
}).toThrow(new Error("Actual is not a Function")); // TODO: this needs to change for self-test
matcherComparator({});
}).toThrowError("Actual is not a Function");
});
it("fails if actual does not throw", function() {
@@ -22,7 +23,7 @@ describe("toThrow", function() {
it("passes if it throws but there is no expected", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.callReturn(true)
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
},
matcher = j$.matchers.toThrow(util),
fn = function() {
@@ -33,7 +34,7 @@ describe("toThrow", function() {
result = matcher.compare(fn);
expect(result.pass).toBe(true);
expect(result.message).toEqual("Expected function not to throw, but it threw 5.");
expect(result.message()).toEqual("Expected function not to throw, but it threw 5.");
});
it("passes even if what is thrown is falsy", function() {
@@ -45,12 +46,12 @@ describe("toThrow", function() {
result = matcher.compare(fn);
expect(result.pass).toBe(true);
expect(result.message).toEqual("Expected function not to throw, but it threw undefined.");
expect(result.message()).toEqual("Expected function not to throw, but it threw undefined.");
});
it("passes if what is thrown is equivalent to what is expected", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.callReturn(true)
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
},
matcher = j$.matchers.toThrow(util),
fn = function() {
@@ -61,12 +62,12 @@ describe("toThrow", function() {
result = matcher.compare(fn, 5);
expect(result.pass).toBe(true);
expect(result.message).toEqual("Expected function not to throw 5.");
expect(result.message()).toEqual("Expected function not to throw 5.");
});
it("fails if what is thrown is not equivalent to what is expected", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.callReturn(false)
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
},
matcher = j$.matchers.toThrow(util),
fn = function() {
@@ -77,12 +78,12 @@ describe("toThrow", function() {
result = matcher.compare(fn, "foo");
expect(result.pass).toBe(false);
expect(result.message).toEqual("Expected function to throw 'foo', but it threw 5.");
expect(result.message()).toEqual("Expected function to throw 'foo', but it threw 5.");
});
it("fails if what is thrown is not equivalent to undefined", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.callReturn(false)
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
},
matcher = j$.matchers.toThrow(util),
fn = function() {
@@ -93,6 +94,6 @@ describe("toThrow", function() {
result = matcher.compare(fn, void 0);
expect(result.pass).toBe(false);
expect(result.message).toEqual("Expected function to throw undefined, but it threw 5.");
expect(result.message()).toEqual("Expected function to throw undefined, but it threw 5.");
});
});
});

View File

@@ -1,19 +1,23 @@
(function(env) {
env.ieVersion = (function() {
function browserVersion(matchFn) {
var userAgent = jasmine.getGlobal().navigator.userAgent;
if (!userAgent) { return Number.MAX_VALUE; }
if (!userAgent) { return void 0; }
var match = /MSIE ([0-9]{1,}[\.0-9]{0,})/.exec(userAgent);
var match = matchFn(userAgent);
return match ? parseFloat(match[1]) : Number.MAX_VALUE;
})();
return match ? parseFloat(match[1]) : void 0;
}
env.safariVersion = (function() {
var userAgent = jasmine.getGlobal().navigator.userAgent;
if (!userAgent) { return Number.MAX_VALUE; }
env.ieVersion = browserVersion(function(userAgent) {
return /MSIE ([0-9]{1,}[\.0-9]{0,})/.exec(userAgent);
});
var match = /Safari/.exec(userAgent) && /Version\/([0-9]{0,})/.exec(userAgent);
env.safariVersion = browserVersion(function(userAgent) {
return /Safari/.exec(userAgent) && /Version\/([0-9]{0,})/.exec(userAgent);
});
env.firefoxVersion = browserVersion(function(userAgent) {
return /Firefox\/([0-9]{0,})/.exec(userAgent);
});
return match ? parseFloat(match[1]) : Number.MAX_VALUE;
})();
})(jasmine.getEnv());

View File

@@ -0,0 +1,7 @@
(function() {
// By the time onload is called, jasmineRequire will be redefined to point
// to the Jasmine source files (and not jasmine.js). So re-require
window.j$ = jasmineRequire.core(jasmineRequire);
jasmineRequire.html(j$);
jasmineRequire.console(jasmineRequire, j$);
})();

View File

@@ -0,0 +1,33 @@
(function() {
var path = require("path"),
fs = require("fs");
var glob = require("glob");
var j$Require = require(path.join(__dirname, "../../src/core/requireCore.js"));
global.getJasmineRequireObj = function () {
return j$Require;
};
function extend(destination, source) {
for (var property in source) destination[property] = source[property];
return destination;
}
function getSourceFiles() {
var src_files = ['core/**/*.js', 'console/**/*.js', 'version.js'];
src_files.forEach(function(file) {
var filePath = path.join(__dirname, "../../", 'src/', file);
glob.sync(filePath).forEach(function(resolvedFile) {
require(resolvedFile);
});
});
}
extend(j$Require, require(path.join(__dirname,"../../src/console/requireConsole.js")));
getSourceFiles();
global.j$ = j$Require.core(j$Require);
j$Require.console(j$Require, j$);
})();

View File

@@ -13,7 +13,7 @@ describe("New HtmlReporter", function() {
reporter.initialize();
// Main top-level elements
expect(container.querySelector("div.html-reporter")).toBeTruthy();
expect(container.querySelector("div.jasmine_html-reporter")).toBeTruthy();
expect(container.querySelector("div.banner")).toBeTruthy();
expect(container.querySelector("div.alert")).toBeTruthy();
expect(container.querySelector("div.results")).toBeTruthy();
@@ -23,18 +23,36 @@ describe("New HtmlReporter", function() {
// title banner
var banner = container.querySelector(".banner");
var title = banner.querySelector(".title");
expect(title.innerHTML).toMatch(/Jasmine/);
var title = banner.querySelector("a.title");
expect(title.getAttribute('href')).toEqual('http://jasmine.github.io/');
expect(title.getAttribute('target')).toEqual('_blank');
var version = banner.querySelector(".version"),
versionText = 'textContent' in version ? version.textContent : version.innerText;
expect(versionText).toEqual(j$.version);
});
it("builds a single reporter even if initialized multiple times", function() {
var env = new j$.Env(),
container = document.createElement("div"),
getContainer = function() { return container; },
reporter = new j$.HtmlReporter({
env: env,
getContainer: getContainer,
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
});
reporter.initialize();
reporter.initialize();
reporter.initialize();
expect(container.querySelectorAll("div.jasmine_html-reporter").length).toEqual(1);
});
it("starts the timer when jasmine begins", function() {
var env = new jasmine.Env(),
startTimerSpy = jasmine.createSpy("start-timer-spy"),
reporter = new jasmine.HtmlReporter({
reporter = new j$.HtmlReporter({
env: env,
createElement: function() { return document.createElement.apply(document, arguments); },
timer: { start: startTimerSpy }
@@ -46,6 +64,36 @@ describe("New HtmlReporter", function() {
});
describe("when a spec is done", function() {
it("logs errors to the console and prints a special symbol if it is an empty spec", function() {
if (!window.console) {
window.console = { error: function(){} };
}
var env = new j$.Env(),
container = document.createElement('div'),
getContainer = function() {return container;},
reporter = new j$.HtmlReporter({
env: env,
getContainer: getContainer,
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
});
spyOn(console, 'error');
reporter.initialize();
reporter.specDone({
status: "passed",
fullName: 'Some Name',
passedExpectations: [],
failedExpectations: []
});
expect(console.error).toHaveBeenCalledWith("Spec \'Some Name\' has no expectations.");
var specEl = container.querySelector('.symbol-summary li');
expect(specEl.getAttribute("class")).toEqual("empty");
});
it("reports the status symbol of a disabled spec", function() {
var env = new j$.Env(),
container = document.createElement("div"),
@@ -58,7 +106,7 @@ describe("New HtmlReporter", function() {
});
reporter.initialize();
reporter.specDone({id: 789, status: "disabled", fullName: "symbols should have titles"});
reporter.specDone({id: 789, status: "disabled", fullName: "symbols should have titles", passedExpectations: [], failedExpectations: []});
var specEl = container.querySelector('.symbol-summary li');
expect(specEl.getAttribute("class")).toEqual("disabled");
@@ -78,7 +126,7 @@ describe("New HtmlReporter", function() {
});
reporter.initialize();
reporter.specDone({id: 789, status: "pending"});
reporter.specDone({id: 789, status: "pending", passedExpectations: [], failedExpectations: []});
var specEl = container.querySelector('.symbol-summary li');
expect(specEl.getAttribute("class")).toEqual("pending");
@@ -97,7 +145,7 @@ describe("New HtmlReporter", function() {
});
reporter.initialize();
reporter.specDone({id: 123, status: "passed"});
reporter.specDone({id: 123, status: "passed", passedExpectations: [{passed: true}], failedExpectations: []});
var statuses = container.querySelector(".symbol-summary");
var specEl = statuses.querySelector("li");
@@ -121,7 +169,8 @@ describe("New HtmlReporter", function() {
reporter.specDone({
id: 345,
status: "failed",
failedExpectations: []
failedExpectations: [],
passedExpectations: []
});
var specEl = container.querySelector(".symbol-summary li");
@@ -131,6 +180,44 @@ describe("New HtmlReporter", function() {
});
describe("when Jasmine is done", function() {
it("adds EMPTY to the link title of specs that have no expectations", function() {
if (!window.console) {
window.console = { error: function(){} };
}
var env = new j$.Env(),
container = document.createElement('div'),
getContainer = function() {return container;},
reporter = new j$.HtmlReporter({
env: env,
getContainer: getContainer,
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
});
spyOn(console, 'error');
reporter.initialize();
reporter.jasmineStarted({});
reporter.suiteStarted({id: 1});
reporter.specStarted({id: 1, status: 'passed', passedExpectations: [], failedExpectations: []});
reporter.specDone({
id: 1,
status: 'passed',
description: 'Spec Description',
passedExpectations: [],
failedExpectations: []
});
reporter.suiteDone({id: 1});
reporter.jasmineDone({});
var summary = container.querySelector('.summary');
var suite = summary.childNodes[0];
var specs = suite.childNodes[1];
var spec = specs.childNodes[0];
var specLink = spec.childNodes[0];
expect(specLink.innerHTML).toMatch(/SPEC HAS NO EXPECTATIONS/);
});
it("reports the run time", function() {
var env = new j$.Env(),
container = document.createElement("div"),
@@ -148,7 +235,7 @@ describe("New HtmlReporter", function() {
reporter.jasmineStarted({});
timer.elapsed.and.callReturn(100);
timer.elapsed.and.returnValue(100);
reporter.jasmineDone();
var duration = container.querySelector(".banner .duration");
@@ -178,7 +265,9 @@ describe("New HtmlReporter", function() {
id: 123,
description: "with a spec",
fullName: "A Suite with a spec",
status: "passed"
status: "passed",
failedExpectations: [],
passedExpectations: [{passed: true}]
};
reporter.specStarted(specResult);
reporter.specDone(specResult);
@@ -193,7 +282,9 @@ describe("New HtmlReporter", function() {
id: 124,
description: "with another spec",
fullName: "A Suite inner suite with another spec",
status: "passed"
status: "passed",
failedExpectations: [],
passedExpectations: [{passed: true}]
};
reporter.specStarted(specResult);
reporter.specDone(specResult);
@@ -205,7 +296,8 @@ describe("New HtmlReporter", function() {
description: "with a failing spec",
fullName: "A Suite inner with a failing spec",
status: "failed",
failedExpectations: []
failedExpectations: [{}],
passedExpectations: []
};
reporter.specStarted(specResult);
reporter.specDone(specResult);
@@ -321,12 +413,33 @@ describe("New HtmlReporter", function() {
});
});
it("shows a message if no specs are run", function(){
var env, container, reporter;
env = new j$.Env();
container = document.createElement("div");
var getContainer = function() { return container; },
reporter = new j$.HtmlReporter({
env: env,
getContainer: getContainer,
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
});
reporter.initialize();
reporter.jasmineStarted({});
reporter.jasmineDone({});
var alertBars = container.querySelectorAll(".alert .bar");
expect(alertBars[0].getAttribute('class')).toMatch(/skipped/);
expect(alertBars[0].innerHTML).toMatch(/No specs found/);
});
describe("and all specs pass", function() {
var env, container, reporter;
beforeEach(function() {
env = new j$.Env();
container = document.createElement("div");
getContainer = function() { return container; },
var getContainer = function() { return container; },
reporter = new j$.HtmlReporter({
env: env,
getContainer: getContainer,
@@ -335,18 +448,22 @@ describe("New HtmlReporter", function() {
});
reporter.initialize();
reporter.jasmineStarted({});
reporter.jasmineStarted({ totalSpecsDefined: 2 });
reporter.specDone({
id: 123,
description: "with a spec",
fullName: "A Suite with a spec",
status: "passed"
status: "passed",
passedExpectations: [{passed: true}],
failedExpectations: []
});
reporter.specDone({
id: 124,
description: "with another spec",
fullName: "A Suite inner suite with another spec",
status: "passed"
status: "passed",
passedExpectations: [{passed: true}],
failedExpectations: []
});
reporter.jasmineDone({});
});
@@ -377,21 +494,23 @@ describe("New HtmlReporter", function() {
beforeEach(function() {
env = new j$.Env();
container = document.createElement("div");
getContainer = function() { return container; },
reporter = new j$.HtmlReporter({
env: env,
getContainer: getContainer,
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
});
var getContainer = function() { return container; };
reporter = new j$.HtmlReporter({
env: env,
getContainer: getContainer,
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
});
reporter.initialize();
reporter.jasmineStarted({});
reporter.jasmineStarted({ totalSpecsDefined: 1 });
reporter.specDone({
id: 123,
description: "with a spec",
fullName: "A Suite with a spec",
status: "pending"
status: "pending",
passedExpectations: [],
failedExpectations: []
});
reporter.jasmineDone({});
});
@@ -414,19 +533,19 @@ describe("New HtmlReporter", function() {
beforeEach(function() {
env = new j$.Env();
container = document.createElement("div"),
getContainer = function() { return container; },
reporter = new j$.HtmlReporter({
env: env,
getContainer: getContainer,
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
});
container = document.createElement("div");
var getContainer = function() { return container; }
reporter = new j$.HtmlReporter({
env: env,
getContainer: getContainer,
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
});
reporter.initialize();
reporter.jasmineStarted({});
reporter.jasmineStarted({ totalSpecsDefined: 1 });
var passingResult = {id: 123, status: "passed"};
var passingResult = {id: 123, status: "passed", passedExpectations: [{passed: true}], failedExpectations: []};
reporter.specStarted(passingResult);
reporter.specDone(passingResult);
@@ -435,6 +554,7 @@ describe("New HtmlReporter", function() {
status: "failed",
description: "a failing spec",
fullName: "a suite with a failing spec",
passedExpectations: [],
failedExpectations: [
{
message: "a failure message",
@@ -461,8 +581,10 @@ describe("New HtmlReporter", function() {
expect(failure.getAttribute("class")).toMatch(/failed/);
expect(failure.getAttribute("class")).toMatch(/spec-detail/);
var specLink = failure.childNodes[0];
expect(specLink.getAttribute("class")).toEqual("description");
var specDiv = failure.childNodes[0];
expect(specDiv.getAttribute("class")).toEqual("description");
var specLink = specDiv.childNodes[0];
expect(specLink.getAttribute("title")).toEqual("a suite with a failing spec");
expect(specLink.getAttribute("href")).toEqual("?spec=a%20suite%20with%20a%20failing%20spec");
@@ -486,7 +608,7 @@ describe("New HtmlReporter", function() {
});
it("sets the reporter to 'Failures List' mode", function() {
var reporterNode = container.querySelector(".html-reporter");
var reporterNode = container.querySelector(".jasmine_html-reporter");
expect(reporterNode.getAttribute("class")).toMatch("failure-list");
});
});

View File

@@ -15,4 +15,4 @@ describe("j$.HtmlSpecFilter", function() {
expect(specFilter.matches("foo")).toBe(true);
expect(specFilter.matches("bar")).toBe(false);
});
});
});

View File

@@ -3,7 +3,6 @@ describe("MatchersSpec - HTML Dependent", function () {
beforeEach(function() {
env = new j$.Env();
env.updateInterval = 0;
var suite = env.describe("suite", function() {
spec = env.it("spec", function() {

View File

@@ -3,6 +3,13 @@ describe("j$.pp (HTML Dependent)", function () {
var sampleNode = document.createElement('div');
sampleNode.innerHTML = 'foo<b>bar</b>';
expect(j$.pp(sampleNode)).toEqual("HTMLNode");
expect(j$.pp({foo: sampleNode})).toEqual("{ foo : HTMLNode }");
expect(j$.pp({foo: sampleNode})).toEqual("{ foo: HTMLNode }");
});
it("should print Firefox's wrapped native objects correctly", function() {
if(jasmine.getEnv().firefoxVersion) {
try { new CustomEvent(); } catch(e) { var err = e; };
expect(j$.pp(err)).toMatch(/Not enough arguments/);
}
});
});

View File

@@ -40,4 +40,4 @@ describe("QueryString", function() {
expect(queryString.getParam("baz")).toBeFalsy();
});
});
});
});

Some files were not shown because too many files have changed in this diff Show More