Compare commits

..

6 Commits

Author SHA1 Message Date
Gregg Van Hove
02c18a3596 Bump version to 2.6.4 2017-06-16 13:41:59 -07:00
Steve Gravrock
0c6397d802 Don't setTimeout() every time the stack is cleared via MessageChannel() 2017-06-16 13:37:07 -07:00
Gregg Van Hove
eb4671452e Don't use window 2017-06-15 14:33:23 -07:00
Gregg Van Hove
b38decf050 Break into a setTimeout every once in a while
- Allows the CPU to run other things that used the real `setTimeout`

- Fixes #1327
- See #1334
- Fixes jasmine/gulp-jasmine-browser#48
2017-06-15 14:21:33 -07:00
Gregg Van Hove
ca5b1de2eb bump version to 2.6.3 2017-06-07 13:41:22 -07:00
Steve Gravrock
a3bc74776a Make sure the queue runner goes async for async specs
- Even if `done` is called synchronously.

See #1327 #1334 jasmine/gulp-jasmine-browser#48

This is a backport of 578f63b9bd
to 2.6.x.
2017-06-06 15:49:37 -07:00
53 changed files with 352 additions and 2294 deletions

View File

@@ -1,44 +1,17 @@
## Are you creating an issue in the correct repository?
### Are you creating an issue in the correct repository?
- When in doubt, create an issue here.
- If you have an issue with the Jasmine docs, file an issue in the docs repo
here: https://github.com/jasmine/jasmine.github.io
- This repository is for the core Jasmine framework
- If you are using a test runner that wraps Jasmine, consider filing an issue with that library if appropriate:
- [Jasmine npm](https://github.com/jasmine/jasmine-npm/issues)
- [Jasmine gem](https://github.com/jasmine/jasmine-gem/issues)
- [Jasmine py](https://github.com/jasmine/jasmine-py/issues)
- [Gulp Jasmine Browser](https://github.com/jasmine/gulp-jasmine-browser/issues)
- [Karma](https://github.com/karma-runner/karma/issues)
- [Grunt Contrib Jasmine](https://github.com/gruntjs/grunt-contrib-jasmine/issues)
- If you are using a test runner that wraps Jasmine (Jasmine npm, karma, etc),
consider filing an issue with that library if appropriate
<!--- Provide a general summary of the issue in the Title above -->
### When submitting an issue, please answer the following:
## Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->
- What version are you using?
- What environment are you running Jasmine in (node, browser, etc)?
- How are you running Jasmine (standalone, npm, karma, etc)?
- If possible, include an example spec that demonstrates your issue.
## Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
## Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
<!--- or ideas how to implement the addition or change -->
## Suite that reproduces the behavior (for bugs)
<!--- Provide a sample suite that reproduces the bug. -->
```javascript
describe("sample", function() {
});
```
## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used:
* Environment name and version (e.g. Chrome 39, node.js 5.4):
* Operating System and version (desktop or mobile):
* Link to your project:
Thanks for using Jasmine!

View File

@@ -1,30 +0,0 @@
<!--- Provide a general summary of your changes in the Title above -->
## Description
<!--- Describe your changes in detail -->
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->
## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the **CONTRIBUTING** document.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.

View File

@@ -1,46 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at jasmine-maintainers@googlegroups.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View File

@@ -43,12 +43,12 @@ To install Jasmine standalone on your local box (where **_{#.#.#}_** below is su
Add the following to your HTML file:
```html
<link rel="shortcut icon" type="image/png" href="jasmine/lib/jasmine-{#.#.#}/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="jasmine/lib/jasmine-{#.#.#}/jasmine.css">
<link rel="shortcut icon" type="image/png" href="jasmine/lib/jasmine-core/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="jasmine/lib/jasmine-core/jasmine.css">
<script type="text/javascript" src="jasmine/lib/jasmine-{#.#.#}/jasmine.js"></script>
<script type="text/javascript" src="jasmine/lib/jasmine-{#.#.#}/jasmine-html.js"></script>
<script type="text/javascript" src="jasmine/lib/jasmine-{#.#.#}/boot.js"></script>
<script type="text/javascript" src="jasmine/lib/jasmine-core/jasmine.js"></script>
<script type="text/javascript" src="jasmine/lib/jasmine-core/jasmine-html.js"></script>
<script type="text/javascript" src="jasmine/lib/jasmine-core/boot.js"></script>
```
## Supported environments

View File

@@ -40,10 +40,7 @@ When ready to release - specs are all green and the stories are done:
### Release the Python egg
Install [twine](https://github.com/pypa/twine)
1. `python setup.py sdist`
1. `twine upload dist/jasmine-core-<version>.tar.gz` You will need pypi credentials to upload the egg.
1. `python setup.py register sdist upload` You will need pypi credentials to upload the egg.
### Release the Ruby gem

View File

@@ -1,6 +1,6 @@
{
"name": "jasmine-core",
"homepage": "https://jasmine.github.io",
"homepage": "http://jasmine.github.io",
"authors": [
"slackersoft <gregg@slackersoft.net>"
],

View File

@@ -210,7 +210,7 @@ jasmineRequire.HtmlReporter = function(j$) {
if (specsExecuted < totalSpecsDefined) {
var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
var skippedLink = addToExistingQueryString('spec', '');
var skippedLink = order && order.random ? '?random=true' : '?';
alert.appendChild(
createDom('span', {className: 'jasmine-bar jasmine-skipped'},
createDom('a', {href: skippedLink, title: 'Run all specs'}, skippedMessage)

File diff suppressed because it is too large Load Diff

View File

@@ -4,6 +4,6 @@
#
module Jasmine
module Core
VERSION = "2.8.0"
VERSION = "2.6.4"
end
end

View File

@@ -1,7 +1,7 @@
{
"name": "jasmine-core",
"license": "MIT",
"version": "2.8.0",
"version": "2.6.4",
"repository": {
"type": "git",
"url": "https://github.com/jasmine/jasmine.git"
@@ -19,7 +19,7 @@
"homepage": "http://jasmine.github.io",
"main": "./lib/jasmine-core.js",
"devDependencies": {
"glob": "~7.1.2",
"glob": "~7.0.5",
"grunt": "^1.0.1",
"grunt-cli": "^1.2.0",
"grunt-contrib-compass": "^1.1.1",

View File

@@ -1,61 +0,0 @@
# Jasmine 2.7.0 Release Notes
## Summary
This release contains a number of fixes and pull requests.
## Pull Requests & Issues
* Add class UserContext
- Merges [#1400](https://github.com/jasmine/jasmine/issues/1400) from @darthjee
* Send unfocused tests through the same queue as focused tests
- Merges [#1399](https://github.com/jasmine/jasmine/issues/1399) from @jberney
* PrettyPrinter allows an object to have a `toString` that isn't a function
- Fixes [#1389](https://github.com/jasmine/jasmine/issues/1389)
* Fix rounding in toBeCloseTo
- Fixes [#1382](https://github.com/jasmine/jasmine/issues/1382)
* When stop on failure is enabled, skip subsequent it() and beforeEach(). Note: afterEach() functions are still run, because skipping them is highly likely to pollute specs that run after the failure.
- Fixes [#577](https://github.com/jasmine/jasmine/issues/577)
- Fixes [#807](https://github.com/jasmine/jasmine/issues/807)
* Only clear out the `spec` param for Run all link
- Fixes [#1369](https://github.com/jasmine/jasmine/issues/1369)
* Pretty printer will now use MAX_PRETTY_PRINT_ARRAY_LENGTH for objects
- Fixes [#1291](https://github.com/jasmine/jasmine/issues/1291)
- Fixes [#1360](https://github.com/jasmine/jasmine/issues/1360)
* updated package glob from 7.0.5 to 7.1.2
- Merges [#1368](https://github.com/jasmine/jasmine/issues/1368) from @EsrefDurna
* Fix bower.json url to be https instead of http
- Merges [#1365](https://github.com/jasmine/jasmine/issues/1365) from @kant
* Fail when one of the arguments passed into toBeCloseTo matcher is null
- Merges [#1362](https://github.com/jasmine/jasmine/issues/1362) from @beatrichartz
* Fixed HTML snippet in README
- Closes [#1366](https://github.com/jasmine/jasmine/issues/1366).
* Report the random seed at the beginning and end of execution. This allows reporters to provide the seed to the user even in cases where Jasmine crashes before completing.
- Merges [#1348](https://github.com/jasmine/jasmine/issues/1348) from @sgravrock
* Add ES6 map support to Jasmine
- Merges [#1340](https://github.com/jasmine/jasmine/issues/1340) from @rmehlinger
- Fixes [#1257](https://github.com/jasmine/jasmine/issues/1257)
* Added support for async before/it/after functions that return promises and added support for ES2017 async functions
- Merges [#1356](https://github.com/jasmine/jasmine/issues/1356) from @sgravrock
- Fixes [#1336](https://github.com/jasmine/jasmine/issues/1336)
- Fixes [#1270](https://github.com/jasmine/jasmine/issues/1270)
- Fixes [#1350](https://github.com/jasmine/jasmine/issues/1350)
- Fixes [#1320](https://github.com/jasmine/jasmine/issues/1320)
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

View File

@@ -1,52 +0,0 @@
# Jasmine 2.8.0 Release Notes
## Summary
This release contains a number of fixes and pull requests.
2.8 should be the last 2.x release of Jasmine, as we aim for 3.0.
## Changes
* Create CODE_OF_CONDUCT.md
* Add jsdocs for reporter events
* Update jsApiReporter docs to link to new suite and spec results
* Add explicit docs for the callback function passed to `it` etc.
* Update afterAll documentation
## Pull Requests & Issues
* Add 'nothing' matcher and tests
- Merges [#1412](https://github.com/jasmine/jasmine/issues/1412) from @ksvitkovsky
- Fixes [#1221](https://github.com/jasmine/jasmine/issues/1221)
* Make toEqual matcher report the difference between array elements when arrays have different length
- Closes [#1375](https://github.com/jasmine/jasmine/issues/1375) from @kiewic
* Add arrayWithExactContents asymmetric matcher
- Fixes [#817](https://github.com/jasmine/jasmine/issues/817)
* Ensure no message added on asym. match success
- Closes [#1408](https://github.com/jasmine/jasmine/issues/1408) from @ksvitkovsky
- Fixes [#1388](https://github.com/jasmine/jasmine/issues/1388)
* Better primitives detection for saveArgsByValue
- Closes [#1407](https://github.com/jasmine/jasmine/issues/1407) from @ksvitkovsky
- Fixes [#1403](https://github.com/jasmine/jasmine/issues/1403)
* Better pretty printing for typed arrays
- Closes [#1404](https://github.com/jasmine/jasmine/issues/1404) from @ksvitkovsky
- Fixes [#1180](https://github.com/jasmine/jasmine/issues/1180)
* Rewrite ES6 Set and Map comparison to ignore insertion order
- Merges [#1406](https://github.com/jasmine/jasmine/issues/1406) from @theefer
- Fixes [#1402](https://github.com/jasmine/jasmine/issues/1402)
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

View File

@@ -117,14 +117,4 @@ describe("CallTracker", function() {
expect(callTracker.mostRecent().args[1]).not.toBe(arrayArg);
expect(callTracker.mostRecent().args[1]).toEqual(arrayArg);
});
it('saves primitive arguments by value', function() {
var callTracker = new jasmineUnderTest.CallTracker(),
args = [undefined, null, false, '', /\s/, 0, 1.2, NaN];
callTracker.saveArgumentsByValue();
callTracker.track({ object: {}, args: args });
expect(callTracker.mostRecent().args).toEqual(args);
});
});

View File

@@ -91,13 +91,6 @@ describe("Env", function() {
env.it('pending spec');
}).not.toThrow();
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.it('async', jasmine.getEnv().makeAsyncAwaitFunction());
}).not.toThrow();
});
});
describe('#xit', function() {
@@ -121,13 +114,6 @@ describe("Env", function() {
env.xit('pending spec');
}).not.toThrow();
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.xit('async', jasmine.getEnv().makeAsyncAwaitFunction());
}).not.toThrow();
});
});
describe('#fit', function () {
@@ -144,13 +130,6 @@ describe("Env", function() {
env.beforeEach(undefined);
}).toThrowError(/beforeEach expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/);
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.beforeEach(jasmine.getEnv().makeAsyncAwaitFunction());
}).not.toThrow();
});
});
describe('#beforeAll', function () {
@@ -159,13 +138,6 @@ describe("Env", function() {
env.beforeAll(undefined);
}).toThrowError(/beforeAll expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/);
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.beforeAll(jasmine.getEnv().makeAsyncAwaitFunction());
}).not.toThrow();
});
});
describe('#afterEach', function () {
@@ -174,13 +146,6 @@ describe("Env", function() {
env.afterEach(undefined);
}).toThrowError(/afterEach expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/);
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.afterEach(jasmine.getEnv().makeAsyncAwaitFunction());
}).not.toThrow();
});
});
describe('#afterAll', function () {
@@ -189,12 +154,5 @@ describe("Env", function() {
env.afterAll(undefined);
}).toThrowError(/afterAll expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/);
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.afterAll(jasmine.getEnv().makeAsyncAwaitFunction());
}).not.toThrow();
});
});
});

View File

@@ -33,26 +33,6 @@ describe("jasmineUnderTest.pp", function () {
})
});
describe('stringify maps', function() {
it("should stringify maps properly", function() {
jasmine.getEnv().requireFunctioningMaps();
expect(jasmineUnderTest.pp(new Map([[1, 2]]))).toEqual("Map( [ 1, 2 ] )");
});
it("should truncate maps with more elments than jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH", function() {
jasmine.getEnv().requireFunctioningMaps();
var originalMaxSize = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH;
try {
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
expect(jasmineUnderTest.pp(new Map([["a", 1], ["b", 2], ["c", 3]]))).toEqual("Map( [ 'a', 1 ], [ 'b', 2 ], ... )");
} finally {
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxSize;
}
})
});
describe('stringify arrays', function() {
it("should stringify arrays properly", function() {
expect(jasmineUnderTest.pp([1, 2])).toEqual("[ 1, 2 ]");
@@ -119,18 +99,6 @@ describe("jasmineUnderTest.pp", function () {
}, bar: [1, 2, 3]})).toEqual("Object({ foo: Function, bar: [ 1, 2, 3 ] })");
});
it("should truncate objects with too many keys", function () {
var originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH;
var long = {a: 1, b: 2, c: 3};
try {
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
expect(jasmineUnderTest.pp(long)).toEqual("Object({ a: 1, b: 2, ... })");
} finally {
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxLength;
}
});
it("should print 'null' as the constructor of an object with its own constructor property", function() {
expect(jasmineUnderTest.pp({constructor: function() {}})).toContain("null({");
expect(jasmineUnderTest.pp({constructor: 'foo'})).toContain("null({");
@@ -257,18 +225,6 @@ describe("jasmineUnderTest.pp", function () {
}
});
it("should stringify objects have have a toString that isn't a function", function() {
var obj = {
toString: "foo"
};
if (jasmine.getEnv().ieVersion < 9) {
expect(jasmineUnderTest.pp(obj)).toEqual("Object({ })");
} else {
expect(jasmineUnderTest.pp(obj)).toEqual("Object({ toString: 'foo' })");
}
});
it("should stringify objects from anonymous constructors with custom toString", function () {
var MyAnonymousConstructor = (function() { return function () {}; })();
MyAnonymousConstructor.toString = function () { return ''; };

View File

@@ -19,26 +19,6 @@ describe("QueueRunner", function() {
expect(calls).toEqual(['fn1', 'fn2']);
});
it("runs cleanup functions after the others", function() {
var calls = [],
queueableFn1 = { fn: jasmine.createSpy('fn1') },
queueableFn2 = { fn: jasmine.createSpy('fn2') },
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn1],
cleanupFns: [queueableFn2]
});
queueableFn1.fn.and.callFake(function() {
calls.push('fn1');
});
queueableFn2.fn.and.callFake(function() {
calls.push('fn2');
});
queueRunner.execute();
expect(calls).toEqual(['fn1', 'fn2']);
});
it("calls each function with a consistent 'this'-- an empty object", function() {
var queueableFn1 = { fn: jasmine.createSpy('fn1') },
queueableFn2 = { fn: jasmine.createSpy('fn2') },
@@ -51,7 +31,7 @@ describe("QueueRunner", function() {
queueRunner.execute();
var context = queueableFn1.fn.calls.first().object;
expect(context).toEqual(new jasmineUnderTest.UserContext());
expect(context).toEqual({});
expect(queueableFn2.fn.calls.first().object).toBe(context);
expect(asyncContext).toBe(context);
});
@@ -190,6 +170,7 @@ describe("QueueRunner", function() {
queueRunner.execute();
jasmine.clock().tick();
expect(onComplete).toHaveBeenCalled();
expect(onException).toHaveBeenCalled();
@@ -322,84 +303,6 @@ describe("QueueRunner", function() {
});
});
describe("with a function that returns a promise", function() {
function StubPromise() {}
StubPromise.prototype.then = function(resolve, reject) {
this.resolveHandler = resolve;
this.rejectHandler = reject;
};
beforeEach(function() {
jasmine.clock().install();
});
afterEach(function() {
jasmine.clock().uninstall();
});
it("runs the function asynchronously, advancing once the promise is settled", function() {
var onComplete = jasmine.createSpy('onComplete'),
fnCallback = jasmine.createSpy('fnCallback'),
p1 = new StubPromise(),
p2 = new StubPromise(),
queueableFn1 = { fn: function() {
setTimeout(function() {
p1.resolveHandler();
}, 100);
return p1;
} };
queueableFn2 = { fn: function() {
fnCallback();
setTimeout(function() {
p2.resolveHandler();
}, 100);
return p2;
} },
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn1, queueableFn2],
onComplete: onComplete
});
queueRunner.execute();
expect(fnCallback).not.toHaveBeenCalled();
expect(onComplete).not.toHaveBeenCalled();
jasmine.clock().tick(100);
expect(fnCallback).toHaveBeenCalled();
expect(onComplete).not.toHaveBeenCalled();
jasmine.clock().tick(100);
expect(onComplete).toHaveBeenCalled();
});
it("fails the function when the promise is rejected", function() {
var promise = new StubPromise(),
queueableFn1 = { fn: function() {
setTimeout(function() { promise.rejectHandler('foo'); }, 100);
return promise;
} },
queueableFn2 = { fn: jasmine.createSpy('fn2') },
failFn = jasmine.createSpy('fail'),
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn1, queueableFn2],
fail: failFn
});
queueRunner.execute();
expect(failFn).not.toHaveBeenCalled();
expect(queueableFn2.fn).not.toHaveBeenCalled();
jasmine.clock().tick(100);
expect(failFn).toHaveBeenCalledWith('foo');
expect(queueableFn2.fn).toHaveBeenCalled();
});
});
it("calls exception handlers when an exception is thrown in a fn", function() {
var queueableFn = { type: 'queueable',
fn: function() {
@@ -433,95 +336,20 @@ describe("QueueRunner", function() {
it("continues running the functions even after an exception is thrown in an async spec", function() {
var queueableFn = { fn: function(done) { throw new Error("error"); } },
nextQueueableFn = { fn: jasmine.createSpy("nextFunction") },
timeout = { setTimeout: jasmine.createSpy("setTimeout"),
clearTimeout: jasmine.createSpy("setTimeout")
},
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn, nextQueueableFn]
queueableFns: [queueableFn, nextQueueableFn],
timeout: timeout
});
queueRunner.execute();
timeout.setTimeout.calls.argsFor(0)[0]();
expect(nextQueueableFn.fn).toHaveBeenCalled();
});
describe("When configured to complete on first error", function() {
it("skips to cleanup functions on the first exception", function() {
var queueableFn = { fn: function() { throw new Error("error"); } },
nextQueueableFn = { fn: jasmine.createSpy("nextFunction") },
cleanupFn = { fn: jasmine.createSpy("cleanup") },
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn, nextQueueableFn],
cleanupFns: [cleanupFn],
completeOnFirstError: true
});
queueRunner.execute();
expect(nextQueueableFn.fn).not.toHaveBeenCalled();
expect(cleanupFn.fn).toHaveBeenCalled();
});
it("does not skip when a cleanup function throws", function() {
var queueableFn = { fn: function() { } },
cleanupFn1 = { fn: function() { throw new Error("error"); } },
cleanupFn2 = { fn: jasmine.createSpy("cleanupFn2") },
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn],
cleanupFns: [cleanupFn1, cleanupFn2],
completeOnFirstError: true
});
queueRunner.execute();
expect(cleanupFn2.fn).toHaveBeenCalled();
});
describe("with an asynchronous function", function() {
beforeEach(function() {
jasmine.clock().install();
});
afterEach(function() {
jasmine.clock().uninstall();
});
it("skips to cleanup functions on the first exception", function() {
var errorListeners = [],
queueableFn = { fn: function(done) {} },
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
cleanupFn = { fn: jasmine.createSpy('cleanup') },
queueRunner = new jasmineUnderTest.QueueRunner({
globalErrors: {
pushListener: function(f) { errorListeners.push(f); },
popListener: function() { errorListeners.pop(); },
},
queueableFns: [queueableFn, nextQueueableFn],
cleanupFns: [cleanupFn],
completeOnFirstError: true,
});
queueRunner.execute();
errorListeners[errorListeners.length - 1](new Error('error'));
expect(nextQueueableFn.fn).not.toHaveBeenCalled();
expect(cleanupFn.fn).toHaveBeenCalled();
});
it("skips to cleanup functions when next.fail is called", function() {
var queueableFn = { fn: function(done) {
done.fail('nope');
} },
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
cleanupFn = { fn: jasmine.createSpy('cleanup') },
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn, nextQueueableFn],
cleanupFns: [cleanupFn],
completeOnFirstError: true,
});
queueRunner.execute();
jasmine.clock().tick();
expect(nextQueueableFn.fn).not.toHaveBeenCalled();
expect(cleanupFn.fn).toHaveBeenCalled();
});
});
});
it("calls a provided complete callback when done", function() {
var queueableFn = { fn: jasmine.createSpy('fn') },
completeCallback = jasmine.createSpy('completeCallback'),
@@ -565,53 +393,4 @@ describe("QueueRunner", function() {
expect(completeCallback).toHaveBeenCalled();
});
});
describe('when user context has not been defined', function() {
beforeEach(function() {
var fn;
this.fn = fn = jasmine.createSpy('fn1');
this.queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [{ fn: fn }]
});
});
it('runs the functions on the scope of a UserContext', function() {
var calls = [],
context;
this.fn.and.callFake(function() {
context = this;
});
this.queueRunner.execute();
expect(context.constructor).toBe(jasmineUnderTest.UserContext);
});
});
describe('when user context has been defined', function() {
beforeEach(function() {
var fn, context;
this.fn = fn = jasmine.createSpy('fn1');
this.context = context = new jasmineUnderTest.UserContext();
this.queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [{ fn: fn }],
userContext: context
});
});
it('runs the functions on the scope of a UserContext', function() {
var calls = [],
context;
this.fn.and.callFake(function() {
context = this;
});
this.queueRunner.execute();
expect(context).toBe(this.context);
});
});
});

View File

@@ -103,26 +103,8 @@ describe("Spec", function() {
spec.execute();
var options = fakeQueueRunner.calls.mostRecent().args[0];
expect(options.queueableFns).toEqual([before, queueableFn]);
expect(options.cleanupFns).toEqual([after]);
});
it("tells the queue runner that it's a leaf node", function() {
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
spec = new jasmineUnderTest.Spec({
queueableFn: { fn: function() {} },
beforeAndAfterFns: function() {
return {befores: [], afters: []}
},
queueRunnerFactory: fakeQueueRunner
});
spec.execute();
expect(fakeQueueRunner).toHaveBeenCalledWith(jasmine.objectContaining({
isLeaf: true
}));
var allSpecFns = fakeQueueRunner.calls.mostRecent().args[0].queueableFns;
expect(allSpecFns).toEqual([before, queueableFn, after]);
});
it("is marked pending if created without a function body", function() {
@@ -141,8 +123,7 @@ describe("Spec", function() {
});
it("can be disabled, but still calls callbacks", function() {
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner')
.and.callFake(function(attrs) { attrs.onComplete(); }),
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
startCallback = jasmine.createSpy('startCallback'),
specBody = jasmine.createSpy('specBody'),
resultCallback = jasmine.createSpy('resultCallback'),
@@ -159,7 +140,7 @@ describe("Spec", function() {
spec.execute();
expect(fakeQueueRunner).toHaveBeenCalled();
expect(fakeQueueRunner).not.toHaveBeenCalled();
expect(specBody).not.toHaveBeenCalled();
expect(startCallback).toHaveBeenCalled();
@@ -167,8 +148,7 @@ describe("Spec", function() {
});
it("can be disabled at execution time by a parent", function() {
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner')
.and.callFake(function(attrs) { attrs.onComplete(); }),
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
startCallback = jasmine.createSpy('startCallback'),
specBody = jasmine.createSpy('specBody'),
resultCallback = jasmine.createSpy('resultCallback'),
@@ -183,7 +163,7 @@ describe("Spec", function() {
expect(spec.result.status).toBe('disabled');
expect(fakeQueueRunner).toHaveBeenCalled();
expect(fakeQueueRunner).not.toHaveBeenCalled();
expect(specBody).not.toHaveBeenCalled();
expect(startCallback).toHaveBeenCalled();
@@ -191,8 +171,7 @@ describe("Spec", function() {
});
it("can be marked pending, but still calls callbacks when executed", function() {
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner')
.and.callFake(function(attrs) { attrs.onComplete(); }),
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
startCallback = jasmine.createSpy('startCallback'),
resultCallback = jasmine.createSpy('resultCallback'),
spec = new jasmineUnderTest.Spec({
@@ -212,7 +191,7 @@ describe("Spec", function() {
spec.execute();
expect(fakeQueueRunner).toHaveBeenCalled();
expect(fakeQueueRunner).not.toHaveBeenCalled();
expect(startCallback).toHaveBeenCalled();
expect(resultCallback).toHaveBeenCalledWith({

View File

@@ -141,15 +141,5 @@ describe("Suite", function() {
suite.onException(new jasmineUnderTest.errors.ExpectationFailed());
expect(suite.getResult().failedExpectations).toEqual([]);
});
describe('#sharedUserContext', function() {
beforeEach(function() {
this.suite = new jasmineUnderTest.Suite({});
});
it('returns a UserContext', function() {
expect(this.suite.sharedUserContext().constructor).toBe(jasmineUnderTest.UserContext);
});
});
})
});

View File

@@ -1,54 +0,0 @@
describe("UserContext", function() {
it("Behaves just like an plain object", function() {
var context = new jasmineUnderTest.UserContext(),
properties = [];
for (var prop in context) {
if (obj.hasOwnProperty(prop)) {
properties.push(prop);
}
}
expect(properties).toEqual([]);
});
describe('.fromExisting', function() {
describe('when using an already built context as model', function() {
beforeEach(function() {
this.context = new jasmineUnderTest.UserContext();
this.context.key = 'value';
this.cloned = jasmineUnderTest.UserContext.fromExisting(this.context);
});
it('returns a cloned object', function() {
expect(this.cloned).toEqual(this.context);
});
it('does not return the same object', function() {
expect(this.cloned).not.toBe(this.context);
});
});
describe('when using a regular object as parameter', function() {
beforeEach(function() {
this.context = {};
this.value = 'value'
this.context.key = this.value;
this.cloned = jasmineUnderTest.UserContext.fromExisting(this.context);
});
it('returns an object with the same attributes', function() {
expect(this.cloned.key).toEqual(this.value);
});
it('does not return the same object', function() {
expect(this.cloned).not.toBe(this.context);
});
it('returns an UserContext', function() {
expect(this.cloned.constructor).toBe(jasmineUnderTest.UserContext);
});
});
});
});

View File

@@ -1,47 +0,0 @@
describe("ArrayWithExactContents", function() {
it("matches an array with the same items in a different order", function() {
var matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]);
expect(matcher.asymmetricMatch([2, 'a', /a/])).toBe(true);
});
it("does not work when not passed an array", function() {
var matcher = new jasmineUnderTest.ArrayWithExactContents("foo");
expect(function() {
matcher.asymmetricMatch([]);
}).toThrowError(/not 'foo'/);
});
it("does not match when an item is missing", function() {
var matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]);
expect(matcher.asymmetricMatch(['a', 2])).toBe(false);
expect(matcher.asymmetricMatch(['a', 2, undefined])).toBe(false);
});
it("does not match when there is an extra item", function() {
var matcher = new jasmineUnderTest.ArrayWithExactContents(['a']);
expect(matcher.asymmetricMatch(['a', 2])).toBe(false);
});
it("jasmineToStrings itself", function() {
var matcher = new jasmineUnderTest.ArrayWithExactContents([]);
expect(matcher.jasmineToString()).toMatch("<jasmine.arrayWithExactContents");
});
it("uses custom equality testers", function() {
var tester = function(a, b) {
// All "foo*" strings match each other.
if (typeof a == "string" && typeof b == "string" &&
a.substr(0, 3) == "foo" && b.substr(0, 3) == "foo") {
return true;
}
};
var matcher = new jasmineUnderTest.ArrayWithExactContents(["fooVal"]);
expect(matcher.asymmetricMatch(["fooBar"], [tester])).toBe(true);
});
});

View File

@@ -67,9 +67,8 @@ describe("Custom Matchers (Integration)", function() {
};
env.addCustomEqualityTester(customEqualityFn);
env.expect({foo: 'fooValue'}).toEqual(jasmineUnderTest.objectContaining({foo: 'fooBar'}));
env.expect(['fooValue', 'things']).toEqual(jasmineUnderTest.arrayContaining(['fooBar']));
env.expect(['fooValue']).toEqual(jasmineUnderTest.arrayWithExactContents(['fooBar']));
env.expect({foo: 'fooValue'}).toEqual(jasmine.objectContaining({foo: 'fooBar'}));
env.expect(['fooValue']).toEqual(jasmine.arrayContaining(['fooBar']));
});
var specExpectations = function(result) {

View File

@@ -243,7 +243,7 @@ describe("Env integration", function() {
} else {
secondSpecContext = this;
}
expect(this).toEqual(new jasmineUnderTest.UserContext());
expect(this).toEqual({});
});
env.it("sync spec", function() {
@@ -277,7 +277,7 @@ describe("Env integration", function() {
env.beforeEach(function() {
specContext = this;
expect(this).toEqual(new jasmineUnderTest.UserContext());
expect(this).toEqual({});
});
env.it("sync spec", function(underTestCallback) {
@@ -786,7 +786,7 @@ describe("Env integration", function() {
env.execute();
});
it('can be configured to allow respying on functions', function (done) {
it('can be configured to allow respying on functions', function () {
var env = new jasmineUnderTest.Env(),
foo = {
bar: function () {
@@ -795,7 +795,6 @@ describe("Env integration", function() {
};
env.allowRespy(true);
env.addReporter({ jasmineDone: done });
env.describe('test suite', function(){
env.it('spec 0', function(){
@@ -929,14 +928,7 @@ describe("Env integration", function() {
});
it("should run async specs in order, waiting for them to complete", function(done) {
var env = new jasmineUnderTest.Env(),
reporter = jasmine.createSpyObj('reporter', ['jasmineDone']),
mutatedVar;
reporter.jasmineDone.and.callFake(function() {
done();
});
env.addReporter(reporter);
var env = new jasmineUnderTest.Env(), mutatedVar;
env.describe("tests", function() {
env.beforeEach(function() {
@@ -947,6 +939,7 @@ describe("Env integration", function() {
setTimeout(function() {
expect(mutatedVar).toEqual(2);
underTestCallback();
done();
}, 0);
});
@@ -1076,6 +1069,7 @@ describe("Env integration", function() {
env.afterAll(function(innerDone) {
jasmine.clock().tick(3001);
innerDone();
jasmine.clock().tick(1);
});
});
@@ -1117,18 +1111,14 @@ describe("Env integration", function() {
env.describe('suite', function() {
env.afterAll(function() {
if (jasmine.getEnv().ieVersion < 9) {
} else {
realSetTimeout(function() {
jasmine.clock().tick(10);
}, 100);
}
realSetTimeout(function() {
jasmine.clock().tick(10);
}, 100);
});
env.describe('beforeAll', function() {
env.beforeAll(function(innerDone) {
realSetTimeout(function() {
jasmine.clock().tick(5001);
}, 0);
jasmine.clock().tick(5001);
innerDone();
}, 5000);
env.it('times out', function() {});
@@ -1136,9 +1126,8 @@ describe("Env integration", function() {
env.describe('afterAll', function() {
env.afterAll(function(innerDone) {
realSetTimeout(function() {
jasmine.clock().tick(2001);
}, 0);
jasmine.clock().tick(2001);
innerDone();
}, 2000);
env.it('times out', function() {});
@@ -1146,9 +1135,8 @@ describe("Env integration", function() {
env.describe('beforeEach', function() {
env.beforeEach(function(innerDone) {
realSetTimeout(function() {
jasmine.clock().tick(1001);
}, 0);
jasmine.clock().tick(1001);
innerDone();
}, 1000);
env.it('times out', function() {});
@@ -1156,18 +1144,16 @@ describe("Env integration", function() {
env.describe('afterEach', function() {
env.afterEach(function(innerDone) {
realSetTimeout(function() {
jasmine.clock().tick(4001);
}, 0);
jasmine.clock().tick(4001);
innerDone();
}, 4000);
env.it('times out', function() {});
});
env.it('it times out', function(innerDone) {
realSetTimeout(function() {
jasmine.clock().tick(6001);
}, 0);
jasmine.clock().tick(6001);
innerDone();
}, 6000);
});
@@ -1314,8 +1300,7 @@ describe("Env integration", function() {
reporter.jasmineDone.and.callFake(function() {
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
totalSpecsDefined: 1,
order: jasmine.any(jasmineUnderTest.Order)
totalSpecsDefined: 1
});
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
@@ -1350,8 +1335,7 @@ describe("Env integration", function() {
reporter.jasmineDone.and.callFake(function() {
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
totalSpecsDefined: 1,
order: jasmine.any(jasmineUnderTest.Order)
totalSpecsDefined: 1
});
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
@@ -1389,8 +1373,7 @@ describe("Env integration", function() {
reporter.jasmineDone.and.callFake(function() {
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
totalSpecsDefined: 5,
order: jasmine.any(jasmineUnderTest.Order)
totalSpecsDefined: 5
});
expect(reporter.specDone.calls.count()).toBe(5);
@@ -1447,34 +1430,6 @@ describe("Env integration", function() {
env.execute();
});
it("should report the random seed at the beginning and end of execution", function(done) {
var env = new jasmineUnderTest.Env(),
reporter = jasmine.createSpyObj('fakeReporter', [
"jasmineStarted",
"jasmineDone",
"suiteStarted",
"suiteDone",
"specStarted",
"specDone"
]);
env.randomizeTests(true);
env.seed('123456');
reporter.jasmineDone.and.callFake(function(doneArg) {
expect(reporter.jasmineStarted).toHaveBeenCalled();
var startedArg = reporter.jasmineStarted.calls.argsFor(0)[0];
expect(startedArg.order.random).toEqual(true);
expect(startedArg.order.seed).toEqual('123456');
expect(doneArg.order.random).toEqual(true);
expect(doneArg.order.seed).toEqual('123456');
done();
});
env.addReporter(reporter);
env.execute();
});
it('should report pending spec messages', function(done) {
var env = new jasmineUnderTest.Env(),
reporter = jasmine.createSpyObj('fakeReporter', [
@@ -1534,8 +1489,7 @@ describe("Env integration", function() {
reporter.jasmineDone.and.callFake(function() {
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
totalSpecsDefined: 1,
order: jasmine.any(jasmineUnderTest.Order)
totalSpecsDefined: 1
});
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({ status: 'disabled' }));

View File

@@ -836,115 +836,4 @@ describe("jasmine spec running", function () {
env.execute();
});
describe("When throwOnExpectationFailure is set", function() {
it("skips to cleanup functions after an error", function(done) {
var actions = [];
env.describe('Something', function() {
env.beforeEach(function() {
actions.push('outer beforeEach');
throw new Error("error");
});
env.afterEach(function() {
actions.push('outer afterEach');
});
env.describe('Inner', function() {
env.beforeEach(function() {
actions.push('inner beforeEach');
});
env.afterEach(function() {
actions.push('inner afterEach');
});
env.it('does it' , function() {
actions.push('inner it');
});
});
});
env.throwOnExpectationFailure(true);
var assertions = function() {
expect(actions).toEqual([
'outer beforeEach',
'inner afterEach',
'outer afterEach'
]);
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
it("skips to cleanup functions after done.fail is called", function(done) {
var actions = [];
env.describe('Something', function() {
env.beforeEach(function(done) {
actions.push('beforeEach');
done.fail('error');
actions.push('after done.fail');
});
env.afterEach(function() {
actions.push('afterEach');
});
env.it('does it' , function() {
actions.push('it');
});
});
env.throwOnExpectationFailure(true);
var assertions = function() {
expect(actions).toEqual([
'beforeEach',
'afterEach'
]);
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
it("skips to cleanup functions when an async function times out", function(done) {
var actions = [];
env.describe('Something', function() {
env.beforeEach(function(innerDone) {
actions.push('beforeEach');
}, 1);
env.afterEach(function() {
actions.push('afterEach');
});
env.it('does it' , function() {
actions.push('it');
});
});
env.throwOnExpectationFailure(true);
var assertions = function() {
expect(actions).toEqual([
'beforeEach',
'afterEach'
]);
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
});

View File

@@ -393,13 +393,6 @@ describe("matchersUtil", function() {
expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(true);
});
it("passes when comparing identical sets with different insertion order", function() {
jasmine.getEnv().requireFunctioningSets();
var setA = new Set([3, 6]);
var setB = new Set([6, 3]);
expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(true);
});
it("fails for sets with different elements", function() {
jasmine.getEnv().requireFunctioningSets();
var setA = new Set([6, 3, 5]);
@@ -414,38 +407,11 @@ describe("matchersUtil", function() {
expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(false);
});
it("passes when comparing two empty maps", function() {
jasmine.getEnv().requireFunctioningMaps();
expect(jasmineUnderTest.matchersUtil.equals(new Map(), new Map())).toBe(true);
});
it("passes when comparing identical maps", function() {
jasmine.getEnv().requireFunctioningMaps();
var mapA = new Map([[6, 5]]);
var mapB = new Map();
mapB.set(6, 5);
expect(jasmineUnderTest.matchersUtil.equals(mapA, mapB)).toBe(true);
});
it("passes when comparing identical maps with different insertion order", function() {
jasmine.getEnv().requireFunctioningMaps();
var mapA = new Map([['a', 3], [6, 1]]);
var mapB = new Map([[6, 1], ['a', 3]]);
expect(jasmineUnderTest.matchersUtil.equals(mapA, mapB)).toBe(true);
});
it("fails for maps with different elements", function() {
jasmine.getEnv().requireFunctioningMaps();
var mapA = new Map([[6, 3], [5, 1]]);
var mapB = new Map([[6, 4], [5, 1]]);
expect(jasmineUnderTest.matchersUtil.equals(mapA, mapB)).toBe(false);
});
it("fails for maps of different size", function() {
jasmine.getEnv().requireFunctioningMaps();
var mapA = new Map([[6, 3]]);
var mapB = new Map([[6, 4], [5, 1]]);
expect(jasmineUnderTest.matchersUtil.equals(mapA, mapB)).toBe(false);
it("fails for sets with different insertion order", function() {
jasmine.getEnv().requireFunctioningSets();
var setA = new Set([3, 6]);
var setB = new Set([6, 3]);
expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(false);
});
describe("when running in an environment with array polyfills", function() {

View File

@@ -1,8 +0,0 @@
describe('nothing', function() {
it('should pass', function() {
var matcher = jasmineUnderTest.matchers.nothing(),
result = matcher.compare();
expect(result.pass).toBe(true);
});
});

View File

@@ -8,9 +8,6 @@ describe("toBeCloseTo", function() {
result = matcher.compare(0, 0.001);
expect(result.pass).toBe(true);
result = matcher.compare(0, 0.005);
expect(result.pass).toBe(true);
});
it("fails when not within two decimal places by default", function() {
@@ -19,9 +16,6 @@ describe("toBeCloseTo", function() {
result = matcher.compare(0, 0.01);
expect(result.pass).toBe(false);
result = matcher.compare(0, 0.05);
expect(result.pass).toBe(false);
});
it("accepts an optional precision argument", function() {
@@ -31,36 +25,8 @@ describe("toBeCloseTo", function() {
result = matcher.compare(0, 0.1, 0);
expect(result.pass).toBe(true);
result = matcher.compare(0, 0.5, 0);
expect(result.pass).toBe(true);
result = matcher.compare(0, 0.0001, 3);
expect(result.pass).toBe(true);
result = matcher.compare(0, 0.0005, 3);
expect(result.pass).toBe(true);
result = matcher.compare(0, 0.00001, 4);
expect(result.pass).toBe(true);
result = matcher.compare(0, 0.00005, 4);
expect(result.pass).toBe(true);
});
it("fails when one of the arguments is null", function() {
var matcher = jasmineUnderTest.matchers.toBeCloseTo();
expect(function() {
matcher.compare(null, null);
}).toThrowError('Cannot use toBeCloseTo with null. Arguments evaluated to: expect(null).toBeCloseTo(null).');
expect(function() {
matcher.compare(0, null);
}).toThrowError('Cannot use toBeCloseTo with null. Arguments evaluated to: expect(0).toBeCloseTo(null).');
expect(function() {
matcher.compare(null, 0);
}).toThrowError('Cannot use toBeCloseTo with null. Arguments evaluated to: expect(null).toBeCloseTo(0).');
});
it("rounds expected values", function() {
@@ -76,15 +42,7 @@ describe("toBeCloseTo", function() {
result = matcher.compare(1.23, 1.225);
expect(result.pass).toBe(true);
result = matcher.compare(1.23, 1.235);
expect(result.pass).toBe(true);
// 1.2249999 will be rounded to 1.225
result = matcher.compare(1.23, 1.2249999);
expect(result.pass).toBe(true);
// 1.2249999 will be rounded to 1.224
result = matcher.compare(1.23, 1.2244999);
expect(result.pass).toBe(false);
result = matcher.compare(1.23, 1.234);

View File

@@ -161,8 +161,8 @@ describe("toEqual", function() {
it("uses the default failure message given arrays with different lengths", function() {
var actual = [1, 2],
expected = [1, 2, 3],
message = 'Expected $.length = 2 to equal 3.\n' +
'Expected $[2] = undefined to equal 3.';
message =
"Expected [ 1, 2 ] to equal [ 1, 2, 3 ].";
expect(compareEquals(actual, expected).message).toEqual(message);
});
@@ -211,16 +211,6 @@ describe("toEqual", function() {
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("reports mismatches between arrays of different types", function() {
jasmine.getEnv().requireFunctioningTypedArrays();
var actual = new Uint32Array([1, 2, 3]),
expected = new Uint16Array([1, 2, 3]),
message = "Expected Uint32Array [ 1, 2, 3 ] to equal Uint16Array [ 1, 2, 3 ].";
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("reports mismatches involving NaN", function() {
var actual = {x: 0},
expected = {x: 0/0},
@@ -369,9 +359,8 @@ describe("toEqual", function() {
expect(compareEquals(actual, expected).message).toEqual(message);
});
// == Sets ==
it("reports mismatches between Sets", function() {
it("does not report deep mismatches within Sets", function() {
// TODO: implement deep comparison of set elements
jasmine.getEnv().requireFunctioningSets();
var actual = new Set([1]),
@@ -381,16 +370,6 @@ describe("toEqual", function() {
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("reports deep mismatches within Sets", function() {
jasmine.getEnv().requireFunctioningSets();
var actual = new Set([{x: 1}]),
expected = new Set([{x: 2}]),
message = 'Expected Set( Object({ x: 1 }) ) to equal Set( Object({ x: 2 }) ).';
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("reports mismatches between Sets nested in objects", function() {
jasmine.getEnv().requireFunctioningSets();
@@ -411,99 +390,6 @@ describe("toEqual", function() {
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("reports mismatches between Sets where actual is missing a value from expected", function() {
jasmine.getEnv().requireFunctioningSets();
// Use 'duplicate' object in actual so sizes match
var actual = new Set([{x: 1}, {x: 1}]),
expected = new Set([{x: 1}, {x: 2}]),
message = 'Expected Set( Object({ x: 1 }), Object({ x: 1 }) ) to equal Set( Object({ x: 1 }), Object({ x: 2 }) ).';
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("reports mismatches between Sets where actual has a value missing from expected", function() {
jasmine.getEnv().requireFunctioningSets();
// Use 'duplicate' object in expected so sizes match
var actual = new Set([{x: 1}, {x: 2}]),
expected = new Set([{x: 1}, {x: 1}]),
message = 'Expected Set( Object({ x: 1 }), Object({ x: 2 }) ) to equal Set( Object({ x: 1 }), Object({ x: 1 }) ).';
expect(compareEquals(actual, expected).message).toEqual(message);
});
// == Maps ==
it("does not report mismatches between deep equal Maps", function() {
jasmine.getEnv().requireFunctioningSets();
// values are the same but with different object identity
var actual = new Map([['a', {x: 1}]]),
expected = new Map([['a', {x: 1}]]);
expect(compareEquals(actual, expected).pass).toBe(true);
});
it("reports deep mismatches within Maps", function() {
jasmine.getEnv().requireFunctioningMaps();
var actual = new Map([['a', {x: 1}]]),
expected = new Map([['a', {x: 2}]]),
message = "Expected Map( [ 'a', Object({ x: 1 }) ] ) to equal Map( [ 'a', Object({ x: 2 }) ] ).";
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("reports mismatches between Maps nested in objects", function() {
jasmine.getEnv().requireFunctioningMaps();
var actual = {Maps: [new Map([['a', 1]])]},
expected = {Maps: [new Map([['a', 2]])]},
message = "Expected $.Maps[0] = Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ] ).";
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("reports mismatches between Maps of different lengths", function() {
jasmine.getEnv().requireFunctioningMaps();
var actual = new Map([['a', 1]]),
expected = new Map([['a', 2], ['b', 1]]),
message = "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ], [ 'b', 1 ] ).";
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("reports mismatches between Maps with equal values but differing keys", function() {
jasmine.getEnv().requireFunctioningMaps();
var actual = new Map([['a', 1]]),
expected = new Map([['b', 1]]),
message = "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'b', 1 ] ).";
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("does not report mismatches between Maps with keys with same object identity", function() {
jasmine.getEnv().requireFunctioningMaps();
var key = {x: 1},
actual = new Map([[key, 2]]),
expected = new Map([[key, 2]]);
expect(compareEquals(actual, expected).pass).toBe(true);
});
it("reports mismatches between Maps with identical keys with different object identity", function() {
jasmine.getEnv().requireFunctioningMaps();
var actual = new Map([[{x: 1}, 2]]),
expected = new Map([[{x: 1}, 2]]),
message = "Expected Map( [ Object({ x: 1 }), 2 ] ) to equal Map( [ Object({ x: 1 }), 2 ] ).";
expect(compareEquals(actual, expected).message).toEqual(message);
});
function isNotRunningInBrowser() {
return typeof document === 'undefined'
}
@@ -570,9 +456,9 @@ describe("toEqual", function() {
it("does not report a mismatch when asymmetric matchers are satisfied", function() {
var actual = {a: 'a'},
expected = {a: jasmineUnderTest.any(String)};
expected = {a: jasmineUnderTest.any(String)},
message = 'Expected $.a = 1 to equal <jasmine.any(String)>.';
expect(compareEquals(actual, expected).message).toEqual('');
expect(compareEquals(actual, expected).pass).toBe(true)
});
@@ -613,8 +499,7 @@ describe("toEqual", function() {
var message =
'Expected $.foo[0].bar = 1 to equal 2.\n' +
'Expected $.foo[0].things.length = 2 to equal 3.\n' +
"Expected $.foo[0].things[2] = undefined to equal 'c'.\n" +
"Expected $.foo[0].things = [ 'a', 'b' ] to equal [ 'a', 'b', 'c' ].\n" +
"Expected $.foo[1].things[1] = 'b' to equal 'd'.\n" +
'Expected $.baz[0].a to have properties\n' +
' c: 1\n' +
@@ -628,92 +513,4 @@ describe("toEqual", function() {
expect(compareEquals(actual, expected).message).toEqual(message);
})
describe("different length arrays", function() {
it("actual array is longer", function() {
var actual = [1, 1, 2, 3, 5],
expected = [1, 1, 2, 3],
message = 'Expected $.length = 5 to equal 4.\n' +
'Expected $[4] = 5 to equal undefined.';
expect(compareEquals(actual, expected).pass).toBe(false)
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("expected array is longer", function() {
var actual = [1, 1, 2, 3],
expected = [1, 1, 2, 3, 5],
message = 'Expected $.length = 4 to equal 5.\n' +
'Expected $[4] = undefined to equal 5.';
expect(compareEquals(actual, expected).pass).toBe(false)
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("expected array is longer by 4 elements", function() {
var actual = [1, 1, 2],
expected = [1, 1, 2, 3, 5, 8, 13],
message = 'Expected $.length = 3 to equal 7.\n' +
'Expected $[3] = undefined to equal 3.\n' +
'Expected $[4] = undefined to equal 5.\n' +
'Expected $[5] = undefined to equal 8.\n' +
'Expected $[6] = undefined to equal 13.';
expect(compareEquals(actual, expected).pass).toBe(false)
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("different length and different elements", function() {
var actual = [1],
expected = [2, 3],
message = 'Expected $.length = 1 to equal 2.\n' +
'Expected $[0] = 1 to equal 2.\n' +
'Expected $[1] = undefined to equal 3.';
expect(compareEquals(actual, expected).pass).toBe(false)
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("object with nested array", function() {
var actual = { values: [1, 1, 2, 3] },
expected = { values: [1, 1, 2] },
message = 'Expected $.values.length = 4 to equal 3.\n' +
'Expected $.values[3] = 3 to equal undefined.';
expect(compareEquals(actual, expected).pass).toBe(false)
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("array with nested object", function() {
var actual = [1, 1, 2, { value: 3 }],
expected = [1, 1, 2],
message = 'Expected $.length = 4 to equal 3.\n' +
'Expected $[3] = Object({ value: 3 }) to equal undefined.';
expect(compareEquals(actual, expected).pass).toBe(false)
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("array with nested different length array", function() {
var actual = [[1], [1, 2]],
expected = [[1, 1], [2]],
message = 'Expected $[0].length = 1 to equal 2.\n' +
'Expected $[0][1] = undefined to equal 1.\n' +
'Expected $[1].length = 2 to equal 1.\n' +
'Expected $[1][0] = 1 to equal 2.\n' +
'Expected $[1][1] = 2 to equal undefined.';
expect(compareEquals(actual, expected).pass).toBe(false)
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("last element of longer array is undefined", function() {
var actual = [1, 2],
expected = [1, 2, void 0],
message = 'Expected $.length = 2 to equal 3.';
expect(compareEquals(actual, expected).pass).toBe(false)
expect(compareEquals(actual, expected).message).toEqual(message);
});
})
});

View File

@@ -1,27 +0,0 @@
(function(env) {
function getAsyncCtor() {
try {
eval("var func = async function(){};");
} catch (e) {
return null;
}
return Object.getPrototypeOf(func).constructor;
}
function hasAsyncAwaitSupport() {
return getAsyncCtor() !== null;
}
env.makeAsyncAwaitFunction = function() {
var AsyncFunction = getAsyncCtor();
return new AsyncFunction("");
};
env.requireAsyncAwait = function() {
if (!hasAsyncAwaitSupport()) {
env.pending("Environment does not support async/await functions");
}
};
})(jasmine.getEnv());

View File

@@ -1,22 +0,0 @@
(function(env) {
function hasFunctioningMaps() {
if (typeof Map === 'undefined') { return false; }
try {
var s = new Map([['a', 4]]);
if (s.size !== 1) { return false; }
if (s.keys().next().value !== 'a') { return false; }
if (s.values().next().value !== 4) { return false; }
return true;
} catch(e) {
return false;
}
}
env.requireFunctioningMaps = function() {
if (!hasFunctioningMaps()) {
env.pending("Browser has incomplete or missing support for Maps");
}
};
})(jasmine.getEnv());

View File

@@ -1,20 +0,0 @@
(function(env) {
function hasFunctioningTypedArrays() {
if (typeof Uint32Array === 'undefined') { return false; }
try {
var a = new Uint32Array([1, 2, 3]);
if (a.length !== 3) { return false; }
return true;
} catch(e) {
return false;
}
}
env.requireFunctioningTypedArrays = function() {
if (!hasFunctioningTypedArrays()) {
env.pending("Browser has incomplete or missing support for typed arrays");
}
};
})(jasmine.getEnv());

View File

@@ -691,15 +691,14 @@ describe("New HtmlReporter", function() {
expect(seedBar).toBeNull();
});
it("should include non-spec query params in the jasmine-skipped link when present", function(){
it("should include the random query param in the jasmine-skipped link when randomizing", function(){
var env = new jasmineUnderTest.Env(),
container = document.createElement("div"),
reporter = new jasmineUnderTest.HtmlReporter({
env: env,
getContainer: function() { return container; },
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
addToExistingQueryString: function(key, value) { return "?foo=bar&" + key + "=" + value; }
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
});
reporter.initialize();
@@ -707,7 +706,25 @@ describe("New HtmlReporter", function() {
reporter.jasmineDone({ order: { random: true } });
var skippedLink = container.querySelector(".jasmine-skipped a");
expect(skippedLink.getAttribute('href')).toEqual('?foo=bar&spec=');
expect(skippedLink.getAttribute('href')).toEqual('?random=true');
});
it("should not include the random query param in the jasmine-skipped link when not randomizing", function(){
var env = new jasmineUnderTest.Env(),
container = document.createElement("div"),
reporter = new jasmineUnderTest.HtmlReporter({
env: env,
getContainer: function() { return container; },
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
});
reporter.initialize();
reporter.jasmineStarted({ totalSpecsDefined: 1 });
reporter.jasmineDone();
var skippedLink = container.querySelector(".jasmine-skipped a");
expect(skippedLink.getAttribute('href')).toEqual('?');
});
});

View File

@@ -6,10 +6,7 @@
"npmPackage/**/*.js"
],
"helpers": [
"helpers/asyncAwait.js",
"helpers/checkForSet.js",
"helpers/checkForMap.js",
"helpers/checkForTypedArrays.js",
"helpers/nodeDefineJasmineUnderTest.js"
],
"random": true

View File

@@ -16,11 +16,8 @@ src_files:
- '**/*.js'
stylesheets:
helpers:
- 'helpers/asyncAwait.js'
- 'helpers/BrowserFlags.js'
- 'helpers/checkForSet.js'
- 'helpers/checkForMap.js'
- 'helpers/checkForTypedArrays.js'
- 'helpers/defineJasmineUnderTest.js'
spec_files:
- '**/*[Ss]pec.js'

View File

@@ -11,13 +11,10 @@ getJasmineRequireObj().CallTracker = function(j$) {
var clonedArgs = [];
var argsAsArray = j$.util.argsToArray(context.args);
for(var i = 0; i < argsAsArray.length; i++) {
var str = Object.prototype.toString.apply(argsAsArray[i]),
primitives = /^\[object (Boolean|String|RegExp|Number)/;
if (argsAsArray[i] == null || str.match(primitives)) {
clonedArgs.push(argsAsArray[i]);
} else {
if(Object.prototype.toString.apply(argsAsArray[i]).match(/^\[object/)) {
clonedArgs.push(j$.util.clone(argsAsArray[i]));
} else {
clonedArgs.push(argsAsArray[i]);
}
}
context.args = clonedArgs;

View File

@@ -37,56 +37,12 @@ getJasmineRequireObj().Env = function(j$) {
return currentSpec || currentSuite();
};
/**
* This represents the available reporter callback for an object passed to {@link Env#addReporter}.
* @interface Reporter
*/
var reporter = new j$.ReportDispatcher([
/**
* `jasmineStarted` is called after all of the specs have been loaded, but just before execution starts.
* @function
* @name Reporter#jasmineStarted
* @param {JasmineStartedInfo} suiteInfo Information about the full Jasmine suite that is being run
*/
'jasmineStarted',
/**
* When the entire suite has finished execution `jasmineDone` is called
* @function
* @name Reporter#jasmineDone
* @param {JasmineDoneInfo} suiteInfo Information about the full Jasmine suite that just finished running.
*/
'jasmineDone',
/**
* `suiteStarted` is invoked when a `describe` starts to run
* @function
* @name Reporter#suiteStarted
* @param {SuiteResult} result Information about the individual {@link describe} being run
*/
'suiteStarted',
/**
* `suiteDone` is invoked when all of the child specs and suites for a given suite have been run
*
* While jasmine doesn't require any specific functions, not defining a `suiteDone` will make it impossible for a reporter to know when a suite has failures in an `afterAll`.
* @function
* @name Reporter#suiteDone
* @param {SuiteResult} result
*/
'suiteDone',
/**
* `specStarted` is invoked when an `it` starts to run (including associated `beforeEach` functions)
* @function
* @name Reporter#specStarted
* @param {SpecResult} result Information about the individual {@link it} being run
*/
'specStarted',
/**
* `specDone` is invoked when an `it` and its associated `beforeEach` and `afterEach` functions have been run.
*
* While jasmine doesn't require any specific functions, not defining a `specDone` will make it impossible for a reporter to know when a spec has failed.
* @function
* @name Reporter#specDone
* @param {SpecResult} result
*/
'specDone'
]);
@@ -240,7 +196,6 @@ getJasmineRequireObj().Env = function(j$) {
options.timeout = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout};
options.fail = self.fail;
options.globalErrors = globalErrors;
options.completeOnFirstError = throwOnExpectationFailure && options.isLeaf;
new j$.QueueRunner(options).execute();
};
@@ -302,15 +257,8 @@ getJasmineRequireObj().Env = function(j$) {
throw new Error('Invalid order: would cause a beforeAll or afterAll to be run multiple times');
}
/**
* Information passed to the {@link Reporter#jasmineStarted} event.
* @typedef JasmineStartedInfo
* @property {Int} totalSpecsDefined - The total number of specs defined in this suite.
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
*/
reporter.jasmineStarted({
totalSpecsDefined: totalSpecsDefined,
order: order
totalSpecsDefined: totalSpecsDefined
});
currentlyExecutingSuites.push(topSuite);
@@ -321,12 +269,6 @@ getJasmineRequireObj().Env = function(j$) {
currentlyExecutingSuites.pop();
globalErrors.uninstall();
/**
* Information passed to the {@link Reporter#jasmineDone} event.
* @typedef JasmineDoneInfo
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
* @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
*/
reporter.jasmineDone({
order: order,
failedExpectations: topSuite.result.failedExpectations
@@ -338,7 +280,6 @@ getJasmineRequireObj().Env = function(j$) {
* Add a custom reporter to the Jasmine environment.
* @name Env#addReporter
* @function
* @param {Reporter} reporterToAdd The reporter to be added.
* @see custom_reporter
*/
this.addReporter = function(reporterToAdd) {
@@ -378,12 +319,6 @@ getJasmineRequireObj().Env = function(j$) {
}
};
var ensureIsFunctionOrAsync = function(fn, caller) {
if (!j$.isFunction_(fn) && !j$.isAsyncFunction_(fn)) {
throw new Error(caller + ' expects a function argument; received ' + j$.getType_(fn));
}
};
var suiteFactory = function(description) {
var suite = new j$.Suite({
env: self,
@@ -522,7 +457,7 @@ getJasmineRequireObj().Env = function(j$) {
// it() sometimes doesn't have a fn argument, so only check the type if
// it's given.
if (arguments.length > 1 && typeof fn !== 'undefined') {
ensureIsFunctionOrAsync(fn, 'it');
ensureIsFunction(fn, 'it');
}
var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
if (currentDeclarationSuite.markedPending) {
@@ -536,7 +471,7 @@ getJasmineRequireObj().Env = function(j$) {
// xit(), like it(), doesn't always have a fn argument, so only check the
// type when needed.
if (arguments.length > 1 && typeof fn !== 'undefined') {
ensureIsFunctionOrAsync(fn, 'xit');
ensureIsFunction(fn, 'xit');
}
var spec = this.it.apply(this, arguments);
spec.pend('Temporarily disabled with xit');
@@ -544,7 +479,7 @@ getJasmineRequireObj().Env = function(j$) {
};
this.fit = function(description, fn, timeout){
ensureIsFunctionOrAsync(fn, 'fit');
ensureIsFunction(fn, 'fit');
var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
currentDeclarationSuite.addChild(spec);
focusedRunnables.push(spec.id);
@@ -561,7 +496,7 @@ getJasmineRequireObj().Env = function(j$) {
};
this.beforeEach = function(beforeEachFunction, timeout) {
ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach');
ensureIsFunction(beforeEachFunction, 'beforeEach');
currentDeclarationSuite.beforeEach({
fn: beforeEachFunction,
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
@@ -569,7 +504,7 @@ getJasmineRequireObj().Env = function(j$) {
};
this.beforeAll = function(beforeAllFunction, timeout) {
ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll');
ensureIsFunction(beforeAllFunction, 'beforeAll');
currentDeclarationSuite.beforeAll({
fn: beforeAllFunction,
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
@@ -577,8 +512,7 @@ getJasmineRequireObj().Env = function(j$) {
};
this.afterEach = function(afterEachFunction, timeout) {
ensureIsFunctionOrAsync(afterEachFunction, 'afterEach');
afterEachFunction.isCleanup = true;
ensureIsFunction(afterEachFunction, 'afterEach');
currentDeclarationSuite.afterEach({
fn: afterEachFunction,
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
@@ -586,7 +520,7 @@ getJasmineRequireObj().Env = function(j$) {
};
this.afterAll = function(afterAllFunction, timeout) {
ensureIsFunctionOrAsync(afterAllFunction, 'afterAll');
ensureIsFunction(afterAllFunction, 'afterAll');
currentDeclarationSuite.afterAll({
fn: afterAllFunction,
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
@@ -627,10 +561,6 @@ getJasmineRequireObj().Env = function(j$) {
message: message,
error: error && error.message ? error : null
});
if (self.throwingExpectationFailures()) {
throw new Error(message);
}
};
}

View File

@@ -4,15 +4,6 @@ getJasmineRequireObj().buildExpectationResult = function() {
var messageFormatter = options.messageFormatter || function() {},
stackFormatter = options.stackFormatter || function() {};
/**
* @typedef Expectation
* @property {String} matcherName - The name of the matcher that was executed for this expectation.
* @property {String} message - The failure message for the expectation.
* @property {String} stack - The stack trace for the failure if available.
* @property {Boolean} passed - Whether the expectation passed or failed.
* @property {Object} expected - If the expectation failed, what was the expected value.
* @property {Object} actual - If the expectation failed, what actual value was produced.
*/
var result = {
matcherName: options.matcherName,
message: message(),

View File

@@ -6,10 +6,11 @@ getJasmineRequireObj().JsApiReporter = function() {
};
/**
* _Note:_ Do not construct this directly, use the global `jsApiReporter` to retrieve the instantiated object.
*
* @name jsApiReporter
* @classdesc {@link Reporter} added by default in `boot.js` to record results for retrieval in javascript code. An instance is made available as `jsApiReporter` on the global object.
* @classdesc Reporter added by default in `boot.js` to record results for retrieval in javascript code.
* @class
* @hideconstructor
*/
function JsApiReporter(options) {
var timer = options.timer || noopTimer,
@@ -63,7 +64,7 @@ getJasmineRequireObj().JsApiReporter = function() {
* @function
* @param {Number} index - The position in the suites list to start from.
* @param {Number} length - Maximum number of suite results to return.
* @return {SuiteResult[]}
* @return {Object[]}
*/
this.suiteResults = function(index, length) {
return suites.slice(index, index + length);
@@ -78,7 +79,7 @@ getJasmineRequireObj().JsApiReporter = function() {
* Get all of the suites in a single object, with their `id` as the key.
* @name jsApiReporter#suites
* @function
* @return {Object} - Map of suite id to {@link SuiteResult}
* @return {Object}
*/
this.suites = function() {
return suites_hash;
@@ -98,7 +99,7 @@ getJasmineRequireObj().JsApiReporter = function() {
* @function
* @param {Number} index - The position in the specs list to start from.
* @param {Number} length - Maximum number of specs results to return.
* @return {SpecResult[]}
* @return {Object[]}
*/
this.specResults = function(index, length) {
return specs.slice(index, index + length);
@@ -108,7 +109,7 @@ getJasmineRequireObj().JsApiReporter = function() {
* Get all spec results.
* @name jsApiReporter#specs
* @function
* @return {SpecResult[]}
* @return {Object[]}
*/
this.specs = function() {
return specs;

View File

@@ -8,7 +8,7 @@ getJasmineRequireObj().pp = function(j$) {
function hasCustomToString(value) {
// value.toString !== Object.prototype.toString if value has no custom toString but is from another context (e.g.
// iframe, web worker)
return j$.isFunction_(value.toString) && value.toString !== Object.prototype.toString && (value.toString() !== Object.prototype.toString.call(value));
return value.toString !== Object.prototype.toString && (value.toString() !== Object.prototype.toString.call(value));
}
PrettyPrinter.prototype.format = function(value) {
@@ -36,12 +36,8 @@ getJasmineRequireObj().pp = function(j$) {
this.emitScalar('HTMLNode');
} else if (value instanceof Date) {
this.emitScalar('Date(' + value + ')');
} else if (j$.getType_(value) == '[object Set]') {
} else if (value.toString && value.toString() == '[object Set]') {
this.emitSet(value);
} else if (j$.getType_(value) == '[object Map]') {
this.emitMap(value);
} else if (j$.isTypedArray_(value)) {
this.emitTypedArray(value);
} else if (value.toString && typeof value === 'object' && !j$.isArray_(value) && hasCustomToString(value)) {
this.emitScalar(value.toString());
} else if (j$.util.arrayContains(this.seen, value)) {
@@ -63,28 +59,15 @@ getJasmineRequireObj().pp = function(j$) {
};
PrettyPrinter.prototype.iterateObject = function(obj, fn) {
var objKeys = keys(obj, j$.isArray_(obj));
var isGetter = function isGetter(prop) {};
if (obj.__lookupGetter__) {
isGetter = function isGetter(prop) {
var getter = obj.__lookupGetter__(prop);
return !j$.util.isUndefined(getter) && getter !== null;
};
for (var property in obj) {
if (!Object.prototype.hasOwnProperty.call(obj, property)) { continue; }
fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) &&
obj.__lookupGetter__(property) !== null) : false);
}
var length = Math.min(objKeys.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
for (var i = 0; i < length; i++) {
var property = objKeys[i];
fn(property, isGetter(property));
}
return objKeys.length > length;
};
PrettyPrinter.prototype.emitArray = j$.unimplementedMethod_;
PrettyPrinter.prototype.emitSet = j$.unimplementedMethod_;
PrettyPrinter.prototype.emitMap = j$.unimplementedMethod_;
PrettyPrinter.prototype.emitObject = j$.unimplementedMethod_;
PrettyPrinter.prototype.emitScalar = j$.unimplementedMethod_;
PrettyPrinter.prototype.emitString = j$.unimplementedMethod_;
@@ -92,7 +75,7 @@ getJasmineRequireObj().pp = function(j$) {
function StringPrettyPrinter() {
PrettyPrinter.call(this);
this.stringParts = [];
this.string = '';
}
j$.util.inherit(StringPrettyPrinter, PrettyPrinter);
@@ -124,7 +107,11 @@ getJasmineRequireObj().pp = function(j$) {
var self = this;
var first = array.length === 0;
var truncated = this.iterateObject(array, function(property, isGetter) {
this.iterateObject(array, function(property, isGetter) {
if (property.match(/^\d+$/)) {
return;
}
if (first) {
first = false;
} else {
@@ -134,8 +121,6 @@ getJasmineRequireObj().pp = function(j$) {
self.formatProperty(array, property, isGetter);
});
if (truncated) { this.append(', ...'); }
this.append(' ]');
};
@@ -159,26 +144,6 @@ getJasmineRequireObj().pp = function(j$) {
this.append(' )');
};
StringPrettyPrinter.prototype.emitMap = function(map) {
if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) {
this.append('Map');
return;
}
this.append('Map( ');
var size = Math.min(map.size, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
var iter = map.entries();
for (var i = 0; i < size; i++) {
if (i > 0) {
this.append(', ');
}
this.format(iter.next().value);
}
if (map.size > size){
this.append(', ...');
}
this.append(' )');
};
StringPrettyPrinter.prototype.emitObject = function(obj) {
var ctor = obj.constructor,
constructorName;
@@ -197,7 +162,7 @@ getJasmineRequireObj().pp = function(j$) {
this.append('({ ');
var first = true;
var truncated = this.iterateObject(obj, function(property, isGetter) {
this.iterateObject(obj, function(property, isGetter) {
if (first) {
first = false;
} else {
@@ -207,23 +172,9 @@ getJasmineRequireObj().pp = function(j$) {
self.formatProperty(obj, property, isGetter);
});
if (truncated) { this.append(', ...'); }
this.append(' })');
};
StringPrettyPrinter.prototype.emitTypedArray = function(arr) {
var constructorName = j$.fnNameFor(arr.constructor),
limitedArray = Array.prototype.slice.call(arr, 0, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH),
itemsString = Array.prototype.join.call(limitedArray, ', ');
if (limitedArray.length !== arr.length) {
itemsString += ', ...';
}
this.append(constructorName + ' [ ' + itemsString + ' ]');
};
StringPrettyPrinter.prototype.formatProperty = function(obj, property, isGetter) {
this.append(property);
this.append(': ');
@@ -235,41 +186,12 @@ getJasmineRequireObj().pp = function(j$) {
};
StringPrettyPrinter.prototype.append = function(value) {
this.stringParts.push(value);
this.string += value;
};
function keys(obj, isArray) {
var allKeys = Object.keys ? Object.keys(obj) :
(function(o) {
var keys = [];
for (var key in o) {
if (j$.util.has(o, key)) {
keys.push(key);
}
}
return keys;
})(obj);
if (!isArray) {
return allKeys;
}
if (allKeys.length === 0) {
return allKeys;
}
var extraKeys = [];
for (var i = 0; i < allKeys.length; i++) {
if (!/^[0-9]+$/.test(allKeys[i])) {
extraKeys.push(allKeys[i]);
}
}
return extraKeys;
}
return function(value) {
var stringPrettyPrinter = new StringPrettyPrinter();
stringPrettyPrinter.format(value);
return stringPrettyPrinter.stringParts.join('');
return stringPrettyPrinter.string;
};
};

View File

@@ -12,18 +12,15 @@ getJasmineRequireObj().QueueRunner = function(j$) {
}
function QueueRunner(attrs) {
var queueableFns = attrs.queueableFns || [];
this.queueableFns = queueableFns.concat(attrs.cleanupFns || []);
this.firstCleanupIx = queueableFns.length;
this.queueableFns = attrs.queueableFns || [];
this.onComplete = attrs.onComplete || function() {};
this.clearStack = attrs.clearStack || function(fn) {fn();};
this.onException = attrs.onException || function() {};
this.catchException = attrs.catchException || function() { return true; };
this.userContext = attrs.userContext || new j$.UserContext();
this.userContext = attrs.userContext || {};
this.timeout = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout};
this.fail = attrs.fail || function() {};
this.globalErrors = attrs.globalErrors || { pushListener: function() {}, popListener: function() {} };
this.completeOnFirstError = !!attrs.completeOnFirstError;
}
QueueRunner.prototype.execute = function() {
@@ -32,33 +29,22 @@ getJasmineRequireObj().QueueRunner = function(j$) {
self.onException(error);
};
this.globalErrors.pushListener(this.handleFinalError);
this.run(0);
this.run(this.queueableFns, 0);
};
QueueRunner.prototype.skipToCleanup = function(lastRanIndex) {
if (lastRanIndex < this.firstCleanupIx) {
this.run(this.firstCleanupIx);
} else {
this.run(lastRanIndex + 1);
}
};
QueueRunner.prototype.run = function(recursiveIndex) {
var length = this.queueableFns.length,
QueueRunner.prototype.run = function(queueableFns, recursiveIndex) {
var length = queueableFns.length,
self = this,
iterativeIndex;
for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
var result = attempt(iterativeIndex);
if (!result.completedSynchronously) {
return;
}
if (this.completeOnFirstError && result.errored) {
this.skipToCleanup(iterativeIndex);
var queueableFn = queueableFns[iterativeIndex];
if (queueableFn.fn.length > 0) {
attemptAsync(queueableFn);
return;
} else {
attemptSync(queueableFn);
}
}
@@ -67,46 +53,41 @@ getJasmineRequireObj().QueueRunner = function(j$) {
self.onComplete();
});
function attempt() {
function attemptSync(queueableFn) {
try {
queueableFn.fn.call(self.userContext);
} catch (e) {
handleException(e, queueableFn);
}
}
function attemptAsync(queueableFn) {
var clearTimeout = function () {
Function.prototype.apply.apply(self.timeout.clearTimeout, [j$.getGlobal(), [timeoutId]]);
},
completedSynchronously = true,
setTimeout = function(delayedFn, delay) {
return Function.prototype.apply.apply(self.timeout.setTimeout, [j$.getGlobal(), [delayedFn, delay]]);
},
completedSynchronously = true,
handleError = function(error) {
onException(error);
next();
},
cleanup = once(function() {
next = once(function () {
clearTimeout(timeoutId);
self.globalErrors.popListener(handleError);
}),
next = once(function () {
cleanup();
function runNext() {
if (self.completeOnFirstError && errored) {
self.skipToCleanup(iterativeIndex);
} else {
self.run(iterativeIndex + 1);
}
}
if (completedSynchronously) {
setTimeout(runNext);
setTimeout(function() {
self.run(queueableFns, iterativeIndex + 1);
});
} else {
runNext();
self.run(queueableFns, iterativeIndex + 1);
}
}),
errored = false,
queueableFn = self.queueableFns[iterativeIndex],
timeoutId;
next.fail = function() {
self.fail.apply(null, arguments);
errored = true;
next();
};
@@ -121,39 +102,24 @@ getJasmineRequireObj().QueueRunner = function(j$) {
}
try {
if (queueableFn.fn.length === 0) {
var maybeThenable = queueableFn.fn.call(self.userContext);
if (maybeThenable && j$.isFunction_(maybeThenable.then)) {
maybeThenable.then(next, next.fail);
completedSynchronously = false;
return { completedSynchronously: false };
}
} else {
queueableFn.fn.call(self.userContext, next);
completedSynchronously = false;
return { completedSynchronously: false };
}
queueableFn.fn.call(self.userContext, next);
completedSynchronously = false;
} catch (e) {
handleException(e, queueableFn);
errored = true;
next();
}
}
cleanup();
return { completedSynchronously: true, errored: errored };
function onException(e) {
self.onException(e);
}
function onException(e) {
self.onException(e);
errored = true;
}
function handleException(e, queueableFn) {
onException(e);
if (!self.catchException(e)) {
//TODO: set a var when we catch an exception and
//use a finally block to close the loop in a nice way..
throw e;
}
function handleException(e, queueableFn) {
onException(e);
if (!self.catchException(e)) {
//TODO: set a var when we catch an exception and
//use a finally block to close the loop in a nice way..
throw e;
}
}
};

View File

@@ -18,16 +18,6 @@ getJasmineRequireObj().Spec = function(j$) {
this.pend();
}
/**
* @typedef SpecResult
* @property {Int} id - The unique id of this spec.
* @property {String} description - The description passed to the {@link it} that created this spec.
* @property {String} fullName - The full description including all ancestors of this spec.
* @property {Expectation[]} failedExpectations - The list of expectations that failed during execution of this spec.
* @property {Expectation[]} passedExpectations - The list of expectations that passed during execution of this spec.
* @property {String} pendingReason - If the spec is {@link pending}, this will be the reason.
* @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
*/
this.result = {
id: this.id,
description: this.description,
@@ -60,25 +50,20 @@ getJasmineRequireObj().Spec = function(j$) {
this.onStart(this);
var fns = this.beforeAndAfterFns();
var regularFns = fns.befores.concat(this.queueableFn);
if (!this.isExecutable() || this.markedPending || enabled === false) {
complete(enabled);
return;
}
var runnerConfig = {
isLeaf: true,
queueableFns: regularFns,
cleanupFns: fns.afters,
var fns = this.beforeAndAfterFns();
var allFns = fns.befores.concat(this.queueableFn).concat(fns.afters);
this.queueRunnerFactory({
queueableFns: allFns,
onException: function() { self.onException.apply(self, arguments); },
onComplete: complete,
userContext: this.userContext()
};
if (!this.isExecutable() || this.markedPending || enabled === false) {
runnerConfig.queueableFns = [];
runnerConfig.cleanupFns = [];
runnerConfig.onComplete = function() { complete(enabled); };
}
this.queueRunnerFactory(runnerConfig);
});
function complete(enabledAgain) {
self.result.status = self.status(enabledAgain);

View File

@@ -15,14 +15,6 @@ getJasmineRequireObj().Suite = function(j$) {
this.children = [];
/**
* @typedef SuiteResult
* @property {Int} id - The unique id of this suite.
* @property {String} description - The description text passed to the {@link describe} that made this suite.
* @property {String} fullName - The full description including all ancestors of this suite.
* @property {Expectation[]} failedExpectations - The list of expectations that failed in an {@link afterAll} for this suite.
* @property {String} status - Once the suite has completed, this string represents the pass/fail status of this suite.
*/
this.result = {
id: this.id,
description: this.description,
@@ -96,14 +88,14 @@ getJasmineRequireObj().Suite = function(j$) {
Suite.prototype.sharedUserContext = function() {
if (!this.sharedContext) {
this.sharedContext = this.parentSuite ? this.parentSuite.clonedSharedUserContext() : new j$.UserContext();
this.sharedContext = this.parentSuite ? clone(this.parentSuite.sharedUserContext()) : {};
}
return this.sharedContext;
};
Suite.prototype.clonedSharedUserContext = function() {
return j$.UserContext.fromExisting(this.sharedUserContext());
return clone(this.sharedUserContext());
};
Suite.prototype.onException = function() {
@@ -155,6 +147,17 @@ getJasmineRequireObj().Suite = function(j$) {
return !args[0];
}
function clone(obj) {
var clonedObj = {};
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) {
clonedObj[prop] = obj[prop];
}
}
return clonedObj;
}
return Suite;
};

View File

@@ -1,18 +0,0 @@
getJasmineRequireObj().UserContext = function(j$) {
function UserContext() {
}
UserContext.fromExisting = function(oldContext) {
var context = new UserContext();
for (var prop in oldContext) {
if (oldContext.hasOwnProperty(prop)) {
context[prop] = oldContext[prop];
}
}
return context;
};
return UserContext;
};

View File

@@ -4,9 +4,8 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
}
ArrayContaining.prototype.asymmetricMatch = function(other, customTesters) {
if (!j$.isArray_(this.sample)) {
throw new Error('You must provide an array to arrayContaining, not ' + j$.pp(this.sample) + '.');
}
var className = Object.prototype.toString.call(this.sample);
if (className !== '[object Array]') { throw new Error('You must provide an array to arrayContaining, not \'' + this.sample + '\'.'); }
for (var i = 0; i < this.sample.length; i++) {
var item = this.sample[i];

View File

@@ -1,31 +0,0 @@
getJasmineRequireObj().ArrayWithExactContents = function(j$) {
function ArrayWithExactContents(sample) {
this.sample = sample;
}
ArrayWithExactContents.prototype.asymmetricMatch = function(other, customTesters) {
if (!j$.isArray_(this.sample)) {
throw new Error('You must provide an array to arrayWithExactContents, not ' + j$.pp(this.sample) + '.');
}
if (this.sample.length !== other.length) {
return false;
}
for (var i = 0; i < this.sample.length; i++) {
var item = this.sample[i];
if (!j$.matchersUtil.contains(other, item, customTesters)) {
return false;
}
}
return true;
};
ArrayWithExactContents.prototype.jasmineToString = function() {
return '<jasmine.arrayWithExactContents ' + j$.pp(this.sample) + '>';
};
return ArrayWithExactContents;
};

View File

@@ -11,7 +11,6 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
j$.MAX_PRETTY_PRINT_DEPTH = 40;
/**
* Maximum number of array elements to display when pretty printing objects.
* This will also limit the number of keys and values displayed for an object.
* Elements past this number will be ellipised.
* @name jasmine.MAX_PRETTY_PRINT_ARRAY_LENGTH
*/
@@ -59,22 +58,6 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return j$.isA_('Function', value);
};
j$.isAsyncFunction_ = function(value) {
return j$.isA_('AsyncFunction', value);
};
j$.isTypedArray_ = function(value) {
return j$.isA_('Float32Array', value) ||
j$.isA_('Float64Array', value) ||
j$.isA_('Int16Array', value) ||
j$.isA_('Int32Array', value) ||
j$.isA_('Int8Array', value) ||
j$.isA_('Uint16Array', value) ||
j$.isA_('Uint32Array', value) ||
j$.isA_('Uint8Array', value) ||
j$.isA_('Uint8ClampedArray', value);
};
j$.isA_ = function(typeName, value) {
return j$.getType_(value) === '[object ' + typeName + ']';
};
@@ -92,9 +75,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return func.name;
}
var matches = func.toString().match(/^\s*function\s*(\w*)\s*\(/) ||
func.toString().match(/^\s*\[object\s*(\w*)Constructor\]/);
var matches = func.toString().match(/^\s*function\s*(\w*)\s*\(/);
return matches ? matches[1] : '<anonymous>';
};
@@ -152,17 +133,6 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return new j$.ArrayContaining(sample);
};
/**
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
* that will succeed if the actual value is an `Array` that contains all of the elements in the sample in any order.
* @name jasmine.arrayWithExactContents
* @function
* @param {Array} sample
*/
j$.arrayWithExactContents = function(sample) {
return new j$.ArrayWithExactContents(sample);
};
/**
* Create a bare {@link Spy} object. This won't be installed anywhere and will not have any implementation behind it.
* @name jasmine.createSpy

View File

@@ -66,17 +66,13 @@ getJasmineRequireObj().matchersUtil = function(j$) {
if (asymmetricA) {
result = a.asymmetricMatch(b, customTesters);
if (!result) {
diffBuilder.record(a, b);
}
diffBuilder.record(a, b);
return result;
}
if (asymmetricB) {
result = b.asymmetricMatch(a, customTesters);
if (!result) {
diffBuilder.record(a, b);
}
diffBuilder.record(a, b);
return result;
}
}
@@ -229,84 +225,35 @@ getJasmineRequireObj().matchersUtil = function(j$) {
// Recursively compare objects and arrays.
// Compare array lengths to determine if a deep comparison is necessary.
if (className == '[object Array]') {
var aLength = a.length;
var bLength = b.length;
size = a.length;
if (size !== b.length) {
diffBuilder.record(a, b);
return false;
}
diffBuilder.withPath('length', function() {
if (aLength !== bLength) {
diffBuilder.record(aLength, bLength);
result = false;
}
});
for (i = 0; i < aLength || i < bLength; i++) {
for (i = 0; i < size; i++) {
diffBuilder.withPath(i, function() {
result = eq(i < aLength ? a[i] : void 0, i < bLength ? b[i] : void 0, aStack, bStack, customTesters, diffBuilder) && result;
result = eq(a[i], b[i], aStack, bStack, customTesters, diffBuilder) && result;
});
}
if (!result) {
return false;
}
} else if (className == '[object Map]') {
if (a.size != b.size) {
diffBuilder.record(a, b);
return false;
}
// For both sets of keys, check they map to equal values in both maps
var mapKeys = [a.keys(), b.keys()];
var mapIter, mapKeyIt, mapKey;
for (i = 0; result && i < mapKeys.length; i++) {
mapIter = mapKeys[i];
mapKeyIt = mapIter.next();
while (result && !mapKeyIt.done) {
mapKey = mapKeyIt.value;
result = eq(a.get(mapKey), b.get(mapKey), aStack, bStack, customTesters, j$.NullDiffBuilder());
mapKeyIt = mapIter.next();
}
}
if (!result) {
diffBuilder.record(a, b);
return false;
}
} else if (className == '[object Set]') {
if (a.size != b.size) {
diffBuilder.record(a, b);
return false;
}
// For both sets, check they are all contained in the other set
var setPairs = [[a, b], [b, a]];
var baseIter, baseValueIt, baseValue;
var otherSet, otherIter, otherValueIt, otherValue, found;
for (i = 0; result && i < setPairs.length; i++) {
baseIter = setPairs[i][0].values();
otherSet = setPairs[i][1];
// For each value in the base set...
baseValueIt = baseIter.next();
while (result && !baseValueIt.done) {
baseValue = baseValueIt.value;
// ... test that it is present in the other set
otherIter = otherSet.values();
otherValueIt = otherIter.next();
// Optimisation: start looking for value by object identity
found = otherSet.has(baseValue);
// If not found, compare by value equality
while (!found && !otherValueIt.done) {
otherValue = otherValueIt.value;
found = eq(baseValue, otherValue, aStack, bStack, customTesters, j$.NullDiffBuilder());
otherValueIt = otherIter.next();
}
result = result && found;
baseValueIt = baseIter.next();
var iterA = a.values(), iterB = b.values();
var valA, valB;
do {
valA = iterA.next();
valB = iterB.next();
if (!eq(valA.value, valB.value, aStack, bStack, customTesters, j$.NullDiffBuilder())) {
diffBuilder.record(a, b);
return false;
}
}
if (!result) {
diffBuilder.record(a, b);
return false;
}
} while (!valA.done && !valB.done);
} else {
// Objects with different constructors are not equivalent, but `Object`s

View File

@@ -1,20 +0,0 @@
getJasmineRequireObj().nothing = function() {
/**
* {@link expect} nothing explicitly.
* @function
* @name matchers#nothing
* @example
* expect().nothing();
*/
function nothing() {
return {
compare: function() {
return {
pass: true
};
}
};
}
return nothing;
};

View File

@@ -1,6 +1,5 @@
getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
var availableMatchers = [
'nothing',
'toBe',
'toBeCloseTo',
'toBeDefined',

View File

@@ -15,18 +15,8 @@ getJasmineRequireObj().toBeCloseTo = function() {
precision = precision || 2;
}
if (expected === null || actual === null) {
throw new Error('Cannot use toBeCloseTo with null. Arguments evaluated to: ' +
'expect(' + actual + ').toBeCloseTo(' + expected + ').'
);
}
var pow = Math.pow(10, precision + 1);
var delta = Math.abs(expected - actual);
var maxDelta = Math.pow(10, -precision) / 2;
return {
pass: Math.round(delta * pow) / pow <= maxDelta
pass: Math.abs(expected - actual) < (Math.pow(10, -precision) / 2)
};
}
};

View File

@@ -41,7 +41,6 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
j$.matchersUtil = jRequire.matchersUtil(j$);
j$.ObjectContaining = jRequire.ObjectContaining(j$);
j$.ArrayContaining = jRequire.ArrayContaining(j$);
j$.ArrayWithExactContents = jRequire.ArrayWithExactContents(j$);
j$.pp = jRequire.pp(j$);
j$.QueueRunner = jRequire.QueueRunner(j$);
j$.ReportDispatcher = jRequire.ReportDispatcher();
@@ -50,7 +49,6 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
j$.SpyRegistry = jRequire.SpyRegistry(j$);
j$.SpyStrategy = jRequire.SpyStrategy(j$);
j$.StringMatching = jRequire.StringMatching(j$);
j$.UserContext = jRequire.UserContext(j$);
j$.Suite = jRequire.Suite(j$);
j$.Timer = jRequire.Timer();
j$.TreeProcessor = jRequire.TreeProcessor();

View File

@@ -1,15 +1,5 @@
getJasmineRequireObj().interface = function(jasmine, env) {
var jasmineInterface = {
/**
* Callback passed to parts of the Jasmine base interface.
*
* By default Jasmine assumes this function completes synchronously.
* If you have code that you need to test asynchronously, you can declare that you receive a `done` callback, return a Promise, or use the `async` keyword if it is supported in your environment.
* @callback implementationCallback
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
*/
/**
* Create a group of specs (often called a suite).
*
@@ -18,7 +8,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @function
* @global
* @param {String} description Textual description of the group
* @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites and specs
* @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites a specs
*/
describe: function(description, specDefinitions) {
return env.describe(description, specDefinitions);
@@ -32,7 +22,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @function
* @global
* @param {String} description Textual description of the group
* @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites and specs
* @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites a specs
*/
xdescribe: function(description, specDefinitions) {
return env.xdescribe(description, specDefinitions);
@@ -47,7 +37,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @function
* @global
* @param {String} description Textual description of the group
* @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites and specs
* @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites a specs
*/
fdescribe: function(description, specDefinitions) {
return env.fdescribe(description, specDefinitions);
@@ -61,7 +51,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @function
* @global
* @param {String} description Textual description of what this spec is checking
* @param {implementationCallback} [testFunction] Function that contains the code of your test. If not provided the test will be `pending`.
* @param {Function} [testFunction] Function that contains the code of your test. If not provided the test will be `pending`.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async spec.
*/
it: function() {
@@ -76,7 +66,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @function
* @global
* @param {String} description Textual description of what this spec is checking.
* @param {implementationCallback} [testFunction] Function that contains the code of your test. Will not be executed.
* @param {Function} [testFunction] Function that contains the code of your test. Will not be executed.
*/
xit: function() {
return env.xit.apply(env, arguments);
@@ -90,7 +80,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @function
* @global
* @param {String} description Textual description of what this spec is checking.
* @param {implementationCallback} testFunction Function that contains the code of your test.
* @param {Function} testFunction Function that contains the code of your test.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async spec.
*/
fit: function() {
@@ -102,7 +92,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @name beforeEach
* @function
* @global
* @param {implementationCallback} [function] Function that contains the code to setup your specs.
* @param {Function} [function] Function that contains the code to setup your specs.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async beforeEach.
*/
beforeEach: function() {
@@ -114,7 +104,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @name afterEach
* @function
* @global
* @param {implementationCallback} [function] Function that contains the code to teardown your specs.
* @param {Function} [function] Function that contains the code to teardown your specs.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async afterEach.
*/
afterEach: function() {
@@ -128,7 +118,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @name beforeAll
* @function
* @global
* @param {implementationCallback} [function] Function that contains the code to setup your specs.
* @param {Function} [function] Function that contains the code to setup your specs.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async beforeAll.
*/
beforeAll: function() {
@@ -136,13 +126,13 @@ getJasmineRequireObj().interface = function(jasmine, env) {
},
/**
* Run some shared teardown once after all of the specs in the {@link describe} are run.
* Run some shared teardown once before all of the specs in the {@link describe} are run.
*
* _Note:_ Be careful, sharing the teardown from a afterAll makes it easy to accidentally leak state between your specs so that they erroneously pass or fail.
* @name afterAll
* @function
* @global
* @param {implementationCallback} [function] Function that contains the code to teardown your specs.
* @param {Function} [function] Function that contains the code to teardown your specs.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async afterAll.
*/
afterAll: function() {

View File

@@ -181,7 +181,7 @@ jasmineRequire.HtmlReporter = function(j$) {
if (specsExecuted < totalSpecsDefined) {
var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
var skippedLink = addToExistingQueryString('spec', '');
var skippedLink = order && order.random ? '?random=true' : '?';
alert.appendChild(
createDom('span', {className: 'jasmine-bar jasmine-skipped'},
createDom('a', {href: skippedLink, title: 'Run all specs'}, skippedMessage)

View File

@@ -1,10 +1,4 @@
#!/bin/bash -e
rm -rf ~/.nvm
git clone https://github.com/creationix/nvm.git ~/.nvm
(cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`)
source ~/.nvm/nvm.sh
nvm install v0.12.18
npm install
npm test