Compare commits
159 Commits
v5.12.0
...
v7.0.0-pre
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9023b1fde | ||
|
|
27319fd6ae | ||
|
|
3de4512681 | ||
|
|
d230b0500d | ||
|
|
c6520763d8 | ||
|
|
e087ebc419 | ||
|
|
4bf333ed38 | ||
|
|
4f5ef7c2d7 | ||
|
|
63ac7da082 | ||
|
|
281c0d1ee8 | ||
|
|
8bb325628f | ||
|
|
ff0699035f | ||
|
|
f12f4395f0 | ||
|
|
5de03beea1 | ||
|
|
42baa422b3 | ||
|
|
6af5d24b3b | ||
|
|
b88ce2d49f | ||
|
|
c216ae1d13 | ||
|
|
319776d241 | ||
|
|
1d0718dc2f | ||
|
|
929694310e | ||
|
|
7379a3a11b | ||
|
|
4db18aafce | ||
|
|
066669cfee | ||
|
|
87177d9d43 | ||
|
|
0c75a154a8 | ||
|
|
0a6f6d2b0e | ||
|
|
6755b03f12 | ||
|
|
e759ddced2 | ||
|
|
1ad28d8515 | ||
|
|
3d36b11c8f | ||
|
|
a15df6d455 | ||
|
|
9f0488dc32 | ||
|
|
f3dba82b04 | ||
|
|
c999ce0787 | ||
|
|
5b76bf9552 | ||
|
|
9cf9b856b0 | ||
|
|
db6c142afd | ||
|
|
79405426fa | ||
|
|
03006080d4 | ||
|
|
876de65803 | ||
|
|
8b3c4ce3b4 | ||
|
|
00b09a9a04 | ||
|
|
f5e9b61f73 | ||
|
|
4371081763 | ||
|
|
9530ff68ab | ||
|
|
51dc79dc22 | ||
|
|
b559faec2a | ||
|
|
d7b1456584 | ||
|
|
23894c1a0a | ||
|
|
1e691b2470 | ||
|
|
c5555dd8cc | ||
|
|
32168be6c7 | ||
|
|
78c14f81a8 | ||
|
|
788eba34b6 | ||
|
|
1f31b4b0f6 | ||
|
|
00a8a11904 | ||
|
|
3899d83fb6 | ||
|
|
8f13684a01 | ||
|
|
bdf63f2402 | ||
|
|
9c2ffae2f9 | ||
|
|
7b2807b321 | ||
|
|
e930622548 | ||
|
|
56e2832ebe | ||
|
|
d31d33aeb3 | ||
|
|
e4c69e960e | ||
|
|
a8431f33bd | ||
|
|
4995c967ac | ||
|
|
9a9d3994da | ||
|
|
ff9feb29d3 | ||
|
|
fee7e6e64e | ||
|
|
18d4d38655 | ||
|
|
53e9bc68d2 | ||
|
|
2be50e1b87 | ||
|
|
27a1257b6d | ||
|
|
75658e0566 | ||
|
|
85322d1877 | ||
|
|
6667a42301 | ||
|
|
020dffd504 | ||
|
|
4201fd848f | ||
|
|
9a67c4e24d | ||
|
|
d66d0d9d2e | ||
|
|
f4b9c889b9 | ||
|
|
388d7fb1a2 | ||
|
|
e993a4a363 | ||
|
|
54ac39a192 | ||
|
|
ea882c2f1e | ||
|
|
4cc605756a | ||
|
|
b6426d2414 | ||
|
|
2352249441 | ||
|
|
4dfc34a7a0 | ||
|
|
695a805844 | ||
|
|
10bc655622 | ||
|
|
4663280528 | ||
|
|
75347d9ba0 | ||
|
|
86387c9068 | ||
|
|
9b3cc08818 | ||
|
|
0ad54fc6f0 | ||
|
|
c042665d9c | ||
|
|
a457cf1b81 | ||
|
|
fb814b5f94 | ||
|
|
77c3b8b07e | ||
|
|
bd89ef66c8 | ||
|
|
01f050eeaa | ||
|
|
de44e909f2 | ||
|
|
10ad40357a | ||
|
|
1f521f2a7f | ||
|
|
5b3e12e4c5 | ||
|
|
cfd8f11b30 | ||
|
|
d95ebf303a | ||
|
|
b881b0077d | ||
|
|
67ef721c85 | ||
|
|
c4abf3265d | ||
|
|
68a7cbb991 | ||
|
|
73a30ffc3e | ||
|
|
18491e9b84 | ||
|
|
0738ba6462 | ||
|
|
712f9bac29 | ||
|
|
d99bc3ab58 | ||
|
|
418393c496 | ||
|
|
2a83f5cc30 | ||
|
|
bca56032e0 | ||
|
|
dbcc1c924a | ||
|
|
90ee9a0cac | ||
|
|
b9f04f8702 | ||
|
|
e11f320df3 | ||
|
|
c2ce55580c | ||
|
|
4598e4049c | ||
|
|
168ff0a751 | ||
|
|
fbec066837 | ||
|
|
190a13ed96 | ||
|
|
979e4a5d0f | ||
|
|
8863643d55 | ||
|
|
7214ccd3dc | ||
|
|
970cbdc69c | ||
|
|
4020da25a4 | ||
|
|
4a36ece65b | ||
|
|
17c0567bae | ||
|
|
e2a7740322 | ||
|
|
6e0342fc8e | ||
|
|
d333ecb5b1 | ||
|
|
1e98a4b61b | ||
|
|
7aaa16f576 | ||
|
|
ee696cbbf6 | ||
|
|
88289f592e | ||
|
|
0462500c31 | ||
|
|
72ecc70c5d | ||
|
|
f86f8c3331 | ||
|
|
70fbdc98b5 | ||
|
|
4166ea791c | ||
|
|
5439c8c9cd | ||
|
|
2c6ce35ccc | ||
|
|
7c34b43607 | ||
|
|
3040abe23d | ||
|
|
4d3f6b272a | ||
|
|
6ab83e25d1 | ||
|
|
27297de3b8 | ||
|
|
3cbf4dc27b | ||
|
|
6d77f3e7f0 |
@@ -1,5 +1,5 @@
|
||||
# Run tests against supported Node versions, and (except for pull requests)
|
||||
# against supported browsers.
|
||||
# against supported browsers that are available on Saucelabs.
|
||||
|
||||
version: 2.1
|
||||
|
||||
@@ -16,10 +16,6 @@ executors:
|
||||
docker:
|
||||
- image: cimg/node:20.0.0
|
||||
working_directory: ~/workspace
|
||||
node18:
|
||||
docker:
|
||||
- image: cimg/node:18.20.5
|
||||
working_directory: ~/workspace
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -68,7 +64,7 @@ jobs:
|
||||
command: npm run test:parallel
|
||||
|
||||
test_browsers: &test_browsers
|
||||
executor: node18
|
||||
executor: node20
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: .
|
||||
@@ -93,7 +89,7 @@ jobs:
|
||||
export SAUCE_TUNNEL_NAME=$CIRCLE_WORKFLOW_JOB_ID
|
||||
scripts/start-sauce-connect
|
||||
set +o errexit
|
||||
scripts/run-all-browsers
|
||||
scripts/run-sauce-browsers
|
||||
exitcode=$?
|
||||
set -o errexit
|
||||
scripts/stop-sauce-connect
|
||||
@@ -113,9 +109,6 @@ workflows:
|
||||
- build:
|
||||
executor: node20
|
||||
name: build_node_20
|
||||
- build:
|
||||
executor: node18
|
||||
name: build_node_18
|
||||
- test_node:
|
||||
executor: node22
|
||||
name: test_node_22
|
||||
@@ -126,11 +119,6 @@ workflows:
|
||||
name: test_node_20
|
||||
requires:
|
||||
- build_node_20
|
||||
- test_node:
|
||||
executor: node18
|
||||
name: test_node_18
|
||||
requires:
|
||||
- build_node_18
|
||||
- test_parallel:
|
||||
executor: node24
|
||||
name: test_parallel_node_24
|
||||
@@ -147,13 +135,13 @@ workflows:
|
||||
requires:
|
||||
- build_node_20
|
||||
- test_parallel:
|
||||
executor: node18
|
||||
name: test_parallel_node_18
|
||||
executor: node20
|
||||
name: test_parallel_node_20
|
||||
requires:
|
||||
- build_node_18
|
||||
- build_node_20
|
||||
- test_browsers:
|
||||
requires:
|
||||
- build_node_18
|
||||
- build_node_20
|
||||
filters:
|
||||
branches:
|
||||
ignore: /pull\/.*/ # Don't run on pull requests.
|
||||
|
||||
10
.github/CONTRIBUTING.md
vendored
10
.github/CONTRIBUTING.md
vendored
@@ -41,13 +41,11 @@ Jasmine tests itself. The files in `lib` are loaded first, defining the referenc
|
||||
|
||||
The tests should always use `jasmineUnderTest` to refer to the objects and functions that are being tested. But the tests can use functions on `jasmine` as needed. _Be careful how you structure any new test code_. Copy the patterns you see in the existing code - this ensures that the code you're testing is not leaking into the `jasmine` reference and vice-versa.
|
||||
|
||||
### `boot0.js` and `boot1.js`
|
||||
### `boot.js`
|
||||
|
||||
These files file does all of the setup necessary for Jasmine to work in a
|
||||
browser. They load all of the code, create an `Env`, attach the global
|
||||
functions, and build the reporter. It also sets up the execution of the
|
||||
`Env` - for browsers this is in `window.onload`. While the default in `lib`
|
||||
is appropriate for browsers, projects may wish to customize this file.
|
||||
This file does all the setup necessary for Jasmine to work in a browser. While
|
||||
the default in `lib`is appropriate for most uses, users may wish to customize
|
||||
this file.
|
||||
|
||||
### Compatibility
|
||||
|
||||
|
||||
23
.github/workflows/safari.yml
vendored
Normal file
23
.github/workflows/safari.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
name: Test in latest available Safari
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
jobs:
|
||||
build:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- name: Report Safari version
|
||||
run: osascript -e 'get version of application "Safari"'
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use Node.js 22.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22.x
|
||||
- run: npm install
|
||||
- run: npm run build
|
||||
- run: JASMINE_BROWSER=safari npm run ci
|
||||
2
LICENSE
2
LICENSE
@@ -1,5 +1,5 @@
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
Copyright (c) 2008-2025 The Jasmine developers
|
||||
Copyright (c) 2008-2026 The Jasmine developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -29,8 +29,8 @@ Microsoft Edge) as well as Node.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|----------------------------------|
|
||||
| Node | 18.20.5+*, 20, 22, 24 |
|
||||
| Safari | 16*, 17* |
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari | 26* |
|
||||
| Chrome | Evergreen |
|
||||
| Firefox | Evergreen, 102*, 115*, 128*, 140 |
|
||||
| Edge | Evergreen |
|
||||
@@ -60,5 +60,5 @@ To find out what environments work with a particular Jasmine release, see the [r
|
||||
* Sheel Choksi
|
||||
|
||||
Copyright (c) 2008-2019 Pivotal Labs<br>
|
||||
Copyright (c) 2008-2025 The Jasmine developers<br>
|
||||
Copyright (c) 2008-2026 The Jasmine developers<br>
|
||||
This software is licensed under the [MIT License](https://github.com/jasmine/jasmine/blob/main/LICENSE).
|
||||
|
||||
15
RELEASE.md
15
RELEASE.md
@@ -28,9 +28,18 @@ should also rev to that version.
|
||||
|
||||
When ready to release - specs are all green and the stories are done:
|
||||
|
||||
1. Update the release notes in `release_notes` - use the Anchorman gem to generate the markdown file and edit accordingly. Include a list of supported environments.
|
||||
1. Update the version in `package.json`
|
||||
1. Run `npm run build`.
|
||||
1. Update the release notes in `release_notes` - use the Anchorman gem to
|
||||
generate the Markdown file and edit accordingly. Include a list of supported
|
||||
environments. Get that information from these places:
|
||||
* For Node, see .circleci/config.yml or the README.
|
||||
* For Firefox ESR and Safari <=17, see scripts/run-sauce-browsers or the README.
|
||||
* For evergreen browsers, trigger a Circle CI run and check the
|
||||
[Saucelabs dashboard](https://app.saucelabs.com/dashboard/tests?ownerId=90a771d55857492da3bd5251a2d92457&ownerType=user&ownerName=jasmine-js&start=last7days)
|
||||
once it's finished.
|
||||
* For Safari >17, trigger the [Safari action](https://github.com/jasmine/jasmine/actions/workflows/safari.yml)
|
||||
and get the version from the output.
|
||||
2. Update the version in `package.json`
|
||||
3. Run `npm run build`.
|
||||
|
||||
### Commit and push core changes
|
||||
|
||||
|
||||
@@ -1,88 +1,99 @@
|
||||
/**
|
||||
* Note: Only available on Node.
|
||||
* @module jasmine-core
|
||||
*/
|
||||
/*
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
Copyright (c) 2008-2026 The Jasmine developers
|
||||
|
||||
const jasmineRequire = require('./jasmine-core/jasmine.js');
|
||||
module.exports = jasmineRequire;
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
const boot = (function() {
|
||||
let jasmine, jasmineInterface;
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
return function bootWithoutGlobals(reinitialize) {
|
||||
if (!jasmineInterface || reinitialize === true) {
|
||||
jasmine = jasmineRequire.core(jasmineRequire);
|
||||
const env = jasmine.getEnv({ suppressLoadErrors: true });
|
||||
jasmineInterface = jasmineRequire.interface(jasmine, env);
|
||||
}
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
return {jasmine, jasmineInterface};
|
||||
};
|
||||
}());
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Boots a copy of Jasmine and returns an object as described in {@link jasmine}.
|
||||
* If boot is called multiple times, the same object is returned every time
|
||||
* unless true is passed.
|
||||
* @param {boolean} [reinitialize=false] Whether to create a new copy of Jasmine if one already exists
|
||||
* @type {function}
|
||||
* @return {jasmine}
|
||||
*/
|
||||
module.exports.boot = function(reinitialize) {
|
||||
const {jasmine, jasmineInterface} = boot(reinitialize);
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const {
|
||||
globals,
|
||||
installGlobals,
|
||||
version,
|
||||
private$
|
||||
} = require('./jasmine-core/jasmine.js');
|
||||
|
||||
for (const k in jasmineInterface) {
|
||||
global[k] = jasmineInterface[k];
|
||||
}
|
||||
|
||||
return jasmine;
|
||||
};
|
||||
|
||||
/**
|
||||
* Boots a copy of Jasmine and returns an object containing the properties
|
||||
* that would normally be added to the global object. If noGlobals is called
|
||||
* multiple times, the same object is returned every time unless true is passed.
|
||||
*
|
||||
* @param {boolean} [reinitialize=false] Whether to create a new copy of Jasmine if one already exists
|
||||
* @example
|
||||
* const {describe, beforeEach, it, expect, jasmine} = require('jasmine-core').noGlobals();
|
||||
*/
|
||||
module.exports.noGlobals = function(reinitialize) {
|
||||
const {jasmineInterface} = boot(reinitialize);
|
||||
return jasmineInterface;
|
||||
};
|
||||
|
||||
const path = require('path'),
|
||||
fs = require('fs');
|
||||
function reset() {
|
||||
private$.currentEnv_ = null;
|
||||
const env = jasmine.getEnv({ suppressLoadErrors: true });
|
||||
rebindInterface(env);
|
||||
}
|
||||
|
||||
const rootPath = path.join(__dirname, 'jasmine-core'),
|
||||
bootFiles = ['boot0.js', 'boot1.js'],
|
||||
legacyBootFiles = ['boot.js'],
|
||||
bootFiles = ['boot.js'],
|
||||
cssFiles = [],
|
||||
jsFiles = [],
|
||||
jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles);
|
||||
jsFilesToSkip = ['jasmine.js'].concat(bootFiles);
|
||||
|
||||
fs.readdirSync(rootPath).forEach(function(file) {
|
||||
if(fs.statSync(path.join(rootPath, file)).isFile()) {
|
||||
switch(path.extname(file)) {
|
||||
if (fs.statSync(path.join(rootPath, file)).isFile()) {
|
||||
switch (path.extname(file)) {
|
||||
case '.css':
|
||||
cssFiles.push(file);
|
||||
break;
|
||||
break;
|
||||
case '.js':
|
||||
if (jsFilesToSkip.indexOf(file) < 0) {
|
||||
jsFiles.push(file);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
module.exports.files = {
|
||||
self: __filename,
|
||||
path: rootPath,
|
||||
bootDir: rootPath,
|
||||
bootFiles: bootFiles,
|
||||
cssFiles: cssFiles,
|
||||
jsFiles: ['jasmine.js'].concat(jsFiles),
|
||||
imagesDir: path.join(__dirname, '../images')
|
||||
/**
|
||||
* Note: Only available on Node.
|
||||
*
|
||||
* In addition to the members documented here, this module's exports include all
|
||||
* {@link globals}.
|
||||
* @module jasmine-core
|
||||
*/
|
||||
module.exports = {
|
||||
...globals,
|
||||
/**
|
||||
* Copies Jasmine globals (jasmine, describe, it, etc) to the specified
|
||||
* object or to globalThis.
|
||||
* @function
|
||||
* @param {object} [dest] - The object to copy globals to.
|
||||
*/
|
||||
installGlobals,
|
||||
/**
|
||||
* Returns the jasmine-core version.
|
||||
* @function
|
||||
*/
|
||||
version,
|
||||
/**
|
||||
* Resets all of jasmine-core's state, including removing specs, suites, and
|
||||
* reporters, and resetting configuration to the default.
|
||||
* @function
|
||||
*/
|
||||
reset,
|
||||
files: {
|
||||
self: __filename,
|
||||
path: rootPath,
|
||||
bootDir: rootPath,
|
||||
bootFiles: bootFiles,
|
||||
cssFiles: cssFiles,
|
||||
jsFiles: ['jasmine.js'].concat(jsFiles),
|
||||
imagesDir: path.join(__dirname, '../images')
|
||||
}
|
||||
};
|
||||
|
||||
51
lib/jasmine-core/boot.js
Normal file
51
lib/jasmine-core/boot.js
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
Copyright (c) 2008-2026 The Jasmine developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
(function() {
|
||||
const env = jasmine.getEnv();
|
||||
const urls = new jasmine.HtmlReporterV2Urls();
|
||||
|
||||
/**
|
||||
* Configures Jasmine based on the current set of query parameters. This
|
||||
* supports all parameters set by the HTML reporter as well as
|
||||
* spec=partialPath, which filters out specs whose paths don't contain the
|
||||
* parameter.
|
||||
*/
|
||||
env.configure(urls.configFromCurrentUrl());
|
||||
|
||||
const currentWindowOnload = window.onload;
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
|
||||
// The HTML reporter needs to be set up here so it can access the DOM. Other
|
||||
// reporters can be added at any time before env.execute() is called.
|
||||
const htmlReporter = new jasmine.HtmlReporterV2({ env, urls });
|
||||
env.addReporter(htmlReporter);
|
||||
env.execute();
|
||||
};
|
||||
})();
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
Copyright (c) 2008-2025 The Jasmine developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
This file starts the process of "booting" Jasmine. It initializes Jasmine,
|
||||
makes its globals available, and creates the env. This file should be loaded
|
||||
after `jasmine.js` and `jasmine_html.js`, but before `boot1.js` or any project
|
||||
source files or spec files are loaded.
|
||||
*/
|
||||
(function() {
|
||||
const jasmineRequire = window.jasmineRequire || require('./jasmine.js');
|
||||
|
||||
/**
|
||||
* ## Require & Instantiate
|
||||
*
|
||||
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
|
||||
*/
|
||||
const jasmine = jasmineRequire.core(jasmineRequire),
|
||||
global = jasmine.getGlobal();
|
||||
global.jasmine = jasmine;
|
||||
|
||||
/**
|
||||
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
|
||||
*/
|
||||
jasmineRequire.html(jasmine);
|
||||
|
||||
/**
|
||||
* Create the Jasmine environment. This is used to run all specs in a project.
|
||||
*/
|
||||
const env = jasmine.getEnv();
|
||||
|
||||
/**
|
||||
* ## The Global Interface
|
||||
*
|
||||
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
|
||||
*/
|
||||
const jasmineInterface = jasmineRequire.interface(jasmine, env);
|
||||
|
||||
/**
|
||||
* Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
|
||||
*/
|
||||
for (const property in jasmineInterface) {
|
||||
global[property] = jasmineInterface[property];
|
||||
}
|
||||
})();
|
||||
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
Copyright (c) 2008-2025 The Jasmine developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
This file finishes 'booting' Jasmine, performing all of the necessary
|
||||
initialization before executing the loaded environment and all of a project's
|
||||
specs. This file should be loaded after `boot0.js` but before any project
|
||||
source files or spec files are loaded. Thus this file can also be used to
|
||||
customize Jasmine for a project.
|
||||
|
||||
If a project is using Jasmine via the standalone distribution, this file can
|
||||
be customized directly. If you only wish to configure the Jasmine env, you
|
||||
can load another file that calls `jasmine.getEnv().configure({...})`
|
||||
after `boot0.js` is loaded and before this file is loaded.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
const env = jasmine.getEnv();
|
||||
|
||||
/**
|
||||
* ## Runner Parameters
|
||||
*
|
||||
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
|
||||
*/
|
||||
|
||||
const queryString = new jasmine.QueryString({
|
||||
getWindowLocation: function() {
|
||||
return window.location;
|
||||
}
|
||||
});
|
||||
|
||||
const filterSpecs = !!queryString.getParam('spec');
|
||||
|
||||
const config = {
|
||||
stopOnSpecFailure: queryString.getParam('stopOnSpecFailure'),
|
||||
stopSpecOnExpectationFailure: queryString.getParam(
|
||||
'stopSpecOnExpectationFailure'
|
||||
),
|
||||
hideDisabled: queryString.getParam('hideDisabled')
|
||||
};
|
||||
|
||||
const random = queryString.getParam('random');
|
||||
|
||||
if (random !== undefined && random !== '') {
|
||||
config.random = random;
|
||||
}
|
||||
|
||||
const seed = queryString.getParam('seed');
|
||||
if (seed) {
|
||||
config.seed = seed;
|
||||
}
|
||||
|
||||
/**
|
||||
* ## Reporters
|
||||
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
|
||||
*/
|
||||
const htmlReporter = new jasmine.HtmlReporter({
|
||||
env: env,
|
||||
navigateWithNewParam: function(key, value) {
|
||||
return queryString.navigateWithNewParam(key, value);
|
||||
},
|
||||
addToExistingQueryString: function(key, value) {
|
||||
return queryString.fullStringWithNewParam(key, value);
|
||||
},
|
||||
getContainer: function() {
|
||||
return document.body;
|
||||
},
|
||||
createElement: function() {
|
||||
return document.createElement.apply(document, arguments);
|
||||
},
|
||||
createTextNode: function() {
|
||||
return document.createTextNode.apply(document, arguments);
|
||||
},
|
||||
timer: new jasmine.Timer(),
|
||||
filterSpecs: filterSpecs
|
||||
});
|
||||
|
||||
/**
|
||||
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
|
||||
*/
|
||||
env.addReporter(jsApiReporter);
|
||||
env.addReporter(htmlReporter);
|
||||
|
||||
/**
|
||||
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
|
||||
*/
|
||||
const specFilter = new jasmine.HtmlSpecFilter({
|
||||
filterString: function() {
|
||||
return queryString.getParam('spec');
|
||||
}
|
||||
});
|
||||
|
||||
config.specFilter = function(spec) {
|
||||
return specFilter.matches(spec.getFullName());
|
||||
};
|
||||
|
||||
env.configure(config);
|
||||
|
||||
/**
|
||||
* ## Execution
|
||||
*
|
||||
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
|
||||
*/
|
||||
const currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
htmlReporter.initialize();
|
||||
env.execute();
|
||||
};
|
||||
})();
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@ body {
|
||||
background-color: #eee;
|
||||
padding: 5px;
|
||||
margin: -8px;
|
||||
font-size: 11px;
|
||||
font-size: 12px;
|
||||
font-family: Monaco, "Lucida Console", monospace;
|
||||
line-height: 14px;
|
||||
color: #333;
|
||||
@@ -24,7 +24,6 @@ body {
|
||||
line-height: 14px;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-banner,
|
||||
.jasmine_html-reporter .jasmine-symbol-summary,
|
||||
.jasmine_html-reporter .jasmine-summary,
|
||||
.jasmine_html-reporter .jasmine-result-message,
|
||||
.jasmine_html-reporter .jasmine-spec .jasmine-description,
|
||||
@@ -63,57 +62,24 @@ body {
|
||||
float: right;
|
||||
line-height: 28px;
|
||||
padding-right: 9px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary {
|
||||
overflow: hidden;
|
||||
margin: 14px 0;
|
||||
.jasmine_html-reporter progress {
|
||||
width: 100%;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li {
|
||||
display: inline-block;
|
||||
height: 10px;
|
||||
width: 14px;
|
||||
font-size: 16px;
|
||||
.jasmine_html-reporter progress[value] {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed {
|
||||
font-size: 14px;
|
||||
.jasmine_html-reporter progress[value]::-webkit-progress-value, .jasmine_html-reporter progress[value]::-moz-progress-bar {
|
||||
background: #007069;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed:before {
|
||||
color: #007069;
|
||||
content: "•";
|
||||
.failed .jasmine_html-reporter progress[value]::-webkit-progress-value, .failed .jasmine_html-reporter progress[value]::-moz-progress-bar {
|
||||
background: #ca3a11;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed {
|
||||
line-height: 9px;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed:before {
|
||||
color: #ca3a11;
|
||||
content: "×";
|
||||
font-weight: bold;
|
||||
margin-left: -1px;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded {
|
||||
font-size: 14px;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded:before {
|
||||
color: #bababa;
|
||||
content: "•";
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded-no-display {
|
||||
font-size: 14px;
|
||||
display: none;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-pending {
|
||||
line-height: 17px;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-pending:before {
|
||||
color: #ba9d37;
|
||||
content: "*";
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-empty {
|
||||
font-size: 14px;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-empty:before {
|
||||
color: #ba9d37;
|
||||
content: "•";
|
||||
.jasmine_html-reporter progress.failed[value]::-webkit-progress-value, .jasmine_html-reporter progress.failed[value]::-moz-progress-bar {
|
||||
background: #ca3a11;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-run-options {
|
||||
float: right;
|
||||
@@ -145,8 +111,12 @@ body {
|
||||
display: block;
|
||||
color: #eee;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-bar.jasmine-in-progress {
|
||||
color: #333;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-bar.jasmine-failed, .jasmine_html-reporter .jasmine-bar.jasmine-errored {
|
||||
background-color: #ca3a11;
|
||||
color: #eee;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-bar.jasmine-passed {
|
||||
@@ -175,12 +145,16 @@ body {
|
||||
.jasmine_html-reporter .jasmine-bar a {
|
||||
color: white;
|
||||
}
|
||||
.jasmine_html-reporter.jasmine-spec-list .jasmine-bar.jasmine-menu.jasmine-failure-list,
|
||||
.jasmine_html-reporter.jasmine-spec-list .jasmine-results .jasmine-failures {
|
||||
.jasmine_html-reporter.jasmine-spec-list .jasmine-results .jasmine-failures,
|
||||
.jasmine_html-reporter.jasmine-spec-list .jasmine-performance-view {
|
||||
display: none;
|
||||
}
|
||||
.jasmine_html-reporter.jasmine-failure-list .jasmine-bar.jasmine-menu.jasmine-spec-list,
|
||||
.jasmine_html-reporter.jasmine-failure-list .jasmine-summary {
|
||||
.jasmine_html-reporter.jasmine-failure-list .jasmine-summary,
|
||||
.jasmine_html-reporter.jasmine-failure-list .jasmine-performance-view {
|
||||
display: none;
|
||||
}
|
||||
.jasmine_html-reporter.jasmine-performance .jasmine-results .jasmine-failures,
|
||||
.jasmine_html-reporter.jasmine-performance .jasmine-summary {
|
||||
display: none;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-results {
|
||||
@@ -301,4 +275,23 @@ body {
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-debug-log .jasmine-debug-log-msg {
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.jasmine-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.jasmine-tab + .jasmine-tab:before {
|
||||
content: " | ";
|
||||
}
|
||||
|
||||
.jasmine-performance-view h2, .jasmine-performance-view h3 {
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
.jasmine-performance-view table {
|
||||
border-spacing: 5px;
|
||||
}
|
||||
.jasmine-performance-view th, .jasmine-performance-view td {
|
||||
text-align: left;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jasmine-core",
|
||||
"license": "MIT",
|
||||
"version": "5.12.0",
|
||||
"version": "7.0.0-pre.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jasmine/jasmine.git"
|
||||
@@ -28,6 +28,9 @@
|
||||
"description": "Simple JavaScript testing framework for browsers and node.js",
|
||||
"homepage": "https://jasmine.github.io",
|
||||
"main": "./lib/jasmine-core.js",
|
||||
"exports": {
|
||||
".": "./lib/jasmine-core.js"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
@@ -43,10 +46,10 @@
|
||||
"ejs": "^3.1.10",
|
||||
"eslint": "^9.24.0",
|
||||
"eslint-plugin-compat": "^6.0.2",
|
||||
"glob": "^10.2.3",
|
||||
"glob": "^13.0.0",
|
||||
"globals": "^16.0.0",
|
||||
"jasmine": "^5.0.0",
|
||||
"jasmine-browser-runner": "github:jasmine/jasmine-browser-runner",
|
||||
"jasmine": "github:jasmine/jasmine-npm#7.0",
|
||||
"jasmine-browser-runner": "github:jasmine/jasmine-browser-runner#5.0",
|
||||
"jsdom": "^26.0.0",
|
||||
"prettier": "1.17.1",
|
||||
"sass": "^1.58.3"
|
||||
|
||||
29
release_notes/5.12.1.md
Normal file
29
release_notes/5.12.1.md
Normal file
@@ -0,0 +1,29 @@
|
||||
Jasmine Core 5.12.1 Release Notes
|
||||
|
||||
## Bug fixes
|
||||
|
||||
* Fix custom matchers in top-level specs
|
||||
* Merges [#2088](https://github.com/jasmine/jasmine/pull/2088) from @bonkevin
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------|--------------------------------|
|
||||
| Node | 18.20.5**, 20, 22, 24 |
|
||||
| Safari | 16**, 17** |
|
||||
| Chrome | 141* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 144* |
|
||||
| Edge | 141* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
44
release_notes/5.13.0.md
Normal file
44
release_notes/5.13.0.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# Jasmine Core 5.13.0 Release Notes
|
||||
|
||||
## Changes to supported environments
|
||||
|
||||
Safari 26 is now supported on a best-effort basis.
|
||||
|
||||
Due to the limited availability of Safari 18 and later on free CI services,
|
||||
Safari support in future jasmine-core versions will be limited to:
|
||||
|
||||
* Best-effort support for the latest Safari version available on GitHub Actions,
|
||||
which may change at any time.
|
||||
* Best-effort support for Safari 16 and 17 for as long as it remains practical.
|
||||
|
||||
## New Features
|
||||
|
||||
* New `extraItStackFrames` and `extraDescribeStackFrames` config options to fix
|
||||
the filename properties of reporter events in configurations that wrap
|
||||
`it`/`describe`, such as zone.js. The `filename` properties of reporter events
|
||||
are no longer deprecated.
|
||||
* `jasmine.allOf` asymmetric equality tester
|
||||
* Merges [#2087](https://github.com/jasmine/jasmine/issues/2083) from @jonahd-g
|
||||
* Fixes [#2083](https://github.com/jasmine/jasmine/pull/2087)
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------|--------------------------------|
|
||||
| Node | 18.20.5**, 20, 22, 24 |
|
||||
| Safari** | 16, 17, 26.1 |
|
||||
| Chrome | 142* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 145* |
|
||||
| Edge | 142* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
116
release_notes/6.0.0-alpha.1.md
Normal file
116
release_notes/6.0.0-alpha.1.md
Normal file
@@ -0,0 +1,116 @@
|
||||
# Jasmine Core 6.0.0-alpha.1 Release Notes
|
||||
|
||||
This is a pre-release, intended to offer a preview of breaking changes and to
|
||||
solicit feedback.
|
||||
|
||||
## A Note About Pre-Release Compatibility
|
||||
|
||||
There may be additional breaking changes in future 6.0 pre-releases or in the
|
||||
final 6.0 release. That's allowed by the semver specification, but users are
|
||||
sometimes unpleasantly surprised by it.
|
||||
|
||||
NPM's implementation of carat version ranges assumes that subsequent
|
||||
pre-releases and final releases are fully compatible with earlier pre-releases.
|
||||
If your package.json contains `"jasmine-core": "^6.0.0-alpha.1`,
|
||||
NPM might install any later 6.x version even though there is no guarantee of
|
||||
compatibility. If that isn't ok, you should specify an exact pre-release version:
|
||||
`"jasmine-core": "6.0.0-alpha.1`.
|
||||
|
||||
|
||||
## Breaking changes
|
||||
|
||||
### Changes that affect reporters
|
||||
|
||||
* Irrelevant properties such as `status` and `failedExpectations` are omitted
|
||||
from [the event passed to suiteStarted](https://jasmine.github.io/api/6.0.0-alpha.1/global.html#SuiteStartedEvent).
|
||||
|
||||
This change should be compatible with most existing reporters but could break
|
||||
reporters that manage their internal state in unusual ways. Please
|
||||
[open an issue](https://github.com/jasmine/jasmine/issues/new?template=bug_report.yml)
|
||||
if you find a published reporter package that works with jasmine-core 5.x but
|
||||
not with this release.
|
||||
|
||||
### Changes that affect browser boot files
|
||||
|
||||
* The `createElement` and `createTextNode` options of `HtmlReporter` are ignored.
|
||||
`HtmlReporter` now unconditionally uses `document.createElement` and
|
||||
`document.createTextNode`.
|
||||
|
||||
### Changes that affect spec writing
|
||||
|
||||
* HTML reporters cache configuration throughout each run. Configuration changes
|
||||
made while specs are running will not affect reporter behavior.
|
||||
* Global error spies always receive a single argument. Previously, the browser
|
||||
error event was passed as the second argument.
|
||||
|
||||
## New features
|
||||
|
||||
* A new `HtmlReporterV2` with several improvements over the old `HtmlReporter`:
|
||||
* Clicking a spec/suite link does exact filtering rather than a substring
|
||||
match.
|
||||
* The old dots are replaced with a progress bar. This improves usability with
|
||||
large suites and fixes an accessibility problem.
|
||||
* Details of failed specs are displayed as soon as each spec finishes.
|
||||
* Initialization and wire-up in boot files are much simpler.
|
||||
|
||||
If you're using jasmine-browser-runner or copying boot1.js from the standalone
|
||||
distribution, you'll automatically get the new reporter. If you maintain your
|
||||
own boot files, you'll get the old reporter unless you update your boot1.js
|
||||
to match the one that's in this package.
|
||||
|
||||
The new reporter produces `spec` query string parameters that are different
|
||||
from those created by the old reporter. If you use non-Jasmine software that
|
||||
interprets the `spec` parameter, such as karma-jasmine, you may not be able to
|
||||
adopt `HtmlReporterV2` unlesss it's updated.
|
||||
* Use `globalThis` to determine the global object during initialization
|
||||
This makes jasmine-core more tolerant of buggy bundlers or loaders that
|
||||
cause `this` to be undefined in the global context.
|
||||
|
||||
|
||||
## Deprecations
|
||||
|
||||
* Warn if jasmine-core is loaded as an ES module in a browser.
|
||||
This is an untested and unsupported configuration that has been known to cause
|
||||
problems in the past.
|
||||
* Deprecated `HtmlReporter` and `HtmlSpecFilter` in favor of `HtmlReporterV2`.
|
||||
|
||||
|
||||
## Documentation improvements
|
||||
|
||||
* Improved API reference documentation for APIs that are used from browser boot
|
||||
files.
|
||||
|
||||
|
||||
## Internal improvements
|
||||
|
||||
* Removed remaining code that supported suite re-entry.
|
||||
* Encapsulated suite and spec result and status management.
|
||||
* Adopted strict mode throughout the codebase.
|
||||
* Decomposed `HtmlReporter` into components and converted to ES6 classes.
|
||||
* Made global error handling more uniform between browsers and Node.
|
||||
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari | 16**, 17** |
|
||||
| Chrome | 141* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 143* |
|
||||
| Edge | 141* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
90
release_notes/6.0.0-alpha.2.md
Normal file
90
release_notes/6.0.0-alpha.2.md
Normal file
@@ -0,0 +1,90 @@
|
||||
# Jasmine Core 6.0.0-alpha.2 Release Notes
|
||||
|
||||
This is a pre-release, intended to offer a preview of upcoming changes and to
|
||||
solicit feedback.
|
||||
|
||||
## A Note About Pre-Release Compatibility
|
||||
|
||||
There may be additional breaking changes in future 6.0 pre-releases or in the
|
||||
final 6.0 release. That's allowed by the semver specification, but users are
|
||||
sometimes unpleasantly surprised by it.
|
||||
|
||||
NPM's implementation of carat version ranges assumes that subsequent
|
||||
pre-releases and final releases are fully compatible with earlier pre-releases.
|
||||
If your package.json contains `"jasmine-core": "^6.0.0-alpha.2`,
|
||||
NPM might install any later 6.x version even though there is no guarantee of
|
||||
compatibility. If that isn't ok, you should specify an exact pre-release version:
|
||||
`"jasmine-core": "6.0.0-alpha.2`.
|
||||
|
||||
|
||||
## Changes to supported environments
|
||||
|
||||
Safari 26 is now supported on a best-effort basis.†
|
||||
|
||||
Due to the limited availability of Safari 18 and later on free CI services,
|
||||
Safari support in future jasmine-core versions will be limited to:
|
||||
|
||||
* Best-effort support for the latest Safari version available on GitHub Actions,
|
||||
which may change at any time.
|
||||
* Best-effort support for Safari 16 and 17 for as long as it remains practical.
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
* Fix custom matchers in top-level specs††
|
||||
* Merges [#2088](https://github.com/jasmine/jasmine/pull/2088) from @bonkevin
|
||||
|
||||
## New features
|
||||
|
||||
* Larger body font size in HTML reporters
|
||||
* New Performance tab in HtmlReporterV2 shows metrics and a list of the slowest
|
||||
specs.
|
||||
* Experimental `safariYieldStrategy: "time"` config option, which may make
|
||||
Jasmine run significantly faster in Safari and similar browsers. So far, this
|
||||
option has not been tested on a wide variety of workloads. Feedback is
|
||||
appreciated.
|
||||
* New `extraItStackFrames` and `extraDescribeStackFrames` config options to fix
|
||||
the filename properties of reporter events in configurations that wrap
|
||||
`it`/`describe`, such as zone.js.†
|
||||
* `jasmine.allOf asymmetric` equality tester†
|
||||
* Merges [#2087](https://github.com/jasmine/jasmine/pull/2087) from @jonahd-g
|
||||
* Fixes [#2083](https://github.com/jasmine/jasmine/issues/2083)
|
||||
* Re-add support for partial spec name filtering via `spec` query parameter
|
||||
* Fixes [#2085](https://github.com/jasmine/jasmine/issues/2085).
|
||||
* Require spec/suite property keys to be strings, not just anything that's
|
||||
cloneable and serializable. This matches the existing API reference
|
||||
documentation.
|
||||
|
||||
## Documentation improvements
|
||||
|
||||
* Fix HtmlReporterV2 ctor example
|
||||
|
||||
## Internal Improvements
|
||||
|
||||
* Remove code to support browsers that don't have MessageChannel. Jasmine hasn't
|
||||
run in any such browsers since 2.x.
|
||||
|
||||
† Also likely to be included in a future 5.x release.<br>
|
||||
†† Also released in 5.12.1.
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari | 16**, 17**, 26** |
|
||||
| Chrome | 142* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 145* |
|
||||
| Edge | 142* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
74
release_notes/6.0.0-beta.0.md
Normal file
74
release_notes/6.0.0-beta.0.md
Normal file
@@ -0,0 +1,74 @@
|
||||
# Jasmine Core 6.0.0-beta.0 Release Notes
|
||||
|
||||
This is a pre-release, intended to offer a preview of upcoming changes and to
|
||||
solicit feedback.
|
||||
|
||||
## A Note About Pre-Release Compatibility
|
||||
|
||||
There may be additional breaking changes in future 6.0 pre-releases or in the
|
||||
final 6.0 release. That's allowed by the semver specification, but users are
|
||||
sometimes unpleasantly surprised by it.
|
||||
|
||||
NPM's implementation of carat version ranges assumes that subsequent
|
||||
pre-releases and final releases are fully compatible with earlier pre-releases.
|
||||
If your package.json contains `"jasmine-core": "^6.0.0-beta.0`,
|
||||
NPM might install any later 6.x version even though there is no guarantee of
|
||||
compatibility. If that isn't ok, you should specify an exact pre-release version:
|
||||
`"jasmine-core": "6.0.0-beta.0`.
|
||||
|
||||
|
||||
## Breaking changes
|
||||
|
||||
* boot1.js no longer adds jsApiReporter to the env.
|
||||
* HtmlReporterV2 initialization and boot1.js have been simplified. If you
|
||||
maintain your own boot file, update it to match the boot1.js included in this
|
||||
package.
|
||||
|
||||
|
||||
## New features
|
||||
|
||||
* Statically exposed pretty printer as jasmine.pp().
|
||||
|
||||
## Bug fixes
|
||||
|
||||
* Fixed HtmlReporterV2 progress bar when running a subset of specs.
|
||||
|
||||
|
||||
## Deprecations
|
||||
|
||||
* jsApiReporter is deprecated.
|
||||
* Detect monkey patching and emit a deprecation warning.
|
||||
|
||||
## Documentation improvements
|
||||
|
||||
* Documented the set of possible spec statuses.
|
||||
|
||||
|
||||
## Internal improvements
|
||||
|
||||
* Replaced isArray helper with native Array.isArray
|
||||
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari | 16**, 17**, 26.1** |
|
||||
| Chrome | 142* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 145* |
|
||||
| Edge | 142* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
47
release_notes/6.0.0-beta.1.md
Normal file
47
release_notes/6.0.0-beta.1.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# Jasmine Core 6.0.0-beta.1 Release Notes
|
||||
|
||||
This is a pre-release, intended to offer a preview of upcoming changes and to
|
||||
solicit feedback.
|
||||
|
||||
A corresponding release of the `jasmine` package is not planned because the
|
||||
change in this release only affects browser users.
|
||||
|
||||
## A Note About Pre-Release Compatibility
|
||||
|
||||
There may be additional breaking changes in future 6.0 pre-releases or in the
|
||||
final 6.0 release. That's allowed by the semver specification, but users are
|
||||
sometimes unpleasantly surprised by it.
|
||||
|
||||
NPM's implementation of carat version ranges assumes that subsequent
|
||||
pre-releases and final releases are fully compatible with earlier pre-releases.
|
||||
If your package.json contains `"jasmine-core": "^6.0.0-beta.1`,
|
||||
NPM might install any later 6.x version even though there is no guarantee of
|
||||
compatibility. If that isn't ok, you should specify an exact pre-release version:
|
||||
`"jasmine-core": "6.0.0-beta.1`.
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
* Revert to using window.onload in boot1.js. This fixes top level await in
|
||||
jasmine-browser-runner.
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari** | 16, 17, 26.1 |
|
||||
| Chrome | 143* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 145* |
|
||||
| Edge | 142* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
190
release_notes/6.0.0.md
Normal file
190
release_notes/6.0.0.md
Normal file
@@ -0,0 +1,190 @@
|
||||
# Jasmine Core 6.0.0 Release Notes
|
||||
|
||||
## Summary
|
||||
|
||||
This is a major release that includes breaking changes as well as significant
|
||||
new features. Many of the breaking changes and deprecations in this release are
|
||||
intended to improve the stability of the Jasmine ecosystem by making the
|
||||
distinction between public and private APIs more obvious, reducing exposure of
|
||||
jasmine-core's internal state, removing ambiguities from the reporter API, and
|
||||
warning about monkey patching.
|
||||
|
||||
6.x is intended to ba a relatively short-lived, transitional series. It is
|
||||
compatible with the current versions of karma-jasmine and other legacy Angular
|
||||
tools but emits deprecation warnings when used with them. 7.0 will drop
|
||||
compatibility with those tools. If you use Karma in a non-Angular context,
|
||||
consider migrating to a maintained alternative such as jasmine-browser-runner or
|
||||
web-test-runner. If you use Angular, please direct any questions about support
|
||||
for future versions of Jasmine to the Angular team.
|
||||
|
||||
Please see the [migration guide](https://jasmine.github.io/upgrade-guides/6.0)
|
||||
for more information. If you use Jasmine via the `jasmine` package, please see
|
||||
[its release notes](https://github.com/jasmine/jasmine-npm/blob/main/release_notes/6.0.0.md)
|
||||
as well.
|
||||
|
||||
|
||||
## Changes to supported environments
|
||||
|
||||
* Node 18 is no longer supported.
|
||||
|
||||
|
||||
## Breaking changes
|
||||
|
||||
### General
|
||||
|
||||
* Private APIs have been removed from the `jasmine` namespace.
|
||||
|
||||
The purpose of this change is to reduce the risk of users inadvertently
|
||||
depending on private APIs. Anything not covered by
|
||||
[the documentation](https://jasmine.github.io/pages/docs_home.html) remains
|
||||
private regardless of namespacing. Private APIs may be changed or removed in
|
||||
any release. This change is being made in a major release as a courtesy to
|
||||
users of libraries that depend on private APIs.
|
||||
|
||||
### Changes that affect spec writing
|
||||
|
||||
* Global error spies always receive a single argument. Previously, the browser
|
||||
error event was passed as the second argument.
|
||||
* If a spy is invoked via `.call(null, ...)` or `.apply(null, ...)`, the spy's
|
||||
`this` argument will be `null`. Previously it was `globalThis`.
|
||||
* Mock clock timing functions cannot be spied on. Previously this "worked" but
|
||||
prevented the mock clock from uninstalling itself.
|
||||
* The mock clock no longer supports the eval forms of `setTimeout` and
|
||||
`setInterval`.
|
||||
* Keys passed to `setSpecProperty`/`setSuiteProperty` must be strings. Values
|
||||
must be both structured-cloneable and JSON-serializable.
|
||||
|
||||
### Changes that affect configuration
|
||||
|
||||
* HTML reporters cache configuration throughout each run. Configuration changes
|
||||
made while specs are running will not affect reporter behavior.
|
||||
* If an execution order is passed to `Env#execute`, it must not enter any suite
|
||||
more than once.
|
||||
* The argument passed to spec filters is a
|
||||
[spec metadata](https://jasmine.github.io/api/6.0/Spec.html)
|
||||
instance, not the internal spec object.
|
||||
* The default value of the `forbidDuplicateNames` config option has been
|
||||
changed to true.
|
||||
|
||||
### Changes that affect reporters
|
||||
|
||||
This release includes changes that are intended to streamline and clarify the
|
||||
reporter interface, prevent sharing of mutable state, and prevent bugs involving
|
||||
non-serializable objects. These changes should be compatible with most existing
|
||||
reporters but could break reporters that manage their internal state in unusual
|
||||
ways.
|
||||
|
||||
* Meaningless properties such as `status` and `failedExpectations` are omitted
|
||||
from the events passed to [suiteStarted](https://jasmine.github.io/api/6.0/global.html#SuiteStartedEvent)
|
||||
and [specStarted](https://jasmine.github.io/api/6.0/global.html#SpecStartedEvent).
|
||||
* Reporter events are deep-cloned before being passed to each reporter. This
|
||||
protects reporters against later mutation by jasmine-core or other reporters.
|
||||
* The `expected` and `actual` properties of
|
||||
[passed and failed expectations](https://jasmine.github.io/api/6.0/global.html#ExpectationResult)
|
||||
have been removed.
|
||||
* The [order](https://jasmine.github.io/api/6.0/global.html#Order)
|
||||
property of the`jasmineStarted` and `jasmineDone` reporter events no longer
|
||||
includes undocumented properties.
|
||||
* boot1.js no longer adds `jsApiReporter` to the env.
|
||||
|
||||
### Changes that affect browser boot files
|
||||
|
||||
* The `createElement` and `createTextNode` options of the legacy `HtmlReporter`
|
||||
are ignored. `HtmlReporter` now unconditionally uses `document.createElement`
|
||||
and `document.createTextNode`.
|
||||
|
||||
### Changes to Node boot functions
|
||||
|
||||
* [boot](https://jasmine.github.io/api/6.0/module-jasmine-core.html#.boot)
|
||||
defaults to creating a new core instance each time it's called. This restores
|
||||
the pre-5.0 default behavior.
|
||||
* [noGlobals](https://jasmine.github.io/api/6.0/module-jasmine-core.html#.noGlobals)
|
||||
no longer takes a parameter. It always returns the same object when called
|
||||
repeatedly.
|
||||
|
||||
|
||||
## New features
|
||||
|
||||
* A new `HtmlReporterV2` with several improvements over the old `HtmlReporter`:
|
||||
* Clicking a spec/suite link does exact filtering rather than a substring
|
||||
match.
|
||||
* The old dots are replaced with a progress bar. This improves usability with
|
||||
large suites and fixes an accessibility problem.
|
||||
* Details of failed specs are displayed as soon as each spec finishes.
|
||||
* A Performance tab shows metrics and a list of the slowest specs.
|
||||
* Initialization and wire-up in boot files are much simpler.
|
||||
|
||||
If you're using jasmine-browser-runner or copying boot1.js from the standalone
|
||||
distribution, you'll automatically get the new reporter. If you maintain your
|
||||
own boot files, you'll get the old reporter unless you update your boot files
|
||||
to match the one that's in this package.
|
||||
|
||||
The new reporter produces `spec` query string parameters that are different
|
||||
from those created by the old reporter. If you use other software that
|
||||
interprets the `spec` parameter, such as karma-jasmine, you won't be able to
|
||||
adopt `HtmlReporterV2` unlesss that other software is updated.
|
||||
|
||||
* Larger body font size in HTML reporters
|
||||
* `globalThis` is used to determine the global object during initialization
|
||||
This makes jasmine-core more tolerant of buggy bundlers or loaders that
|
||||
cause `this` to be undefined in the global context.
|
||||
* Experimental [`safariYieldStrategy: "time"`](https://jasmine.github.io/api/6.0/Configuration.html#safariYieldStrategy)
|
||||
config option, which may make Jasmine run significantly faster in Safari and
|
||||
similar browsers. So far, this option has not been tested on a wide variety of
|
||||
workloads. Feedback is appreciated.
|
||||
* Statically exposed pretty printer as `jasmine.pp()`.
|
||||
|
||||
|
||||
## Deprecations
|
||||
|
||||
* Common monkey patching patterns are detected and result in a deprecation
|
||||
warning. Code that overwrites anything provided by jasmine-core (other than
|
||||
globals like `it`/`expect`/etc or configuration properties like
|
||||
`jasmine.DEFAULT_TIMEOUT_INTERVAL`) may be broken by any jasmine-core release.
|
||||
* Warn if jasmine-core is loaded as an ES module in a browser.
|
||||
This is an untested and unsupported configuration that has been known to cause
|
||||
problems.
|
||||
* `HtmlReporter` and `HtmlSpecFilter` are deprecated in favor of `HtmlReporterV2`.
|
||||
* `jsApiReporter` is deprecated.
|
||||
|
||||
|
||||
## Documentation improvements
|
||||
|
||||
* Improved API reference documentation for APIs that are used from browser boot
|
||||
files.
|
||||
* Documented the set of possible spec statuses.
|
||||
* Documented that globals are overwriteable.
|
||||
|
||||
|
||||
## Internal improvements
|
||||
|
||||
* Encapsulated suite and spec result and status management.
|
||||
* Adopted strict mode throughout the codebase.
|
||||
* Decomposed `HtmlReporter` into components and converted to ES6 classes.
|
||||
* Made global error handling more uniform between browsers and Node.
|
||||
* Removed code to support browsers that don't have `MessageChannel`. Jasmine
|
||||
hasn't run in any such browsers since 2.x.
|
||||
* Replaced `isArray` helper with native `Array.isArray`.
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari** | 16, 17, 26.2 |
|
||||
| Chrome | 143* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 147* |
|
||||
| Edge | 143* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
29
release_notes/6.0.1.md
Normal file
29
release_notes/6.0.1.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Jasmine Core 6.0.1 Release Notes
|
||||
|
||||
## Bug fixes
|
||||
|
||||
* Don't emit a deprecation warning when `jasmineRequire.core` is called from an
|
||||
ES module
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari** | 16, 17, 26.2 |
|
||||
| Chrome | 143* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 147* |
|
||||
| Edge | 143* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
40
release_notes/6.1.0.md
Normal file
40
release_notes/6.1.0.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# Jasmine Core 6.1.0 Release Notes
|
||||
|
||||
## Changes to supported environments
|
||||
|
||||
* Safari 16 and 17 are no longer supported. Although jasmine-core may still work
|
||||
in those versions, we no longer have a reliable way to test them and won't try
|
||||
to maintain compatibility with them in future releases.
|
||||
|
||||
## New features
|
||||
|
||||
* Report the underlying errors that make up an `AggregateError`.
|
||||
* Merges [#2093](https://github.com/jasmine/jasmine/pull/2093) from @puglyfe
|
||||
* Fixes [#2063](https://github.com/jasmine/jasmine/issues/2063)
|
||||
|
||||
## Documentation improvements
|
||||
|
||||
* Fix default MAX_PRETTY_PRINT_CHARS in JsDoc.
|
||||
* Merges [#2091](https://github.com/jasmine/jasmine/pull/2091) from @HolgerJeromin
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari | 26.3** |
|
||||
| Chrome | 144* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 147* |
|
||||
| Edge | 144* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
58
release_notes/7.0.0-pre.0.md
Normal file
58
release_notes/7.0.0-pre.0.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# Jasmine Core 7.0.0-pre.0 Release Notes
|
||||
|
||||
This is a pre-release, intended to offer a preview of breaking changes and to
|
||||
solicit feedback.
|
||||
|
||||
Before installing this release, update to 6.0.1 or later and fix all
|
||||
deprecation warnings.
|
||||
|
||||
## Breaking changes
|
||||
|
||||
* `HtmlReporter`, `HtmlSpecFilter`, and `jsApiReporter`, which were deprecated
|
||||
in 6.0, have been removed.
|
||||
* Most private APIs are no longer exposed.
|
||||
* Monkey patching is blocked. This does not affect globals (`describe`,
|
||||
`expect`, etc.) or properties that are explicitly documented as writeable.
|
||||
Those can still be overwritten.
|
||||
* Redesigned boot process:
|
||||
* `jasmineRequire`, `boot`, and `noGlobals` have been removed.
|
||||
* The core instance is automatically created.
|
||||
* In browsers, globals are automatically created.
|
||||
* In Node, globals are not automatically created. Call the exported
|
||||
`installGlobals` function to create them. If you're using the `jasmine`
|
||||
package, this is done for you by default.
|
||||
* In Node, the same instance is returned every time jasmine-core is imported.
|
||||
If you need to do multiple consecutive independent test runs, call the
|
||||
exported `reset` function to reset all state and configuration between runs.
|
||||
|
||||
If you maintain your own browser boot files, you may be able to update by just
|
||||
removing `boot1.js`. See the `boot.js` file in this package for a working
|
||||
example. If you boot jasmine-core in Node, remove the call to `boot` or
|
||||
`noGlobals` and add a call to `installGlobals` if desired:
|
||||
|
||||
```javascript
|
||||
const jasmineCore = require('jasmine-core');
|
||||
jasmineCore.installGlobals();
|
||||
```
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari | 26.3** |
|
||||
| Chrome | 144* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 147* |
|
||||
| Edge | 144* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
@@ -42,8 +42,7 @@ async function zipStandaloneDist(jasmineVersion) {
|
||||
'lib/jasmine-core/jasmine.js',
|
||||
'lib/jasmine-core/jasmine-html.js',
|
||||
'lib/jasmine-core/jasmine.css',
|
||||
'lib/jasmine-core/boot0.js',
|
||||
'lib/jasmine-core/boot1.js',
|
||||
'lib/jasmine-core/boot.js',
|
||||
],
|
||||
destDir: 'lib/jasmine-' + jasmineVersion
|
||||
},
|
||||
|
||||
@@ -34,18 +34,20 @@ function concatFiles() {
|
||||
const configs = [
|
||||
{
|
||||
src: [
|
||||
{ literal: '(function() {' },
|
||||
'src/html/requireHtml.js',
|
||||
'src/html/HtmlReporter.js',
|
||||
'src/html/HtmlSpecFilter.js',
|
||||
'src/html/ResultsNode.js',
|
||||
'src/html/QueryString.js',
|
||||
'src/html/**/*.js'
|
||||
{ glob: 'src/html/**/*.js', exclude: 'src/html/requireSuffix.js' },
|
||||
'src/html/requireSuffix.js',
|
||||
{ literal: '})()' },
|
||||
],
|
||||
dest: 'lib/jasmine-core/jasmine-html.js',
|
||||
},
|
||||
{
|
||||
dest: 'lib/jasmine-core/jasmine.js',
|
||||
src: [
|
||||
{ literal: '(function() {' },
|
||||
'src/core/requireCore.js',
|
||||
'src/core/matchers/requireMatchers.js',
|
||||
'src/core/base.js',
|
||||
@@ -53,23 +55,24 @@ function concatFiles() {
|
||||
'src/core/Spec.js',
|
||||
'src/core/Order.js',
|
||||
'src/core/Env.js',
|
||||
'src/core/JsApiReporter.js',
|
||||
'src/core/PrettyPrinter',
|
||||
'src/core/Suite',
|
||||
'src/core/**/*.js',
|
||||
{ glob: 'src/core/**/*.js', exclude: 'src/core/requireSuffix.js'},
|
||||
{
|
||||
template: 'src/version.js',
|
||||
data: {version: pkg.version}
|
||||
},
|
||||
'src/core/requireSuffix.js',
|
||||
{ literal: '})()' },
|
||||
],
|
||||
},
|
||||
{
|
||||
dest: 'lib/jasmine-core/boot0.js',
|
||||
src: ['src/boot/boot0.js'],
|
||||
dest: 'lib/jasmine-core/boot.js',
|
||||
src: ['src/boot/boot.js'],
|
||||
},
|
||||
{
|
||||
dest: 'lib/jasmine-core/boot1.js',
|
||||
src: ['src/boot/boot1.js'],
|
||||
dest: 'lib/jasmine-core.js',
|
||||
src: ['src/boot/jasmine-core.js'],
|
||||
}
|
||||
];
|
||||
const licenseBanner = {
|
||||
@@ -81,25 +84,28 @@ function concatFiles() {
|
||||
src.unshift(licenseBanner);
|
||||
|
||||
function expand(srcListEntry) {
|
||||
if (typeof srcListEntry === 'object') {
|
||||
if (typeof srcListEntry === 'object' && !srcListEntry.glob) {
|
||||
return srcListEntry;
|
||||
}
|
||||
|
||||
return glob.sync(srcListEntry)
|
||||
.sort(function (a, b) {
|
||||
// Match the sort order of previous build tools, so that the
|
||||
// output is the same.
|
||||
a = a.toLowerCase();
|
||||
b = b.toLowerCase();
|
||||
const matches = glob.sync(
|
||||
srcListEntry.glob ?? srcListEntry,
|
||||
{ignore: srcListEntry.exclude}
|
||||
);
|
||||
return matches.sort(function (a, b) {
|
||||
// Match the sort order of previous build tools, so that the
|
||||
// output is the same.
|
||||
a = a.toLowerCase();
|
||||
b = b.toLowerCase();
|
||||
|
||||
if (a < b) {
|
||||
return -1;
|
||||
} else if (a === b) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
if (a < b) {
|
||||
return -1;
|
||||
} else if (a === b) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const srcs = src.flatMap(expand);
|
||||
@@ -113,6 +119,8 @@ function concatFiles() {
|
||||
if (s.template) {
|
||||
const template = fs.readFileSync(s.template, {encoding: 'utf8'});
|
||||
content = ejs.render(template, s.data);
|
||||
} else if (s.literal) {
|
||||
content = s.literal;
|
||||
} else {
|
||||
content = fs.readFileSync(s, {encoding: 'utf8'});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Run tests in supported browsers that are available on Saucelabs.
|
||||
# Note: Safari is tested via GitHub Actions because Saucelabs only makes Safari
|
||||
# 18 and later available to paid enterprise accounts. See
|
||||
# .github/workflows/safari.yml.
|
||||
|
||||
run_browser() {
|
||||
browser=$1
|
||||
version=$2
|
||||
@@ -39,9 +44,6 @@ else
|
||||
fi
|
||||
run_browser firefox 102
|
||||
|
||||
run_browser safari 17
|
||||
run_browser safari 16
|
||||
|
||||
run_browser MicrosoftEdge latest
|
||||
|
||||
echo
|
||||
@@ -1,8 +1,9 @@
|
||||
verifyNoGlobals(() => require('../lib/jasmine-core.js').noGlobals());
|
||||
let jasmineCore;
|
||||
verifyNoGlobals(() => { jasmineCore = require('../lib/jasmine-core.js'); });
|
||||
jasmineCore.installGlobals();
|
||||
|
||||
const Jasmine = require('jasmine');
|
||||
const jasmineCore = require('../lib/jasmine-core.js');
|
||||
const runner = new Jasmine({jasmineCore: jasmineCore});
|
||||
const runner = new Jasmine({jasmineCore});
|
||||
|
||||
runner.loadConfigFile('./spec/support/jasmine.json');
|
||||
runner.exitOnCompletion = false;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('AsyncExpectation', function() {
|
||||
beforeEach(function() {
|
||||
jasmineUnderTest.Expectation.addAsyncCoreMatchers(
|
||||
jasmineUnderTest.asyncMatchers
|
||||
privateUnderTest.Expectation.addAsyncCoreMatchers(
|
||||
privateUnderTest.asyncMatchers
|
||||
);
|
||||
});
|
||||
|
||||
@@ -9,9 +9,9 @@ describe('AsyncExpectation', function() {
|
||||
it('converts a pass to a fail', function() {
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
actual = Promise.resolve(),
|
||||
pp = jasmineUnderTest.makePrettyPrinter(),
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
matchersUtil: new jasmineUnderTest.MatchersUtil({ pp: pp }),
|
||||
pp = privateUnderTest.makePrettyPrinter(),
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
actual: actual,
|
||||
addExpectationResult: addExpectationResult
|
||||
});
|
||||
@@ -30,8 +30,8 @@ describe('AsyncExpectation', function() {
|
||||
it('converts a fail to a pass', function() {
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
actual = Promise.reject(new Error('nope')),
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
matchersUtil: new jasmineUnderTest.MatchersUtil({
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
matchersUtil: new privateUnderTest.MatchersUtil({
|
||||
pp: function() {}
|
||||
}),
|
||||
actual: actual,
|
||||
@@ -55,7 +55,7 @@ describe('AsyncExpectation', function() {
|
||||
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
actual = dummyPromise(),
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
actual: actual,
|
||||
addExpectationResult: addExpectationResult
|
||||
});
|
||||
@@ -80,7 +80,7 @@ describe('AsyncExpectation', function() {
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
actual: Promise.reject('rejected'),
|
||||
addExpectationResult: addExpectationResult,
|
||||
matchersUtil: matchersUtil
|
||||
@@ -105,10 +105,10 @@ describe('AsyncExpectation', function() {
|
||||
buildFailureMessage: function() {
|
||||
return 'failure message';
|
||||
},
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
actual: Promise.reject('b'),
|
||||
addExpectationResult: addExpectationResult,
|
||||
matchersUtil: matchersUtil
|
||||
@@ -140,7 +140,7 @@ describe('AsyncExpectation', function() {
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const actual = Promise.reject(new Error('nope'));
|
||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
actual: actual,
|
||||
addExpectationResult: addExpectationResult,
|
||||
matchersUtil: matchersUtil
|
||||
@@ -161,11 +161,11 @@ describe('AsyncExpectation', function() {
|
||||
it('works with #not', function() {
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
actual = Promise.resolve(),
|
||||
pp = jasmineUnderTest.makePrettyPrinter(),
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
pp = privateUnderTest.makePrettyPrinter(),
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
actual: actual,
|
||||
addExpectationResult: addExpectationResult,
|
||||
matchersUtil: new jasmineUnderTest.MatchersUtil({ pp: pp })
|
||||
matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp })
|
||||
});
|
||||
|
||||
return expectation
|
||||
@@ -185,11 +185,11 @@ describe('AsyncExpectation', function() {
|
||||
it('works with #not and a custom message', function() {
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
actual = Promise.resolve('a'),
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
actual: actual,
|
||||
addExpectationResult: addExpectationResult,
|
||||
matchersUtil: new jasmineUnderTest.MatchersUtil({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
matchersUtil: new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
})
|
||||
});
|
||||
|
||||
@@ -214,7 +214,7 @@ describe('AsyncExpectation', function() {
|
||||
toFoo: function() {},
|
||||
toBar: function() {}
|
||||
},
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
customAsyncMatchers: asyncMatchers
|
||||
});
|
||||
|
||||
@@ -236,7 +236,7 @@ describe('AsyncExpectation', function() {
|
||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
matchersUtil: matchersUtil,
|
||||
customAsyncMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
@@ -263,7 +263,7 @@ describe('AsyncExpectation', function() {
|
||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
matchersUtil: matchersUtil,
|
||||
customAsyncMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
@@ -290,7 +290,7 @@ describe('AsyncExpectation', function() {
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
customAsyncMatchers: matchers,
|
||||
matchersUtil: matchersUtil,
|
||||
actual: 'an actual',
|
||||
@@ -303,8 +303,6 @@ describe('AsyncExpectation', function() {
|
||||
passed: true,
|
||||
message: '',
|
||||
error: undefined,
|
||||
expected: 'hello',
|
||||
actual: 'an actual',
|
||||
errorForStack: jasmine.any(Error)
|
||||
});
|
||||
});
|
||||
@@ -327,7 +325,7 @@ describe('AsyncExpectation', function() {
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
customAsyncMatchers: matchers,
|
||||
matchersUtil: matchersUtil,
|
||||
actual: 'an actual',
|
||||
@@ -338,8 +336,6 @@ describe('AsyncExpectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: 'an actual',
|
||||
message: '',
|
||||
error: undefined,
|
||||
errorForStack: jasmine.any(Error)
|
||||
@@ -362,7 +358,7 @@ describe('AsyncExpectation', function() {
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
actual: 'an actual',
|
||||
customAsyncMatchers: matchers,
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -372,8 +368,6 @@ describe('AsyncExpectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: 'an actual',
|
||||
message: 'I am a custom message',
|
||||
error: undefined,
|
||||
errorForStack: jasmine.any(Error)
|
||||
@@ -398,7 +392,7 @@ describe('AsyncExpectation', function() {
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
customAsyncMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -408,8 +402,6 @@ describe('AsyncExpectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: 'an actual',
|
||||
message: 'I am a custom message',
|
||||
error: undefined,
|
||||
errorForStack: jasmine.any(Error)
|
||||
@@ -428,9 +420,8 @@ describe('AsyncExpectation', function() {
|
||||
}
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const actual = 'an actual';
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
customAsyncMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -442,8 +433,6 @@ describe('AsyncExpectation', function() {
|
||||
passed: true,
|
||||
message: '',
|
||||
error: undefined,
|
||||
expected: 'hello',
|
||||
actual: actual,
|
||||
errorForStack: jasmine.any(Error)
|
||||
});
|
||||
});
|
||||
@@ -465,9 +454,8 @@ describe('AsyncExpectation', function() {
|
||||
}
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const actual = 'an actual';
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
customAsyncMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
matchersUtil: matchersUtil,
|
||||
@@ -478,8 +466,6 @@ describe('AsyncExpectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: actual,
|
||||
message: 'default message',
|
||||
error: undefined,
|
||||
errorForStack: jasmine.any(Error)
|
||||
@@ -501,9 +487,8 @@ describe('AsyncExpectation', function() {
|
||||
}
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const actual = 'an actual';
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
customAsyncMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -513,8 +498,6 @@ describe('AsyncExpectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: actual,
|
||||
message: 'I am a custom message',
|
||||
error: undefined,
|
||||
errorForStack: jasmine.any(Error)
|
||||
@@ -536,9 +519,8 @@ describe('AsyncExpectation', function() {
|
||||
}
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const actual = 'an actual';
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
customAsyncMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -548,8 +530,6 @@ describe('AsyncExpectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(true, {
|
||||
matcherName: 'toFoo',
|
||||
passed: true,
|
||||
expected: 'hello',
|
||||
actual: actual,
|
||||
message: '',
|
||||
error: undefined,
|
||||
errorForStack: jasmine.any(Error)
|
||||
@@ -574,9 +554,8 @@ describe('AsyncExpectation', function() {
|
||||
}
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const actual = 'an actual';
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
customAsyncMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -586,8 +565,6 @@ describe('AsyncExpectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: actual,
|
||||
message: "I'm a custom message",
|
||||
error: undefined,
|
||||
errorForStack: jasmine.any(Error)
|
||||
@@ -612,7 +589,7 @@ describe('AsyncExpectation', function() {
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
actual: 'an actual',
|
||||
customAsyncMatchers: matchers,
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -622,8 +599,6 @@ describe('AsyncExpectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: 'an actual',
|
||||
message: 'I am a custom message',
|
||||
error: undefined,
|
||||
errorForStack: jasmine.any(Error)
|
||||
@@ -646,7 +621,7 @@ describe('AsyncExpectation', function() {
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
actual: 'an actual',
|
||||
customAsyncMatchers: matchers,
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -656,8 +631,6 @@ describe('AsyncExpectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: 'an actual',
|
||||
message: 'I am a custom message',
|
||||
error: undefined,
|
||||
errorForStack: jasmine.any(Error)
|
||||
@@ -682,7 +655,7 @@ describe('AsyncExpectation', function() {
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
let expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
let expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
actual: 'an actual',
|
||||
customAsyncMatchers: matchers,
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -692,8 +665,6 @@ describe('AsyncExpectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: 'an actual',
|
||||
message: 'I am a custom message',
|
||||
error: undefined,
|
||||
errorForStack: jasmine.any(Error)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
describe('CallTracker', function() {
|
||||
it('tracks that it was called when executed', function() {
|
||||
const callTracker = new jasmineUnderTest.CallTracker();
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
|
||||
expect(callTracker.any()).toBe(false);
|
||||
|
||||
@@ -10,7 +10,7 @@ describe('CallTracker', function() {
|
||||
});
|
||||
|
||||
it('tracks that number of times that it is executed', function() {
|
||||
const callTracker = new jasmineUnderTest.CallTracker();
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
|
||||
expect(callTracker.count()).toEqual(0);
|
||||
|
||||
@@ -20,7 +20,7 @@ describe('CallTracker', function() {
|
||||
});
|
||||
|
||||
it('tracks the params from each execution', function() {
|
||||
const callTracker = new jasmineUnderTest.CallTracker();
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
|
||||
callTracker.track({ object: void 0, args: [] });
|
||||
callTracker.track({ object: {}, args: [0, 'foo'] });
|
||||
@@ -31,7 +31,7 @@ describe('CallTracker', function() {
|
||||
});
|
||||
|
||||
it("tracks the 'this' object from each execution", function() {
|
||||
const callTracker = new jasmineUnderTest.CallTracker();
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
|
||||
const this0 = {},
|
||||
this1 = {};
|
||||
@@ -45,13 +45,13 @@ describe('CallTracker', function() {
|
||||
});
|
||||
|
||||
it('returns any empty array when there was no call', function() {
|
||||
const callTracker = new jasmineUnderTest.CallTracker();
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
|
||||
expect(callTracker.argsFor(0)).toEqual([]);
|
||||
});
|
||||
|
||||
it('allows access for the arguments for all calls', function() {
|
||||
const callTracker = new jasmineUnderTest.CallTracker();
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
|
||||
callTracker.track({ object: {}, args: [] });
|
||||
callTracker.track({ object: {}, args: [0, 'foo'] });
|
||||
@@ -60,7 +60,7 @@ describe('CallTracker', function() {
|
||||
});
|
||||
|
||||
it('tracks the context and arguments for each call', function() {
|
||||
const callTracker = new jasmineUnderTest.CallTracker();
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
|
||||
callTracker.track({ object: {}, args: [] });
|
||||
callTracker.track({ object: {}, args: [0, 'foo'] });
|
||||
@@ -71,7 +71,7 @@ describe('CallTracker', function() {
|
||||
});
|
||||
|
||||
it('simplifies access to the arguments for the last (most recent) call', function() {
|
||||
const callTracker = new jasmineUnderTest.CallTracker();
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
|
||||
callTracker.track();
|
||||
callTracker.track({ object: {}, args: [0, 'foo'] });
|
||||
@@ -83,13 +83,13 @@ describe('CallTracker', function() {
|
||||
});
|
||||
|
||||
it("returns a useful falsy value when there isn't a last (most recent) call", function() {
|
||||
const callTracker = new jasmineUnderTest.CallTracker();
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
|
||||
expect(callTracker.mostRecent()).toBeFalsy();
|
||||
});
|
||||
|
||||
it('simplifies access to the arguments for the first (oldest) call', function() {
|
||||
const callTracker = new jasmineUnderTest.CallTracker();
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
|
||||
callTracker.track({ object: {}, args: [0, 'foo'] });
|
||||
|
||||
@@ -97,13 +97,13 @@ describe('CallTracker', function() {
|
||||
});
|
||||
|
||||
it("returns a useful falsy value when there isn't a first (oldest) call", function() {
|
||||
const callTracker = new jasmineUnderTest.CallTracker();
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
|
||||
expect(callTracker.first()).toBeFalsy();
|
||||
});
|
||||
|
||||
it('allows the tracking to be reset', function() {
|
||||
const callTracker = new jasmineUnderTest.CallTracker();
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
|
||||
callTracker.track();
|
||||
callTracker.track({ object: {}, args: [0, 'foo'] });
|
||||
@@ -117,7 +117,7 @@ describe('CallTracker', function() {
|
||||
});
|
||||
|
||||
it('allows object arguments to be shallow cloned', function() {
|
||||
const callTracker = new jasmineUnderTest.CallTracker();
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
callTracker.saveArgumentsByValue();
|
||||
|
||||
const objectArg = { foo: 'bar' },
|
||||
@@ -135,7 +135,7 @@ describe('CallTracker', function() {
|
||||
});
|
||||
|
||||
it('allows object arguments to be deep cloned', function() {
|
||||
const callTracker = new jasmineUnderTest.CallTracker();
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
callTracker.saveArgumentsByValue(args => JSON.parse(JSON.stringify(args)));
|
||||
|
||||
const objectArg = { foo: { bar: { baz: ['qux'] } } },
|
||||
@@ -158,7 +158,7 @@ describe('CallTracker', function() {
|
||||
});
|
||||
|
||||
it('can take any function to transform arguments when saving by value', function() {
|
||||
const callTracker = new jasmineUnderTest.CallTracker();
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
callTracker.saveArgumentsByValue(JSON.stringify);
|
||||
|
||||
const objectArg = { foo: { bar: { baz: ['qux'] } } },
|
||||
@@ -171,7 +171,7 @@ describe('CallTracker', function() {
|
||||
});
|
||||
|
||||
it('saves primitive arguments by value', function() {
|
||||
const callTracker = new jasmineUnderTest.CallTracker(),
|
||||
const callTracker = new privateUnderTest.CallTracker(),
|
||||
args = [undefined, null, false, '', /\s/, 0, 1.2, NaN];
|
||||
|
||||
callTracker.saveArgumentsByValue();
|
||||
|
||||
@@ -17,7 +17,7 @@ describe('Clock', function() {
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -51,7 +51,7 @@ describe('Clock', function() {
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -88,7 +88,7 @@ describe('Clock', function() {
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -122,7 +122,7 @@ describe('Clock', function() {
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -154,7 +154,7 @@ describe('Clock', function() {
|
||||
'delayedFunctionSchedulerFactory'
|
||||
),
|
||||
mockDate = {},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
delayedFunctionSchedulerFactory,
|
||||
mockDate
|
||||
@@ -178,7 +178,7 @@ describe('Clock', function() {
|
||||
'delayedFunctionSchedulerFactory'
|
||||
),
|
||||
mockDate = {},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
delayedFunctionSchedulerFactory,
|
||||
mockDate
|
||||
@@ -202,7 +202,7 @@ describe('Clock', function() {
|
||||
'delayedFunctionSchedulerFactory'
|
||||
),
|
||||
mockDate = {},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
delayedFunctionSchedulerFactory,
|
||||
mockDate
|
||||
@@ -226,7 +226,7 @@ describe('Clock', function() {
|
||||
'delayedFunctionSchedulerFactory'
|
||||
),
|
||||
mockDate = {},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
delayedFunctionSchedulerFactory,
|
||||
mockDate
|
||||
@@ -263,7 +263,7 @@ describe('Clock', function() {
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -306,7 +306,7 @@ describe('Clock', function() {
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -366,7 +366,7 @@ describe('Clock', function() {
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -408,6 +408,41 @@ describe('Clock', function() {
|
||||
expect(delayedFunctionScheduler.scheduleFunction).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('identifies its timing functions', function() {
|
||||
const fakeSetTimeout = jasmine.createSpy('global setTimeout');
|
||||
const fakeGlobal = { setTimeout: fakeSetTimeout };
|
||||
const delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
'delayedFunctionScheduler',
|
||||
['scheduleFunction']
|
||||
);
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
},
|
||||
mockDate
|
||||
);
|
||||
clock.install();
|
||||
|
||||
expect(
|
||||
fakeGlobal.setTimeout[privateUnderTest.Clock.IsMockClockTimingFn]
|
||||
).toEqual(true);
|
||||
expect(
|
||||
fakeGlobal.clearTimeout[privateUnderTest.Clock.IsMockClockTimingFn]
|
||||
).toEqual(true);
|
||||
expect(
|
||||
fakeGlobal.setInterval[privateUnderTest.Clock.IsMockClockTimingFn]
|
||||
).toEqual(true);
|
||||
expect(
|
||||
fakeGlobal.clearInterval[privateUnderTest.Clock.IsMockClockTimingFn]
|
||||
).toEqual(true);
|
||||
});
|
||||
|
||||
describe('setTimeout', function() {
|
||||
it('schedules the delayed function with the fake timer', function() {
|
||||
const fakeSetTimeout = jasmine.createSpy('setTimeout'),
|
||||
@@ -420,7 +455,7 @@ describe('Clock', function() {
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -465,7 +500,7 @@ describe('Clock', function() {
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -497,7 +532,7 @@ describe('Clock', function() {
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -527,7 +562,7 @@ describe('Clock', function() {
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -573,7 +608,7 @@ describe('Clock', function() {
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -605,7 +640,7 @@ describe('Clock', function() {
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -624,7 +659,7 @@ describe('Clock', function() {
|
||||
});
|
||||
|
||||
it('gives you a friendly reminder if the Clock is not installed and you tick', function() {
|
||||
const clock = new jasmineUnderTest.Clock(
|
||||
const clock = new privateUnderTest.Clock(
|
||||
{},
|
||||
jasmine.createSpyObj('delayedFunctionScheduler', ['tick'])
|
||||
);
|
||||
@@ -640,13 +675,13 @@ describe('Clock (acceptance)', function() {
|
||||
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
||||
delayedFn3 = jasmine.createSpy('delayedFn3'),
|
||||
recurring1 = jasmine.createSpy('recurring1'),
|
||||
delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: setTimeout },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -701,7 +736,7 @@ describe('Clock (acceptance)', function() {
|
||||
let clock;
|
||||
|
||||
beforeEach(() => {
|
||||
delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler();
|
||||
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
@@ -712,7 +747,7 @@ describe('Clock (acceptance)', function() {
|
||||
typeof window !== 'undefined' ? setTimeout.bind(window) : setTimeout;
|
||||
// passing a fake global allows us to preserve the real timing functions for use in tests
|
||||
const _global = { setTimeout: _setTimeout, setInterval: setInterval };
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
_global,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -850,13 +885,13 @@ describe('Clock (acceptance)', function() {
|
||||
|
||||
it('can clear a previously set timeout', function() {
|
||||
const clearedFn = jasmine.createSpy('clearedFn'),
|
||||
delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: function() {} },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -877,13 +912,13 @@ describe('Clock (acceptance)', function() {
|
||||
|
||||
it("can clear a previously set interval using that interval's handler", function() {
|
||||
const spy = jasmine.createSpy('spy'),
|
||||
delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
{ setInterval: function() {} },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -904,13 +939,13 @@ describe('Clock (acceptance)', function() {
|
||||
|
||||
it('correctly schedules functions after the Clock has advanced', function() {
|
||||
const delayedFn1 = jasmine.createSpy('delayedFn1'),
|
||||
delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: function() {} },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -931,13 +966,13 @@ describe('Clock (acceptance)', function() {
|
||||
it('correctly schedules functions while the Clock is advancing', function() {
|
||||
const delayedFn1 = jasmine.createSpy('delayedFn1'),
|
||||
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
||||
delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: function() {} },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -962,13 +997,13 @@ describe('Clock (acceptance)', function() {
|
||||
it('correctly calls functions scheduled while the Clock is advancing', function() {
|
||||
const delayedFn1 = jasmine.createSpy('delayedFn1'),
|
||||
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
||||
delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: function() {} },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -990,13 +1025,13 @@ describe('Clock (acceptance)', function() {
|
||||
it('correctly schedules functions scheduled while the Clock is advancing but after the Clock is uninstalled', function() {
|
||||
const delayedFn1 = jasmine.createSpy('delayedFn1'),
|
||||
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
||||
delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: function() {} },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -1022,10 +1057,10 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('does not mock the Date object by default', function() {
|
||||
const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
global = { Date: Date },
|
||||
mockDate = new jasmineUnderTest.MockDate(global),
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
mockDate = new privateUnderTest.MockDate(global),
|
||||
clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: setTimeout },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -1045,10 +1080,10 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('mocks the Date object and sets it to current time', function() {
|
||||
const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
global = { Date: Date },
|
||||
mockDate = new jasmineUnderTest.MockDate(global),
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
mockDate = new privateUnderTest.MockDate(global),
|
||||
clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: setTimeout },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -1075,10 +1110,10 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('mocks the Date object and sets it to a given time', function() {
|
||||
const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
global = { Date: Date },
|
||||
mockDate = new jasmineUnderTest.MockDate(global),
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
mockDate = new privateUnderTest.MockDate(global),
|
||||
clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: setTimeout },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -1108,10 +1143,10 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('throws mockDate is called with a non-Date', function() {
|
||||
const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
global = { Date: Date },
|
||||
mockDate = new jasmineUnderTest.MockDate(global),
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
mockDate = new privateUnderTest.MockDate(global),
|
||||
clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: setTimeout },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -1126,10 +1161,10 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('mocks the Date object and updates the date per delayed function', function() {
|
||||
const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
global = { Date: Date },
|
||||
mockDate = new jasmineUnderTest.MockDate(global),
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
mockDate = new privateUnderTest.MockDate(global),
|
||||
clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: setTimeout },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -1165,10 +1200,10 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('correctly clears a scheduled timeout while the Clock is advancing', function() {
|
||||
const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
global = { Date: Date, setTimeout: undefined },
|
||||
mockDate = new jasmineUnderTest.MockDate(global),
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
mockDate = new privateUnderTest.MockDate(global),
|
||||
clock = new privateUnderTest.Clock(
|
||||
global,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -1190,10 +1225,10 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('correctly clears a scheduled interval while the Clock is advancing', function() {
|
||||
const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
global = { Date: Date, setTimeout: undefined },
|
||||
mockDate = new jasmineUnderTest.MockDate(global),
|
||||
clock = new jasmineUnderTest.Clock(
|
||||
mockDate = new privateUnderTest.MockDate(global),
|
||||
clock = new privateUnderTest.Clock(
|
||||
global,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -1212,4 +1247,8 @@ describe('Clock (acceptance)', function() {
|
||||
|
||||
clock.tick(400);
|
||||
});
|
||||
|
||||
isNonMonkeyPatchableClass(privateUnderTest.Clock, function() {
|
||||
return new privateUnderTest.Clock({}, function() {}, {});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ describe('CompleteOnFirstErrorSkipPolicy', function() {
|
||||
describe('#skipTo', function() {
|
||||
describe('Before anything has errored', function() {
|
||||
it('returns the next index', function() {
|
||||
const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy(
|
||||
const policy = new privateUnderTest.CompleteOnFirstErrorSkipPolicy(
|
||||
arrayOfArbitraryFns(4),
|
||||
4
|
||||
);
|
||||
@@ -15,7 +15,7 @@ describe('CompleteOnFirstErrorSkipPolicy', function() {
|
||||
const fns = arrayOfArbitraryFns(4);
|
||||
fns[2].type = arbitraryCleanupType();
|
||||
fns[3].type = arbitraryCleanupType();
|
||||
const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy(fns);
|
||||
const policy = new privateUnderTest.CompleteOnFirstErrorSkipPolicy(fns);
|
||||
|
||||
policy.fnErrored(0);
|
||||
expect(policy.skipTo(0)).toEqual(2);
|
||||
@@ -27,7 +27,7 @@ describe('CompleteOnFirstErrorSkipPolicy', function() {
|
||||
it(`does not skip ${type} fns`, function() {
|
||||
const fns = arrayOfArbitraryFns(2);
|
||||
fns[1].type = type;
|
||||
const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy(
|
||||
const policy = new privateUnderTest.CompleteOnFirstErrorSkipPolicy(
|
||||
fns
|
||||
);
|
||||
|
||||
@@ -58,7 +58,7 @@ describe('CompleteOnFirstErrorSkipPolicy', function() {
|
||||
type: arbitraryCleanupType()
|
||||
}
|
||||
];
|
||||
const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy(
|
||||
const policy = new privateUnderTest.CompleteOnFirstErrorSkipPolicy(
|
||||
fns
|
||||
);
|
||||
|
||||
@@ -90,7 +90,7 @@ describe('CompleteOnFirstErrorSkipPolicy', function() {
|
||||
type: arbitraryCleanupType()
|
||||
}
|
||||
];
|
||||
const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy(
|
||||
const policy = new privateUnderTest.CompleteOnFirstErrorSkipPolicy(
|
||||
fns
|
||||
);
|
||||
|
||||
@@ -107,7 +107,7 @@ describe('CompleteOnFirstErrorSkipPolicy', function() {
|
||||
type: arbitraryCleanupType()
|
||||
}
|
||||
];
|
||||
const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy(fns);
|
||||
const policy = new privateUnderTest.CompleteOnFirstErrorSkipPolicy(fns);
|
||||
|
||||
policy.fnErrored(0);
|
||||
expect(policy.skipTo(0)).toEqual(1);
|
||||
|
||||
@@ -7,19 +7,22 @@ describe('Configuration', function() {
|
||||
'hideDisabled',
|
||||
'autoCleanClosures',
|
||||
'forbidDuplicateNames',
|
||||
'detectLateRejectionHandling'
|
||||
'detectLateRejectionHandling',
|
||||
'verboseDeprecations'
|
||||
];
|
||||
const allKeys = [
|
||||
...standardBooleanKeys,
|
||||
'seed',
|
||||
'specFilter',
|
||||
'verboseDeprecations'
|
||||
'extraItStackFrames',
|
||||
'extraDescribeStackFrames',
|
||||
'safariYieldStrategy'
|
||||
];
|
||||
Object.freeze(standardBooleanKeys);
|
||||
Object.freeze(allKeys);
|
||||
|
||||
it('provides defaults', function() {
|
||||
const subject = new jasmineUnderTest.Configuration();
|
||||
const subject = new privateUnderTest.Configuration();
|
||||
expect(subject.random).toEqual(true);
|
||||
expect(subject.seed).toBeNull();
|
||||
expect(subject.stopOnSpecFailure).toEqual(false);
|
||||
@@ -29,14 +32,17 @@ describe('Configuration', function() {
|
||||
expect(subject.specFilter()).toEqual(true);
|
||||
expect(subject.hideDisabled).toEqual(false);
|
||||
expect(subject.autoCleanClosures).toEqual(true);
|
||||
expect(subject.forbidDuplicateNames).toEqual(false);
|
||||
expect(subject.forbidDuplicateNames).toEqual(true);
|
||||
expect(subject.verboseDeprecations).toEqual(false);
|
||||
expect(subject.detectLateRejectionHandling).toEqual(false);
|
||||
expect(subject.extraItStackFrames).toEqual(0);
|
||||
expect(subject.extraDescribeStackFrames).toEqual(0);
|
||||
expect(subject.safariYieldStrategy).toEqual('count');
|
||||
});
|
||||
|
||||
describe('copy()', function() {
|
||||
it('returns a copy of the configuration as a plain old JS object', function() {
|
||||
const subject = new jasmineUnderTest.Configuration();
|
||||
const subject = new privateUnderTest.Configuration();
|
||||
|
||||
const copy = subject.copy();
|
||||
|
||||
@@ -51,7 +57,7 @@ describe('Configuration', function() {
|
||||
|
||||
describe('update()', function() {
|
||||
it('does not update properties that are absent from the parameter', function() {
|
||||
const subject = new jasmineUnderTest.Configuration();
|
||||
const subject = new privateUnderTest.Configuration();
|
||||
const originalValues = subject.copy();
|
||||
|
||||
subject.update({});
|
||||
@@ -60,7 +66,7 @@ describe('Configuration', function() {
|
||||
|
||||
function booleanPropertyBehavior(key) {
|
||||
it('does not update the property if the specified value is undefined', function() {
|
||||
const subject = new jasmineUnderTest.Configuration();
|
||||
const subject = new privateUnderTest.Configuration();
|
||||
const orig = subject[key];
|
||||
|
||||
subject.update({ [key]: undefined });
|
||||
@@ -69,7 +75,7 @@ describe('Configuration', function() {
|
||||
});
|
||||
|
||||
it('updates the property if the specified value is not undefined', function() {
|
||||
const subject = new jasmineUnderTest.Configuration();
|
||||
const subject = new privateUnderTest.Configuration();
|
||||
const orig = subject[key];
|
||||
|
||||
subject.update({ [key]: !orig });
|
||||
@@ -86,25 +92,8 @@ describe('Configuration', function() {
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: in the next major release, treat verboseDeprecations like other booleans
|
||||
it('sets verboseDeprecations when present', function() {
|
||||
const subject = new jasmineUnderTest.Configuration();
|
||||
const orig = subject.verboseDeprecations;
|
||||
|
||||
subject.update({ verboseDeprecations: !orig });
|
||||
expect(subject.verboseDeprecations).toEqual(!orig);
|
||||
|
||||
subject.update({ verboseDeprecations: orig });
|
||||
expect(subject.verboseDeprecations).toEqual(orig);
|
||||
|
||||
// For backwards compatibility, explicitly setting to undefined should
|
||||
// work. Undefined isn't officially valid but gets treated like false.
|
||||
subject.update({ verboseDeprecations: undefined });
|
||||
expect(subject.verboseDeprecations).toBeUndefined();
|
||||
});
|
||||
|
||||
it('sets specFilter when truthy', function() {
|
||||
const subject = new jasmineUnderTest.Configuration();
|
||||
const subject = new privateUnderTest.Configuration();
|
||||
const orig = subject.specFilter;
|
||||
|
||||
subject.update({ specFilter: undefined });
|
||||
@@ -119,7 +108,7 @@ describe('Configuration', function() {
|
||||
});
|
||||
|
||||
it('sets seed when not undefined', function() {
|
||||
const subject = new jasmineUnderTest.Configuration();
|
||||
const subject = new privateUnderTest.Configuration();
|
||||
|
||||
subject.update({ seed: undefined });
|
||||
expect(subject.seed).toBeNull();
|
||||
@@ -130,5 +119,48 @@ describe('Configuration', function() {
|
||||
subject.update({ seed: null });
|
||||
expect(subject.seed).toBeNull();
|
||||
});
|
||||
|
||||
it('sets extraItStackFrames when not undefined', function() {
|
||||
const subject = new privateUnderTest.Configuration();
|
||||
|
||||
subject.update({ extraItStackFrames: undefined });
|
||||
expect(subject.extraItStackFrames).toEqual(0);
|
||||
|
||||
subject.update({ extraItStackFrames: 100000 });
|
||||
expect(subject.extraItStackFrames).toEqual(100000);
|
||||
});
|
||||
|
||||
it('sets extraDescribeStackFrames when not undefined', function() {
|
||||
const subject = new privateUnderTest.Configuration();
|
||||
|
||||
subject.update({ extraDescribeStackFrames: undefined });
|
||||
expect(subject.extraDescribeStackFrames).toEqual(0);
|
||||
|
||||
subject.update({ extraDescribeStackFrames: 100000 });
|
||||
expect(subject.extraDescribeStackFrames).toEqual(100000);
|
||||
});
|
||||
|
||||
it('sets safariYieldStrategy when valid', function() {
|
||||
const subject = new privateUnderTest.Configuration();
|
||||
|
||||
subject.update({ safariYieldStrategy: undefined });
|
||||
expect(subject.safariYieldStrategy).toEqual('count');
|
||||
|
||||
subject.update({ safariYieldStrategy: 'time' });
|
||||
expect(subject.safariYieldStrategy).toEqual('time');
|
||||
|
||||
subject.update({ safariYieldStrategy: 'count' });
|
||||
expect(subject.safariYieldStrategy).toEqual('count');
|
||||
});
|
||||
|
||||
it('rejcts invalid safariYieldStrategy values', function() {
|
||||
const subject = new privateUnderTest.Configuration();
|
||||
|
||||
expect(function() {
|
||||
subject.update({ safariYieldStrategy: 'thyme' });
|
||||
}).toThrowError(
|
||||
"Invalid safariYieldStrategy value. Valid values are 'count' and 'time'."
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
describe('DelayedFunctionScheduler', function() {
|
||||
'use strict';
|
||||
|
||||
it('schedules a function for later execution', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn');
|
||||
|
||||
scheduler.scheduleFunction(fn, 0);
|
||||
@@ -12,19 +14,18 @@ describe('DelayedFunctionScheduler', function() {
|
||||
expect(fn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('schedules a string for later execution', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
strfn = 'horrible = true;';
|
||||
it('throws if a string is passed', function() {
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
|
||||
scheduler.scheduleFunction(strfn, 0);
|
||||
|
||||
scheduler.tick(0);
|
||||
|
||||
expect(horrible).toEqual(true);
|
||||
expect(function() {
|
||||
scheduler.scheduleFunction('horrible = true;', 0);
|
||||
}).toThrowError(
|
||||
'The mock clock does not support the eval form of setTimeout and setInterval. Pass a function instead of a string.'
|
||||
);
|
||||
});
|
||||
|
||||
it('#tick defaults to 0', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn');
|
||||
|
||||
scheduler.scheduleFunction(fn, 0);
|
||||
@@ -37,7 +38,7 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('defaults delay to 0', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn');
|
||||
|
||||
scheduler.scheduleFunction(fn);
|
||||
@@ -50,7 +51,7 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('optionally passes params to scheduled functions', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn');
|
||||
|
||||
scheduler.scheduleFunction(fn, 0, ['foo', 'bar']);
|
||||
@@ -63,7 +64,7 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('scheduled fns can optionally reoccur', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn');
|
||||
|
||||
scheduler.scheduleFunction(fn, 20, [], true);
|
||||
@@ -84,7 +85,7 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('increments scheduled fns ids unless one is passed', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler();
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
|
||||
const initial = scheduler.scheduleFunction(function() {}, 0);
|
||||
expect(scheduler.scheduleFunction(function() {}, 0)).toBe(initial + 1);
|
||||
@@ -96,7 +97,7 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('#removeFunctionWithId removes a previously scheduled function with a given id', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn'),
|
||||
timeoutKey = scheduler.scheduleFunction(fn, 0);
|
||||
|
||||
@@ -110,7 +111,7 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('executes recurring functions interleaved with regular functions in the correct order', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler();
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const fn = jasmine.createSpy('fn');
|
||||
let recurringCallCount = 0;
|
||||
const recurring = jasmine.createSpy('recurring').and.callFake(function() {
|
||||
@@ -131,7 +132,7 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('schedules a function for later execution during a tick', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn'),
|
||||
fnDelay = 10;
|
||||
|
||||
@@ -147,7 +148,7 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('#removeFunctionWithId removes a previously scheduled function with a given id during a tick', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn'),
|
||||
fnDelay = 10;
|
||||
let timeoutKey;
|
||||
@@ -165,7 +166,7 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('executes recurring functions interleaved with regular functions and functions scheduled during a tick in the correct order', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler();
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const fn = jasmine.createSpy('fn');
|
||||
let recurringCallCount = 0;
|
||||
const recurring = jasmine.createSpy('recurring').and.callFake(function() {
|
||||
@@ -198,7 +199,7 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('executes recurring functions after rescheduling them', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
recurring = function() {
|
||||
expect(scheduler.scheduleFunction).toHaveBeenCalled();
|
||||
};
|
||||
@@ -211,7 +212,7 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('removes functions during a tick that runs the function', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
spy = jasmine.createSpy('fn'),
|
||||
spyAndRemove = jasmine.createSpy('fn'),
|
||||
fnDelay = 10;
|
||||
@@ -232,7 +233,7 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('removes functions during the first tick that runs the function', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn'),
|
||||
fnDelay = 10;
|
||||
let timeoutKey;
|
||||
@@ -251,7 +252,7 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it("does not remove a function that hasn't been added yet", function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn'),
|
||||
fnDelay = 10;
|
||||
|
||||
@@ -266,7 +267,7 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('runs the next scheduled funtion', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler();
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const fn = jasmine.createSpy('fn');
|
||||
const tickSpy = jasmine.createSpy('tick');
|
||||
|
||||
@@ -281,7 +282,7 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('runs the only a single scheduled funtion in a time slot', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler();
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const fn1 = jasmine.createSpy('fn');
|
||||
const fn2 = jasmine.createSpy('fn2');
|
||||
const tickSpy = jasmine.createSpy('tick');
|
||||
@@ -302,7 +303,7 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('updates the mockDate per scheduled time', function() {
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
tickDate = jasmine.createSpy('tickDate');
|
||||
|
||||
scheduler.scheduleFunction(function() {});
|
||||
@@ -324,7 +325,7 @@ describe('DelayedFunctionScheduler', function() {
|
||||
}
|
||||
const nativeTimeoutId = setTimeout(function() {}, 100);
|
||||
|
||||
const scheduler = new jasmineUnderTest.DelayedFunctionScheduler();
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const fn = jasmine.createSpy('fn');
|
||||
|
||||
for (let i = 0; i < nativeTimeoutId; i++) {
|
||||
|
||||
@@ -7,7 +7,7 @@ describe('Deprecator', function() {
|
||||
|
||||
it('logs the mesage without context when the runnable is the top suite', function() {
|
||||
const runnable = { addDeprecationWarning: function() {} };
|
||||
const deprecator = new jasmineUnderTest.Deprecator(runnable);
|
||||
const deprecator = new privateUnderTest.Deprecator(runnable);
|
||||
deprecator.verboseDeprecations(true);
|
||||
|
||||
deprecator.addDeprecationWarning(runnable, 'the message', {
|
||||
@@ -25,7 +25,7 @@ describe('Deprecator', function() {
|
||||
},
|
||||
children: []
|
||||
};
|
||||
const deprecator = new jasmineUnderTest.Deprecator({});
|
||||
const deprecator = new privateUnderTest.Deprecator({});
|
||||
deprecator.verboseDeprecations(true);
|
||||
|
||||
deprecator.addDeprecationWarning(runnable, 'the message', {
|
||||
@@ -44,7 +44,7 @@ describe('Deprecator', function() {
|
||||
return 'the spec';
|
||||
}
|
||||
};
|
||||
const deprecator = new jasmineUnderTest.Deprecator({});
|
||||
const deprecator = new privateUnderTest.Deprecator({});
|
||||
deprecator.verboseDeprecations(true);
|
||||
|
||||
deprecator.addDeprecationWarning(runnable, 'the message', {
|
||||
@@ -61,7 +61,7 @@ describe('Deprecator', function() {
|
||||
'addDeprecationWarning',
|
||||
'getFullName'
|
||||
]);
|
||||
const deprecator = new jasmineUnderTest.Deprecator(topSuite);
|
||||
const deprecator = new privateUnderTest.Deprecator(topSuite);
|
||||
const runnable = jasmine.createSpyObj('spec', [
|
||||
'addDeprecationWarning',
|
||||
'getFullName'
|
||||
@@ -105,7 +105,7 @@ describe('Deprecator', function() {
|
||||
});
|
||||
|
||||
it('emits the deprecation only once when verboseDeprecations is not set', function() {
|
||||
const deprecator = new jasmineUnderTest.Deprecator({});
|
||||
const deprecator = new privateUnderTest.Deprecator({});
|
||||
const runnable1 = jasmine.createSpyObj('runnable1', [
|
||||
'addDeprecationWarning',
|
||||
'getFullName'
|
||||
@@ -124,7 +124,7 @@ describe('Deprecator', function() {
|
||||
});
|
||||
|
||||
it('emits the deprecation only once when verboseDeprecations is false', function() {
|
||||
const deprecator = new jasmineUnderTest.Deprecator({});
|
||||
const deprecator = new privateUnderTest.Deprecator({});
|
||||
const runnable1 = jasmine.createSpyObj('runnable1', [
|
||||
'addDeprecationWarning',
|
||||
'getFullName'
|
||||
@@ -144,7 +144,7 @@ describe('Deprecator', function() {
|
||||
});
|
||||
|
||||
it('emits the deprecation for each call when verboseDeprecations is true', function() {
|
||||
const deprecator = new jasmineUnderTest.Deprecator({});
|
||||
const deprecator = new privateUnderTest.Deprecator({});
|
||||
const runnable1 = jasmine.createSpyObj('runnable1', [
|
||||
'addDeprecationWarning',
|
||||
'getFullName'
|
||||
@@ -164,7 +164,7 @@ describe('Deprecator', function() {
|
||||
});
|
||||
|
||||
it('includes a note about verboseDeprecations', function() {
|
||||
const deprecator = new jasmineUnderTest.Deprecator({});
|
||||
const deprecator = new privateUnderTest.Deprecator({});
|
||||
const runnable = jasmine.createSpyObj('runnable', [
|
||||
'addDeprecationWarning',
|
||||
'getFullName'
|
||||
@@ -183,7 +183,7 @@ describe('Deprecator', function() {
|
||||
});
|
||||
|
||||
it('omits the note about verboseDeprecations when verboseDeprecations is true', function() {
|
||||
const deprecator = new jasmineUnderTest.Deprecator({});
|
||||
const deprecator = new privateUnderTest.Deprecator({});
|
||||
const runnable = jasmine.createSpyObj('runnable', [
|
||||
'addDeprecationWarning',
|
||||
'getFullName'
|
||||
@@ -207,7 +207,7 @@ describe('Deprecator', function() {
|
||||
// to report their own deprecations through Jasmine. See
|
||||
// <https://github.com/jasmine/jasmine/pull/1498>.
|
||||
it('passes the error through unchanged', function() {
|
||||
const deprecator = new jasmineUnderTest.Deprecator({});
|
||||
const deprecator = new privateUnderTest.Deprecator({});
|
||||
const runnable = jasmine.createSpyObj('runnable', [
|
||||
'addDeprecationWarning',
|
||||
'getFullName'
|
||||
@@ -238,7 +238,7 @@ describe('Deprecator', function() {
|
||||
});
|
||||
|
||||
it('reports the deprecation every time, regardless of config.verboseDeprecations', function() {
|
||||
const deprecator = new jasmineUnderTest.Deprecator({});
|
||||
const deprecator = new privateUnderTest.Deprecator({});
|
||||
const runnable = jasmine.createSpyObj('runnable', [
|
||||
'addDeprecationWarning',
|
||||
'getFullName'
|
||||
@@ -259,7 +259,7 @@ describe('Deprecator', function() {
|
||||
});
|
||||
|
||||
it('omits the note about verboseDeprecations', function() {
|
||||
const deprecator = new jasmineUnderTest.Deprecator({});
|
||||
const deprecator = new privateUnderTest.Deprecator({});
|
||||
const runnable = jasmine.createSpyObj('runnable', [
|
||||
'addDeprecationWarning',
|
||||
'getFullName'
|
||||
@@ -293,7 +293,7 @@ describe('Deprecator', function() {
|
||||
}
|
||||
|
||||
function testStackTrace(options) {
|
||||
const deprecator = new jasmineUnderTest.Deprecator({});
|
||||
const deprecator = new privateUnderTest.Deprecator({});
|
||||
const runnable = jasmine.createSpyObj('runnable', [
|
||||
'addDeprecationWarning',
|
||||
'getFullName'
|
||||
@@ -311,7 +311,7 @@ describe('Deprecator', function() {
|
||||
}
|
||||
|
||||
function testNoStackTrace(options) {
|
||||
const deprecator = new jasmineUnderTest.Deprecator({});
|
||||
const deprecator = new privateUnderTest.Deprecator({});
|
||||
const runnable = jasmine.createSpyObj('runnable', [
|
||||
'addDeprecationWarning',
|
||||
'getFullName'
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// TODO: Fix these unit tests!
|
||||
describe('Env', function() {
|
||||
let env;
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
@@ -13,22 +12,20 @@ describe('Env', function() {
|
||||
it('throws the Pending Spec exception', function() {
|
||||
expect(function() {
|
||||
env.pending();
|
||||
}).toThrow(jasmineUnderTest.Spec.pendingSpecExceptionMessage);
|
||||
}).toThrow(privateUnderTest.Spec.pendingSpecExceptionMessage);
|
||||
});
|
||||
|
||||
it('throws the Pending Spec exception with a custom message', function() {
|
||||
expect(function() {
|
||||
env.pending('custom message');
|
||||
}).toThrow(
|
||||
jasmineUnderTest.Spec.pendingSpecExceptionMessage + 'custom message'
|
||||
privateUnderTest.Spec.pendingSpecExceptionMessage + 'custom message'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#topSuite', function() {
|
||||
it('returns an object that describes the tree of suites and specs', function() {
|
||||
spyOn(env, 'deprecated');
|
||||
|
||||
env.it('a top level spec');
|
||||
env.describe('a suite', function() {
|
||||
env.it('a spec');
|
||||
@@ -38,24 +35,24 @@ describe('Env', function() {
|
||||
});
|
||||
|
||||
const suite = env.topSuite();
|
||||
expect(suite).not.toBeInstanceOf(jasmineUnderTest.Suite);
|
||||
expect(suite).not.toBeInstanceOf(privateUnderTest.Suite);
|
||||
expect(suite.description).toEqual('Jasmine__TopLevel__Suite');
|
||||
expect(suite.getFullName()).toEqual('');
|
||||
expect(suite.children.length).toEqual(2);
|
||||
|
||||
expect(suite.children[0]).not.toBeInstanceOf(jasmineUnderTest.Spec);
|
||||
expect(suite.children[0]).not.toBeInstanceOf(privateUnderTest.Spec);
|
||||
expect(suite.children[0].description).toEqual('a top level spec');
|
||||
expect(suite.children[0].getFullName()).toEqual('a top level spec');
|
||||
expect(suite.children[0].children).toBeFalsy();
|
||||
|
||||
expect(suite.children[1]).not.toBeInstanceOf(jasmineUnderTest.Suite);
|
||||
expect(suite.children[1]).not.toBeInstanceOf(privateUnderTest.Suite);
|
||||
expect(suite.children[1].description).toEqual('a suite');
|
||||
expect(suite.children[1].getFullName()).toEqual('a suite');
|
||||
expect(suite.children[1].parentSuite).toBe(suite);
|
||||
expect(suite.children[1].children.length).toEqual(2);
|
||||
|
||||
expect(suite.children[1].children[0]).not.toBeInstanceOf(
|
||||
jasmineUnderTest.Spec
|
||||
privateUnderTest.Spec
|
||||
);
|
||||
expect(suite.children[1].children[0].description).toEqual('a spec');
|
||||
expect(suite.children[1].children[0].getFullName()).toEqual(
|
||||
@@ -95,16 +92,16 @@ describe('Env', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('accepts its own current configureation', function() {
|
||||
it('accepts its own current configuration', function() {
|
||||
env.configure(env.configuration());
|
||||
});
|
||||
|
||||
it('can configure specs to throw errors on expectation failures', function() {
|
||||
env.configure({ stopSpecOnExpectationFailure: true });
|
||||
|
||||
spyOn(jasmineUnderTest, 'Spec').and.callThrough();
|
||||
spyOn(privateUnderTest, 'Spec').and.callThrough();
|
||||
env.it('foo', function() {});
|
||||
expect(jasmineUnderTest.Spec).toHaveBeenCalledWith(
|
||||
expect(privateUnderTest.Spec).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
throwOnExpectationFailure: true
|
||||
})
|
||||
@@ -114,9 +111,9 @@ describe('Env', function() {
|
||||
it('can configure suites to throw errors on expectation failures', function() {
|
||||
env.configure({ stopSpecOnExpectationFailure: true });
|
||||
|
||||
spyOn(jasmineUnderTest, 'Suite');
|
||||
spyOn(privateUnderTest, 'Suite');
|
||||
env.describe('foo', function() {});
|
||||
expect(jasmineUnderTest.Suite).toHaveBeenCalledWith(
|
||||
expect(privateUnderTest.Suite).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
throwOnExpectationFailure: true
|
||||
})
|
||||
@@ -124,7 +121,6 @@ describe('Env', function() {
|
||||
});
|
||||
|
||||
it('ignores configuration properties that are present but undefined', function() {
|
||||
spyOn(env, 'deprecated');
|
||||
const initialConfig = {
|
||||
random: true,
|
||||
seed: '123',
|
||||
@@ -150,9 +146,9 @@ describe('Env', function() {
|
||||
});
|
||||
|
||||
it('defaults to multiple failures for specs', function() {
|
||||
spyOn(jasmineUnderTest, 'Spec').and.callThrough();
|
||||
spyOn(privateUnderTest, 'Spec').and.callThrough();
|
||||
env.it('bar', function() {});
|
||||
expect(jasmineUnderTest.Spec).toHaveBeenCalledWith(
|
||||
expect(privateUnderTest.Spec).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
throwOnExpectationFailure: false
|
||||
})
|
||||
@@ -160,9 +156,9 @@ describe('Env', function() {
|
||||
});
|
||||
|
||||
it('defaults to multiple failures for suites', function() {
|
||||
spyOn(jasmineUnderTest, 'Suite');
|
||||
spyOn(privateUnderTest, 'Suite');
|
||||
env.describe('foo', function() {});
|
||||
expect(jasmineUnderTest.Suite).toHaveBeenCalledWith(
|
||||
expect(privateUnderTest.Suite).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
throwOnExpectationFailure: false
|
||||
})
|
||||
@@ -198,6 +194,29 @@ describe('Env', function() {
|
||||
expect(innerSuite.parentSuite).toBe(suite);
|
||||
expect(spec.getFullName()).toEqual('outer suite inner suite a spec');
|
||||
});
|
||||
|
||||
it('sets the caller filename correctly when extraDescribeStackFrames is not set', function() {
|
||||
// IIFE is used to match the stack depth when global describe() is called
|
||||
const suite = (function() {
|
||||
return env[methodName]('a suite', function() {
|
||||
env.it('a spec');
|
||||
});
|
||||
})();
|
||||
expect(suite.filename).toMatch(/EnvSpec\.js$/);
|
||||
});
|
||||
|
||||
it('sets the caller filename correctly when extraDescribeStackFrames is set', function() {
|
||||
env.configure({ extraDescribeStackFrames: 2 });
|
||||
// IIFE is used to match the stack depth when global describe() is called
|
||||
const suite = (function() {
|
||||
return specHelpers.callerFilenameShim(function() {
|
||||
return env[methodName]('a suite', function() {
|
||||
env.it('a spec');
|
||||
});
|
||||
});
|
||||
})();
|
||||
expect(suite.filename).toMatch(/EnvSpec\.js$/);
|
||||
});
|
||||
}
|
||||
|
||||
describe('#describe', function() {
|
||||
@@ -300,6 +319,25 @@ describe('Env', function() {
|
||||
.not.toEqual('');
|
||||
expect(spec.pend).toBeFalsy();
|
||||
});
|
||||
|
||||
it('sets the caller filename correctly when extraItStackFrames is not set', function() {
|
||||
// IIFE is used to match the stack depth when global it() is called
|
||||
const spec = (function() {
|
||||
return env[methodName]('a spec', function() {});
|
||||
})();
|
||||
expect(spec.filename).toMatch(/EnvSpec\.js$/);
|
||||
});
|
||||
|
||||
it('sets the caller filename correctly when extraItStackFrames is set', function() {
|
||||
env.configure({ extraItStackFrames: 2 });
|
||||
// IIFE is used to match the stack depth when global it() is called
|
||||
const spec = (function() {
|
||||
return specHelpers.callerFilenameShim(function() {
|
||||
return env[methodName]('a spec', function() {});
|
||||
});
|
||||
})();
|
||||
expect(spec.filename).toMatch(/EnvSpec\.js$/);
|
||||
});
|
||||
}
|
||||
|
||||
describe('#it', function() {
|
||||
@@ -337,7 +375,7 @@ describe('Env', function() {
|
||||
|
||||
it('calls spec.exclude with "Temporarily disabled with xit"', function() {
|
||||
const excludeSpy = jasmine.createSpy();
|
||||
spyOn(jasmineUnderTest.SuiteBuilder.prototype, 'it_').and.returnValue({
|
||||
spyOn(privateUnderTest.SuiteBuilder.prototype, 'it_').and.returnValue({
|
||||
exclude: excludeSpy
|
||||
});
|
||||
env.xit('foo', function() {});
|
||||
@@ -346,9 +384,9 @@ describe('Env', function() {
|
||||
|
||||
it('calls spec.pend with "Temporarily disabled with xit"', function() {
|
||||
const pendSpy = jasmine.createSpy();
|
||||
const realExclude = jasmineUnderTest.Spec.prototype.exclude;
|
||||
const realExclude = privateUnderTest.Spec.prototype.exclude;
|
||||
|
||||
spyOn(jasmineUnderTest.SuiteBuilder.prototype, 'it_').and.returnValue({
|
||||
spyOn(privateUnderTest.SuiteBuilder.prototype, 'it_').and.returnValue({
|
||||
exclude: realExclude,
|
||||
pend: pendSpy
|
||||
});
|
||||
@@ -487,14 +525,14 @@ describe('Env', function() {
|
||||
|
||||
it('does not throw an error when called in a describe', function() {
|
||||
env.setParallelLoadingState('helpers');
|
||||
check();
|
||||
check(1);
|
||||
env.setParallelLoadingState('specs');
|
||||
check();
|
||||
check(2);
|
||||
|
||||
function check() {
|
||||
function check(disambiguator) {
|
||||
let done = false;
|
||||
|
||||
env.describe('a suite', function() {
|
||||
env.describe('a suite ' + disambiguator, function() {
|
||||
expect(function() {
|
||||
env.it('a spec');
|
||||
env.beforeAll(function() {});
|
||||
@@ -594,14 +632,14 @@ describe('Env', function() {
|
||||
|
||||
it('does not throw an error when called in a describe', function() {
|
||||
env.setParallelLoadingState('helpers');
|
||||
check();
|
||||
check(1);
|
||||
env.setParallelLoadingState('specs');
|
||||
check();
|
||||
check(2);
|
||||
|
||||
function check() {
|
||||
function check(disambiguator) {
|
||||
let done = false;
|
||||
|
||||
env.describe('a suite', function() {
|
||||
env.describe('a suite ' + disambiguator, function() {
|
||||
expect(function() {
|
||||
env.it('a spec');
|
||||
env.afterAll(function() {});
|
||||
@@ -626,7 +664,7 @@ describe('Env', function() {
|
||||
'removeOverrideListener'
|
||||
]);
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env({
|
||||
env = new privateUnderTest.Env({
|
||||
GlobalErrors: function() {
|
||||
return globalErrors;
|
||||
}
|
||||
@@ -645,7 +683,7 @@ describe('Env', function() {
|
||||
'removeOverrideListener'
|
||||
]);
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env({
|
||||
env = new privateUnderTest.Env({
|
||||
suppressLoadErrors: true,
|
||||
GlobalErrors: function() {
|
||||
return globalErrors;
|
||||
@@ -661,12 +699,12 @@ describe('Env', function() {
|
||||
function customEqualityTester() {}
|
||||
function customObjectFormatter() {}
|
||||
function prettyPrinter() {}
|
||||
const RealSpec = jasmineUnderTest.Spec;
|
||||
const RealSpec = privateUnderTest.Spec;
|
||||
let specInstance;
|
||||
let expectationFactory;
|
||||
spyOn(jasmineUnderTest, 'MatchersUtil');
|
||||
spyOn(jasmineUnderTest, 'makePrettyPrinter').and.returnValue(prettyPrinter);
|
||||
spyOn(jasmineUnderTest, 'Spec').and.callFake(function(options) {
|
||||
spyOn(privateUnderTest, 'MatchersUtil');
|
||||
spyOn(privateUnderTest, 'makePrettyPrinter').and.returnValue(prettyPrinter);
|
||||
spyOn(privateUnderTest, 'Spec').and.callFake(function(options) {
|
||||
expectationFactory = options.expectationFactory;
|
||||
specInstance = new RealSpec(options);
|
||||
return specInstance;
|
||||
@@ -679,10 +717,10 @@ describe('Env', function() {
|
||||
});
|
||||
|
||||
await env.execute();
|
||||
expect(jasmineUnderTest.makePrettyPrinter).toHaveBeenCalledWith([
|
||||
expect(privateUnderTest.makePrettyPrinter).toHaveBeenCalledWith([
|
||||
customObjectFormatter
|
||||
]);
|
||||
expect(jasmineUnderTest.MatchersUtil).toHaveBeenCalledWith({
|
||||
expect(privateUnderTest.MatchersUtil).toHaveBeenCalledWith({
|
||||
customTesters: [customEqualityTester],
|
||||
pp: prettyPrinter
|
||||
});
|
||||
@@ -692,12 +730,12 @@ describe('Env', function() {
|
||||
function customEqualityTester() {}
|
||||
function customObjectFormatter() {}
|
||||
function prettyPrinter() {}
|
||||
const RealSpec = jasmineUnderTest.Spec;
|
||||
const RealSpec = privateUnderTest.Spec;
|
||||
let specInstance;
|
||||
let asyncExpectationFactory;
|
||||
spyOn(jasmineUnderTest, 'MatchersUtil');
|
||||
spyOn(jasmineUnderTest, 'makePrettyPrinter').and.returnValue(prettyPrinter);
|
||||
spyOn(jasmineUnderTest, 'Spec').and.callFake(function(options) {
|
||||
spyOn(privateUnderTest, 'MatchersUtil');
|
||||
spyOn(privateUnderTest, 'makePrettyPrinter').and.returnValue(prettyPrinter);
|
||||
spyOn(privateUnderTest, 'Spec').and.callFake(function(options) {
|
||||
asyncExpectationFactory = options.asyncExpectationFactory;
|
||||
specInstance = new RealSpec(options);
|
||||
return specInstance;
|
||||
@@ -711,10 +749,10 @@ describe('Env', function() {
|
||||
|
||||
await env.execute();
|
||||
|
||||
expect(jasmineUnderTest.makePrettyPrinter).toHaveBeenCalledWith([
|
||||
expect(privateUnderTest.makePrettyPrinter).toHaveBeenCalledWith([
|
||||
customObjectFormatter
|
||||
]);
|
||||
expect(jasmineUnderTest.MatchersUtil).toHaveBeenCalledWith({
|
||||
expect(privateUnderTest.MatchersUtil).toHaveBeenCalledWith({
|
||||
customTesters: [customEqualityTester],
|
||||
pp: prettyPrinter
|
||||
});
|
||||
@@ -722,14 +760,13 @@ describe('Env', function() {
|
||||
|
||||
it("does not expose the suite as 'this'", function() {
|
||||
let suiteThis;
|
||||
spyOn(env, 'deprecated');
|
||||
|
||||
env.describe('a suite', function() {
|
||||
suiteThis = this;
|
||||
env.it('has a spec');
|
||||
});
|
||||
|
||||
expect(suiteThis).not.toBeInstanceOf(jasmineUnderTest.Suite);
|
||||
expect(suiteThis).not.toBeInstanceOf(privateUnderTest.Suite);
|
||||
});
|
||||
|
||||
describe('#execute', function() {
|
||||
@@ -738,7 +775,7 @@ describe('Env', function() {
|
||||
});
|
||||
|
||||
it('should reset the topSuite when run twice', function() {
|
||||
spyOn(jasmineUnderTest.Suite.prototype, 'reset');
|
||||
spyOn(privateUnderTest.Suite.prototype, 'reset');
|
||||
return env
|
||||
.execute() // 1
|
||||
.then(function() {
|
||||
@@ -746,9 +783,9 @@ describe('Env', function() {
|
||||
})
|
||||
.then(function() {
|
||||
expect(
|
||||
jasmineUnderTest.Suite.prototype.reset
|
||||
privateUnderTest.Suite.prototype.reset
|
||||
).toHaveBeenCalledOnceWith();
|
||||
const id = jasmineUnderTest.Suite.prototype.reset.calls.thisFor(0).id;
|
||||
const id = privateUnderTest.Suite.prototype.reset.calls.thisFor(0).id;
|
||||
expect(id).toBeTruthy();
|
||||
expect(id).toEqual(env.topSuite().id);
|
||||
});
|
||||
@@ -757,9 +794,9 @@ describe('Env', function() {
|
||||
it('should not reset the topSuite if parallelReset was called since the last run', async function() {
|
||||
await env.execute();
|
||||
env.parallelReset();
|
||||
spyOn(jasmineUnderTest.Suite.prototype, 'reset');
|
||||
spyOn(privateUnderTest.Suite.prototype, 'reset');
|
||||
await env.execute();
|
||||
expect(jasmineUnderTest.Suite.prototype.reset).not.toHaveBeenCalled();
|
||||
expect(privateUnderTest.Suite.prototype.reset).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe('In parallel mode', function() {
|
||||
@@ -837,4 +874,8 @@ describe('Env', function() {
|
||||
}).toThrowError('Jasmine cannot be configured via Env in parallel mode');
|
||||
});
|
||||
});
|
||||
|
||||
isNonMonkeyPatchableClass(privateUnderTest.Env, function() {
|
||||
return new privateUnderTest.Env();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@ describe('ExceptionFormatter', function() {
|
||||
message: 'you got your foo in my bar',
|
||||
name: 'A Classic Mistake'
|
||||
},
|
||||
exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
||||
exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
||||
message = exceptionFormatter.message(sampleFirefoxException);
|
||||
|
||||
expect(message).toEqual(
|
||||
@@ -22,7 +22,7 @@ describe('ExceptionFormatter', function() {
|
||||
message: 'you got your foo in my bar',
|
||||
name: 'A Classic Mistake'
|
||||
},
|
||||
exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
||||
exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
||||
message = exceptionFormatter.message(sampleWebkitException);
|
||||
|
||||
expect(message).toEqual(
|
||||
@@ -35,7 +35,7 @@ describe('ExceptionFormatter', function() {
|
||||
message: 'you got your foo in my bar',
|
||||
name: 'A Classic Mistake'
|
||||
},
|
||||
exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
||||
exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
||||
message = exceptionFormatter.message(sampleV8);
|
||||
|
||||
expect(message).toEqual('A Classic Mistake: you got your foo in my bar');
|
||||
@@ -44,7 +44,7 @@ describe('ExceptionFormatter', function() {
|
||||
it('formats unnamed exceptions with message', function() {
|
||||
const unnamedError = { message: 'This is an unnamed error message.' };
|
||||
|
||||
const exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
||||
const exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
||||
message = exceptionFormatter.message(unnamedError);
|
||||
|
||||
expect(message).toEqual('This is an unnamed error message.');
|
||||
@@ -57,7 +57,7 @@ describe('ExceptionFormatter', function() {
|
||||
};
|
||||
const emptyError = new EmptyError();
|
||||
|
||||
const exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
||||
const exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
||||
message = exceptionFormatter.message(emptyError);
|
||||
|
||||
expect(message).toEqual('[EmptyError] thrown');
|
||||
@@ -65,7 +65,7 @@ describe('ExceptionFormatter', function() {
|
||||
|
||||
it("formats thrown exceptions that aren't errors", function() {
|
||||
const thrown = 'crazy error',
|
||||
exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
||||
exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
||||
message = exceptionFormatter.message(thrown);
|
||||
|
||||
expect(message).toEqual('crazy error thrown');
|
||||
@@ -76,7 +76,7 @@ describe('ExceptionFormatter', function() {
|
||||
it('formats stack traces', function() {
|
||||
const error = new Error('an error');
|
||||
|
||||
expect(new jasmineUnderTest.ExceptionFormatter().stack(error)).toMatch(
|
||||
expect(new privateUnderTest.ExceptionFormatter().stack(error)).toMatch(
|
||||
/ExceptionFormatterSpec\.js.*\d+/
|
||||
);
|
||||
});
|
||||
@@ -96,7 +96,7 @@ describe('ExceptionFormatter', function() {
|
||||
' at fn3 (C:\\__jasmine__\\lib\\jasmine-core\\jasmine.js:7575:25)\n' +
|
||||
' at fn4 (node:internal/timers:462:21)\n'
|
||||
};
|
||||
const subject = new jasmineUnderTest.ExceptionFormatter({
|
||||
const subject = new privateUnderTest.ExceptionFormatter({
|
||||
jasmineFile: 'C:\\__jasmine__\\lib\\jasmine-core\\jasmine.js'
|
||||
});
|
||||
const result = subject.stack(error);
|
||||
@@ -122,7 +122,7 @@ describe('ExceptionFormatter', function() {
|
||||
' at fn3 (http://localhost:8888/__jasmine__/jasmine.js:4320:20)\n' +
|
||||
' at fn4 (http://localhost:8888/__spec__/core/UtilSpec.js:110:19)\n'
|
||||
};
|
||||
const subject = new jasmineUnderTest.ExceptionFormatter({
|
||||
const subject = new privateUnderTest.ExceptionFormatter({
|
||||
jasmineFile: 'http://localhost:8888/__jasmine__/jasmine.js'
|
||||
});
|
||||
const result = subject.stack(error);
|
||||
@@ -142,7 +142,7 @@ describe('ExceptionFormatter', function() {
|
||||
'fn2@http://localhost:8888/__jasmine__/jasmine.js:4320:27\n' +
|
||||
'http://localhost:8888/__spec__/core/UtilSpec.js:115:28'
|
||||
};
|
||||
const subject = new jasmineUnderTest.ExceptionFormatter({
|
||||
const subject = new privateUnderTest.ExceptionFormatter({
|
||||
jasmineFile: 'http://localhost:8888/__jasmine__/jasmine.js'
|
||||
});
|
||||
const result = subject.stack(error);
|
||||
@@ -161,7 +161,7 @@ describe('ExceptionFormatter', function() {
|
||||
'setTimeout handler*fn2@http://localhost:8888/__jasmine__/jasmine.js:4320:27\n' +
|
||||
'http://localhost:8888/__spec__/core/UtilSpec.js:115:28'
|
||||
};
|
||||
const subject = new jasmineUnderTest.ExceptionFormatter({
|
||||
const subject = new privateUnderTest.ExceptionFormatter({
|
||||
jasmineFile: 'http://localhost:8888/__jasmine__/jasmine.js'
|
||||
});
|
||||
const result = subject.stack(error);
|
||||
@@ -173,10 +173,13 @@ describe('ExceptionFormatter', function() {
|
||||
});
|
||||
|
||||
it('filters Jasmine stack frames in this environment', function() {
|
||||
const jasmineFile = (function() {
|
||||
const trace = new privateUnderTest.StackTrace(new Error());
|
||||
return trace.frames[2].file;
|
||||
})();
|
||||
expect(jasmineFile).toMatch(/\/jasmine.js$/);
|
||||
const error = new Error('an error');
|
||||
const subject = new jasmineUnderTest.ExceptionFormatter({
|
||||
jasmineFile: jasmine.util.jasmineFile()
|
||||
});
|
||||
const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile });
|
||||
const result = subject.stack(error);
|
||||
jasmine.debugLog('Original stack trace: ' + error.stack);
|
||||
jasmine.debugLog('Filtered stack trace: ' + result);
|
||||
@@ -196,15 +199,18 @@ describe('ExceptionFormatter', function() {
|
||||
});
|
||||
|
||||
it('handles multiline error messages in this environment', function() {
|
||||
const jasmineFile = (function() {
|
||||
const trace = new privateUnderTest.StackTrace(new Error());
|
||||
return trace.frames[2].file;
|
||||
})();
|
||||
expect(jasmineFile).toMatch(/\/jasmine.js$/);
|
||||
const msg = 'an error\nwith two lines';
|
||||
const error = new Error(msg);
|
||||
|
||||
if (error.stack.indexOf(msg) === -1) {
|
||||
pending("Stack traces don't have messages in this environment");
|
||||
}
|
||||
const subject = new jasmineUnderTest.ExceptionFormatter({
|
||||
jasmineFile: jasmine.util.jasmineFile()
|
||||
});
|
||||
const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile });
|
||||
const result = subject.stack(error);
|
||||
const lines = result.split('\n');
|
||||
|
||||
@@ -215,14 +221,14 @@ describe('ExceptionFormatter', function() {
|
||||
});
|
||||
|
||||
it('returns null if no Error provided', function() {
|
||||
expect(new jasmineUnderTest.ExceptionFormatter().stack()).toBeNull();
|
||||
expect(new privateUnderTest.ExceptionFormatter().stack()).toBeNull();
|
||||
});
|
||||
|
||||
it("includes the error's own properties in stack", function() {
|
||||
const error = new Error('an error');
|
||||
error.someProperty = 'hello there';
|
||||
|
||||
const result = new jasmineUnderTest.ExceptionFormatter().stack(error);
|
||||
const result = new privateUnderTest.ExceptionFormatter().stack(error);
|
||||
|
||||
expect(result).toMatch(/error properties:.*someProperty.*hello there/);
|
||||
});
|
||||
@@ -236,7 +242,7 @@ describe('ExceptionFormatter', function() {
|
||||
CustomError.prototype.anInheritedProp = 'something';
|
||||
const error = new CustomError('nope');
|
||||
|
||||
const result = new jasmineUnderTest.ExceptionFormatter().stack(error);
|
||||
const result = new privateUnderTest.ExceptionFormatter().stack(error);
|
||||
expect(result).not.toContain('anInheritedProp');
|
||||
});
|
||||
|
||||
@@ -251,7 +257,7 @@ describe('ExceptionFormatter', function() {
|
||||
' at fn3 (http://localhost:8888/__jasmine__/jasmine.js:4320:20)\n' +
|
||||
' at fn4 (http://localhost:8888/__spec__/core/UtilSpec.js:110:19)\n'
|
||||
};
|
||||
const subject = new jasmineUnderTest.ExceptionFormatter({
|
||||
const subject = new privateUnderTest.ExceptionFormatter({
|
||||
jasmineFile: 'http://localhost:8888/__jasmine__/jasmine.js'
|
||||
});
|
||||
const result = subject.stack(error, { omitMessage: true });
|
||||
@@ -270,7 +276,7 @@ describe('ExceptionFormatter', function() {
|
||||
'fn2@http://localhost:8888/__jasmine__/jasmine.js:4320:27\n' +
|
||||
'http://localhost:8888/__spec__/core/UtilSpec.js:115:28'
|
||||
};
|
||||
const subject = new jasmineUnderTest.ExceptionFormatter({
|
||||
const subject = new privateUnderTest.ExceptionFormatter({
|
||||
jasmineFile: 'http://localhost:8888/__jasmine__/jasmine.js'
|
||||
});
|
||||
const result = subject.stack(error, { omitMessage: true });
|
||||
@@ -283,8 +289,8 @@ describe('ExceptionFormatter', function() {
|
||||
|
||||
it('ensures that stack traces do not include the message in this environment', function() {
|
||||
const error = new Error('an error');
|
||||
const subject = new jasmineUnderTest.ExceptionFormatter({
|
||||
jasmineFile: jasmine.util.jasmineFile()
|
||||
const subject = new privateUnderTest.ExceptionFormatter({
|
||||
jasmineFile: "doesn't matter"
|
||||
});
|
||||
const result = subject.stack(error, { omitMessage: true });
|
||||
expect(result).not.toContain('an error');
|
||||
@@ -293,7 +299,7 @@ describe('ExceptionFormatter', function() {
|
||||
|
||||
describe('when the error has a cause property', function() {
|
||||
it('recursively includes the cause in the stack trace in this environment', function() {
|
||||
const subject = new jasmineUnderTest.ExceptionFormatter();
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const rootCause = new Error('root cause');
|
||||
const proximateCause = new Error('proximate cause', {
|
||||
cause: rootCause
|
||||
@@ -327,7 +333,7 @@ describe('ExceptionFormatter', function() {
|
||||
});
|
||||
|
||||
it('does not throw if cause is a non Error', function() {
|
||||
const formatter = new jasmineUnderTest.ExceptionFormatter();
|
||||
const formatter = new privateUnderTest.ExceptionFormatter();
|
||||
|
||||
expect(function() {
|
||||
formatter.stack(
|
||||
@@ -346,5 +352,184 @@ describe('ExceptionFormatter', function() {
|
||||
}).not.toThrowError();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the error has an errors array (AggregateError)', function() {
|
||||
it('includes all aggregated errors in the stack trace', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const error1 = (function fn1() {
|
||||
return new Error('first error');
|
||||
})();
|
||||
const error2 = (function fn2() {
|
||||
return new Error('second error');
|
||||
})();
|
||||
const aggregateError = (function fn3() {
|
||||
return new Error('Multiple errors occurred');
|
||||
})();
|
||||
aggregateError.errors = [error1, error2];
|
||||
|
||||
const lines = subject.stack(aggregateError).split('\n');
|
||||
|
||||
// TODO: be consistent across environments about whether the message is
|
||||
// included in the stack trace
|
||||
if (lines[0] === 'Error: Multiple errors occurred') {
|
||||
lines.shift();
|
||||
}
|
||||
|
||||
// Exclude lines that vary from environment to environment
|
||||
const filteredLines = lines.filter(
|
||||
x =>
|
||||
!x.includes('/jasmine.js:') &&
|
||||
// Some Node 20 and 22 minors when running in parallel
|
||||
!x.includes('process.processTicksAndRejections')
|
||||
);
|
||||
|
||||
for (let i = 0; i < filteredLines.length; i++) {
|
||||
jasmine.debugLog(`Line ${i} after filtering: ${filteredLines[i]}`);
|
||||
}
|
||||
|
||||
// Inexact matching because stack frame formatting varies from runtime
|
||||
// to runtime
|
||||
const expectedPatterns = [
|
||||
// Overall error
|
||||
/fn3.*ExceptionFormatterSpec\.js/,
|
||||
/ExceptionFormatterSpec\.js/,
|
||||
/^$/,
|
||||
|
||||
// First nested error
|
||||
/^ Error 1: Error: first error$/,
|
||||
/^ .*fn1.*ExceptionFormatterSpec\.js/,
|
||||
/^ .*ExceptionFormatterSpec\.js/,
|
||||
/^$/,
|
||||
|
||||
// Second nested error
|
||||
/^ .*Error 2: Error: second error$/,
|
||||
/^ .*fn2.*ExceptionFormatterSpec\.js/,
|
||||
/^ .*ExceptionFormatterSpec\.js/
|
||||
];
|
||||
|
||||
expect(filteredLines).toEqual(
|
||||
expectedPatterns.map(p => jasmine.stringMatching(p))
|
||||
);
|
||||
});
|
||||
|
||||
it('handles empty errors array', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const aggregateError = new Error('No errors');
|
||||
aggregateError.errors = [];
|
||||
|
||||
expect(function() {
|
||||
subject.stack(aggregateError);
|
||||
}).not.toThrowError();
|
||||
});
|
||||
|
||||
it('handles nested AggregateError', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const innerError1 = new Error('inner error 1');
|
||||
const innerError2 = new Error('inner error 2');
|
||||
const innerAggregate = new Error('Inner aggregate');
|
||||
innerAggregate.errors = [innerError1, innerError2];
|
||||
|
||||
const outerError = new Error('outer error');
|
||||
const outerAggregate = new Error('Outer aggregate');
|
||||
outerAggregate.errors = [innerAggregate, outerError];
|
||||
|
||||
const lines = subject.stack(outerAggregate).split('\n');
|
||||
|
||||
const innerAggMsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 1: Error: Inner aggregate')
|
||||
);
|
||||
expect(innerAggMsgIx).toBeGreaterThan(-1);
|
||||
|
||||
const innerError1MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 1: Error: inner error 1')
|
||||
);
|
||||
expect(innerError1MsgIx).toBeGreaterThan(innerAggMsgIx);
|
||||
|
||||
const innerError2MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 2: Error: inner error 2')
|
||||
);
|
||||
expect(innerError2MsgIx).toBeGreaterThan(innerError1MsgIx);
|
||||
|
||||
const outerErrorMsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 2: Error: outer error')
|
||||
);
|
||||
expect(outerErrorMsgIx).toBeGreaterThan(innerError2MsgIx);
|
||||
});
|
||||
|
||||
it('handles AggregateError containing error with cause', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const rootCause = new Error('root cause');
|
||||
const errorWithCause = new Error('error with cause', {
|
||||
cause: rootCause
|
||||
});
|
||||
const aggregateError = new Error('Aggregate with cause chain');
|
||||
aggregateError.errors = [errorWithCause];
|
||||
|
||||
const lines = subject.stack(aggregateError).split('\n');
|
||||
|
||||
const error1MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 1: Error: error with cause')
|
||||
);
|
||||
expect(error1MsgIx).toBeGreaterThan(-1);
|
||||
|
||||
const causeMsgIx = lines.findIndex(line =>
|
||||
line.includes('Caused by: Error: root cause')
|
||||
);
|
||||
expect(causeMsgIx).toBeGreaterThan(error1MsgIx);
|
||||
});
|
||||
|
||||
it('skips non-Error items in errors array', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const error1 = new Error('real error');
|
||||
const aggregateError = new Error('Mixed array');
|
||||
aggregateError.errors = [
|
||||
error1,
|
||||
'string error',
|
||||
{ message: 'object error' },
|
||||
null,
|
||||
undefined,
|
||||
42
|
||||
];
|
||||
|
||||
const lines = subject.stack(aggregateError).split('\n');
|
||||
|
||||
const error1MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 1: Error: real error')
|
||||
);
|
||||
expect(error1MsgIx).toBeGreaterThan(-1);
|
||||
|
||||
const hasStringError = lines.some(line =>
|
||||
line.includes('string error')
|
||||
);
|
||||
expect(hasStringError).toBe(false);
|
||||
|
||||
const hasObjectError = lines.some(line =>
|
||||
line.includes('object error')
|
||||
);
|
||||
expect(hasObjectError).toBe(false);
|
||||
});
|
||||
|
||||
it('works with native AggregateError constructor', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const error1 = new Error('first error');
|
||||
const error2 = new Error('second error');
|
||||
const aggregateError = new AggregateError(
|
||||
[error1, error2],
|
||||
'Multiple errors'
|
||||
);
|
||||
|
||||
const lines = subject.stack(aggregateError).split('\n');
|
||||
|
||||
const error1MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 1: Error: first error')
|
||||
);
|
||||
expect(error1MsgIx).toBeGreaterThan(-1);
|
||||
|
||||
const error2MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 2: Error: second error')
|
||||
);
|
||||
expect(error2MsgIx).toBeGreaterThan(error1MsgIx);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ describe('Exceptions:', function() {
|
||||
let env;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
|
||||
@@ -3,7 +3,7 @@ describe('ExpectationFilterChain', function() {
|
||||
it('returns a new filter chain with the added filter', function() {
|
||||
const first = jasmine.createSpy('first'),
|
||||
second = jasmine.createSpy('second'),
|
||||
orig = new jasmineUnderTest.ExpectationFilterChain({
|
||||
orig = new privateUnderTest.ExpectationFilterChain({
|
||||
modifyFailureMessage: first
|
||||
}),
|
||||
added = orig.addFilter({ selectComparisonFunc: second });
|
||||
@@ -15,7 +15,7 @@ describe('ExpectationFilterChain', function() {
|
||||
});
|
||||
|
||||
it('does not modify the original filter chain', function() {
|
||||
const orig = new jasmineUnderTest.ExpectationFilterChain({}),
|
||||
const orig = new privateUnderTest.ExpectationFilterChain({}),
|
||||
f = jasmine.createSpy('f');
|
||||
|
||||
orig.addFilter({ selectComparisonFunc: f });
|
||||
@@ -28,7 +28,7 @@ describe('ExpectationFilterChain', function() {
|
||||
describe('#selectComparisonFunc', function() {
|
||||
describe('When no filters have #selectComparisonFunc', function() {
|
||||
it('returns undefined', function() {
|
||||
const chain = new jasmineUnderTest.ExpectationFilterChain();
|
||||
const chain = new privateUnderTest.ExpectationFilterChain();
|
||||
chain.addFilter({});
|
||||
expect(chain.selectComparisonFunc()).toBeUndefined();
|
||||
});
|
||||
@@ -38,7 +38,7 @@ describe('ExpectationFilterChain', function() {
|
||||
it('calls the first filter that has #selectComparisonFunc', function() {
|
||||
const first = jasmine.createSpy('first').and.returnValue('first'),
|
||||
second = jasmine.createSpy('second').and.returnValue('second'),
|
||||
chain = new jasmineUnderTest.ExpectationFilterChain()
|
||||
chain = new privateUnderTest.ExpectationFilterChain()
|
||||
.addFilter({ selectComparisonFunc: first })
|
||||
.addFilter({ selectComparisonFunc: second }),
|
||||
matcher = {},
|
||||
@@ -54,7 +54,7 @@ describe('ExpectationFilterChain', function() {
|
||||
describe('#buildFailureMessage', function() {
|
||||
describe('When no filters have #buildFailureMessage', function() {
|
||||
it('returns undefined', function() {
|
||||
const chain = new jasmineUnderTest.ExpectationFilterChain();
|
||||
const chain = new privateUnderTest.ExpectationFilterChain();
|
||||
chain.addFilter({});
|
||||
expect(chain.buildFailureMessage()).toBeUndefined();
|
||||
});
|
||||
@@ -64,7 +64,7 @@ describe('ExpectationFilterChain', function() {
|
||||
it('calls the first filter that has #buildFailureMessage', function() {
|
||||
const first = jasmine.createSpy('first').and.returnValue('first'),
|
||||
second = jasmine.createSpy('second').and.returnValue('second'),
|
||||
chain = new jasmineUnderTest.ExpectationFilterChain()
|
||||
chain = new privateUnderTest.ExpectationFilterChain()
|
||||
.addFilter({ buildFailureMessage: first })
|
||||
.addFilter({ buildFailureMessage: second }),
|
||||
matcherResult = { pass: false },
|
||||
@@ -94,7 +94,7 @@ describe('ExpectationFilterChain', function() {
|
||||
describe('#modifyFailureMessage', function() {
|
||||
describe('When no filters have #modifyFailureMessage', function() {
|
||||
it('returns the original message', function() {
|
||||
const chain = new jasmineUnderTest.ExpectationFilterChain();
|
||||
const chain = new privateUnderTest.ExpectationFilterChain();
|
||||
chain.addFilter({});
|
||||
expect(chain.modifyFailureMessage('msg')).toEqual('msg');
|
||||
});
|
||||
@@ -104,7 +104,7 @@ describe('ExpectationFilterChain', function() {
|
||||
it('calls the first filter that has #modifyFailureMessage', function() {
|
||||
const first = jasmine.createSpy('first').and.returnValue('first'),
|
||||
second = jasmine.createSpy('second').and.returnValue('second'),
|
||||
chain = new jasmineUnderTest.ExpectationFilterChain()
|
||||
chain = new privateUnderTest.ExpectationFilterChain()
|
||||
.addFilter({ modifyFailureMessage: first })
|
||||
.addFilter({ modifyFailureMessage: second }),
|
||||
result = chain.modifyFailureMessage('original');
|
||||
|
||||
@@ -4,7 +4,7 @@ describe('Expectation', function() {
|
||||
toFoo: function() {},
|
||||
toBar: function() {}
|
||||
},
|
||||
expectation = jasmineUnderTest.Expectation.factory({
|
||||
expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers
|
||||
});
|
||||
|
||||
@@ -17,9 +17,9 @@ describe('Expectation', function() {
|
||||
toQuux: function() {}
|
||||
};
|
||||
|
||||
jasmineUnderTest.Expectation.addCoreMatchers(coreMatchers);
|
||||
privateUnderTest.Expectation.addCoreMatchers(coreMatchers);
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.factory({});
|
||||
const expectation = privateUnderTest.Expectation.factory({});
|
||||
|
||||
expect(expectation.toQuux).toBeDefined();
|
||||
});
|
||||
@@ -39,7 +39,7 @@ describe('Expectation', function() {
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.factory({
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
matchersUtil: matchersUtil,
|
||||
customMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
@@ -67,7 +67,7 @@ describe('Expectation', function() {
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.factory({
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
matchersUtil: matchersUtil,
|
||||
customMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
@@ -94,7 +94,7 @@ describe('Expectation', function() {
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.factory({
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
matchersUtil: matchersUtil,
|
||||
actual: 'an actual',
|
||||
@@ -108,8 +108,6 @@ describe('Expectation', function() {
|
||||
passed: true,
|
||||
message: '',
|
||||
error: undefined,
|
||||
expected: 'hello',
|
||||
actual: 'an actual',
|
||||
errorForStack: undefined
|
||||
});
|
||||
});
|
||||
@@ -131,7 +129,7 @@ describe('Expectation', function() {
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.factory({
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
matchersUtil: matchersUtil,
|
||||
actual: 'an actual',
|
||||
@@ -143,8 +141,6 @@ describe('Expectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: 'an actual',
|
||||
message: '',
|
||||
error: undefined,
|
||||
errorForStack: undefined
|
||||
@@ -166,7 +162,7 @@ describe('Expectation', function() {
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.factory({
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
actual: 'an actual',
|
||||
customMatchers: matchers,
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -177,8 +173,6 @@ describe('Expectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: 'an actual',
|
||||
message: 'I am a custom message',
|
||||
error: undefined,
|
||||
errorForStack: undefined
|
||||
@@ -202,7 +196,7 @@ describe('Expectation', function() {
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.factory({
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -213,8 +207,6 @@ describe('Expectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: 'an actual',
|
||||
message: 'I am a custom message',
|
||||
error: undefined,
|
||||
errorForStack: undefined
|
||||
@@ -231,10 +223,9 @@ describe('Expectation', function() {
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
actual = 'an actual';
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.factory({
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -247,8 +238,6 @@ describe('Expectation', function() {
|
||||
passed: true,
|
||||
message: '',
|
||||
error: undefined,
|
||||
expected: 'hello',
|
||||
actual: actual,
|
||||
errorForStack: undefined
|
||||
});
|
||||
});
|
||||
@@ -268,10 +257,9 @@ describe('Expectation', function() {
|
||||
return 'default message';
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
actual = 'an actual';
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.factory({
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
matchersUtil: matchersUtil,
|
||||
@@ -283,8 +271,6 @@ describe('Expectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: actual,
|
||||
message: 'default message',
|
||||
error: undefined,
|
||||
errorForStack: undefined
|
||||
@@ -304,10 +290,9 @@ describe('Expectation', function() {
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
actual = 'an actual';
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.factory({
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -318,8 +303,6 @@ describe('Expectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: actual,
|
||||
message: 'I am a custom message',
|
||||
error: undefined,
|
||||
errorForStack: undefined
|
||||
@@ -339,10 +322,9 @@ describe('Expectation', function() {
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
actual = 'an actual';
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.factory({
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -353,8 +335,6 @@ describe('Expectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(true, {
|
||||
matcherName: 'toFoo',
|
||||
passed: true,
|
||||
expected: 'hello',
|
||||
actual: actual,
|
||||
message: '',
|
||||
error: undefined,
|
||||
errorForStack: undefined
|
||||
@@ -377,10 +357,9 @@ describe('Expectation', function() {
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
actual = 'an actual';
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.factory({
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -391,8 +370,6 @@ describe('Expectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: actual,
|
||||
message: "I'm a custom message",
|
||||
error: undefined,
|
||||
errorForStack: undefined
|
||||
@@ -416,7 +393,7 @@ describe('Expectation', function() {
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.factory({
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
actual: 'an actual',
|
||||
customMatchers: matchers,
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -427,8 +404,6 @@ describe('Expectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: 'an actual',
|
||||
message: 'I am a custom message',
|
||||
error: customError,
|
||||
errorForStack: undefined
|
||||
@@ -452,7 +427,7 @@ describe('Expectation', function() {
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.factory({
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
actual: 'an actual',
|
||||
customMatchers: matchers,
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -463,8 +438,6 @@ describe('Expectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: 'an actual',
|
||||
message: 'I am a custom message',
|
||||
error: customError,
|
||||
errorForStack: undefined
|
||||
@@ -490,7 +463,7 @@ describe('Expectation', function() {
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = jasmineUnderTest.Expectation.factory({
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
actual: 'an actual',
|
||||
customMatchers: matchers,
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -501,8 +474,6 @@ describe('Expectation', function() {
|
||||
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||
matcherName: 'toFoo',
|
||||
passed: false,
|
||||
expected: 'hello',
|
||||
actual: 'an actual',
|
||||
message: 'I am a custom message',
|
||||
error: customError,
|
||||
errorForStack: undefined
|
||||
@@ -526,7 +497,7 @@ describe('Expectation', function() {
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = jasmineUnderTest.Expectation.factory({
|
||||
expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
matchersUtil: matchersUtil,
|
||||
actual: 'an actual',
|
||||
@@ -554,7 +525,7 @@ describe('Expectation', function() {
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = jasmineUnderTest.Expectation.factory({
|
||||
expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -581,7 +552,7 @@ describe('Expectation', function() {
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = jasmineUnderTest.Expectation.factory({
|
||||
expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -611,7 +582,7 @@ describe('Expectation', function() {
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = jasmineUnderTest.Expectation.factory({
|
||||
expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -638,10 +609,10 @@ describe('Expectation', function() {
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
pp = jasmineUnderTest.makePrettyPrinter(),
|
||||
expectation = jasmineUnderTest.Expectation.factory({
|
||||
pp = privateUnderTest.makePrettyPrinter(),
|
||||
expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
matchersUtil: new jasmineUnderTest.MatchersUtil({ pp: pp }),
|
||||
matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
});
|
||||
@@ -674,7 +645,7 @@ describe('Expectation', function() {
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = jasmineUnderTest.Expectation.factory({
|
||||
expectation = privateUnderTest.Expectation.factory({
|
||||
actual: 'an actual',
|
||||
customMatchers: matchers,
|
||||
addExpectationResult: addExpectationResult
|
||||
|
||||
@@ -2,7 +2,7 @@ describe('GlobalErrors', function() {
|
||||
it('calls the added handler on error', function() {
|
||||
const globals = browserGlobals();
|
||||
const handler = jasmine.createSpy('errorHandler');
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -13,16 +13,13 @@ describe('GlobalErrors', function() {
|
||||
const error = new Error('nope');
|
||||
dispatchEvent(globals.listeners, 'error', { error });
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
jasmine.is(error),
|
||||
jasmine.objectContaining({ error: jasmine.is(error) })
|
||||
);
|
||||
expect(handler).toHaveBeenCalledWith(jasmine.is(error));
|
||||
});
|
||||
|
||||
it('is not affected by overriding global.onerror', function() {
|
||||
const globals = browserGlobals();
|
||||
const handler = jasmine.createSpy('errorHandler');
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -35,17 +32,14 @@ describe('GlobalErrors', function() {
|
||||
const error = new Error('nope');
|
||||
dispatchEvent(globals.listeners, 'error', { error });
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
jasmine.is(error),
|
||||
jasmine.objectContaining({ error: jasmine.is(error) })
|
||||
);
|
||||
expect(handler).toHaveBeenCalledWith(jasmine.is(error));
|
||||
});
|
||||
|
||||
it('only calls the most recent handler', function() {
|
||||
const globals = browserGlobals();
|
||||
const handler1 = jasmine.createSpy('errorHandler1');
|
||||
const handler2 = jasmine.createSpy('errorHandler2');
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -58,17 +52,14 @@ describe('GlobalErrors', function() {
|
||||
dispatchEvent(globals.listeners, 'error', { error });
|
||||
|
||||
expect(handler1).not.toHaveBeenCalled();
|
||||
expect(handler2).toHaveBeenCalledWith(
|
||||
jasmine.is(error),
|
||||
jasmine.objectContaining({ error: jasmine.is(error) })
|
||||
);
|
||||
expect(handler2).toHaveBeenCalledWith(jasmine.is(error));
|
||||
});
|
||||
|
||||
it('calls previous handlers when one is removed', function() {
|
||||
const globals = browserGlobals();
|
||||
const handler1 = jasmine.createSpy('errorHandler1');
|
||||
const handler2 = jasmine.createSpy('errorHandler2');
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -82,15 +73,12 @@ describe('GlobalErrors', function() {
|
||||
const error = new Error('nope');
|
||||
dispatchEvent(globals.listeners, 'error', { error });
|
||||
|
||||
expect(handler1).toHaveBeenCalledWith(
|
||||
jasmine.is(error),
|
||||
jasmine.objectContaining({ error: jasmine.is(error) })
|
||||
);
|
||||
expect(handler1).toHaveBeenCalledWith(jasmine.is(error));
|
||||
expect(handler2).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('throws when no listener is passed to #popListener', function() {
|
||||
const errors = new jasmineUnderTest.GlobalErrors({});
|
||||
const errors = new privateUnderTest.GlobalErrors({});
|
||||
expect(function() {
|
||||
errors.popListener();
|
||||
}).toThrowError('popListener expects a listener');
|
||||
@@ -98,7 +86,7 @@ describe('GlobalErrors', function() {
|
||||
|
||||
it('uninstalls itself', function() {
|
||||
const globals = browserGlobals();
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -113,7 +101,7 @@ describe('GlobalErrors', function() {
|
||||
|
||||
it('rethrows the original error when there is no handler', function() {
|
||||
const globals = browserGlobals();
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -130,9 +118,35 @@ describe('GlobalErrors', function() {
|
||||
errors.uninstall();
|
||||
});
|
||||
|
||||
it("reports browser error events that don't have errors", function() {
|
||||
const globals = browserGlobals();
|
||||
const handler = jasmine.createSpy('errorHandler');
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
errors.install();
|
||||
errors.pushListener(handler);
|
||||
|
||||
const event = {
|
||||
message: 'Uncaught SyntaxError: Unexpected end of input',
|
||||
error: undefined,
|
||||
filename: 'borkenSpec.js',
|
||||
lineno: 42
|
||||
};
|
||||
dispatchEvent(globals.listeners, 'error', event);
|
||||
|
||||
expect(handler).toHaveBeenCalledWith({
|
||||
message: 'Uncaught SyntaxError: Unexpected end of input',
|
||||
filename: 'borkenSpec.js',
|
||||
lineno: 42,
|
||||
stack: '@borkenSpec.js:42'
|
||||
});
|
||||
});
|
||||
|
||||
it('reports uncaught exceptions in node.js', function() {
|
||||
const globals = nodeGlobals();
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -152,7 +166,7 @@ describe('GlobalErrors', function() {
|
||||
|
||||
dispatchEvent(globals.listeners, 'uncaughtException', new Error('bar'));
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(new Error('bar'), undefined);
|
||||
expect(handler).toHaveBeenCalledWith(new Error('bar'));
|
||||
expect(handler.calls.argsFor(0)[0].jasmineMessage).toBe(
|
||||
'Uncaught exception: Error: bar'
|
||||
);
|
||||
@@ -165,7 +179,7 @@ describe('GlobalErrors', function() {
|
||||
describe('Reporting unhandled promise rejections in node.js', function() {
|
||||
it('reports rejections with `Error` reasons', function() {
|
||||
const globals = nodeGlobals();
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -185,7 +199,7 @@ describe('GlobalErrors', function() {
|
||||
|
||||
dispatchEvent(globals.listeners, 'unhandledRejection', new Error('bar'));
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(new Error('bar'), undefined);
|
||||
expect(handler).toHaveBeenCalledWith(new Error('bar'));
|
||||
expect(handler.calls.argsFor(0)[0].jasmineMessage).toBe(
|
||||
'Unhandled promise rejection: Error: bar'
|
||||
);
|
||||
@@ -197,7 +211,7 @@ describe('GlobalErrors', function() {
|
||||
|
||||
it('reports rejections with non-`Error` reasons', function() {
|
||||
const globals = nodeGlobals();
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -213,14 +227,13 @@ describe('GlobalErrors', function() {
|
||||
'Unhandled promise rejection: 17\n' +
|
||||
'(Tip: to get a useful stack trace, use ' +
|
||||
'Promise.reject(new Error(...)) instead of Promise.reject(...).)'
|
||||
),
|
||||
undefined
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
it('reports rejections with no reason provided', function() {
|
||||
const globals = nodeGlobals();
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -236,8 +249,7 @@ describe('GlobalErrors', function() {
|
||||
'Unhandled promise rejection with no error or message\n' +
|
||||
'(Tip: to get a useful stack trace, use ' +
|
||||
'Promise.reject(new Error(...)) instead of Promise.reject().)'
|
||||
),
|
||||
undefined
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -246,7 +258,7 @@ describe('GlobalErrors', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
globals = nodeGlobals();
|
||||
errors = new jasmineUnderTest.GlobalErrors(globals.global, () => ({
|
||||
errors = new privateUnderTest.GlobalErrors(globals.global, () => ({
|
||||
detectLateRejectionHandling: true
|
||||
}));
|
||||
});
|
||||
@@ -281,7 +293,7 @@ describe('GlobalErrors', function() {
|
||||
undefined
|
||||
);
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(new Error('nope'), undefined);
|
||||
expect(handler).toHaveBeenCalledWith(new Error('nope'));
|
||||
expect(handler.calls.argsFor(0)[0].jasmineMessage).toBe(
|
||||
'Unhandled promise rejection: Error: nope'
|
||||
);
|
||||
@@ -324,7 +336,7 @@ describe('GlobalErrors', function() {
|
||||
);
|
||||
errors.reportUnhandledRejections();
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(new Error('nope'), undefined);
|
||||
expect(handler).toHaveBeenCalledWith(new Error('nope'));
|
||||
expect(handler.calls.argsFor(0)[0].jasmineMessage).toBe(
|
||||
'Unhandled promise rejection: Error: nope'
|
||||
);
|
||||
@@ -379,7 +391,7 @@ describe('GlobalErrors', function() {
|
||||
describe('Reporting unhandled promise rejections in the browser', function() {
|
||||
it('subscribes and unsubscribes from the unhandledrejection event', function() {
|
||||
const globals = browserGlobals();
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -396,7 +408,7 @@ describe('GlobalErrors', function() {
|
||||
it('reports rejections whose reason is a string', function() {
|
||||
const globals = browserGlobals();
|
||||
const handler = jasmine.createSpy('errorHandler');
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -407,16 +419,13 @@ describe('GlobalErrors', function() {
|
||||
const event = { reason: 'nope' };
|
||||
dispatchEvent(globals.listeners, 'unhandledrejection', event);
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
'Unhandled promise rejection: nope',
|
||||
event
|
||||
);
|
||||
expect(handler).toHaveBeenCalledWith('Unhandled promise rejection: nope');
|
||||
});
|
||||
|
||||
it('reports rejections whose reason is an Error', function() {
|
||||
const globals = browserGlobals();
|
||||
const handler = jasmine.createSpy('errorHandler');
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -428,13 +437,15 @@ describe('GlobalErrors', function() {
|
||||
const event = { reason };
|
||||
dispatchEvent(globals.listeners, 'unhandledrejection', event);
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
expect(handler).toHaveBeenCalledTimes(1);
|
||||
const received = handler.calls.argsFor(0)[0];
|
||||
expect(received).toBeInstanceOf(Error);
|
||||
expect(received).toEqual(
|
||||
jasmine.objectContaining({
|
||||
jasmineMessage: 'Unhandled promise rejection: Error: bar',
|
||||
message: reason.message,
|
||||
stack: reason.stack
|
||||
}),
|
||||
event
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
@@ -443,7 +454,7 @@ describe('GlobalErrors', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
globals = browserGlobals();
|
||||
errors = new jasmineUnderTest.GlobalErrors(globals.global, () => ({
|
||||
errors = new privateUnderTest.GlobalErrors(globals.global, () => ({
|
||||
detectLateRejectionHandling: true
|
||||
}));
|
||||
});
|
||||
@@ -469,8 +480,7 @@ describe('GlobalErrors', function() {
|
||||
dispatchEvent(globals.listeners, 'unhandledrejection', event);
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
'Unhandled promise rejection: nope',
|
||||
event
|
||||
'Unhandled promise rejection: nope'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -507,8 +517,7 @@ describe('GlobalErrors', function() {
|
||||
errors.reportUnhandledRejections();
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
'Unhandled promise rejection: nope',
|
||||
{ reason: 'nope', promise }
|
||||
'Unhandled promise rejection: nope'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -556,7 +565,7 @@ describe('GlobalErrors', function() {
|
||||
describe('Reporting uncaught exceptions in node.js', function() {
|
||||
it('prepends a descriptive message when the error is not an `Error`', function() {
|
||||
const globals = nodeGlobals();
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -567,15 +576,12 @@ describe('GlobalErrors', function() {
|
||||
|
||||
dispatchEvent(globals.listeners, 'uncaughtException', 17);
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
new Error('Uncaught exception: 17'),
|
||||
undefined
|
||||
);
|
||||
expect(handler).toHaveBeenCalledWith(new Error('Uncaught exception: 17'));
|
||||
});
|
||||
|
||||
it('substitutes a descriptive message when the error is falsy', function() {
|
||||
const globals = nodeGlobals();
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -587,8 +593,7 @@ describe('GlobalErrors', function() {
|
||||
dispatchEvent(globals.listeners, 'uncaughtException', undefined);
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
new Error('Uncaught exception with no error or message'),
|
||||
undefined
|
||||
new Error('Uncaught exception with no error or message')
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -599,7 +604,7 @@ describe('GlobalErrors', function() {
|
||||
const handler0 = jasmine.createSpy('handler0');
|
||||
const handler1 = jasmine.createSpy('handler1');
|
||||
const overrideHandler = jasmine.createSpy('overrideHandler');
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -619,7 +624,7 @@ describe('GlobalErrors', function() {
|
||||
const event = { error: 'baz' };
|
||||
dispatchEvent(globals.listeners, 'error', event);
|
||||
expect(overrideHandler).not.toHaveBeenCalledWith('baz');
|
||||
expect(handler1).toHaveBeenCalledWith('baz', event);
|
||||
expect(handler1).toHaveBeenCalledWith('baz');
|
||||
});
|
||||
|
||||
it('overrides the existing handlers in Node until removed', function() {
|
||||
@@ -627,7 +632,7 @@ describe('GlobalErrors', function() {
|
||||
const handler0 = jasmine.createSpy('handler0');
|
||||
const handler1 = jasmine.createSpy('handler1');
|
||||
const overrideHandler = jasmine.createSpy('overrideHandler');
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -648,14 +653,14 @@ describe('GlobalErrors', function() {
|
||||
|
||||
dispatchEvent(globals.listeners, 'uncaughtException', new Error('bar'));
|
||||
expect(overrideHandler).not.toHaveBeenCalled();
|
||||
expect(handler1).toHaveBeenCalledWith(new Error('bar'), undefined);
|
||||
expect(handler1).toHaveBeenCalledWith(new Error('bar'));
|
||||
});
|
||||
|
||||
it('handles unhandled promise rejections in browsers', function() {
|
||||
const globals = browserGlobals();
|
||||
const handler = jasmine.createSpy('handler');
|
||||
const overrideHandler = jasmine.createSpy('overrideHandler');
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -683,7 +688,7 @@ describe('GlobalErrors', function() {
|
||||
const handler0 = jasmine.createSpy('handler0');
|
||||
const handler1 = jasmine.createSpy('handler1');
|
||||
const overrideHandler = jasmine.createSpy('overrideHandler');
|
||||
const errors = new jasmineUnderTest.GlobalErrors(
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
@@ -701,7 +706,7 @@ describe('GlobalErrors', function() {
|
||||
});
|
||||
|
||||
it('throws if there is already an override handler', function() {
|
||||
const errors = new jasmineUnderTest.GlobalErrors(browserGlobals().global);
|
||||
const errors = new privateUnderTest.GlobalErrors(browserGlobals().global);
|
||||
|
||||
errors.setOverrideListener(() => {}, () => {});
|
||||
expect(function() {
|
||||
@@ -713,7 +718,7 @@ describe('GlobalErrors', function() {
|
||||
describe('#removeOverrideListener', function() {
|
||||
it("calls the handler's onRemove callback", function() {
|
||||
const onRemove = jasmine.createSpy('onRemove');
|
||||
const errors = new jasmineUnderTest.GlobalErrors(browserGlobals().global);
|
||||
const errors = new privateUnderTest.GlobalErrors(browserGlobals().global);
|
||||
|
||||
errors.setOverrideListener(() => {}, onRemove);
|
||||
errors.removeOverrideListener();
|
||||
@@ -722,7 +727,7 @@ describe('GlobalErrors', function() {
|
||||
});
|
||||
|
||||
it('does not throw if there is no handler', function() {
|
||||
const errors = new jasmineUnderTest.GlobalErrors(browserGlobals().global);
|
||||
const errors = new privateUnderTest.GlobalErrors(browserGlobals().global);
|
||||
|
||||
expect(() => errors.removeOverrideListener()).not.toThrow();
|
||||
});
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
describe('JsApiReporter', function() {
|
||||
it('knows when a full environment is started', function() {
|
||||
const reporter = new jasmineUnderTest.JsApiReporter({});
|
||||
|
||||
expect(reporter.started).toBe(false);
|
||||
expect(reporter.finished).toBe(false);
|
||||
|
||||
reporter.jasmineStarted();
|
||||
|
||||
expect(reporter.started).toBe(true);
|
||||
expect(reporter.finished).toBe(false);
|
||||
});
|
||||
|
||||
it('knows when a full environment is done', function() {
|
||||
const reporter = new jasmineUnderTest.JsApiReporter({});
|
||||
|
||||
expect(reporter.started).toBe(false);
|
||||
expect(reporter.finished).toBe(false);
|
||||
|
||||
reporter.jasmineStarted();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
expect(reporter.finished).toBe(true);
|
||||
});
|
||||
|
||||
it("defaults to 'loaded' status", function() {
|
||||
const reporter = new jasmineUnderTest.JsApiReporter({});
|
||||
|
||||
expect(reporter.status()).toEqual('loaded');
|
||||
});
|
||||
|
||||
it("reports 'started' when Jasmine has started", function() {
|
||||
const reporter = new jasmineUnderTest.JsApiReporter({});
|
||||
|
||||
reporter.jasmineStarted();
|
||||
|
||||
expect(reporter.status()).toEqual('started');
|
||||
});
|
||||
|
||||
it("reports 'done' when Jasmine is done", function() {
|
||||
const reporter = new jasmineUnderTest.JsApiReporter({});
|
||||
|
||||
reporter.jasmineDone({});
|
||||
|
||||
expect(reporter.status()).toEqual('done');
|
||||
});
|
||||
|
||||
it('tracks a suite', function() {
|
||||
const reporter = new jasmineUnderTest.JsApiReporter({});
|
||||
|
||||
reporter.suiteStarted({
|
||||
id: 123,
|
||||
description: 'A suite'
|
||||
});
|
||||
|
||||
const suites = reporter.suites();
|
||||
|
||||
expect(suites).toEqual({ 123: { id: 123, description: 'A suite' } });
|
||||
|
||||
reporter.suiteDone({
|
||||
id: 123,
|
||||
description: 'A suite',
|
||||
status: 'passed'
|
||||
});
|
||||
|
||||
expect(suites).toEqual({
|
||||
123: { id: 123, description: 'A suite', status: 'passed' }
|
||||
});
|
||||
});
|
||||
|
||||
describe('#specResults', function() {
|
||||
let reporter, specResult1, specResult2;
|
||||
beforeEach(function() {
|
||||
reporter = new jasmineUnderTest.JsApiReporter({});
|
||||
specResult1 = {
|
||||
id: 1,
|
||||
description: 'A spec'
|
||||
};
|
||||
specResult2 = {
|
||||
id: 2,
|
||||
description: 'Another spec'
|
||||
};
|
||||
|
||||
reporter.specDone(specResult1);
|
||||
reporter.specDone(specResult2);
|
||||
});
|
||||
|
||||
it('should return a slice of results', function() {
|
||||
expect(reporter.specResults(0, 1)).toEqual([specResult1]);
|
||||
expect(reporter.specResults(1, 1)).toEqual([specResult2]);
|
||||
});
|
||||
|
||||
describe('when the results do not exist', function() {
|
||||
it('should return a slice of shorter length', function() {
|
||||
expect(reporter.specResults(0, 3)).toEqual([specResult1, specResult2]);
|
||||
expect(reporter.specResults(2, 3)).toEqual([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#suiteResults', function() {
|
||||
let reporter, suiteStarted1, suiteResult1, suiteResult2;
|
||||
beforeEach(function() {
|
||||
reporter = new jasmineUnderTest.JsApiReporter({});
|
||||
suiteStarted1 = {
|
||||
id: 1
|
||||
};
|
||||
suiteResult1 = {
|
||||
id: 1,
|
||||
status: 'failed',
|
||||
failedExpectations: [{ message: 'My After All Exception' }]
|
||||
};
|
||||
suiteResult2 = {
|
||||
id: 2,
|
||||
status: 'passed'
|
||||
};
|
||||
|
||||
reporter.suiteStarted(suiteStarted1);
|
||||
reporter.suiteDone(suiteResult1);
|
||||
reporter.suiteDone(suiteResult2);
|
||||
});
|
||||
|
||||
it('should not include suite starts', function() {
|
||||
expect(reporter.suiteResults(0, 3).length).toEqual(2);
|
||||
});
|
||||
|
||||
it('should return a slice of results', function() {
|
||||
expect(reporter.suiteResults(0, 1)).toEqual([suiteResult1]);
|
||||
expect(reporter.suiteResults(1, 1)).toEqual([suiteResult2]);
|
||||
});
|
||||
|
||||
it('returns nothing for out of bounds indices', function() {
|
||||
expect(reporter.suiteResults(0, 3)).toEqual([suiteResult1, suiteResult2]);
|
||||
expect(reporter.suiteResults(2, 3)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#executionTime', function() {
|
||||
it('should start the timer when jasmine starts', function() {
|
||||
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
||||
reporter = new jasmineUnderTest.JsApiReporter({
|
||||
timer: timerSpy
|
||||
});
|
||||
|
||||
reporter.jasmineStarted();
|
||||
expect(timerSpy.start).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should return the time it took the specs to run, in ms', function() {
|
||||
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
||||
reporter = new jasmineUnderTest.JsApiReporter({
|
||||
timer: timerSpy
|
||||
});
|
||||
|
||||
timerSpy.elapsed.and.returnValue(1000);
|
||||
reporter.jasmineDone();
|
||||
expect(reporter.executionTime()).toEqual(1000);
|
||||
});
|
||||
|
||||
describe("when the specs haven't finished being run", function() {
|
||||
it('should return undefined', function() {
|
||||
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
||||
reporter = new jasmineUnderTest.JsApiReporter({
|
||||
timer: timerSpy
|
||||
});
|
||||
|
||||
expect(reporter.executionTime()).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#runDetails', function() {
|
||||
it('should have details about the run', function() {
|
||||
const reporter = new jasmineUnderTest.JsApiReporter({});
|
||||
reporter.jasmineDone({ some: { run: 'details' } });
|
||||
expect(reporter.runDetails).toEqual({ some: { run: 'details' } });
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('FakeDate', function() {
|
||||
it('does not fail if no global date is found', function() {
|
||||
const fakeGlobal = {},
|
||||
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
expect(function() {
|
||||
mockDate.install();
|
||||
@@ -19,7 +19,7 @@ describe('FakeDate', function() {
|
||||
};
|
||||
}),
|
||||
fakeGlobal = { Date: globalDate },
|
||||
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
expect(fakeGlobal.Date).toEqual(globalDate);
|
||||
mockDate.install();
|
||||
@@ -36,7 +36,7 @@ describe('FakeDate', function() {
|
||||
};
|
||||
}),
|
||||
fakeGlobal = { Date: globalDate },
|
||||
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
mockDate.uninstall();
|
||||
@@ -55,7 +55,7 @@ describe('FakeDate', function() {
|
||||
};
|
||||
}),
|
||||
fakeGlobal = { Date: globalDate },
|
||||
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
|
||||
@@ -66,7 +66,7 @@ describe('FakeDate', function() {
|
||||
|
||||
it('can accept a date as time base when installing', function() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new jasmineUnderTest.MockDate(fakeGlobal),
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal),
|
||||
baseDate = new Date();
|
||||
|
||||
spyOn(baseDate, 'getTime').and.returnValue(123);
|
||||
@@ -77,7 +77,7 @@ describe('FakeDate', function() {
|
||||
|
||||
it('makes real dates', function() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
expect(new fakeGlobal.Date()).toEqual(jasmine.any(Date));
|
||||
@@ -97,7 +97,7 @@ describe('FakeDate', function() {
|
||||
fakeGlobal = { Date: globalDate };
|
||||
|
||||
globalDate.now = function() {};
|
||||
const mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
|
||||
@@ -117,7 +117,7 @@ describe('FakeDate', function() {
|
||||
fakeGlobal = { Date: globalDate };
|
||||
|
||||
globalDate.now = function() {};
|
||||
const mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
|
||||
@@ -143,7 +143,7 @@ describe('FakeDate', function() {
|
||||
fakeGlobal = { Date: globalDate };
|
||||
|
||||
globalDate.now = function() {};
|
||||
const mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
|
||||
@@ -156,7 +156,7 @@ describe('FakeDate', function() {
|
||||
|
||||
it('allows creation of a Date in a different time than the mocked time', function() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
|
||||
@@ -168,7 +168,7 @@ describe('FakeDate', function() {
|
||||
|
||||
it("allows creation of a Date that isn't fully specified", function() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
|
||||
@@ -178,7 +178,7 @@ describe('FakeDate', function() {
|
||||
|
||||
it('allows creation of a Date with millis', function() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new jasmineUnderTest.MockDate(fakeGlobal),
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal),
|
||||
now = new Date(2014, 3, 15).getTime();
|
||||
|
||||
mockDate.install();
|
||||
@@ -189,7 +189,7 @@ describe('FakeDate', function() {
|
||||
|
||||
it('copies all Date properties to the mocked date', function() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
|
||||
|
||||
@@ -160,6 +160,13 @@ describe('ParallelReportDispatcher', function() {
|
||||
);
|
||||
});
|
||||
|
||||
isNonMonkeyPatchableClass(
|
||||
jasmineUnderTest.ParallelReportDispatcher,
|
||||
function() {
|
||||
return new jasmineUnderTest.ParallelReportDispatcher();
|
||||
}
|
||||
);
|
||||
|
||||
function mockGlobalErrors() {
|
||||
const globalErrors = jasmine.createSpyObj('globalErrors', [
|
||||
'install',
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
describe('PrettyPrinter', function() {
|
||||
it('should wrap strings in single quotes', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
expect(pp('some string')).toEqual("'some string'");
|
||||
expect(pp("som' string")).toEqual("'som' string'");
|
||||
});
|
||||
|
||||
it('stringifies empty string primitives and objects recognizably', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
expect(pp(new String(''))).toEqual(pp(''));
|
||||
expect(pp(new String(''))).toEqual("''");
|
||||
expect(pp([new String('')])).toEqual(pp(['']));
|
||||
@@ -14,7 +14,7 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('should stringify primitives properly', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
expect(pp(true)).toEqual('true');
|
||||
expect(pp(false)).toEqual('false');
|
||||
expect(pp(null)).toEqual('null');
|
||||
@@ -29,7 +29,7 @@ describe('PrettyPrinter', function() {
|
||||
const set = new Set();
|
||||
set.add(1);
|
||||
set.add(2);
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
expect(pp(set)).toEqual('Set( 1, 2 )');
|
||||
});
|
||||
|
||||
@@ -42,7 +42,7 @@ describe('PrettyPrinter', function() {
|
||||
set.add('a');
|
||||
set.add('b');
|
||||
set.add('c');
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
expect(pp(set)).toEqual("Set( 'a', 'b', ... )");
|
||||
} finally {
|
||||
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxSize;
|
||||
@@ -54,7 +54,7 @@ describe('PrettyPrinter', function() {
|
||||
it('should stringify maps properly', function() {
|
||||
const map = new Map();
|
||||
map.set(1, 2);
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
expect(pp(map)).toEqual('Map( [ 1, 2 ] )');
|
||||
});
|
||||
|
||||
@@ -67,7 +67,7 @@ describe('PrettyPrinter', function() {
|
||||
map.set('a', 1);
|
||||
map.set('b', 2);
|
||||
map.set('c', 3);
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
expect(pp(map)).toEqual("Map( [ 'a', 1 ], [ 'b', 2 ], ... )");
|
||||
} finally {
|
||||
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxSize;
|
||||
@@ -77,7 +77,7 @@ describe('PrettyPrinter', function() {
|
||||
|
||||
describe('stringify arrays', function() {
|
||||
it('should stringify arrays properly', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
expect(pp([1, 2])).toEqual('[ 1, 2 ]');
|
||||
expect(pp([1, 'foo', {}, jasmine.undefined, null])).toEqual(
|
||||
"[ 1, 'foo', Object({ }), undefined, null ]"
|
||||
@@ -85,14 +85,14 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('includes symbols', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
expect(pp([1, Symbol('foo'), 2])).toEqual('[ 1, Symbol(foo), 2 ]');
|
||||
});
|
||||
|
||||
it('should truncate arrays that are longer than jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH', function() {
|
||||
const originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH;
|
||||
const array = [1, 2, 3];
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
|
||||
try {
|
||||
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
|
||||
@@ -103,7 +103,7 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('should stringify arrays with properties properly', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const arr = [1, 2];
|
||||
arr.foo = 'bar';
|
||||
arr.baz = {};
|
||||
@@ -111,7 +111,7 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('should stringify empty arrays with properties properly', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const empty = [];
|
||||
empty.foo = 'bar';
|
||||
empty.baz = {};
|
||||
@@ -119,7 +119,7 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('should stringify long arrays with properties properly', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH;
|
||||
const long = [1, 2, 3];
|
||||
long.foo = 'bar';
|
||||
@@ -136,7 +136,7 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('should indicate circular array references', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const array1 = [1, 2];
|
||||
const array2 = [array1];
|
||||
array1.push(array2);
|
||||
@@ -144,14 +144,14 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('should not indicate circular references incorrectly', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const array = [[1]];
|
||||
expect(pp(array)).toEqual('[ [ 1 ] ]');
|
||||
});
|
||||
});
|
||||
|
||||
it('should stringify objects properly', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
expect(pp({ foo: 'bar' })).toEqual("Object({ foo: 'bar' })");
|
||||
expect(
|
||||
pp({
|
||||
@@ -169,14 +169,14 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('includes symbol keys in objects', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const obj = {};
|
||||
obj[Symbol('foo')] = 'bar';
|
||||
expect(pp(obj)).toEqual("Object({ Symbol(foo): 'bar' })");
|
||||
});
|
||||
|
||||
it('stringifies string and symbol keys differently', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const symObj = {};
|
||||
const strObj = {};
|
||||
const k = 'foo';
|
||||
@@ -188,12 +188,12 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('should stringify objects that almost look like DOM nodes', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
expect(pp({ nodeType: 1 })).toEqual('Object({ nodeType: 1 })');
|
||||
});
|
||||
|
||||
it('should truncate objects with too many keys', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH;
|
||||
const long = { a: 1, b: 2, c: 3 };
|
||||
|
||||
@@ -217,7 +217,7 @@ describe('PrettyPrinter', function() {
|
||||
}
|
||||
|
||||
it('should truncate outputs that are too long', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const big = [{ a: 1, b: 'a long string' }, {}];
|
||||
|
||||
withMaxChars(34, function() {
|
||||
@@ -246,7 +246,7 @@ describe('PrettyPrinter', function() {
|
||||
.createSpy('d jasmineToString')
|
||||
.and.returnValue('')
|
||||
},
|
||||
pp = jasmineUnderTest.makePrettyPrinter();
|
||||
pp = privateUnderTest.makePrettyPrinter();
|
||||
|
||||
withMaxChars(30, function() {
|
||||
pp([{ a: a, b: b, c: c }, d]);
|
||||
@@ -256,13 +256,13 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it("should print 'null' as the constructor of an object with its own constructor property", function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
expect(pp({ constructor: function() {} })).toContain('null({');
|
||||
expect(pp({ constructor: 'foo' })).toContain('null({');
|
||||
});
|
||||
|
||||
it('should not include inherited properties when stringifying an object', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const SomeClass = function SomeClass() {};
|
||||
SomeClass.prototype.foo = 'inherited foo';
|
||||
const instance = new SomeClass();
|
||||
@@ -271,7 +271,7 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('should not recurse objects and arrays more deeply than jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const originalMaxDepth = jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH;
|
||||
const nestedObject = { level1: { level2: { level3: { level4: 'leaf' } } } };
|
||||
const nestedArray = [1, [2, [3, [4, 'leaf']]]];
|
||||
@@ -300,7 +300,7 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('should stringify immutable circular objects', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
let frozenObject = { foo: { bar: 'baz' } };
|
||||
frozenObject.circular = frozenObject;
|
||||
frozenObject = Object.freeze(frozenObject);
|
||||
@@ -310,12 +310,12 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('should stringify RegExp objects properly', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
expect(pp(/x|y|z/)).toEqual('/x|y|z/');
|
||||
});
|
||||
|
||||
it('should indicate circular object references', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const sampleValue = { foo: 'hello' };
|
||||
sampleValue.nested = sampleValue;
|
||||
expect(pp(sampleValue)).toEqual(
|
||||
@@ -324,7 +324,7 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('should use the return value of getters', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const sampleValue = {
|
||||
id: 1,
|
||||
get calculatedValue() {
|
||||
@@ -337,19 +337,19 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('should not do HTML escaping of strings', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
expect(pp('some <b>html string</b> &', false)).toEqual(
|
||||
"'some <b>html string</b> &'"
|
||||
);
|
||||
});
|
||||
|
||||
it('should abbreviate the global (usually window) object', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
expect(pp(jasmine.getGlobal())).toEqual('<global>');
|
||||
});
|
||||
|
||||
it('should stringify Date objects properly', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const now = new Date();
|
||||
expect(pp(now)).toEqual('Date(' + now.toString() + ')');
|
||||
});
|
||||
@@ -358,8 +358,8 @@ describe('PrettyPrinter', function() {
|
||||
let env, pp;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
pp = jasmineUnderTest.makePrettyPrinter();
|
||||
env = new privateUnderTest.Env();
|
||||
pp = privateUnderTest.makePrettyPrinter();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
@@ -371,12 +371,12 @@ describe('PrettyPrinter', function() {
|
||||
someFunction: function() {}
|
||||
};
|
||||
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return [];
|
||||
},
|
||||
createSpy: function(name, originalFn) {
|
||||
return jasmineUnderTest.Spy(name, originalFn);
|
||||
return privateUnderTest.Spy(name, originalFn);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -390,15 +390,15 @@ describe('PrettyPrinter', function() {
|
||||
const TestObject = {
|
||||
someFunction: function() {}
|
||||
},
|
||||
env = new jasmineUnderTest.Env(),
|
||||
pp = jasmineUnderTest.makePrettyPrinter();
|
||||
env = new privateUnderTest.Env(),
|
||||
pp = privateUnderTest.makePrettyPrinter();
|
||||
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return [];
|
||||
},
|
||||
createSpy: function(name, originalFn) {
|
||||
return jasmineUnderTest.Spy(name, originalFn);
|
||||
return privateUnderTest.Spy(name, originalFn);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -410,7 +410,7 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('should stringify objects that implement jasmineToString', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const obj = {
|
||||
jasmineToString: function() {
|
||||
return 'strung';
|
||||
@@ -421,7 +421,7 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('should pass itself to jasmineToString', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter([]);
|
||||
const pp = privateUnderTest.makePrettyPrinter([]);
|
||||
const obj = {
|
||||
jasmineToString: jasmine.createSpy('jasmineToString').and.returnValue('')
|
||||
};
|
||||
@@ -431,7 +431,7 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('should stringify objects that implement custom toString', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const obj = {
|
||||
toString: function() {
|
||||
return 'my toString';
|
||||
@@ -455,7 +455,7 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it("should stringify objects have have a toString that isn't a function", function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const obj = {
|
||||
toString: 'foo'
|
||||
};
|
||||
@@ -464,7 +464,7 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('should stringify objects from anonymous constructors with custom toString', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const MyAnonymousConstructor = (function() {
|
||||
return function() {};
|
||||
})();
|
||||
@@ -478,18 +478,18 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('stringifies functions with names', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
expect(pp(foo)).toEqual("Function 'foo'");
|
||||
function foo() {}
|
||||
});
|
||||
|
||||
it('stringifies functions without names', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
expect(pp(function() {})).toEqual('Function');
|
||||
});
|
||||
|
||||
it('should handle objects with null prototype', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const obj = Object.create(null);
|
||||
obj.foo = 'bar';
|
||||
|
||||
@@ -497,7 +497,7 @@ describe('PrettyPrinter', function() {
|
||||
});
|
||||
|
||||
it('should gracefully handle objects with invalid toString implementations', function() {
|
||||
const pp = jasmineUnderTest.makePrettyPrinter();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const obj = {
|
||||
foo: {
|
||||
toString: function() {
|
||||
@@ -545,7 +545,7 @@ describe('PrettyPrinter', function() {
|
||||
return '3rd: ' + obj.foo;
|
||||
}
|
||||
],
|
||||
pp = jasmineUnderTest.makePrettyPrinter(customObjectFormatters),
|
||||
pp = privateUnderTest.makePrettyPrinter(customObjectFormatters),
|
||||
obj = { foo: 'bar' };
|
||||
|
||||
expect(pp(obj)).toEqual('2nd: bar');
|
||||
@@ -557,7 +557,7 @@ describe('PrettyPrinter', function() {
|
||||
return undefined;
|
||||
}
|
||||
],
|
||||
pp = jasmineUnderTest.makePrettyPrinter(customObjectFormatters),
|
||||
pp = privateUnderTest.makePrettyPrinter(customObjectFormatters),
|
||||
obj = { foo: 'bar' };
|
||||
|
||||
expect(pp(obj)).toEqual("Object({ foo: 'bar' })");
|
||||
@@ -577,7 +577,7 @@ describe('PrettyPrinter', function() {
|
||||
return '3rd: ' + obj.foo;
|
||||
}
|
||||
],
|
||||
pp = jasmineUnderTest.makePrettyPrinter(customObjectFormatters),
|
||||
pp = privateUnderTest.makePrettyPrinter(customObjectFormatters),
|
||||
obj = { foo: 'bar' };
|
||||
|
||||
expect(pp.customFormat_(obj)).toEqual('2nd: bar');
|
||||
@@ -589,7 +589,7 @@ describe('PrettyPrinter', function() {
|
||||
return undefined;
|
||||
}
|
||||
],
|
||||
pp = jasmineUnderTest.makePrettyPrinter(customObjectFormatters),
|
||||
pp = privateUnderTest.makePrettyPrinter(customObjectFormatters),
|
||||
obj = { foo: 'bar' };
|
||||
|
||||
expect(pp.customFormat_(obj)).toBeUndefined();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('QueueRunner', function() {
|
||||
it('validates that queueableFns are truthy', function() {
|
||||
expect(function() {
|
||||
new jasmineUnderTest.QueueRunner({
|
||||
new privateUnderTest.QueueRunner({
|
||||
queueableFns: [undefined]
|
||||
});
|
||||
}).toThrowError('Received a falsy queueableFn');
|
||||
@@ -9,7 +9,7 @@ describe('QueueRunner', function() {
|
||||
|
||||
it('validates that queueableFns have fn properties', function() {
|
||||
expect(function() {
|
||||
new jasmineUnderTest.QueueRunner({
|
||||
new privateUnderTest.QueueRunner({
|
||||
queueableFns: [{ fn: undefined }]
|
||||
});
|
||||
}).toThrowError('Received a queueableFn with no fn');
|
||||
@@ -19,7 +19,7 @@ describe('QueueRunner', function() {
|
||||
const calls = [],
|
||||
queueableFn1 = { fn: jasmine.createSpy('fn1') },
|
||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2]
|
||||
});
|
||||
queueableFn1.fn.and.callFake(function() {
|
||||
@@ -44,14 +44,14 @@ describe('QueueRunner', function() {
|
||||
done();
|
||||
}
|
||||
},
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2, queueableFn3]
|
||||
});
|
||||
|
||||
queueRunner.execute();
|
||||
|
||||
const context = queueableFn1.fn.calls.first().object;
|
||||
expect(context).toEqual(new jasmineUnderTest.UserContext());
|
||||
expect(context).toEqual(new privateUnderTest.UserContext());
|
||||
expect(queueableFn2.fn.calls.first().object).toBe(context);
|
||||
expect(asyncContext).toBe(context);
|
||||
});
|
||||
@@ -91,7 +91,7 @@ describe('QueueRunner', function() {
|
||||
setTimeout(done, 100);
|
||||
}
|
||||
},
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2, queueableFn3],
|
||||
onComplete: onComplete
|
||||
});
|
||||
@@ -129,7 +129,7 @@ describe('QueueRunner', function() {
|
||||
},
|
||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
||||
failFn = jasmine.createSpy('fail'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2],
|
||||
fail: failFn
|
||||
});
|
||||
@@ -157,7 +157,7 @@ describe('QueueRunner', function() {
|
||||
},
|
||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
||||
failFn = jasmine.createSpy('fail'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2],
|
||||
fail: failFn
|
||||
});
|
||||
@@ -189,7 +189,7 @@ describe('QueueRunner', function() {
|
||||
},
|
||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
||||
failFn = jasmine.createSpy('fail'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2],
|
||||
fail: failFn,
|
||||
onComplete: function() {
|
||||
@@ -211,7 +211,7 @@ describe('QueueRunner', function() {
|
||||
}
|
||||
},
|
||||
failFn = jasmine.createSpy('fail'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1],
|
||||
fail: failFn,
|
||||
onComplete: function() {
|
||||
@@ -227,7 +227,7 @@ describe('QueueRunner', function() {
|
||||
});
|
||||
|
||||
it('does not cause an explicit fail if execution is being stopped', function() {
|
||||
const err = new jasmineUnderTest.StopExecutionError('foo'),
|
||||
const err = new privateUnderTest.StopExecutionError('foo'),
|
||||
queueableFn1 = {
|
||||
fn: function(done) {
|
||||
setTimeout(function() {
|
||||
@@ -237,7 +237,7 @@ describe('QueueRunner', function() {
|
||||
},
|
||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
||||
failFn = jasmine.createSpy('fail'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2],
|
||||
fail: failFn
|
||||
});
|
||||
@@ -259,7 +259,7 @@ describe('QueueRunner', function() {
|
||||
queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' },
|
||||
onComplete = jasmine.createSpy('onComplete'),
|
||||
onException = jasmine.createSpy('onException'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [beforeFn, queueableFn],
|
||||
onComplete: onComplete,
|
||||
onException: onException
|
||||
@@ -287,7 +287,7 @@ describe('QueueRunner', function() {
|
||||
};
|
||||
const onComplete = jasmine.createSpy('onComplete');
|
||||
const onMultipleDone = jasmine.createSpy('onMultipleDone');
|
||||
const queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
onComplete: onComplete,
|
||||
onMultipleDone: onMultipleDone
|
||||
@@ -306,7 +306,7 @@ describe('QueueRunner', function() {
|
||||
queueableFn = { fn: jasmine.createSpy('fn') },
|
||||
onComplete = jasmine.createSpy('onComplete'),
|
||||
onException = jasmine.createSpy('onException'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [beforeFn, queueableFn],
|
||||
onComplete: onComplete,
|
||||
onException: onException
|
||||
@@ -330,7 +330,7 @@ describe('QueueRunner', function() {
|
||||
},
|
||||
onComplete = jasmine.createSpy('onComplete'),
|
||||
onException = jasmine.createSpy('onException'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
onComplete: onComplete,
|
||||
onException: onException
|
||||
@@ -353,7 +353,7 @@ describe('QueueRunner', function() {
|
||||
},
|
||||
onComplete = jasmine.createSpy('onComplete'),
|
||||
onException = jasmine.createSpy('onException'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
onComplete: onComplete,
|
||||
onException: onException
|
||||
@@ -377,7 +377,7 @@ describe('QueueRunner', function() {
|
||||
},
|
||||
nextQueueableFn = { fn: jasmine.createSpy('nextFn') },
|
||||
onMultipleDone = jasmine.createSpy('onMultipleDone'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn, nextQueueableFn],
|
||||
onMultipleDone: onMultipleDone
|
||||
});
|
||||
@@ -396,7 +396,7 @@ describe('QueueRunner', function() {
|
||||
}
|
||||
},
|
||||
nextQueueableFn = { fn: jasmine.createSpy('nextFn') },
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn, nextQueueableFn]
|
||||
});
|
||||
queueRunner.execute();
|
||||
@@ -412,7 +412,7 @@ describe('QueueRunner', function() {
|
||||
doneReturn = done();
|
||||
}
|
||||
};
|
||||
const queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn]
|
||||
});
|
||||
|
||||
@@ -433,7 +433,7 @@ describe('QueueRunner', function() {
|
||||
pushListener: jasmine.createSpy('pushListener'),
|
||||
popListener: jasmine.createSpy('popListener')
|
||||
},
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn, nextQueueableFn],
|
||||
onException: onException,
|
||||
globalErrors: globalErrors
|
||||
@@ -471,31 +471,6 @@ describe('QueueRunner', function() {
|
||||
expect(nextQueueableFn.fn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('handles a global error event with a message but no error', function() {
|
||||
const queueableFn = {
|
||||
fn: function(done) {
|
||||
const currentHandler = globalErrors.pushListener.calls.mostRecent()
|
||||
.args[0];
|
||||
currentHandler(undefined, { message: 'nope' });
|
||||
},
|
||||
timeout: 1
|
||||
};
|
||||
const onException = jasmine.createSpy('onException');
|
||||
const globalErrors = {
|
||||
pushListener: jasmine.createSpy('pushListener'),
|
||||
popListener: jasmine.createSpy('popListener')
|
||||
};
|
||||
const queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
onException: onException,
|
||||
globalErrors: globalErrors
|
||||
});
|
||||
|
||||
queueRunner.execute();
|
||||
|
||||
expect(onException).toHaveBeenCalledWith('nope');
|
||||
});
|
||||
|
||||
it('handles exceptions thrown while waiting for the stack to clear', function() {
|
||||
const queueableFn = {
|
||||
fn: function(done) {
|
||||
@@ -511,9 +486,9 @@ describe('QueueRunner', function() {
|
||||
errorListeners.pop();
|
||||
}
|
||||
},
|
||||
clearStack = jasmine.createSpy('clearStack'),
|
||||
clearStack = jasmine.createSpyObj('clearStack', ['clearStack']),
|
||||
onException = jasmine.createSpy('onException'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
globalErrors: globalErrors,
|
||||
clearStack: clearStack,
|
||||
@@ -523,46 +498,12 @@ describe('QueueRunner', function() {
|
||||
|
||||
queueRunner.execute();
|
||||
jasmine.clock().tick();
|
||||
expect(clearStack).toHaveBeenCalled();
|
||||
expect(clearStack.clearStack).toHaveBeenCalled();
|
||||
expect(errorListeners.length).toEqual(1);
|
||||
errorListeners[0](error);
|
||||
clearStack.calls.argsFor(0)[0]();
|
||||
clearStack.clearStack.calls.argsFor(0)[0]();
|
||||
expect(onException).toHaveBeenCalledWith(error);
|
||||
});
|
||||
|
||||
it('handles a global error event with no error while waiting for the stack to clear', function() {
|
||||
const queueableFn = {
|
||||
fn: function(done) {
|
||||
done();
|
||||
}
|
||||
};
|
||||
const errorListeners = [];
|
||||
const globalErrors = {
|
||||
pushListener: function(f) {
|
||||
errorListeners.push(f);
|
||||
},
|
||||
popListener: function() {
|
||||
errorListeners.pop();
|
||||
}
|
||||
};
|
||||
const clearStack = jasmine.createSpy('clearStack');
|
||||
const onException = jasmine.createSpy('onException');
|
||||
const queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
globalErrors: globalErrors,
|
||||
clearStack: clearStack,
|
||||
onException: onException
|
||||
});
|
||||
|
||||
queueRunner.execute();
|
||||
jasmine.clock().tick();
|
||||
expect(clearStack).toHaveBeenCalled();
|
||||
expect(errorListeners.length).toEqual(1);
|
||||
errorListeners[0](undefined, { message: 'nope' });
|
||||
|
||||
clearStack.calls.argsFor(0)[0]();
|
||||
expect(onException).toHaveBeenCalledWith('nope');
|
||||
});
|
||||
});
|
||||
|
||||
describe('with a function that returns a promise', function() {
|
||||
@@ -603,7 +544,7 @@ describe('QueueRunner', function() {
|
||||
return p2;
|
||||
}
|
||||
},
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2],
|
||||
onComplete: onComplete
|
||||
});
|
||||
@@ -634,7 +575,7 @@ describe('QueueRunner', function() {
|
||||
},
|
||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
||||
onExceptionCallback = jasmine.createSpy('on exception callback'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2],
|
||||
onException: onExceptionCallback
|
||||
});
|
||||
@@ -657,7 +598,7 @@ describe('QueueRunner', function() {
|
||||
}
|
||||
},
|
||||
onException = jasmine.createSpy('onException'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
onException: onException
|
||||
});
|
||||
@@ -678,7 +619,7 @@ describe('QueueRunner', function() {
|
||||
it('issues a more specific error if the function is `async`', function() {
|
||||
async function fn(done) {}
|
||||
const onException = jasmine.createSpy('onException'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [{ fn: fn }],
|
||||
onException: onException
|
||||
});
|
||||
@@ -699,7 +640,7 @@ describe('QueueRunner', function() {
|
||||
it('passes final errors to exception handlers', function() {
|
||||
const error = new Error('fake error'),
|
||||
onExceptionCallback = jasmine.createSpy('on exception callback'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
onException: onExceptionCallback
|
||||
});
|
||||
|
||||
@@ -717,7 +658,7 @@ describe('QueueRunner', function() {
|
||||
}
|
||||
},
|
||||
onExceptionCallback = jasmine.createSpy('on exception callback'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
onException: onExceptionCallback
|
||||
});
|
||||
@@ -734,7 +675,7 @@ describe('QueueRunner', function() {
|
||||
}
|
||||
},
|
||||
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn, nextQueueableFn]
|
||||
});
|
||||
|
||||
@@ -747,7 +688,7 @@ describe('QueueRunner', function() {
|
||||
const SkipPolicy = jasmine.createSpy('SkipPolicy ctor');
|
||||
const queueableFns = [{ fn: () => {} }, { fn: () => {} }];
|
||||
|
||||
new jasmineUnderTest.QueueRunner({
|
||||
new privateUnderTest.QueueRunner({
|
||||
queueableFns,
|
||||
SkipPolicy
|
||||
});
|
||||
@@ -769,7 +710,7 @@ describe('QueueRunner', function() {
|
||||
skipPolicy.skipTo.and.callFake(function(lastRanIx) {
|
||||
return lastRanIx === 0 ? 2 : lastRanIx + 1;
|
||||
});
|
||||
const queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns,
|
||||
SkipPolicy: function() {
|
||||
return skipPolicy;
|
||||
@@ -790,7 +731,7 @@ describe('QueueRunner', function() {
|
||||
it('throws if the skip policy returns the current fn', function() {
|
||||
const skipPolicy = { skipTo: i => i };
|
||||
const queueableFns = [{ fn: () => {} }];
|
||||
const queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns,
|
||||
SkipPolicy: function() {
|
||||
return skipPolicy;
|
||||
@@ -816,17 +757,17 @@ describe('QueueRunner', function() {
|
||||
type: 'specCleanup'
|
||||
},
|
||||
onComplete = jasmine.createSpy('onComplete'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
|
||||
onComplete: onComplete,
|
||||
SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||
});
|
||||
|
||||
queueRunner.execute();
|
||||
expect(nextQueueableFn.fn).not.toHaveBeenCalled();
|
||||
expect(cleanupFn.fn).toHaveBeenCalled();
|
||||
expect(onComplete).toHaveBeenCalledWith(
|
||||
jasmine.any(jasmineUnderTest.StopExecutionError)
|
||||
jasmine.any(privateUnderTest.StopExecutionError)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -842,9 +783,9 @@ describe('QueueRunner', function() {
|
||||
fn: jasmine.createSpy('cleanupFn2'),
|
||||
type: 'afterEach'
|
||||
},
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn, cleanupFn1, cleanupFn2],
|
||||
SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||
});
|
||||
|
||||
queueRunner.execute();
|
||||
@@ -873,7 +814,7 @@ describe('QueueRunner', function() {
|
||||
fn: jasmine.createSpy('cleanup'),
|
||||
type: 'specCleanup'
|
||||
};
|
||||
const queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
globalErrors: {
|
||||
pushListener: function(f) {
|
||||
errorListeners.push(f);
|
||||
@@ -883,7 +824,7 @@ describe('QueueRunner', function() {
|
||||
}
|
||||
},
|
||||
queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
|
||||
SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||
});
|
||||
|
||||
queueRunner.execute();
|
||||
@@ -902,9 +843,9 @@ describe('QueueRunner', function() {
|
||||
},
|
||||
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
|
||||
cleanupFn = { fn: jasmine.createSpy('cleanup'), type: 'specCleanup' },
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
|
||||
SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||
});
|
||||
|
||||
queueRunner.execute();
|
||||
@@ -924,9 +865,9 @@ describe('QueueRunner', function() {
|
||||
fn: jasmine.createSpy('cleanup'),
|
||||
type: 'specCleanup'
|
||||
},
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
|
||||
SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||
});
|
||||
|
||||
queueRunner.execute();
|
||||
@@ -940,7 +881,7 @@ describe('QueueRunner', function() {
|
||||
it('calls a provided complete callback when done', function() {
|
||||
const queueableFn = { fn: jasmine.createSpy('fn') },
|
||||
completeCallback = jasmine.createSpy('completeCallback'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
onComplete: completeCallback
|
||||
});
|
||||
@@ -967,22 +908,22 @@ describe('QueueRunner', function() {
|
||||
},
|
||||
afterFn = { fn: jasmine.createSpy('afterFn') },
|
||||
completeCallback = jasmine.createSpy('completeCallback'),
|
||||
clearStack = jasmine.createSpy('clearStack'),
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
clearStack = jasmine.createSpyObj('clearStack', ['clearStack']),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [asyncFn, afterFn],
|
||||
clearStack: clearStack,
|
||||
onComplete: completeCallback
|
||||
});
|
||||
|
||||
clearStack.and.callFake(function(fn) {
|
||||
clearStack.clearStack.and.callFake(function(fn) {
|
||||
fn();
|
||||
});
|
||||
|
||||
queueRunner.execute();
|
||||
jasmine.clock().tick();
|
||||
expect(afterFn.fn).toHaveBeenCalled();
|
||||
expect(clearStack).toHaveBeenCalled();
|
||||
clearStack.calls.argsFor(0)[0]();
|
||||
expect(clearStack.clearStack).toHaveBeenCalled();
|
||||
clearStack.clearStack.calls.argsFor(0)[0]();
|
||||
expect(completeCallback).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -992,7 +933,7 @@ describe('QueueRunner', function() {
|
||||
const fn = jasmine.createSpy('fn1');
|
||||
|
||||
this.fn = fn;
|
||||
this.queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
this.queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [{ fn: fn }]
|
||||
});
|
||||
});
|
||||
@@ -1005,7 +946,7 @@ describe('QueueRunner', function() {
|
||||
|
||||
this.queueRunner.execute();
|
||||
|
||||
expect(context.constructor).toBe(jasmineUnderTest.UserContext);
|
||||
expect(context.constructor).toBe(privateUnderTest.UserContext);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1015,8 +956,8 @@ describe('QueueRunner', function() {
|
||||
let context;
|
||||
|
||||
this.fn = fn;
|
||||
this.context = context = new jasmineUnderTest.UserContext();
|
||||
this.queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
this.context = context = new privateUnderTest.UserContext();
|
||||
this.queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [{ fn: fn }],
|
||||
userContext: context
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
describe('ReportDispatcher', function() {
|
||||
it('builds an interface of requested methods', function() {
|
||||
const dispatcher = new jasmineUnderTest.ReportDispatcher([
|
||||
const dispatcher = new privateUnderTest.ReportDispatcher([
|
||||
'foo',
|
||||
'bar',
|
||||
'baz'
|
||||
@@ -13,7 +13,7 @@ describe('ReportDispatcher', function() {
|
||||
|
||||
it('dispatches requested methods to added reporters', function() {
|
||||
const runQueue = jasmine.createSpy('runQueue'),
|
||||
dispatcher = new jasmineUnderTest.ReportDispatcher(
|
||||
dispatcher = new privateUnderTest.ReportDispatcher(
|
||||
['foo', 'bar'],
|
||||
runQueue
|
||||
),
|
||||
@@ -23,7 +23,7 @@ describe('ReportDispatcher', function() {
|
||||
dispatcher.addReporter(reporter);
|
||||
dispatcher.addReporter(anotherReporter);
|
||||
|
||||
dispatcher.foo(123, 456);
|
||||
dispatcher.foo({ an: 'event' });
|
||||
|
||||
expect(runQueue).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
@@ -37,16 +37,16 @@ describe('ReportDispatcher', function() {
|
||||
|
||||
let fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||
fns[0].fn();
|
||||
expect(reporter.foo).toHaveBeenCalledWith(123, 456);
|
||||
expect(reporter.foo).toHaveBeenCalledWith({ an: 'event' });
|
||||
expect(reporter.foo.calls.mostRecent().object).toBe(reporter);
|
||||
|
||||
fns[1].fn();
|
||||
expect(anotherReporter.foo).toHaveBeenCalledWith(123, 456);
|
||||
expect(anotherReporter.foo).toHaveBeenCalledWith({ an: 'event' });
|
||||
expect(anotherReporter.foo.calls.mostRecent().object).toBe(anotherReporter);
|
||||
|
||||
runQueue.calls.reset();
|
||||
|
||||
dispatcher.bar('a', 'b');
|
||||
dispatcher.bar({ another: 'event' });
|
||||
|
||||
expect(runQueue).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
@@ -60,15 +60,48 @@ describe('ReportDispatcher', function() {
|
||||
|
||||
fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||
fns[0].fn();
|
||||
expect(reporter.bar).toHaveBeenCalledWith('a', 'b');
|
||||
expect(reporter.bar).toHaveBeenCalledWith({ another: 'event' });
|
||||
|
||||
fns[1].fn();
|
||||
expect(anotherReporter.bar).toHaveBeenCalledWith('a', 'b');
|
||||
expect(anotherReporter.bar).toHaveBeenCalledWith({ another: 'event' });
|
||||
});
|
||||
|
||||
it('passes each reporter a separate deep copy of the event', function() {
|
||||
const runQueue = jasmine.createSpy('runQueue');
|
||||
const dispatcher = new privateUnderTest.ReportDispatcher(
|
||||
['foo', 'bar'],
|
||||
runQueue
|
||||
);
|
||||
const reporter = jasmine.createSpyObj('reporter', ['foo']);
|
||||
const anotherReporter = jasmine.createSpyObj('anotherReporter', ['foo']);
|
||||
const event = {
|
||||
child: {
|
||||
grandchild: 'something'
|
||||
}
|
||||
};
|
||||
dispatcher.addReporter(reporter);
|
||||
dispatcher.addReporter(anotherReporter);
|
||||
|
||||
dispatcher.foo(event);
|
||||
|
||||
for (const fn of runQueue.calls.mostRecent().args[0].queueableFns) {
|
||||
fn.fn();
|
||||
}
|
||||
|
||||
expect(reporter.foo).toHaveBeenCalledWith(event);
|
||||
expect(anotherReporter.foo).toHaveBeenCalledWith(event);
|
||||
const receivedEvents = [reporter, anotherReporter].map(function(reporter) {
|
||||
return reporter.foo.calls.mostRecent().args[0];
|
||||
});
|
||||
expect(receivedEvents[0]).not.toBe(event);
|
||||
expect(receivedEvents[0]).not.toBe(receivedEvents[1]);
|
||||
expect(receivedEvents[0].child).not.toBe(event.child);
|
||||
expect(receivedEvents[0].child).not.toBe(receivedEvents[1].child);
|
||||
});
|
||||
|
||||
it("does not dispatch to a reporter if the reporter doesn't accept the method", function() {
|
||||
const runQueue = jasmine.createSpy('runQueue'),
|
||||
dispatcher = new jasmineUnderTest.ReportDispatcher(['foo'], runQueue),
|
||||
dispatcher = new privateUnderTest.ReportDispatcher(['foo'], runQueue),
|
||||
reporter = jasmine.createSpyObj('reporter', ['baz']);
|
||||
|
||||
dispatcher.addReporter(reporter);
|
||||
@@ -83,14 +116,14 @@ describe('ReportDispatcher', function() {
|
||||
|
||||
it("allows providing a fallback reporter in case there's no other reporter", function() {
|
||||
const runQueue = jasmine.createSpy('runQueue'),
|
||||
dispatcher = new jasmineUnderTest.ReportDispatcher(
|
||||
dispatcher = new privateUnderTest.ReportDispatcher(
|
||||
['foo', 'bar'],
|
||||
runQueue
|
||||
),
|
||||
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
||||
|
||||
dispatcher.provideFallbackReporter(reporter);
|
||||
dispatcher.foo(123, 456);
|
||||
dispatcher.foo({ an: 'event' });
|
||||
|
||||
expect(runQueue).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
@@ -101,12 +134,12 @@ describe('ReportDispatcher', function() {
|
||||
|
||||
const fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||
fns[0].fn();
|
||||
expect(reporter.foo).toHaveBeenCalledWith(123, 456);
|
||||
expect(reporter.foo).toHaveBeenCalledWith({ an: 'event' });
|
||||
});
|
||||
|
||||
it('does not call fallback reporting methods when another reporter is provided', function() {
|
||||
const runQueue = jasmine.createSpy('runQueue'),
|
||||
dispatcher = new jasmineUnderTest.ReportDispatcher(
|
||||
dispatcher = new privateUnderTest.ReportDispatcher(
|
||||
['foo', 'bar'],
|
||||
runQueue
|
||||
),
|
||||
@@ -115,7 +148,7 @@ describe('ReportDispatcher', function() {
|
||||
|
||||
dispatcher.provideFallbackReporter(fallbackReporter);
|
||||
dispatcher.addReporter(reporter);
|
||||
dispatcher.foo(123, 456);
|
||||
dispatcher.foo({ an: 'event' });
|
||||
|
||||
expect(runQueue).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
@@ -126,13 +159,13 @@ describe('ReportDispatcher', function() {
|
||||
|
||||
const fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||
fns[0].fn();
|
||||
expect(reporter.foo).toHaveBeenCalledWith(123, 456);
|
||||
expect(fallbackReporter.foo).not.toHaveBeenCalledWith(123, 456);
|
||||
expect(reporter.foo).toHaveBeenCalledWith({ an: 'event' });
|
||||
expect(fallbackReporter.foo).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('allows registered reporters to be cleared', function() {
|
||||
const runQueue = jasmine.createSpy('runQueue'),
|
||||
dispatcher = new jasmineUnderTest.ReportDispatcher(
|
||||
dispatcher = new privateUnderTest.ReportDispatcher(
|
||||
['foo', 'bar'],
|
||||
runQueue
|
||||
),
|
||||
@@ -140,7 +173,7 @@ describe('ReportDispatcher', function() {
|
||||
reporter2 = jasmine.createSpyObj('reporter2', ['foo', 'bar']);
|
||||
|
||||
dispatcher.addReporter(reporter1);
|
||||
dispatcher.foo(123);
|
||||
dispatcher.foo({ an: 'event' });
|
||||
expect(runQueue).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
queueableFns: [{ fn: jasmine.any(Function) }],
|
||||
@@ -150,11 +183,11 @@ describe('ReportDispatcher', function() {
|
||||
|
||||
let fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||
fns[0].fn();
|
||||
expect(reporter1.foo).toHaveBeenCalledWith(123);
|
||||
expect(reporter1.foo).toHaveBeenCalledWith({ an: 'event' });
|
||||
|
||||
dispatcher.clearReporters();
|
||||
dispatcher.addReporter(reporter2);
|
||||
dispatcher.bar(456);
|
||||
dispatcher.bar({ another: 'event' });
|
||||
|
||||
expect(runQueue).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
@@ -166,6 +199,6 @@ describe('ReportDispatcher', function() {
|
||||
fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||
fns[0].fn();
|
||||
expect(reporter1.bar).not.toHaveBeenCalled();
|
||||
expect(reporter2.bar).toHaveBeenCalledWith(456);
|
||||
expect(reporter2.bar).toHaveBeenCalledWith({ another: 'event' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('RunableResources', function() {
|
||||
describe('#addCustomMatchers', function() {
|
||||
it("adds all properties to the current runable's matchers", function() {
|
||||
const currentRunableId = 1;
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => currentRunableId
|
||||
});
|
||||
@@ -70,7 +70,7 @@ describe('RunableResources', function() {
|
||||
describe('#addCustomAsyncMatchers', function() {
|
||||
it("adds all properties to the current runable's matchers", function() {
|
||||
const currentRunableId = 1;
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => currentRunableId
|
||||
});
|
||||
@@ -95,7 +95,7 @@ describe('RunableResources', function() {
|
||||
describe('#defaultSpyStrategy', function() {
|
||||
it('returns undefined for a newly initialized resource', function() {
|
||||
let currentRunableId = 1;
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => currentRunableId
|
||||
});
|
||||
@@ -106,7 +106,7 @@ describe('RunableResources', function() {
|
||||
|
||||
it('returns the value previously set by #setDefaultSpyStrategy', function() {
|
||||
let currentRunableId = 1;
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => currentRunableId
|
||||
});
|
||||
@@ -119,7 +119,7 @@ describe('RunableResources', function() {
|
||||
|
||||
it('is per-runable', function() {
|
||||
let currentRunableId = 1;
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => currentRunableId
|
||||
});
|
||||
@@ -132,7 +132,7 @@ describe('RunableResources', function() {
|
||||
});
|
||||
|
||||
it('does not require a current runable', function() {
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => null
|
||||
});
|
||||
@@ -141,7 +141,7 @@ describe('RunableResources', function() {
|
||||
|
||||
it("inherits the parent runable's value", function() {
|
||||
let currentRunableId = 1;
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => currentRunableId
|
||||
});
|
||||
@@ -157,7 +157,7 @@ describe('RunableResources', function() {
|
||||
|
||||
describe('#setDefaultSpyStrategy', function() {
|
||||
it('throws a user-facing error when there is no current runable', function() {
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => null
|
||||
});
|
||||
@@ -171,21 +171,21 @@ describe('RunableResources', function() {
|
||||
|
||||
describe('#makePrettyPrinter', function() {
|
||||
it('returns a pretty printer configured with the current customObjectFormatters', function() {
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => 1
|
||||
});
|
||||
runableResources.initForRunable(1);
|
||||
function cof() {}
|
||||
runableResources.customObjectFormatters().push(cof);
|
||||
spyOn(jasmineUnderTest, 'makePrettyPrinter').and.callThrough();
|
||||
spyOn(privateUnderTest, 'makePrettyPrinter').and.callThrough();
|
||||
const pp = runableResources.makePrettyPrinter();
|
||||
|
||||
expect(jasmineUnderTest.makePrettyPrinter).toHaveBeenCalledOnceWith([
|
||||
expect(privateUnderTest.makePrettyPrinter).toHaveBeenCalledOnceWith([
|
||||
cof
|
||||
]);
|
||||
expect(pp).toBe(
|
||||
jasmineUnderTest.makePrettyPrinter.calls.first().returnValue
|
||||
privateUnderTest.makePrettyPrinter.calls.first().returnValue
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -193,7 +193,7 @@ describe('RunableResources', function() {
|
||||
describe('#makeMatchersUtil', function() {
|
||||
describe('When there is a current runable', function() {
|
||||
it('returns a MatchersUtil configured with the current resources', function() {
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => 1
|
||||
});
|
||||
@@ -204,26 +204,26 @@ describe('RunableResources', function() {
|
||||
runableResources.customEqualityTesters().push(ceq);
|
||||
const expectedPP = {};
|
||||
const expectedMatchersUtil = {};
|
||||
spyOn(jasmineUnderTest, 'makePrettyPrinter').and.returnValue(
|
||||
spyOn(privateUnderTest, 'makePrettyPrinter').and.returnValue(
|
||||
expectedPP
|
||||
);
|
||||
spyOn(jasmineUnderTest, 'MatchersUtil').and.returnValue(
|
||||
spyOn(privateUnderTest, 'MatchersUtil').and.returnValue(
|
||||
expectedMatchersUtil
|
||||
);
|
||||
|
||||
const matchersUtil = runableResources.makeMatchersUtil();
|
||||
|
||||
expect(matchersUtil).toBe(expectedMatchersUtil);
|
||||
expect(jasmineUnderTest.makePrettyPrinter).toHaveBeenCalledOnceWith([
|
||||
expect(privateUnderTest.makePrettyPrinter).toHaveBeenCalledOnceWith([
|
||||
cof
|
||||
]);
|
||||
// We need === equality on the pp passed to MatchersUtil
|
||||
expect(jasmineUnderTest.MatchersUtil).toHaveBeenCalledOnceWith(
|
||||
expect(privateUnderTest.MatchersUtil).toHaveBeenCalledOnceWith(
|
||||
jasmine.objectContaining({
|
||||
customTesters: [ceq]
|
||||
})
|
||||
);
|
||||
expect(jasmineUnderTest.MatchersUtil.calls.argsFor(0)[0].pp).toBe(
|
||||
expect(privateUnderTest.MatchersUtil.calls.argsFor(0)[0].pp).toBe(
|
||||
expectedPP
|
||||
);
|
||||
});
|
||||
@@ -231,12 +231,12 @@ describe('RunableResources', function() {
|
||||
|
||||
describe('When there is no current runable', function() {
|
||||
it('returns a MatchersUtil configured with defaults', function() {
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => null
|
||||
});
|
||||
const expectedMatchersUtil = {};
|
||||
spyOn(jasmineUnderTest, 'MatchersUtil').and.returnValue(
|
||||
spyOn(privateUnderTest, 'MatchersUtil').and.returnValue(
|
||||
expectedMatchersUtil
|
||||
);
|
||||
|
||||
@@ -244,12 +244,12 @@ describe('RunableResources', function() {
|
||||
|
||||
expect(matchersUtil).toBe(expectedMatchersUtil);
|
||||
// We need === equality on the pp passed to MatchersUtil
|
||||
expect(jasmineUnderTest.MatchersUtil).toHaveBeenCalledTimes(1);
|
||||
expect(jasmineUnderTest.MatchersUtil.calls.argsFor(0)[0].pp).toBe(
|
||||
jasmineUnderTest.basicPrettyPrinter_
|
||||
expect(privateUnderTest.MatchersUtil).toHaveBeenCalledTimes(1);
|
||||
expect(privateUnderTest.MatchersUtil.calls.argsFor(0)[0].pp).toBe(
|
||||
privateUnderTest.basicPrettyPrinter
|
||||
);
|
||||
expect(
|
||||
jasmineUnderTest.MatchersUtil.calls.argsFor(0)[0].customTesters
|
||||
privateUnderTest.MatchersUtil.calls.argsFor(0)[0].customTesters
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -258,11 +258,11 @@ describe('RunableResources', function() {
|
||||
describe('.spyFactory', function() {
|
||||
describe('When there is no current runable', function() {
|
||||
it('is configured with default strategies and matchersUtil', function() {
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => null
|
||||
});
|
||||
spyOn(jasmineUnderTest, 'Spy');
|
||||
spyOn(privateUnderTest, 'Spy');
|
||||
const matchersUtil = {};
|
||||
spyOn(runableResources, 'makeMatchersUtil').and.returnValue(
|
||||
matchersUtil
|
||||
@@ -270,7 +270,7 @@ describe('RunableResources', function() {
|
||||
|
||||
runableResources.spyFactory.createSpy('foo');
|
||||
|
||||
expect(jasmineUnderTest.Spy).toHaveBeenCalledWith(
|
||||
expect(privateUnderTest.Spy).toHaveBeenCalledWith(
|
||||
'foo',
|
||||
is(matchersUtil),
|
||||
jasmine.objectContaining({
|
||||
@@ -283,7 +283,7 @@ describe('RunableResources', function() {
|
||||
|
||||
describe('When there is a current runable', function() {
|
||||
it("is configured with the current runable's strategies and matchersUtil", function() {
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => 1
|
||||
});
|
||||
@@ -292,7 +292,7 @@ describe('RunableResources', function() {
|
||||
function defaultStrategy() {}
|
||||
runableResources.customSpyStrategies().foo = customStrategy;
|
||||
runableResources.setDefaultSpyStrategy(defaultStrategy);
|
||||
spyOn(jasmineUnderTest, 'Spy');
|
||||
spyOn(privateUnderTest, 'Spy');
|
||||
const matchersUtil = {};
|
||||
spyOn(runableResources, 'makeMatchersUtil').and.returnValue(
|
||||
matchersUtil
|
||||
@@ -300,7 +300,7 @@ describe('RunableResources', function() {
|
||||
|
||||
runableResources.spyFactory.createSpy('foo');
|
||||
|
||||
expect(jasmineUnderTest.Spy).toHaveBeenCalledWith(
|
||||
expect(privateUnderTest.Spy).toHaveBeenCalledWith(
|
||||
'foo',
|
||||
is(matchersUtil),
|
||||
jasmine.objectContaining({
|
||||
@@ -325,7 +325,7 @@ describe('RunableResources', function() {
|
||||
|
||||
describe('.spyRegistry', function() {
|
||||
it("writes to the current runable's spies", function() {
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => 1
|
||||
});
|
||||
@@ -348,7 +348,7 @@ describe('RunableResources', function() {
|
||||
|
||||
describe('#clearForRunable', function() {
|
||||
it('removes resources for the specified runable', function() {
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => 1
|
||||
});
|
||||
@@ -363,7 +363,7 @@ describe('RunableResources', function() {
|
||||
});
|
||||
|
||||
it('clears spies', function() {
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => 1
|
||||
});
|
||||
@@ -381,7 +381,7 @@ describe('RunableResources', function() {
|
||||
const globalErrors = jasmine.createSpyObj('globalErrors', [
|
||||
'removeOverrideListener'
|
||||
]);
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
getCurrentRunableId: () => 1,
|
||||
globalErrors
|
||||
});
|
||||
@@ -392,7 +392,7 @@ describe('RunableResources', function() {
|
||||
});
|
||||
|
||||
it('does not remove resources for other runables', function() {
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => 1
|
||||
});
|
||||
@@ -411,7 +411,7 @@ describe('RunableResources', function() {
|
||||
) {
|
||||
it('is initially empty', function() {
|
||||
const currentRunableId = 1;
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => currentRunableId
|
||||
});
|
||||
@@ -422,7 +422,7 @@ describe('RunableResources', function() {
|
||||
|
||||
it('is mutable', function() {
|
||||
const currentRunableId = 1;
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => currentRunableId
|
||||
});
|
||||
@@ -434,7 +434,7 @@ describe('RunableResources', function() {
|
||||
|
||||
it('is per-runable', function() {
|
||||
let currentRunableId = 1;
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => currentRunableId
|
||||
});
|
||||
@@ -446,7 +446,7 @@ describe('RunableResources', function() {
|
||||
});
|
||||
|
||||
it('throws a user-facing error when there is no current runable', function() {
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => null
|
||||
});
|
||||
@@ -458,7 +458,7 @@ describe('RunableResources', function() {
|
||||
if (inherits) {
|
||||
it('inherits from the parent runable', function() {
|
||||
let currentRunableId = 1;
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => currentRunableId
|
||||
});
|
||||
@@ -480,7 +480,7 @@ describe('RunableResources', function() {
|
||||
function behavesLikeAPerRunableMutableObject(methodName, errorMsg) {
|
||||
it('is initially empty', function() {
|
||||
const currentRunableId = 1;
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => currentRunableId
|
||||
});
|
||||
@@ -491,7 +491,7 @@ describe('RunableResources', function() {
|
||||
|
||||
it('is mutable', function() {
|
||||
const currentRunableId = 1;
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => currentRunableId
|
||||
});
|
||||
@@ -503,7 +503,7 @@ describe('RunableResources', function() {
|
||||
|
||||
it('is per-runable', function() {
|
||||
let currentRunableId = 1;
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => currentRunableId
|
||||
});
|
||||
@@ -515,7 +515,7 @@ describe('RunableResources', function() {
|
||||
});
|
||||
|
||||
it('throws a user-facing error when there is no current runable', function() {
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => null
|
||||
});
|
||||
@@ -526,7 +526,7 @@ describe('RunableResources', function() {
|
||||
|
||||
it('inherits from the parent runable', function() {
|
||||
let currentRunableId = 1;
|
||||
const runableResources = new jasmineUnderTest.RunableResources({
|
||||
const runableResources = new privateUnderTest.RunableResources({
|
||||
globalErrors: stubGlobalErrors(),
|
||||
getCurrentRunableId: () => currentRunableId
|
||||
});
|
||||
|
||||
@@ -15,10 +15,10 @@ describe('Runner', function() {
|
||||
globalErrors = 'the global errors instance';
|
||||
reportDispatcher = jasmine.createSpyObj(
|
||||
'reportDispatcher',
|
||||
jasmineUnderTest.reporterEvents
|
||||
privateUnderTest.reporterEvents
|
||||
);
|
||||
|
||||
for (const k of jasmineUnderTest.reporterEvents) {
|
||||
for (const k of privateUnderTest.reporterEvents) {
|
||||
reportDispatcher[k].and.returnValue(Promise.resolve());
|
||||
}
|
||||
|
||||
@@ -26,25 +26,22 @@ describe('Runner', function() {
|
||||
failSpecWithNoExpectations = false;
|
||||
detectLateRejectionHandling = false;
|
||||
|
||||
spyOn(jasmineUnderTest.TreeRunner.prototype, '_executeSpec');
|
||||
spyOn(privateUnderTest.TreeRunner.prototype, '_executeSpec');
|
||||
});
|
||||
|
||||
function StubSuite(attrs) {
|
||||
attrs = attrs || {};
|
||||
this.id = 'suite' + suiteNumber++;
|
||||
this.children = attrs.children || [];
|
||||
this.canBeReentered = function() {
|
||||
return !attrs.noReenter;
|
||||
};
|
||||
this.markedPending = attrs.markedPending || false;
|
||||
this.sharedUserContext = function() {
|
||||
return attrs.userContext || {};
|
||||
};
|
||||
this.result = {
|
||||
id: this.id,
|
||||
failedExpectations: []
|
||||
};
|
||||
this.getResult = jasmine.createSpy('getResult');
|
||||
this.startedEvent = jasmine.createSpy('startedEvent');
|
||||
this.doneEvent = jasmine.createSpy('doneEvent');
|
||||
this.hasOwnFailedExpectations = jasmine.createSpy(
|
||||
'hasOwnFailedExpectations'
|
||||
);
|
||||
this.beforeAllFns = attrs.beforeAllFns || [];
|
||||
this.afterAllFns = attrs.afterAllFns || [];
|
||||
this.cleanupBeforeAfter = function() {};
|
||||
@@ -72,7 +69,7 @@ describe('Runner', function() {
|
||||
}),
|
||||
focusedRunables: () => [],
|
||||
totalSpecsDefined: () => 1,
|
||||
TreeProcessor: jasmineUnderTest.TreeProcessor,
|
||||
TreeProcessor: privateUnderTest.TreeProcessor,
|
||||
runableResources: {
|
||||
initForRunable: () => {},
|
||||
clearForRunable: () => {}
|
||||
@@ -81,7 +78,7 @@ describe('Runner', function() {
|
||||
globalErrors,
|
||||
runQueue
|
||||
};
|
||||
return new jasmineUnderTest.Runner({
|
||||
return new privateUnderTest.Runner({
|
||||
...defaultOptions,
|
||||
topSuite
|
||||
});
|
||||
@@ -90,7 +87,7 @@ describe('Runner', function() {
|
||||
function arrayNotContaining(item) {
|
||||
return {
|
||||
asymmetricMatch(other, matchersUtil) {
|
||||
if (!jasmine.isArray_(other)) {
|
||||
if (!Array.isArray(other)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -105,9 +102,9 @@ describe('Runner', function() {
|
||||
};
|
||||
}
|
||||
|
||||
// Precondition: jasmineUnderTest.TreeRunner.prototype._executeSpec is a spy
|
||||
// Precondition: privateUnderTest.TreeRunner.prototype._executeSpec is a spy
|
||||
function verifyAndFinishSpec(spec, queueableFn, shouldBeExcluded) {
|
||||
const ex = jasmineUnderTest.TreeRunner.prototype._executeSpec;
|
||||
const ex = privateUnderTest.TreeRunner.prototype._executeSpec;
|
||||
ex.withArgs(spec, 'onComplete').and.callThrough();
|
||||
|
||||
queueableFn.fn('onComplete');
|
||||
@@ -116,7 +113,7 @@ describe('Runner', function() {
|
||||
expect(runQueue).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
isLeaf: true,
|
||||
SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy,
|
||||
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy,
|
||||
queueableFns: shouldBeExcluded
|
||||
? arrayNotContaining(spec.queueableFn)
|
||||
: jasmine.arrayContaining([spec.queueableFn])
|
||||
@@ -130,6 +127,7 @@ describe('Runner', function() {
|
||||
children: [spec],
|
||||
userContext: { root: 'context' }
|
||||
});
|
||||
topSuite.doneEvent.and.returnValue({});
|
||||
detectLateRejectionHandling = true;
|
||||
const subject = makeRunner(topSuite);
|
||||
|
||||
@@ -142,7 +140,7 @@ describe('Runner', function() {
|
||||
userContext: { root: 'context' },
|
||||
queueableFns: [{ fn: jasmine.any(Function) }],
|
||||
onMultipleDone: null,
|
||||
SkipPolicy: jasmineUnderTest.SkipAfterBeforeAllErrorPolicy
|
||||
SkipPolicy: privateUnderTest.SkipAfterBeforeAllErrorPolicy
|
||||
});
|
||||
|
||||
const runQueueArgs = runQueue.calls.mostRecent().args[0];
|
||||
@@ -157,6 +155,7 @@ describe('Runner', function() {
|
||||
children: [suite],
|
||||
userContext: { for: 'topSuite' }
|
||||
});
|
||||
topSuite.doneEvent.and.returnValue({});
|
||||
suite.parentSuite = topSuite;
|
||||
const subject = makeRunner(topSuite);
|
||||
|
||||
@@ -169,7 +168,7 @@ describe('Runner', function() {
|
||||
userContext: { for: 'topSuite' },
|
||||
queueableFns: [{ fn: jasmine.any(Function) }],
|
||||
onMultipleDone: null,
|
||||
SkipPolicy: jasmineUnderTest.SkipAfterBeforeAllErrorPolicy
|
||||
SkipPolicy: privateUnderTest.SkipAfterBeforeAllErrorPolicy
|
||||
});
|
||||
|
||||
const runQueueArgs = runQueue.calls.mostRecent().args[0];
|
||||
@@ -182,13 +181,16 @@ describe('Runner', function() {
|
||||
userContext: { for: 'suite' },
|
||||
onException: jasmine.any(Function),
|
||||
onMultipleDone: null,
|
||||
SkipPolicy: jasmineUnderTest.SkipAfterBeforeAllErrorPolicy
|
||||
SkipPolicy: privateUnderTest.SkipAfterBeforeAllErrorPolicy
|
||||
});
|
||||
|
||||
suite.startedEvent.and.returnValue('suite started event');
|
||||
runQueue.calls.mostRecent().args[0].queueableFns[0].fn('foo');
|
||||
expect(reportDispatcher.suiteStarted).toHaveBeenCalledWith(suite.result);
|
||||
expect(reportDispatcher.suiteStarted).toHaveBeenCalledWith(
|
||||
'suite started event'
|
||||
);
|
||||
|
||||
suite.getResult.and.returnValue({ my: 'result' });
|
||||
suite.doneEvent.and.returnValue({ my: 'result' });
|
||||
|
||||
runQueue.calls.mostRecent().args[0].onComplete();
|
||||
expect(reportDispatcher.suiteDone).toHaveBeenCalledWith({ my: 'result' });
|
||||
@@ -236,14 +238,19 @@ describe('Runner', function() {
|
||||
queueableFns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||
expect(queueableFns.length).toBe(2);
|
||||
|
||||
parent.startedEvent.and.returnValue('parent suite started event');
|
||||
queueableFns[0].fn();
|
||||
expect(reportDispatcher.suiteStarted).toHaveBeenCalledWith(parent.result);
|
||||
expect(reportDispatcher.suiteStarted).toHaveBeenCalledWith(
|
||||
'parent suite started event'
|
||||
);
|
||||
|
||||
verifyAndFinishSpec(spec, queueableFns[1], true);
|
||||
|
||||
parent.getResult.and.returnValue(parent.result);
|
||||
parent.doneEvent.and.returnValue('parent suite done event');
|
||||
runQueue.calls.argsFor(1)[0].onComplete();
|
||||
expect(reportDispatcher.suiteDone).toHaveBeenCalledWith(parent.result);
|
||||
expect(reportDispatcher.suiteDone).toHaveBeenCalledWith(
|
||||
'parent suite done event'
|
||||
);
|
||||
await expectAsync(promise).toBePending();
|
||||
});
|
||||
|
||||
@@ -266,7 +273,7 @@ describe('Runner', function() {
|
||||
|
||||
queueableFns[1].fn('foo');
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
privateUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(spec, 'foo');
|
||||
|
||||
await expectAsync(promise).toBePending();
|
||||
@@ -362,16 +369,16 @@ describe('Runner', function() {
|
||||
queueableFns[0].fn('done');
|
||||
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
privateUnderTest.TreeRunner.prototype._executeSpec
|
||||
).not.toHaveBeenCalledWith(specs[0], jasmine.anything());
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
privateUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(specs[1], 'done');
|
||||
|
||||
queueableFns[1].fn('done');
|
||||
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
privateUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(specs[0], 'done');
|
||||
|
||||
await expectAsync(promise).toBePending();
|
||||
@@ -390,16 +397,16 @@ describe('Runner', function() {
|
||||
queueableFns[0].fn('done');
|
||||
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
privateUnderTest.TreeRunner.prototype._executeSpec
|
||||
).not.toHaveBeenCalledWith(nonSpecified, jasmine.anything());
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
privateUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(specified, 'done');
|
||||
|
||||
queueableFns[1].fn('done');
|
||||
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
privateUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(nonSpecified, 'done');
|
||||
|
||||
await expectAsync(promise).toBePending();
|
||||
@@ -424,12 +431,12 @@ describe('Runner', function() {
|
||||
const nodeQueueableFns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||
nodeQueueableFns[1].fn('done');
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
privateUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(nonSpecifiedSpec, 'done');
|
||||
|
||||
queueableFns[1].fn('done');
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
privateUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(specifiedSpec, 'done');
|
||||
|
||||
await expectAsync(promise).toBePending();
|
||||
@@ -451,7 +458,7 @@ describe('Runner', function() {
|
||||
|
||||
queueableFns[0].fn('done');
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
privateUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(spec1, 'done');
|
||||
|
||||
queueableFns[1].fn();
|
||||
@@ -459,143 +466,12 @@ describe('Runner', function() {
|
||||
expect(childFns.length).toBe(3);
|
||||
childFns[1].fn('done');
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
privateUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(spec2, 'done');
|
||||
|
||||
childFns[2].fn('done');
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(spec3, 'done');
|
||||
|
||||
await expectAsync(promise).toBePending();
|
||||
});
|
||||
|
||||
it('runs a suite multiple times if the order specified leaves and re-enters it', async function() {
|
||||
const spec1 = new StubSpec();
|
||||
const spec2 = new StubSpec();
|
||||
const spec3 = new StubSpec();
|
||||
const spec4 = new StubSpec();
|
||||
const spec5 = new StubSpec();
|
||||
const reentered = new StubSuite({ children: [spec1, spec2, spec3] });
|
||||
const topSuite = new StubSuite({ children: [reentered, spec4, spec5] });
|
||||
const subject = makeRunner(topSuite);
|
||||
|
||||
spyOn(jasmineUnderTest.getEnv(), 'deprecated');
|
||||
const promise = subject.execute([
|
||||
spec1.id,
|
||||
spec4.id,
|
||||
spec2.id,
|
||||
spec5.id,
|
||||
spec3.id
|
||||
]);
|
||||
await Promise.resolve();
|
||||
expect(runQueue).toHaveBeenCalledTimes(1);
|
||||
const queueableFns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||
|
||||
queueableFns[0].fn();
|
||||
expect(runQueue.calls.mostRecent().args[0].queueableFns.length).toBe(2);
|
||||
runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done');
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(spec1, 'done');
|
||||
|
||||
queueableFns[1].fn('done');
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(spec4, 'done');
|
||||
|
||||
queueableFns[2].fn();
|
||||
expect(runQueue.calls.count()).toBe(3);
|
||||
expect(runQueue.calls.mostRecent().args[0].queueableFns.length).toBe(2);
|
||||
runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done');
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(spec2, 'done');
|
||||
|
||||
queueableFns[3].fn('done');
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(spec5, 'done');
|
||||
|
||||
queueableFns[4].fn();
|
||||
expect(runQueue.calls.count()).toBe(4);
|
||||
expect(runQueue.calls.mostRecent().args[0].queueableFns.length).toBe(2);
|
||||
runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done');
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(spec3, 'done');
|
||||
|
||||
await expectAsync(promise).toBePending();
|
||||
});
|
||||
|
||||
it('runs a parent of a suite with multiple segments correctly', async function() {
|
||||
const spec1 = new StubSpec();
|
||||
const spec2 = new StubSpec();
|
||||
const spec3 = new StubSpec();
|
||||
const spec4 = new StubSpec();
|
||||
const spec5 = new StubSpec();
|
||||
const parent = new StubSuite({ children: [spec1, spec2, spec3] });
|
||||
const grandparent = new StubSuite({ children: [parent] });
|
||||
const topSuite = new StubSuite({ children: [grandparent, spec4, spec5] });
|
||||
const subject = makeRunner(topSuite);
|
||||
|
||||
spyOn(jasmineUnderTest.getEnv(), 'deprecated');
|
||||
const promise = subject.execute([
|
||||
spec1.id,
|
||||
spec4.id,
|
||||
spec2.id,
|
||||
spec5.id,
|
||||
spec3.id
|
||||
]);
|
||||
await Promise.resolve();
|
||||
expect(runQueue).toHaveBeenCalledTimes(1);
|
||||
const queueableFns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||
expect(queueableFns.length).toBe(5);
|
||||
|
||||
queueableFns[0].fn();
|
||||
expect(runQueue.calls.count()).toBe(2);
|
||||
expect(runQueue.calls.mostRecent().args[0].queueableFns.length).toBe(2);
|
||||
|
||||
runQueue.calls.mostRecent().args[0].queueableFns[1].fn();
|
||||
expect(runQueue.calls.count()).toBe(3);
|
||||
|
||||
runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done');
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(spec1, 'done');
|
||||
|
||||
queueableFns[1].fn('done');
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(spec4, 'done');
|
||||
|
||||
queueableFns[2].fn();
|
||||
expect(runQueue.calls.count()).toBe(4);
|
||||
expect(runQueue.calls.mostRecent().args[0].queueableFns.length).toBe(2);
|
||||
|
||||
runQueue.calls.mostRecent().args[0].queueableFns[1].fn();
|
||||
expect(runQueue.calls.count()).toBe(5);
|
||||
|
||||
runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done');
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(spec2, 'done');
|
||||
|
||||
queueableFns[3].fn('done');
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(spec5, 'done');
|
||||
|
||||
queueableFns[4].fn();
|
||||
expect(runQueue.calls.count()).toBe(6);
|
||||
expect(runQueue.calls.mostRecent().args[0].queueableFns.length).toBe(2);
|
||||
|
||||
runQueue.calls.mostRecent().args[0].queueableFns[1].fn();
|
||||
expect(runQueue.calls.count()).toBe(7);
|
||||
|
||||
runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done');
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
privateUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(spec3, 'done');
|
||||
|
||||
await expectAsync(promise).toBePending();
|
||||
@@ -620,7 +496,7 @@ describe('Runner', function() {
|
||||
for (let i = 0; i < 11; i++) {
|
||||
queueableFns[i].fn('done');
|
||||
expect(
|
||||
jasmineUnderTest.TreeRunner.prototype._executeSpec
|
||||
privateUnderTest.TreeRunner.prototype._executeSpec
|
||||
).toHaveBeenCalledWith(specs[i], 'done');
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ describe('SkipAfterBeforeAllErrorPolicy', function() {
|
||||
describe('#skipTo', function() {
|
||||
describe('When nothing has errored', function() {
|
||||
it('does not skip anything', function() {
|
||||
const policy = new jasmineUnderTest.SkipAfterBeforeAllErrorPolicy(
|
||||
const policy = new privateUnderTest.SkipAfterBeforeAllErrorPolicy(
|
||||
arrayOfArbitraryFns(4)
|
||||
);
|
||||
|
||||
@@ -15,7 +15,7 @@ describe('SkipAfterBeforeAllErrorPolicy', function() {
|
||||
|
||||
describe('When anything but a beforeAll has errored', function() {
|
||||
it('does not skip anything', function() {
|
||||
const policy = new jasmineUnderTest.SkipAfterBeforeAllErrorPolicy(
|
||||
const policy = new privateUnderTest.SkipAfterBeforeAllErrorPolicy(
|
||||
arrayOfArbitraryFns(4)
|
||||
);
|
||||
|
||||
@@ -40,7 +40,7 @@ describe('SkipAfterBeforeAllErrorPolicy', function() {
|
||||
{ type: 'afterAll', fn: () => {} },
|
||||
{ type: 'afterAll', fn: () => {} }
|
||||
];
|
||||
const policy = new jasmineUnderTest.SkipAfterBeforeAllErrorPolicy(fns);
|
||||
const policy = new privateUnderTest.SkipAfterBeforeAllErrorPolicy(fns);
|
||||
|
||||
policy.fnErrored(0);
|
||||
expect(policy.skipTo(0)).toEqual(3);
|
||||
@@ -54,7 +54,7 @@ describe('SkipAfterBeforeAllErrorPolicy', function() {
|
||||
it("sets the suite's hadBeforeAllFailure property to true", function() {
|
||||
const suite = {};
|
||||
const fns = [{ type: 'beforeAll', fn: () => {}, suite }];
|
||||
const policy = new jasmineUnderTest.SkipAfterBeforeAllErrorPolicy(fns);
|
||||
const policy = new privateUnderTest.SkipAfterBeforeAllErrorPolicy(fns);
|
||||
|
||||
policy.fnErrored(0);
|
||||
|
||||
@@ -65,7 +65,7 @@ describe('SkipAfterBeforeAllErrorPolicy', function() {
|
||||
describe('When the fn is not a beforeAll', function() {
|
||||
it('does not try to access the suite, which is probably not there', function() {
|
||||
const fns = [{ fn: () => {} /* no suite */ }];
|
||||
const policy = new jasmineUnderTest.SkipAfterBeforeAllErrorPolicy(fns);
|
||||
const policy = new privateUnderTest.SkipAfterBeforeAllErrorPolicy(fns);
|
||||
|
||||
expect(() => policy.fnErrored(0)).not.toThrow();
|
||||
});
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
describe('Spec', function() {
|
||||
it('#isPendingSpecException returns true for a pending spec exception', function() {
|
||||
const e = new Error(jasmineUnderTest.Spec.pendingSpecExceptionMessage);
|
||||
const e = new Error(privateUnderTest.Spec.pendingSpecExceptionMessage);
|
||||
|
||||
expect(jasmineUnderTest.Spec.isPendingSpecException(e)).toBe(true);
|
||||
expect(privateUnderTest.Spec.isPendingSpecException(e)).toBe(true);
|
||||
});
|
||||
|
||||
it('#isPendingSpecException returns true for a pending spec exception (even when FF bug is present)', function() {
|
||||
const fakeError = {
|
||||
toString: function() {
|
||||
return 'Error: ' + jasmineUnderTest.Spec.pendingSpecExceptionMessage;
|
||||
return 'Error: ' + privateUnderTest.Spec.pendingSpecExceptionMessage;
|
||||
}
|
||||
};
|
||||
|
||||
expect(jasmineUnderTest.Spec.isPendingSpecException(fakeError)).toBe(true);
|
||||
expect(privateUnderTest.Spec.isPendingSpecException(fakeError)).toBe(true);
|
||||
});
|
||||
|
||||
it('#isPendingSpecException returns true for a pending spec exception with a custom message', function() {
|
||||
expect(
|
||||
jasmineUnderTest.Spec.isPendingSpecException(
|
||||
jasmineUnderTest.Spec.pendingSpecExceptionMessage + 'foo'
|
||||
privateUnderTest.Spec.isPendingSpecException(
|
||||
privateUnderTest.Spec.pendingSpecExceptionMessage + 'foo'
|
||||
)
|
||||
).toBe(true);
|
||||
});
|
||||
@@ -26,16 +26,16 @@ describe('Spec', function() {
|
||||
it('#isPendingSpecException returns false for not a pending spec exception', function() {
|
||||
const e = new Error('foo');
|
||||
|
||||
expect(jasmineUnderTest.Spec.isPendingSpecException(e)).toBe(false);
|
||||
expect(privateUnderTest.Spec.isPendingSpecException(e)).toBe(false);
|
||||
});
|
||||
|
||||
it("#isPendingSpecException returns false for thrown values that don't have toString", function() {
|
||||
expect(jasmineUnderTest.Spec.isPendingSpecException(void 0)).toBe(false);
|
||||
expect(privateUnderTest.Spec.isPendingSpecException(void 0)).toBe(false);
|
||||
});
|
||||
|
||||
describe('#executionFinished', function() {
|
||||
it('removes the fn if autoCleanClosures is true', function() {
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} },
|
||||
autoCleanClosures: true
|
||||
});
|
||||
@@ -45,7 +45,7 @@ describe('Spec', function() {
|
||||
});
|
||||
|
||||
it('removes the fn after execution if autoCleanClosures is undefined', function() {
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} },
|
||||
autoCleanClosures: undefined
|
||||
});
|
||||
@@ -56,7 +56,7 @@ describe('Spec', function() {
|
||||
|
||||
it('does not remove the fn after execution if autoCleanClosures is false', function() {
|
||||
function originalFn() {}
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: originalFn },
|
||||
autoCleanClosures: false
|
||||
});
|
||||
@@ -68,7 +68,7 @@ describe('Spec', function() {
|
||||
|
||||
describe('#getSpecProperty', function() {
|
||||
it('get the property value', function() {
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
@@ -79,17 +79,17 @@ describe('Spec', function() {
|
||||
|
||||
describe('#setSpecProperty', function() {
|
||||
it('adds the property to the result', function() {
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.setSpecProperty('a', 4);
|
||||
|
||||
expect(spec.result.properties).toEqual({ a: 4 });
|
||||
expect(spec.doneEvent().properties).toEqual({ a: 4 });
|
||||
});
|
||||
|
||||
it('replace the property result when it was previously set', function() {
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
@@ -97,75 +97,180 @@ describe('Spec', function() {
|
||||
spec.setSpecProperty('b', 'original-value');
|
||||
spec.setSpecProperty('a', 'new-value');
|
||||
|
||||
expect(spec.result.properties).toEqual({
|
||||
expect(spec.doneEvent().properties).toEqual({
|
||||
a: 'new-value',
|
||||
b: 'original-value'
|
||||
});
|
||||
});
|
||||
|
||||
it('throws if the key is not a string', function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
spec.setSpecProperty({}, '');
|
||||
}).toThrowError('Key must be a string');
|
||||
});
|
||||
|
||||
it('throws if the value is not structured-cloneable', function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
spec.setSpecProperty('k', new Promise(() => {}));
|
||||
}).toThrowError("Value can't be cloned");
|
||||
});
|
||||
|
||||
it('throws if the value is not JSON-serializable', function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
const v = {};
|
||||
v.self = v;
|
||||
spec.setSpecProperty('k', v);
|
||||
}).toThrowError("Value can't be cloned");
|
||||
});
|
||||
});
|
||||
|
||||
describe('status', function() {
|
||||
it('is "passed" by default', function() {
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
it('returns "passed" by default', function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
expect(spec.getResult().status).toBe('passed');
|
||||
expect(spec.status())
|
||||
.withContext('status()')
|
||||
.toBe('passed');
|
||||
expect(spec.doneEvent().status)
|
||||
.withContext('doneEvent().status')
|
||||
.toBe('passed');
|
||||
});
|
||||
|
||||
it('is "passed" if all expectations passed', function() {
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.addExpectationResult(true, {});
|
||||
|
||||
expect(spec.getResult().status).toBe('passed');
|
||||
expect(spec.status())
|
||||
.withContext('status()')
|
||||
.toBe('passed');
|
||||
expect(spec.doneEvent().status)
|
||||
.withContext('doneEvent().status')
|
||||
.toBe('passed');
|
||||
});
|
||||
|
||||
it('is "failed" if any expectation failed', function() {
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.addExpectationResult(true, {});
|
||||
spec.addExpectationResult(false, {});
|
||||
|
||||
expect(spec.getResult().status).toBe('failed');
|
||||
expect(spec.status())
|
||||
.withContext('status()')
|
||||
.toBe('failed');
|
||||
expect(spec.doneEvent().status)
|
||||
.withContext('doneEvent().status')
|
||||
.toBe('failed');
|
||||
});
|
||||
|
||||
it('is "pending" if created without a function body', function() {
|
||||
const startCallback = jasmine.createSpy('startCallback'),
|
||||
resultCallback = jasmine.createSpy('resultCallback'),
|
||||
spec = new jasmineUnderTest.Spec({
|
||||
spec = new privateUnderTest.Spec({
|
||||
onStart: startCallback,
|
||||
queueableFn: { fn: null },
|
||||
resultCallback: resultCallback
|
||||
});
|
||||
|
||||
expect(spec.getResult().status).toBe('pending');
|
||||
expect(spec.status())
|
||||
.withContext('status()')
|
||||
.toBe('pending');
|
||||
expect(spec.doneEvent().status)
|
||||
.withContext('doneEvent().status')
|
||||
.toBe('pending');
|
||||
});
|
||||
|
||||
describe('after a call to executionFinished()', function() {
|
||||
describe('with excluded true', function() {
|
||||
it("is 'excluded'", function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.executionFinished(true, false);
|
||||
|
||||
expect(spec.status())
|
||||
.withContext('status()')
|
||||
.toBe('excluded');
|
||||
expect(spec.doneEvent().status)
|
||||
.withContext('doneEvent().status')
|
||||
.toBe('excluded');
|
||||
});
|
||||
});
|
||||
|
||||
describe('with failSpecWithNoExp true', function() {
|
||||
it("is 'failed' if there were no expectations", function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.executionFinished(false, true);
|
||||
|
||||
expect(spec.status())
|
||||
.withContext('status()')
|
||||
.toBe('failed');
|
||||
expect(spec.doneEvent().status)
|
||||
.withContext('doneEvent().status')
|
||||
.toBe('failed');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('after a call to hadBeforeAllFailure()', function() {
|
||||
it("is 'failed'", function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.hadBeforeAllFailure();
|
||||
|
||||
expect(spec.status())
|
||||
.withContext('status()')
|
||||
.toBe('failed');
|
||||
expect(spec.doneEvent().status)
|
||||
.withContext('doneEvent().status')
|
||||
.toBe('failed');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#addExpectationResult', function() {
|
||||
it('keeps track of passed and failed expectations', function() {
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.addExpectationResult(true, { message: 'expectation1' });
|
||||
spec.addExpectationResult(false, { message: 'expectation2' });
|
||||
|
||||
expect(spec.result.passedExpectations).toEqual([
|
||||
expect(spec.doneEvent().passedExpectations).toEqual([
|
||||
jasmine.objectContaining({ message: 'expectation1' })
|
||||
]);
|
||||
expect(spec.result.failedExpectations).toEqual([
|
||||
expect(spec.doneEvent().failedExpectations).toEqual([
|
||||
jasmine.objectContaining({ message: 'expectation2' })
|
||||
]);
|
||||
});
|
||||
|
||||
describe("when 'throwOnExpectationFailure' is set", function() {
|
||||
it('throws an ExpectationFailed error', function() {
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} },
|
||||
throwOnExpectationFailure: true
|
||||
});
|
||||
@@ -173,9 +278,9 @@ describe('Spec', function() {
|
||||
spec.addExpectationResult(true, { message: 'passed' });
|
||||
expect(function() {
|
||||
spec.addExpectationResult(false, { message: 'failed' });
|
||||
}).toThrowError(jasmineUnderTest.errors.ExpectationFailed);
|
||||
}).toThrowError(privateUnderTest.errors.ExpectationFailed);
|
||||
|
||||
expect(spec.result.failedExpectations).toEqual([
|
||||
expect(spec.doneEvent().failedExpectations).toEqual([
|
||||
jasmine.objectContaining({ message: 'failed' })
|
||||
]);
|
||||
});
|
||||
@@ -183,13 +288,13 @@ describe('Spec', function() {
|
||||
|
||||
describe("when 'throwOnExpectationFailure' is not set", function() {
|
||||
it('does not throw', function() {
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.addExpectationResult(false, { message: 'failed' });
|
||||
|
||||
expect(spec.result.failedExpectations).toEqual([
|
||||
expect(spec.doneEvent().failedExpectations).toEqual([
|
||||
jasmine.objectContaining({ message: 'failed' })
|
||||
]);
|
||||
});
|
||||
@@ -198,7 +303,7 @@ describe('Spec', function() {
|
||||
|
||||
it('forwards late expectation failures to onLateError', function() {
|
||||
const onLateError = jasmine.createSpy('onLateError');
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
onLateError,
|
||||
queueableFn: { fn: function() {} }
|
||||
});
|
||||
@@ -218,12 +323,12 @@ describe('Spec', function() {
|
||||
message: jasmine.stringMatching(/^Error: nope/)
|
||||
})
|
||||
);
|
||||
expect(spec.result.failedExpectations).toEqual([]);
|
||||
expect(spec.doneEvent().failedExpectations).toEqual([]);
|
||||
});
|
||||
|
||||
it('does not forward non-late expectation failures to onLateError', function() {
|
||||
const onLateError = jasmine.createSpy('onLateError');
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
onLateError,
|
||||
queueableFn: { fn: function() {} }
|
||||
});
|
||||
@@ -242,7 +347,7 @@ describe('Spec', function() {
|
||||
|
||||
it('forwards late handleException calls to onLateError', function() {
|
||||
const onLateError = jasmine.createSpy('onLateError');
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
onLateError,
|
||||
queueableFn: { fn: function() {} }
|
||||
});
|
||||
@@ -255,12 +360,12 @@ describe('Spec', function() {
|
||||
message: jasmine.stringMatching(/^Error: oops/)
|
||||
})
|
||||
);
|
||||
expect(spec.result.failedExpectations).toEqual([]);
|
||||
expect(spec.doneEvent().failedExpectations).toEqual([]);
|
||||
});
|
||||
|
||||
it('does not forward non-late handleException calls to onLateError', function() {
|
||||
const onLateError = jasmine.createSpy('onLateError');
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
onLateError,
|
||||
queueableFn: { fn: function() {} }
|
||||
});
|
||||
@@ -269,11 +374,11 @@ describe('Spec', function() {
|
||||
spec.handleException(error);
|
||||
|
||||
expect(onLateError).not.toHaveBeenCalled();
|
||||
expect(spec.result.failedExpectations.length).toEqual(1);
|
||||
expect(spec.doneEvent().failedExpectations.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('clears the reportedDone flag when reset', function() {
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: function() {} }
|
||||
});
|
||||
spec.reportedDone = true;
|
||||
@@ -285,7 +390,7 @@ describe('Spec', function() {
|
||||
|
||||
it('does not throw an ExpectationFailed error when handling an error', function() {
|
||||
const resultCallback = jasmine.createSpy('resultCallback'),
|
||||
spec = new jasmineUnderTest.Spec({
|
||||
spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: function() {} },
|
||||
resultCallback: resultCallback,
|
||||
throwOnExpectationFailure: true
|
||||
@@ -299,7 +404,7 @@ describe('Spec', function() {
|
||||
.createSpy('getPath')
|
||||
.and.returnValue(['expected', 'val']);
|
||||
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
getPath,
|
||||
queueableFn: { fn: null }
|
||||
});
|
||||
@@ -313,7 +418,7 @@ describe('Spec', function() {
|
||||
.createSpy('getPath')
|
||||
.and.returnValue(['expected val']);
|
||||
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
getPath,
|
||||
queueableFn: { fn: null }
|
||||
});
|
||||
@@ -326,54 +431,53 @@ describe('Spec', function() {
|
||||
|
||||
describe('#handleException', function() {
|
||||
it('records a failure', function() {
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: {}
|
||||
});
|
||||
|
||||
spec.handleException('foo');
|
||||
|
||||
expect(spec.result.failedExpectations).toEqual([
|
||||
expect(spec.doneEvent().failedExpectations).toEqual([
|
||||
{
|
||||
message: 'foo thrown',
|
||||
matcherName: '',
|
||||
passed: false,
|
||||
expected: '',
|
||||
actual: '',
|
||||
stack: null
|
||||
stack: null,
|
||||
globalErrorType: undefined
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('does not record an additional failure when the error is ExpectationFailed', function() {
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: {}
|
||||
});
|
||||
|
||||
spec.handleException(new jasmineUnderTest.errors.ExpectationFailed());
|
||||
spec.handleException(new privateUnderTest.errors.ExpectationFailed());
|
||||
|
||||
expect(spec.result.failedExpectations).toEqual([]);
|
||||
expect(spec.doneEvent().failedExpectations).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#debugLog', function() {
|
||||
it('adds the messages to the result', function() {
|
||||
const timer = jasmine.createSpyObj('timer', ['start', 'elapsed']);
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} },
|
||||
timer: timer
|
||||
});
|
||||
const t1 = 123;
|
||||
const t2 = 456;
|
||||
|
||||
expect(spec.result.debugLogs).toBeNull();
|
||||
expect(spec.doneEvent().debugLogs).toBeNull();
|
||||
timer.elapsed.and.returnValue(t1);
|
||||
spec.debugLog('msg 1');
|
||||
expect(spec.result.debugLogs).toEqual([
|
||||
expect(spec.doneEvent().debugLogs).toEqual([
|
||||
{ message: 'msg 1', timestamp: t1 }
|
||||
]);
|
||||
timer.elapsed.and.returnValue(t2);
|
||||
spec.debugLog('msg 2');
|
||||
expect(spec.result.debugLogs).toEqual([
|
||||
expect(spec.doneEvent().debugLogs).toEqual([
|
||||
{ message: 'msg 1', timestamp: t1 },
|
||||
{ message: 'msg 2', timestamp: t2 }
|
||||
]);
|
||||
@@ -381,21 +485,21 @@ describe('Spec', function() {
|
||||
|
||||
describe('When the spec passes', function() {
|
||||
it('removes the logs from the result', function() {
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.debugLog('msg');
|
||||
spec.executionFinished();
|
||||
|
||||
expect(spec.result.debugLogs).toBeNull();
|
||||
expect(spec.doneEvent().debugLogs).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the spec fails', function() {
|
||||
it('includes the messages in the result', function() {
|
||||
const timer = jasmine.createSpyObj('timer', ['start', 'elapsed']);
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} },
|
||||
timer: timer
|
||||
});
|
||||
@@ -407,10 +511,252 @@ describe('Spec', function() {
|
||||
spec.handleException(new Error('nope'));
|
||||
spec.executionFinished();
|
||||
|
||||
expect(spec.result.debugLogs).toEqual([
|
||||
expect(spec.doneEvent().debugLogs).toEqual([
|
||||
{ message: 'msg', timestamp: timestamp }
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#startedEvent', function() {
|
||||
it('includes only properties that are known before execution', function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
id: 'spec1',
|
||||
parentSuiteId: 'suite1',
|
||||
description: 'a spec',
|
||||
filename: 'somefile.js',
|
||||
getPath() {
|
||||
return ['a suite', 'a spec'];
|
||||
},
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
expect(spec.startedEvent()).toEqual({
|
||||
id: 'spec1',
|
||||
parentSuiteId: 'suite1',
|
||||
description: 'a spec',
|
||||
fullName: 'a suite a spec',
|
||||
filename: 'somefile.js'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#doneEvent', function() {
|
||||
it('returns the event for a passed spec', function() {
|
||||
const timer = {
|
||||
start() {},
|
||||
elapsed() {
|
||||
return 123;
|
||||
}
|
||||
};
|
||||
const spec = new privateUnderTest.Spec({
|
||||
id: 'spec1',
|
||||
parentSuiteId: 'suite1',
|
||||
description: 'a spec',
|
||||
filename: 'somefile.js',
|
||||
getPath() {
|
||||
return ['a suite', 'a spec'];
|
||||
},
|
||||
queueableFn: { fn: () => {} },
|
||||
timer: timer
|
||||
});
|
||||
|
||||
spec.addExpectationResult(true, {
|
||||
matcherName: 'a passing expectation',
|
||||
passed: true
|
||||
});
|
||||
spec.executionFinished(false, false);
|
||||
|
||||
expect(spec.doneEvent()).toEqual({
|
||||
id: 'spec1',
|
||||
parentSuiteId: 'suite1',
|
||||
description: 'a spec',
|
||||
fullName: 'a suite a spec',
|
||||
filename: 'somefile.js',
|
||||
status: 'passed',
|
||||
passedExpectations: [
|
||||
{
|
||||
matcherName: 'a passing expectation',
|
||||
passed: true,
|
||||
message: 'Passed.',
|
||||
stack: '',
|
||||
globalErrorType: undefined
|
||||
}
|
||||
],
|
||||
failedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
debugLogs: null, // TODO change to []
|
||||
properties: null, // TODO change to {}
|
||||
pendingReason: '',
|
||||
duration: 123
|
||||
});
|
||||
});
|
||||
|
||||
it('returns the event for a failed spec', function() {
|
||||
const timer = {
|
||||
start() {},
|
||||
elapsed() {
|
||||
return 123;
|
||||
}
|
||||
};
|
||||
const spec = new privateUnderTest.Spec({
|
||||
id: 'spec1',
|
||||
parentSuiteId: 'suite1',
|
||||
description: 'a spec',
|
||||
filename: 'somefile.js',
|
||||
getPath() {
|
||||
return ['a suite', 'a spec'];
|
||||
},
|
||||
queueableFn: { fn: () => {} },
|
||||
timer: timer
|
||||
});
|
||||
|
||||
spec.addExpectationResult(true, {
|
||||
matcherName: 'a passing expectation',
|
||||
passed: true
|
||||
});
|
||||
spec.addExpectationResult(false, {
|
||||
matcherName: 'a failing expectation',
|
||||
passed: false,
|
||||
error: new Error('failed')
|
||||
});
|
||||
spec.executionFinished(false, false);
|
||||
|
||||
expect(spec.doneEvent()).toEqual({
|
||||
id: 'spec1',
|
||||
parentSuiteId: 'suite1',
|
||||
description: 'a spec',
|
||||
fullName: 'a suite a spec',
|
||||
filename: 'somefile.js',
|
||||
status: 'failed',
|
||||
passedExpectations: [
|
||||
{
|
||||
matcherName: 'a passing expectation',
|
||||
passed: true,
|
||||
message: 'Passed.',
|
||||
stack: '',
|
||||
globalErrorType: undefined
|
||||
}
|
||||
],
|
||||
failedExpectations: [
|
||||
{
|
||||
matcherName: 'a failing expectation',
|
||||
passed: false,
|
||||
message: jasmine.stringMatching(/^Error: failed/),
|
||||
stack: jasmine.stringContaining('SpecSpec.js'),
|
||||
globalErrorType: undefined
|
||||
}
|
||||
],
|
||||
deprecationWarnings: [],
|
||||
debugLogs: null, // TODO change to []
|
||||
properties: null, // TODO change to {}
|
||||
pendingReason: '',
|
||||
duration: 123
|
||||
});
|
||||
});
|
||||
|
||||
it("reports a status of 'pending' for a declaratively pended spec", function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: {}
|
||||
});
|
||||
|
||||
spec.executionFinished(false, false);
|
||||
|
||||
const result = spec.doneEvent();
|
||||
expect(result.status).toEqual('pending');
|
||||
expect(result.pendingReason).toEqual('');
|
||||
});
|
||||
|
||||
it("reports a status of 'pending' for a spec pended by #pend", function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.pend('nope');
|
||||
spec.executionFinished(false, false);
|
||||
|
||||
const result = spec.doneEvent();
|
||||
expect(result.status).toEqual('pending');
|
||||
expect(result.pendingReason).toEqual('nope');
|
||||
});
|
||||
|
||||
it("reports a status of 'excluded' for an excluded spec", function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.executionFinished(true, false);
|
||||
|
||||
expect(spec.doneEvent().status).toEqual('excluded');
|
||||
});
|
||||
|
||||
describe('When failSpecWithNoExpectations is true', function() {
|
||||
it("reports a status of 'failed' for a spec with no expectations", function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.executionFinished(false, true);
|
||||
|
||||
expect(spec.doneEvent().status).toEqual('failed');
|
||||
});
|
||||
});
|
||||
|
||||
it('includes deprecation warnings', function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.addDeprecationWarning('stop that');
|
||||
|
||||
expect(spec.doneEvent().deprecationWarnings).toEqual([
|
||||
{
|
||||
// TODO: remove irrelevant properties
|
||||
message: 'stop that',
|
||||
stack: jasmine.stringContaining('SpecSpec.js'),
|
||||
matcherName: undefined,
|
||||
passed: undefined,
|
||||
globalErrorType: undefined
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('includes debug logs', function() {
|
||||
const timer = {
|
||||
start() {},
|
||||
elapsed() {
|
||||
return 123;
|
||||
}
|
||||
};
|
||||
const spec = new privateUnderTest.Spec({
|
||||
timer,
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.debugLog('maybe this will help');
|
||||
|
||||
expect(spec.doneEvent().debugLogs).toEqual([
|
||||
{
|
||||
message: 'maybe this will help',
|
||||
timestamp: 123
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('includes spec properties', function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.setSpecProperty('foo', 'bar');
|
||||
spec.setSpecProperty('baz', { grault: ['wombat'] });
|
||||
|
||||
expect(spec.doneEvent().properties).toEqual({
|
||||
foo: 'bar',
|
||||
baz: { grault: ['wombat'] }
|
||||
});
|
||||
});
|
||||
|
||||
// it("excludes properties that aren't in the public API");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
describe('SpyRegistry', function() {
|
||||
function createSpy(name, originalFn) {
|
||||
return jasmineUnderTest.Spy(name, originalFn);
|
||||
return privateUnderTest.Spy(name, originalFn);
|
||||
}
|
||||
|
||||
describe('#spyOn', function() {
|
||||
it('checks for the existence of the object', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: createSpy
|
||||
});
|
||||
expect(function() {
|
||||
@@ -14,53 +14,53 @@ describe('SpyRegistry', function() {
|
||||
});
|
||||
|
||||
it('checks that a method name was passed', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry(),
|
||||
subject = {};
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
||||
target = {};
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOn(subject);
|
||||
spyRegistry.spyOn(target);
|
||||
}).toThrowError(/No method name supplied/);
|
||||
});
|
||||
|
||||
it('checks that the object is not `null`', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry();
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry();
|
||||
expect(function() {
|
||||
spyRegistry.spyOn(null, 'pants');
|
||||
}).toThrowError(/could not find an object/);
|
||||
});
|
||||
|
||||
it('checks that the method name is not `null`', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry(),
|
||||
subject = {};
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
||||
target = {};
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOn(subject, null);
|
||||
spyRegistry.spyOn(target, null);
|
||||
}).toThrowError(/No method name supplied/);
|
||||
});
|
||||
|
||||
it('checks for the existence of the method', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry(),
|
||||
subject = {};
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
||||
target = {};
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOn(subject, 'pants');
|
||||
spyRegistry.spyOn(target, 'pants');
|
||||
}).toThrowError(/method does not exist/);
|
||||
});
|
||||
|
||||
it('checks if it has already been spied upon', function() {
|
||||
const spies = [],
|
||||
spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
},
|
||||
createSpy: createSpy
|
||||
}),
|
||||
subject = { spiedFunc: function() {} };
|
||||
target = { spiedFunc: function() {} };
|
||||
|
||||
spyRegistry.spyOn(subject, 'spiedFunc');
|
||||
spyRegistry.spyOn(target, 'spiedFunc');
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOn(subject, 'spiedFunc');
|
||||
spyRegistry.spyOn(target, 'spiedFunc');
|
||||
}).toThrowError(/has already been spied upon/);
|
||||
});
|
||||
|
||||
@@ -78,19 +78,19 @@ describe('SpyRegistry', function() {
|
||||
});
|
||||
|
||||
const spies = [],
|
||||
spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
}
|
||||
}),
|
||||
subject = { spiedFunc: scope.myFunc };
|
||||
target = { spiedFunc: scope.myFunc };
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOn(scope, 'myFunc');
|
||||
}).toThrowError(/is not declared writable or has no setter/);
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOn(subject, 'spiedFunc');
|
||||
spyRegistry.spyOn(target, 'spiedFunc');
|
||||
}).not.toThrowError(/is not declared writable or has no setter/);
|
||||
});
|
||||
|
||||
@@ -108,7 +108,7 @@ describe('SpyRegistry', function() {
|
||||
set() {}
|
||||
});
|
||||
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: createSpy
|
||||
});
|
||||
expect(function() {
|
||||
@@ -119,55 +119,67 @@ describe('SpyRegistry', function() {
|
||||
});
|
||||
|
||||
it('overrides the method on the object and returns the spy', function() {
|
||||
const originalFunctionWasCalled = false,
|
||||
spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
createSpy: createSpy
|
||||
}),
|
||||
subject = {
|
||||
spiedFunc: function() {
|
||||
originalFunctionWasCalled = true;
|
||||
}
|
||||
};
|
||||
let originalFunctionWasCalled = false;
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: createSpy
|
||||
});
|
||||
const target = {
|
||||
spiedFunc: function() {
|
||||
originalFunctionWasCalled = true;
|
||||
}
|
||||
};
|
||||
|
||||
const spy = spyRegistry.spyOn(subject, 'spiedFunc');
|
||||
const spy = spyRegistry.spyOn(target, 'spiedFunc');
|
||||
|
||||
expect(subject.spiedFunc).toEqual(spy);
|
||||
subject.spiedFunc();
|
||||
expect(target.spiedFunc).toEqual(spy);
|
||||
target.spiedFunc();
|
||||
expect(originalFunctionWasCalled).toBe(false);
|
||||
});
|
||||
|
||||
it('throws if the method is a mock clock method', function() {
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: createSpy
|
||||
});
|
||||
const target = { spiedFunc: function() {} };
|
||||
target.spiedFunc[privateUnderTest.Clock.IsMockClockTimingFn] = true;
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOn(target, 'spiedFunc');
|
||||
}).toThrowError("Mock clock timing functions can't be spied on");
|
||||
});
|
||||
});
|
||||
|
||||
describe('#spyOnProperty', function() {
|
||||
it('checks for the existence of the object', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry();
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry();
|
||||
expect(function() {
|
||||
spyRegistry.spyOnProperty(void 0, 'pants');
|
||||
}).toThrowError(/could not find an object/);
|
||||
});
|
||||
|
||||
it('checks that a property name was passed', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry(),
|
||||
subject = {};
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
||||
target = {};
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOnProperty(subject);
|
||||
spyRegistry.spyOnProperty(target);
|
||||
}).toThrowError(/No property name supplied/);
|
||||
});
|
||||
|
||||
it('checks for the existence of the method', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry(),
|
||||
subject = {};
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
||||
target = {};
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOnProperty(subject, 'pants');
|
||||
spyRegistry.spyOnProperty(target, 'pants');
|
||||
}).toThrowError(/property does not exist/);
|
||||
});
|
||||
|
||||
it('checks for the existence of access type', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry(),
|
||||
subject = {};
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
||||
target = {};
|
||||
|
||||
Object.defineProperty(subject, 'pants', {
|
||||
Object.defineProperty(target, 'pants', {
|
||||
get: function() {
|
||||
return 1;
|
||||
},
|
||||
@@ -175,65 +187,65 @@ describe('SpyRegistry', function() {
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOnProperty(subject, 'pants', 'set');
|
||||
spyRegistry.spyOnProperty(target, 'pants', 'set');
|
||||
}).toThrowError(/does not have access type/);
|
||||
});
|
||||
|
||||
it('checks if it can be spied upon', function() {
|
||||
const subject = {};
|
||||
const target = {};
|
||||
|
||||
Object.defineProperty(subject, 'myProp', {
|
||||
Object.defineProperty(target, 'myProp', {
|
||||
get: function() {}
|
||||
});
|
||||
|
||||
Object.defineProperty(subject, 'spiedProp', {
|
||||
Object.defineProperty(target, 'spiedProp', {
|
||||
get: function() {},
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry();
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry();
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOnProperty(subject, 'myProp');
|
||||
spyRegistry.spyOnProperty(target, 'myProp');
|
||||
}).toThrowError(/is not declared configurable/);
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOnProperty(subject, 'spiedProp');
|
||||
spyRegistry.spyOnProperty(target, 'spiedProp');
|
||||
}).not.toThrowError(/is not declared configurable/);
|
||||
});
|
||||
|
||||
it('overrides the property getter on the object and returns the spy', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: createSpy
|
||||
}),
|
||||
subject = {},
|
||||
target = {},
|
||||
returnValue = 1;
|
||||
|
||||
Object.defineProperty(subject, 'spiedProperty', {
|
||||
Object.defineProperty(target, 'spiedProperty', {
|
||||
get: function() {
|
||||
return returnValue;
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
|
||||
expect(subject.spiedProperty).toEqual(returnValue);
|
||||
expect(target.spiedProperty).toEqual(returnValue);
|
||||
|
||||
const spy = spyRegistry.spyOnProperty(subject, 'spiedProperty');
|
||||
const getter = Object.getOwnPropertyDescriptor(subject, 'spiedProperty')
|
||||
const spy = spyRegistry.spyOnProperty(target, 'spiedProperty');
|
||||
const getter = Object.getOwnPropertyDescriptor(target, 'spiedProperty')
|
||||
.get;
|
||||
|
||||
expect(getter).toEqual(spy);
|
||||
expect(subject.spiedProperty).toBeUndefined();
|
||||
expect(target.spiedProperty).toBeUndefined();
|
||||
});
|
||||
|
||||
it('overrides the property setter on the object and returns the spy', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: createSpy
|
||||
}),
|
||||
subject = {},
|
||||
target = {},
|
||||
returnValue = 1;
|
||||
|
||||
Object.defineProperty(subject, 'spiedProperty', {
|
||||
Object.defineProperty(target, 'spiedProperty', {
|
||||
get: function() {
|
||||
return returnValue;
|
||||
},
|
||||
@@ -241,53 +253,53 @@ describe('SpyRegistry', function() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const spy = spyRegistry.spyOnProperty(subject, 'spiedProperty', 'set');
|
||||
const setter = Object.getOwnPropertyDescriptor(subject, 'spiedProperty')
|
||||
const spy = spyRegistry.spyOnProperty(target, 'spiedProperty', 'set');
|
||||
const setter = Object.getOwnPropertyDescriptor(target, 'spiedProperty')
|
||||
.set;
|
||||
|
||||
expect(subject.spiedProperty).toEqual(returnValue);
|
||||
expect(target.spiedProperty).toEqual(returnValue);
|
||||
expect(setter).toEqual(spy);
|
||||
});
|
||||
|
||||
describe('when the property is already spied upon', function() {
|
||||
it('throws an error if respy is not allowed', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: createSpy
|
||||
}),
|
||||
subject = {};
|
||||
target = {};
|
||||
|
||||
Object.defineProperty(subject, 'spiedProp', {
|
||||
Object.defineProperty(target, 'spiedProp', {
|
||||
get: function() {
|
||||
return 1;
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
|
||||
spyRegistry.spyOnProperty(subject, 'spiedProp');
|
||||
spyRegistry.spyOnProperty(target, 'spiedProp');
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOnProperty(subject, 'spiedProp');
|
||||
spyRegistry.spyOnProperty(target, 'spiedProp');
|
||||
}).toThrowError(/spiedProp#get has already been spied upon/);
|
||||
});
|
||||
|
||||
it('returns the original spy if respy is allowed', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: createSpy
|
||||
}),
|
||||
subject = {};
|
||||
target = {};
|
||||
|
||||
spyRegistry.allowRespy(true);
|
||||
|
||||
Object.defineProperty(subject, 'spiedProp', {
|
||||
Object.defineProperty(target, 'spiedProp', {
|
||||
get: function() {
|
||||
return 1;
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const originalSpy = spyRegistry.spyOnProperty(subject, 'spiedProp');
|
||||
const originalSpy = spyRegistry.spyOnProperty(target, 'spiedProp');
|
||||
|
||||
expect(spyRegistry.spyOnProperty(subject, 'spiedProp')).toBe(
|
||||
expect(spyRegistry.spyOnProperty(target, 'spiedProp')).toBe(
|
||||
originalSpy
|
||||
);
|
||||
});
|
||||
@@ -296,14 +308,14 @@ describe('SpyRegistry', function() {
|
||||
|
||||
describe('#spyOnAllFunctions', function() {
|
||||
it('checks for the existence of the object', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry();
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry();
|
||||
expect(function() {
|
||||
spyRegistry.spyOnAllFunctions(void 0);
|
||||
}).toThrowError(/spyOnAllFunctions could not find an object to spy upon/);
|
||||
});
|
||||
|
||||
it('overrides all writable and configurable functions of the object and its parents', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: function() {
|
||||
return 'I am a spy';
|
||||
}
|
||||
@@ -322,21 +334,21 @@ describe('SpyRegistry', function() {
|
||||
const parent = {
|
||||
parentSpied1: noop1
|
||||
};
|
||||
const subject = Object.create(parent);
|
||||
Object.defineProperty(subject, 'spied1', {
|
||||
const target = Object.create(parent);
|
||||
Object.defineProperty(target, 'spied1', {
|
||||
value: noop1,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(subject, 'spied2', {
|
||||
Object.defineProperty(target, 'spied2', {
|
||||
value: noop2,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
enumerable: true
|
||||
});
|
||||
let _spied3 = noop3;
|
||||
Object.defineProperty(subject, 'spied3', {
|
||||
Object.defineProperty(target, 'spied3', {
|
||||
configurable: true,
|
||||
set: function(val) {
|
||||
_spied3 = val;
|
||||
@@ -346,20 +358,20 @@ describe('SpyRegistry', function() {
|
||||
},
|
||||
enumerable: true
|
||||
});
|
||||
subject.spied4 = noop4;
|
||||
Object.defineProperty(subject, 'notSpied2', {
|
||||
target.spied4 = noop4;
|
||||
Object.defineProperty(target, 'notSpied2', {
|
||||
value: noop2,
|
||||
writable: false,
|
||||
configurable: true,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(subject, 'notSpied3', {
|
||||
Object.defineProperty(target, 'notSpied3', {
|
||||
value: noop3,
|
||||
writable: true,
|
||||
configurable: false,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(subject, 'notSpied4', {
|
||||
Object.defineProperty(target, 'notSpied4', {
|
||||
configurable: false,
|
||||
set: function() {
|
||||
/**/
|
||||
@@ -369,31 +381,31 @@ describe('SpyRegistry', function() {
|
||||
},
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(subject, 'notSpied5', {
|
||||
Object.defineProperty(target, 'notSpied5', {
|
||||
value: noop5,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
enumerable: false
|
||||
});
|
||||
subject.notSpied6 = 6;
|
||||
target.notSpied6 = 6;
|
||||
|
||||
const spiedObject = spyRegistry.spyOnAllFunctions(subject);
|
||||
const spiedObject = spyRegistry.spyOnAllFunctions(target);
|
||||
|
||||
expect(subject.parentSpied1).toBe('I am a spy');
|
||||
expect(subject.notSpied2).toBe(noop2);
|
||||
expect(subject.notSpied3).toBe(noop3);
|
||||
expect(subject.notSpied4).toBe(noop4);
|
||||
expect(subject.notSpied5).toBe(noop5);
|
||||
expect(subject.notSpied6).toBe(6);
|
||||
expect(subject.spied1).toBe('I am a spy');
|
||||
expect(subject.spied2).toBe('I am a spy');
|
||||
expect(subject.spied3).toBe('I am a spy');
|
||||
expect(subject.spied4).toBe('I am a spy');
|
||||
expect(spiedObject).toBe(subject);
|
||||
expect(target.parentSpied1).toBe('I am a spy');
|
||||
expect(target.notSpied2).toBe(noop2);
|
||||
expect(target.notSpied3).toBe(noop3);
|
||||
expect(target.notSpied4).toBe(noop4);
|
||||
expect(target.notSpied5).toBe(noop5);
|
||||
expect(target.notSpied6).toBe(6);
|
||||
expect(target.spied1).toBe('I am a spy');
|
||||
expect(target.spied2).toBe('I am a spy');
|
||||
expect(target.spied3).toBe('I am a spy');
|
||||
expect(target.spied4).toBe('I am a spy');
|
||||
expect(spiedObject).toBe(target);
|
||||
});
|
||||
|
||||
it('overrides prototype methods on the object', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: function() {
|
||||
return 'I am a spy';
|
||||
}
|
||||
@@ -407,145 +419,145 @@ describe('SpyRegistry', function() {
|
||||
};
|
||||
MyClass.prototype.spied2 = noop2;
|
||||
|
||||
const subject = new MyClass();
|
||||
spyRegistry.spyOnAllFunctions(subject);
|
||||
const target = new MyClass();
|
||||
spyRegistry.spyOnAllFunctions(target);
|
||||
|
||||
expect(subject.spied1).toBe('I am a spy');
|
||||
expect(subject.spied2).toBe('I am a spy');
|
||||
expect(target.spied1).toBe('I am a spy');
|
||||
expect(target.spied2).toBe('I am a spy');
|
||||
expect(MyClass.prototype.spied2).toBe(noop2);
|
||||
});
|
||||
|
||||
it('does not override non-enumerable properties (like Object.prototype methods)', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: function() {
|
||||
return 'I am a spy';
|
||||
}
|
||||
});
|
||||
const subject = {
|
||||
const target = {
|
||||
spied1: function() {}
|
||||
};
|
||||
|
||||
spyRegistry.spyOnAllFunctions(subject);
|
||||
spyRegistry.spyOnAllFunctions(target);
|
||||
|
||||
expect(subject.spied1).toBe('I am a spy');
|
||||
expect(subject.toString).not.toBe('I am a spy');
|
||||
expect(subject.hasOwnProperty).not.toBe('I am a spy');
|
||||
expect(target.spied1).toBe('I am a spy');
|
||||
expect(target.toString).not.toBe('I am a spy');
|
||||
expect(target.hasOwnProperty).not.toBe('I am a spy');
|
||||
});
|
||||
describe('when includeNonEnumerable is true', function() {
|
||||
it('does not override Object.prototype methods', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: function() {
|
||||
return 'I am a spy';
|
||||
}
|
||||
});
|
||||
const subject = {
|
||||
const target = {
|
||||
spied1: function() {}
|
||||
};
|
||||
|
||||
spyRegistry.spyOnAllFunctions(subject, true);
|
||||
spyRegistry.spyOnAllFunctions(target, true);
|
||||
|
||||
expect(subject.spied1).toBe('I am a spy');
|
||||
expect(subject.toString).not.toBe('I am a spy');
|
||||
expect(subject.hasOwnProperty).not.toBe('I am a spy');
|
||||
expect(target.spied1).toBe('I am a spy');
|
||||
expect(target.toString).not.toBe('I am a spy');
|
||||
expect(target.hasOwnProperty).not.toBe('I am a spy');
|
||||
});
|
||||
|
||||
it('overrides non-enumerable properties', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: function() {
|
||||
return 'I am a spy';
|
||||
}
|
||||
});
|
||||
const subject = {
|
||||
const target = {
|
||||
spied1: function() {},
|
||||
spied2: function() {}
|
||||
};
|
||||
|
||||
Object.defineProperty(subject, 'spied2', {
|
||||
Object.defineProperty(target, 'spied2', {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
spyRegistry.spyOnAllFunctions(subject, true);
|
||||
spyRegistry.spyOnAllFunctions(target, true);
|
||||
|
||||
expect(subject.spied1).toBe('I am a spy');
|
||||
expect(subject.spied2).toBe('I am a spy');
|
||||
expect(target.spied1).toBe('I am a spy');
|
||||
expect(target.spied2).toBe('I am a spy');
|
||||
});
|
||||
|
||||
it('should not spy on non-enumerable functions named constructor', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: function() {
|
||||
return 'I am a spy';
|
||||
}
|
||||
});
|
||||
const subject = {
|
||||
const target = {
|
||||
constructor: function() {}
|
||||
};
|
||||
|
||||
Object.defineProperty(subject, 'constructor', {
|
||||
Object.defineProperty(target, 'constructor', {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
spyRegistry.spyOnAllFunctions(subject, true);
|
||||
spyRegistry.spyOnAllFunctions(target, true);
|
||||
|
||||
expect(subject.constructor).not.toBe('I am a spy');
|
||||
expect(target.constructor).not.toBe('I am a spy');
|
||||
});
|
||||
|
||||
it('should spy on enumerable functions named constructor', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: function() {
|
||||
return 'I am a spy';
|
||||
}
|
||||
});
|
||||
const subject = {
|
||||
const target = {
|
||||
constructor: function() {}
|
||||
};
|
||||
|
||||
spyRegistry.spyOnAllFunctions(subject, true);
|
||||
spyRegistry.spyOnAllFunctions(target, true);
|
||||
|
||||
expect(subject.constructor).toBe('I am a spy');
|
||||
expect(target.constructor).toBe('I am a spy');
|
||||
});
|
||||
|
||||
it('should not throw an exception if we try and access strict mode restricted properties', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: function() {
|
||||
return 'I am a spy';
|
||||
}
|
||||
});
|
||||
const subject = function() {};
|
||||
const target = function() {};
|
||||
const fn = function() {
|
||||
spyRegistry.spyOnAllFunctions(subject, true);
|
||||
spyRegistry.spyOnAllFunctions(target, true);
|
||||
};
|
||||
|
||||
expect(fn).not.toThrow();
|
||||
});
|
||||
|
||||
it('should not spy on properties which are more permissable further up the prototype chain', function() {
|
||||
const spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: function() {
|
||||
return 'I am a spy';
|
||||
}
|
||||
});
|
||||
const subjectParent = Object.defineProperty({}, 'sharedProp', {
|
||||
const targetParent = Object.defineProperty({}, 'sharedProp', {
|
||||
value: function() {},
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const subject = Object.create(subjectParent);
|
||||
const target = Object.create(targetParent);
|
||||
|
||||
Object.defineProperty(subject, 'sharedProp', {
|
||||
Object.defineProperty(target, 'sharedProp', {
|
||||
value: function() {}
|
||||
});
|
||||
|
||||
const fn = function() {
|
||||
spyRegistry.spyOnAllFunctions(subject, true);
|
||||
spyRegistry.spyOnAllFunctions(target, true);
|
||||
};
|
||||
|
||||
expect(fn).not.toThrow();
|
||||
expect(subject).not.toBe('I am a spy');
|
||||
expect(target).not.toBe('I am a spy');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -553,90 +565,90 @@ describe('SpyRegistry', function() {
|
||||
describe('#clearSpies', function() {
|
||||
it('restores the original functions on the spied-upon objects', function() {
|
||||
const spies = [],
|
||||
spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
},
|
||||
createSpy: createSpy
|
||||
}),
|
||||
originalFunction = function() {},
|
||||
subject = { spiedFunc: originalFunction };
|
||||
target = { spiedFunc: originalFunction };
|
||||
|
||||
spyRegistry.spyOn(subject, 'spiedFunc');
|
||||
spyRegistry.spyOn(target, 'spiedFunc');
|
||||
spyRegistry.clearSpies();
|
||||
|
||||
expect(subject.spiedFunc).toBe(originalFunction);
|
||||
expect(target.spiedFunc).toBe(originalFunction);
|
||||
});
|
||||
|
||||
it('restores the original functions, even when that spy has been replace and re-spied upon', function() {
|
||||
const spies = [],
|
||||
spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
},
|
||||
createSpy: createSpy
|
||||
}),
|
||||
originalFunction = function() {},
|
||||
subject = { spiedFunc: originalFunction };
|
||||
target = { spiedFunc: originalFunction };
|
||||
|
||||
spyRegistry.spyOn(subject, 'spiedFunc');
|
||||
spyRegistry.spyOn(target, 'spiedFunc');
|
||||
|
||||
// replace the original spy with some other function
|
||||
subject.spiedFunc = function() {};
|
||||
target.spiedFunc = function() {};
|
||||
|
||||
// spy on the function in that location again
|
||||
spyRegistry.spyOn(subject, 'spiedFunc');
|
||||
spyRegistry.spyOn(target, 'spiedFunc');
|
||||
|
||||
spyRegistry.clearSpies();
|
||||
|
||||
expect(subject.spiedFunc).toBe(originalFunction);
|
||||
expect(target.spiedFunc).toBe(originalFunction);
|
||||
});
|
||||
|
||||
it("does not add a property that the spied-upon object didn't originally have", function() {
|
||||
const spies = [],
|
||||
spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
},
|
||||
createSpy: createSpy
|
||||
}),
|
||||
originalFunction = function() {},
|
||||
subjectParent = { spiedFunc: originalFunction };
|
||||
targetParent = { spiedFunc: originalFunction };
|
||||
|
||||
const subject = Object.create(subjectParent);
|
||||
const target = Object.create(targetParent);
|
||||
|
||||
expect(subject.hasOwnProperty('spiedFunc')).toBe(false);
|
||||
expect(target.hasOwnProperty('spiedFunc')).toBe(false);
|
||||
|
||||
spyRegistry.spyOn(subject, 'spiedFunc');
|
||||
spyRegistry.spyOn(target, 'spiedFunc');
|
||||
spyRegistry.clearSpies();
|
||||
|
||||
expect(subject.hasOwnProperty('spiedFunc')).toBe(false);
|
||||
expect(subject.spiedFunc).toBe(originalFunction);
|
||||
expect(target.hasOwnProperty('spiedFunc')).toBe(false);
|
||||
expect(target.spiedFunc).toBe(originalFunction);
|
||||
});
|
||||
|
||||
it("restores the original function when it's inherited and cannot be deleted", function() {
|
||||
const spies = [],
|
||||
spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
},
|
||||
createSpy: createSpy
|
||||
}),
|
||||
originalFunction = function() {},
|
||||
subjectParent = { spiedFunc: originalFunction };
|
||||
targetParent = { spiedFunc: originalFunction };
|
||||
|
||||
const subject = Object.create(subjectParent);
|
||||
const target = Object.create(targetParent);
|
||||
|
||||
spyRegistry.spyOn(subject, 'spiedFunc');
|
||||
spyRegistry.spyOn(target, 'spiedFunc');
|
||||
|
||||
// simulate a spy that cannot be deleted
|
||||
Object.defineProperty(subject, 'spiedFunc', {
|
||||
Object.defineProperty(target, 'spiedFunc', {
|
||||
configurable: false
|
||||
});
|
||||
|
||||
spyRegistry.clearSpies();
|
||||
|
||||
expect(jasmineUnderTest.isSpy(subject.spiedFunc)).toBe(false);
|
||||
expect(jasmineUnderTest.isSpy(target.spiedFunc)).toBe(false);
|
||||
});
|
||||
|
||||
it('restores window.onerror by overwriting, not deleting', function() {
|
||||
@@ -645,7 +657,7 @@ describe('SpyRegistry', function() {
|
||||
|
||||
const spies = [],
|
||||
global = new FakeWindow(),
|
||||
spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
},
|
||||
@@ -663,55 +675,55 @@ describe('SpyRegistry', function() {
|
||||
describe('spying on properties', function() {
|
||||
it('restores the original properties on the spied-upon objects', function() {
|
||||
const spies = [],
|
||||
spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
},
|
||||
createSpy: createSpy
|
||||
}),
|
||||
originalReturn = 1,
|
||||
subject = {};
|
||||
target = {};
|
||||
|
||||
Object.defineProperty(subject, 'spiedProp', {
|
||||
Object.defineProperty(target, 'spiedProp', {
|
||||
get: function() {
|
||||
return originalReturn;
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
|
||||
spyRegistry.spyOnProperty(subject, 'spiedProp');
|
||||
spyRegistry.spyOnProperty(target, 'spiedProp');
|
||||
spyRegistry.clearSpies();
|
||||
|
||||
expect(subject.spiedProp).toBe(originalReturn);
|
||||
expect(target.spiedProp).toBe(originalReturn);
|
||||
});
|
||||
|
||||
it("does not add a property that the spied-upon object didn't originally have", function() {
|
||||
const spies = [],
|
||||
spyRegistry = new jasmineUnderTest.SpyRegistry({
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
},
|
||||
createSpy: createSpy
|
||||
}),
|
||||
originalReturn = 1,
|
||||
subjectParent = {};
|
||||
targetParent = {};
|
||||
|
||||
Object.defineProperty(subjectParent, 'spiedProp', {
|
||||
Object.defineProperty(targetParent, 'spiedProp', {
|
||||
get: function() {
|
||||
return originalReturn;
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const subject = Object.create(subjectParent);
|
||||
const target = Object.create(targetParent);
|
||||
|
||||
expect(subject.hasOwnProperty('spiedProp')).toBe(false);
|
||||
expect(target.hasOwnProperty('spiedProp')).toBe(false);
|
||||
|
||||
spyRegistry.spyOnProperty(subject, 'spiedProp');
|
||||
spyRegistry.spyOnProperty(target, 'spiedProp');
|
||||
spyRegistry.clearSpies();
|
||||
|
||||
expect(subject.hasOwnProperty('spiedProp')).toBe(false);
|
||||
expect(subject.spiedProp).toBe(originalReturn);
|
||||
expect(target.hasOwnProperty('spiedProp')).toBe(false);
|
||||
expect(target.spiedProp).toBe(originalReturn);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ describe('Spies', function() {
|
||||
let env;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
@@ -50,8 +50,8 @@ describe('Spies', function() {
|
||||
TestClass.prototype.someFunction
|
||||
);
|
||||
|
||||
expect(spy.and).toEqual(jasmine.any(jasmineUnderTest.SpyStrategy));
|
||||
expect(spy.calls).toEqual(jasmine.any(jasmineUnderTest.CallTracker));
|
||||
expect(spy.and).toEqual(jasmine.any(privateUnderTest.SpyStrategy));
|
||||
expect(spy.calls).toEqual(jasmine.any(privateUnderTest.CallTracker));
|
||||
});
|
||||
|
||||
it('tracks the argument of calls', function() {
|
||||
@@ -241,7 +241,7 @@ describe('Spies', function() {
|
||||
});
|
||||
|
||||
it('uses the provided matchersUtil selecting a strategy', function() {
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
customTesters: [
|
||||
function(a, b) {
|
||||
if ((a === 'bar' && b === 'baz') || (a === 'baz' && b === 'bar')) {
|
||||
@@ -250,7 +250,7 @@ describe('Spies', function() {
|
||||
}
|
||||
]
|
||||
});
|
||||
const spy = new jasmineUnderTest.Spy('aSpy', matchersUtil);
|
||||
const spy = new privateUnderTest.Spy('aSpy', matchersUtil);
|
||||
spy.and.returnValue('default strategy return value');
|
||||
spy.withArgs('bar').and.returnValue('custom strategy return value');
|
||||
expect(spy('foo')).toEqual('default strategy return value');
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
describe('SpyStrategy', function() {
|
||||
it('defaults its name to unknown', function() {
|
||||
const spyStrategy = new jasmineUnderTest.SpyStrategy();
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy();
|
||||
|
||||
expect(spyStrategy.identity).toEqual('unknown');
|
||||
});
|
||||
|
||||
it('takes a name', function() {
|
||||
const spyStrategy = new jasmineUnderTest.SpyStrategy({ name: 'foo' });
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({ name: 'foo' });
|
||||
|
||||
expect(spyStrategy.identity).toEqual('foo');
|
||||
});
|
||||
|
||||
it('stubs an original function, if provided', function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn });
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.exec();
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('SpyStrategy', function() {
|
||||
|
||||
it("allows an original function to be called, passed through the params and returns it's value", function() {
|
||||
const originalFn = jasmine.createSpy('original').and.returnValue(42),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn });
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.callThrough();
|
||||
const returnValue = spyStrategy.exec(null, ['foo']);
|
||||
@@ -34,7 +34,7 @@ describe('SpyStrategy', function() {
|
||||
|
||||
it('can return a specified value when executed', function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn });
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.returnValue(17);
|
||||
const returnValue = spyStrategy.exec();
|
||||
@@ -45,7 +45,7 @@ describe('SpyStrategy', function() {
|
||||
|
||||
it('can return specified values in order specified when executed', function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn });
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.returnValues('value1', 'value2', 'value3');
|
||||
|
||||
@@ -58,7 +58,7 @@ describe('SpyStrategy', function() {
|
||||
|
||||
it('allows an exception to be thrown when executed', function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn });
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.throwError(new TypeError('bar'));
|
||||
|
||||
@@ -70,7 +70,7 @@ describe('SpyStrategy', function() {
|
||||
|
||||
it('allows a string to be thrown, wrapping it into an exception when executed', function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn });
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.throwError('bar');
|
||||
|
||||
@@ -82,7 +82,7 @@ describe('SpyStrategy', function() {
|
||||
|
||||
it('allows a non-Error to be thrown when executed', function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn });
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.throwError({ code: 'ESRCH' });
|
||||
|
||||
@@ -95,7 +95,7 @@ describe('SpyStrategy', function() {
|
||||
it('allows a fake function to be called instead', function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
fakeFn = jasmine.createSpy('fake').and.returnValue(67),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn });
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.callFake(fakeFn);
|
||||
const returnValue = spyStrategy.exec();
|
||||
@@ -109,7 +109,7 @@ describe('SpyStrategy', function() {
|
||||
fakeFn = jasmine.createSpy('fake').and.callFake(async () => {
|
||||
return 67;
|
||||
}),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn });
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.callFake(fakeFn);
|
||||
spyStrategy
|
||||
@@ -128,7 +128,7 @@ describe('SpyStrategy', function() {
|
||||
describe('#resolveTo', function() {
|
||||
it('allows a resolved promise to be returned', function(done) {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
fn: originalFn
|
||||
});
|
||||
|
||||
@@ -144,7 +144,7 @@ describe('SpyStrategy', function() {
|
||||
|
||||
it('allows an empty resolved promise to be returned', function(done) {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
fn: originalFn
|
||||
});
|
||||
|
||||
@@ -162,7 +162,7 @@ describe('SpyStrategy', function() {
|
||||
describe('#rejectWith', function() {
|
||||
it('allows a rejected promise to be returned', function(done) {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
fn: originalFn
|
||||
});
|
||||
|
||||
@@ -179,7 +179,7 @@ describe('SpyStrategy', function() {
|
||||
|
||||
it('allows an empty rejected promise to be returned', function(done) {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
fn: originalFn
|
||||
});
|
||||
|
||||
@@ -196,7 +196,7 @@ describe('SpyStrategy', function() {
|
||||
|
||||
it('allows a non-Error to be rejected', function(done) {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
fn: originalFn
|
||||
});
|
||||
|
||||
@@ -220,7 +220,7 @@ describe('SpyStrategy', function() {
|
||||
.createSpy('custom strategy')
|
||||
.and.returnValue(plan),
|
||||
originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
fn: originalFn,
|
||||
customStrategies: {
|
||||
doSomething: customStrategy
|
||||
@@ -237,7 +237,7 @@ describe('SpyStrategy', function() {
|
||||
|
||||
it("throws an error if a custom strategy doesn't return a function", function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
fn: originalFn,
|
||||
customStrategies: {
|
||||
doSomething: function() {
|
||||
@@ -252,37 +252,32 @@ describe('SpyStrategy', function() {
|
||||
});
|
||||
|
||||
it('does not allow custom strategies to overwrite existing methods', function() {
|
||||
const spyStrategy = new jasmineUnderTest.SpyStrategy({
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
fn: function() {},
|
||||
customStrategies: {
|
||||
exec: function() {}
|
||||
}
|
||||
});
|
||||
|
||||
expect(spyStrategy.exec).toBe(jasmineUnderTest.SpyStrategy.prototype.exec);
|
||||
expect(spyStrategy.exec).toBe(privateUnderTest.SpyStrategy.prototype.exec);
|
||||
});
|
||||
|
||||
it('throws an error when a non-function is passed to callFake strategy', function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyOn(jasmineUnderTest, 'isFunction_').and.returnValue(false);
|
||||
spyOn(jasmineUnderTest, 'isAsyncFunction_').and.returnValue(false);
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
expect(function() {
|
||||
spyStrategy.callFake(function() {});
|
||||
}).toThrowError(/^Argument passed to callFake should be a function, got/);
|
||||
|
||||
expect(function() {
|
||||
spyStrategy.callFake(function() {});
|
||||
}).toThrowError(/^Argument passed to callFake should be a function, got/);
|
||||
spyStrategy.callFake('not a function');
|
||||
}).toThrowError(
|
||||
'Argument passed to callFake should be a function, got not a function'
|
||||
);
|
||||
});
|
||||
|
||||
it('allows generator functions to be passed to callFake strategy', function() {
|
||||
const generator = function*() {
|
||||
yield 'ok';
|
||||
},
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: function() {} });
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: function() {} });
|
||||
|
||||
spyStrategy.callFake(generator);
|
||||
|
||||
@@ -292,7 +287,7 @@ describe('SpyStrategy', function() {
|
||||
it('allows a return to plan stubbing after another strategy', function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
fakeFn = jasmine.createSpy('fake').and.returnValue(67),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn });
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.callFake(fakeFn);
|
||||
let returnValue = spyStrategy.exec();
|
||||
@@ -309,7 +304,7 @@ describe('SpyStrategy', function() {
|
||||
it('returns the spy after changing the strategy', function() {
|
||||
const spy = {},
|
||||
spyFn = jasmine.createSpy('spyFn').and.returnValue(spy),
|
||||
spyStrategy = new jasmineUnderTest.SpyStrategy({ getSpy: spyFn });
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ getSpy: spyFn });
|
||||
|
||||
expect(spyStrategy.callThrough()).toBe(spy);
|
||||
expect(spyStrategy.returnValue()).toBe(spy);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
describe('ClearStack', function() {
|
||||
describe('StackClearer', function() {
|
||||
it('works in an integrationy way', function(done) {
|
||||
const clearStack = jasmineUnderTest.getClearStack(
|
||||
const { clearStack } = privateUnderTest.getStackClearer(
|
||||
jasmineUnderTest.getGlobal()
|
||||
);
|
||||
|
||||
@@ -36,7 +36,7 @@ describe('ClearStack', function() {
|
||||
queueMicrotask
|
||||
};
|
||||
|
||||
const clearStack = jasmineUnderTest.getClearStack(global);
|
||||
const { clearStack } = privateUnderTest.getStackClearer(global);
|
||||
|
||||
for (let i = 0; i < 9; i++) {
|
||||
clearStack(function() {});
|
||||
@@ -73,17 +73,6 @@ describe('ClearStack', function() {
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
describe('when MessageChannel is unavailable', function() {
|
||||
usesQueueMicrotaskWithSetTimeout(function() {
|
||||
return {
|
||||
navigator: {
|
||||
userAgent: 'CERN-LineMode/2.15 libwww/2.17b3',
|
||||
MessageChannel: undefined
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('in Node', function() {
|
||||
@@ -104,7 +93,7 @@ describe('ClearStack', function() {
|
||||
...makeGlobal(),
|
||||
MessageChannel: fakeMessageChannel
|
||||
};
|
||||
const clearStack = jasmineUnderTest.getClearStack(global);
|
||||
const { clearStack } = privateUnderTest.getStackClearer(global);
|
||||
let called = false;
|
||||
|
||||
clearStack(function() {
|
||||
@@ -125,7 +114,7 @@ describe('ClearStack', function() {
|
||||
return fakeChannel;
|
||||
}
|
||||
};
|
||||
const clearStack = jasmineUnderTest.getClearStack(global);
|
||||
const { clearStack } = privateUnderTest.getStackClearer(global);
|
||||
|
||||
for (let i = 0; i < 9; i++) {
|
||||
clearStack(function() {});
|
||||
@@ -150,7 +139,7 @@ describe('ClearStack', function() {
|
||||
setTimeout,
|
||||
MessageChannel: fakeMessageChannel
|
||||
};
|
||||
const clearStack = jasmineUnderTest.getClearStack(global);
|
||||
const { clearStack } = privateUnderTest.getStackClearer(global);
|
||||
const fn = jasmine.createSpy('second clearStack function');
|
||||
|
||||
clearStack(function() {
|
||||
@@ -170,7 +159,7 @@ describe('ClearStack', function() {
|
||||
fn();
|
||||
}
|
||||
};
|
||||
const clearStack = jasmineUnderTest.getClearStack(global);
|
||||
const { clearStack } = privateUnderTest.getStackClearer(global);
|
||||
let called = false;
|
||||
|
||||
clearStack(function() {
|
||||
@@ -180,30 +169,82 @@ describe('ClearStack', function() {
|
||||
expect(called).toBe(true);
|
||||
});
|
||||
|
||||
it('uses setTimeout instead of queueMicrotask every 10 calls to make sure we release the CPU', function() {
|
||||
const queueMicrotask = jasmine.createSpy('queueMicrotask');
|
||||
const setTimeout = jasmine.createSpy('setTimeout');
|
||||
const global = {
|
||||
...makeGlobal(),
|
||||
queueMicrotask,
|
||||
setTimeout
|
||||
};
|
||||
const clearStack = jasmineUnderTest.getClearStack(global);
|
||||
function hasSetTimeoutBehavior(configure) {
|
||||
it('uses setTimeout instead of queueMicrotask every 10 calls', function() {
|
||||
const queueMicrotask = jasmine.createSpy('queueMicrotask');
|
||||
const setTimeout = jasmine.createSpy('setTimeout');
|
||||
const global = {
|
||||
...makeGlobal(),
|
||||
queueMicrotask,
|
||||
setTimeout
|
||||
};
|
||||
const stackClearer = privateUnderTest.getStackClearer(global);
|
||||
|
||||
for (let i = 0; i < 9; i++) {
|
||||
clearStack(function() {});
|
||||
}
|
||||
if (configure) {
|
||||
configure(stackClearer);
|
||||
}
|
||||
|
||||
expect(queueMicrotask).toHaveBeenCalled();
|
||||
expect(setTimeout).not.toHaveBeenCalled();
|
||||
for (let i = 0; i < 9; i++) {
|
||||
stackClearer.clearStack(function() {});
|
||||
}
|
||||
|
||||
clearStack(function() {});
|
||||
expect(queueMicrotask).toHaveBeenCalledTimes(9);
|
||||
expect(setTimeout).toHaveBeenCalledTimes(1);
|
||||
expect(queueMicrotask).toHaveBeenCalled();
|
||||
expect(setTimeout).not.toHaveBeenCalled();
|
||||
|
||||
clearStack(function() {});
|
||||
expect(queueMicrotask).toHaveBeenCalledTimes(10);
|
||||
expect(setTimeout).toHaveBeenCalledTimes(1);
|
||||
stackClearer.clearStack(function() {});
|
||||
expect(queueMicrotask).toHaveBeenCalledTimes(9);
|
||||
expect(setTimeout).toHaveBeenCalledTimes(1);
|
||||
|
||||
stackClearer.clearStack(function() {});
|
||||
expect(queueMicrotask).toHaveBeenCalledTimes(10);
|
||||
expect(setTimeout).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
}
|
||||
|
||||
hasSetTimeoutBehavior();
|
||||
|
||||
describe('With yield strategy explicitly set to count', function() {
|
||||
hasSetTimeoutBehavior(function(stackClearer) {
|
||||
stackClearer.setSafariYieldStrategy('count');
|
||||
});
|
||||
});
|
||||
|
||||
describe('With yield strategy set to time', function() {
|
||||
beforeEach(function() {
|
||||
jasmine.clock().install();
|
||||
jasmine.clock().mockDate();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmine.clock().uninstall();
|
||||
});
|
||||
|
||||
it('uses setTimeout instead of queueMicrotask every 25 milliseconds', function() {
|
||||
const queueMicrotask = jasmine.createSpy('queueMicrotask');
|
||||
const setTimeout = jasmine.createSpy('setTimeout');
|
||||
const global = {
|
||||
...makeGlobal(),
|
||||
queueMicrotask,
|
||||
setTimeout
|
||||
};
|
||||
const stackClearer = privateUnderTest.getStackClearer(global);
|
||||
stackClearer.setSafariYieldStrategy('time');
|
||||
|
||||
// 10+ counts should not trigger a setTimeout if they happen fast enough
|
||||
jasmine.clock().tick(24);
|
||||
for (let i = 0; i < 11; i++) {
|
||||
stackClearer.clearStack(function() {});
|
||||
}
|
||||
|
||||
expect(queueMicrotask).toHaveBeenCalled();
|
||||
expect(setTimeout).not.toHaveBeenCalled();
|
||||
|
||||
queueMicrotask.calls.reset();
|
||||
jasmine.clock().tick(1);
|
||||
stackClearer.clearStack(function() {});
|
||||
expect(queueMicrotask).not.toHaveBeenCalled();
|
||||
expect(setTimeout).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -215,7 +256,7 @@ describe('ClearStack', function() {
|
||||
fn();
|
||||
}
|
||||
};
|
||||
const clearStack = jasmineUnderTest.getClearStack(global);
|
||||
const { clearStack } = privateUnderTest.getStackClearer(global);
|
||||
let called = false;
|
||||
|
||||
clearStack(function() {
|
||||
@@ -233,7 +274,7 @@ describe('ClearStack', function() {
|
||||
queueMicrotask,
|
||||
setTimeout
|
||||
};
|
||||
const clearStack = jasmineUnderTest.getClearStack(global);
|
||||
const { clearStack } = privateUnderTest.getStackClearer(global);
|
||||
|
||||
clearStack(function() {});
|
||||
clearStack(function() {});
|
||||
@@ -8,7 +8,7 @@ describe('StackTrace', function() {
|
||||
' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)'
|
||||
};
|
||||
|
||||
const result = new jasmineUnderTest.StackTrace(error);
|
||||
const result = new privateUnderTest.StackTrace(error);
|
||||
|
||||
expect(result.message).toEqual('Error: nope');
|
||||
expect(result.style).toEqual('v8');
|
||||
@@ -39,7 +39,7 @@ describe('StackTrace', function() {
|
||||
' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)'
|
||||
};
|
||||
|
||||
const result = new jasmineUnderTest.StackTrace(error);
|
||||
const result = new privateUnderTest.StackTrace(error);
|
||||
|
||||
expect(result.message).toEqual('Error: line 1\nline 2');
|
||||
const rawFrames = result.frames.map(function(f) {
|
||||
@@ -60,7 +60,7 @@ describe('StackTrace', function() {
|
||||
' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)'
|
||||
};
|
||||
|
||||
const result = new jasmineUnderTest.StackTrace(error);
|
||||
const result = new privateUnderTest.StackTrace(error);
|
||||
|
||||
expect(result.message).toEqual('Error: line 1\n\nline 2');
|
||||
const rawFrames = result.frames.map(function(f) {
|
||||
@@ -82,7 +82,7 @@ describe('StackTrace', function() {
|
||||
' at Immediate.<anonymous> (/somewhere/jasmine/lib/jasmine-core/jasmine.js:4314:12)\n' +
|
||||
' at runCallback (timers.js:672:20)'
|
||||
};
|
||||
const result = new jasmineUnderTest.StackTrace(error);
|
||||
const result = new privateUnderTest.StackTrace(error);
|
||||
|
||||
expect(result.message).toEqual('Error');
|
||||
expect(result.style).toEqual('v8');
|
||||
@@ -123,7 +123,7 @@ describe('StackTrace', function() {
|
||||
'http://localhost:8888/__spec__/core/UtilSpec.js:115:28\n' +
|
||||
'run@http://localhost:8888/__jasmine__/jasmine.js:4320:27'
|
||||
};
|
||||
const result = new jasmineUnderTest.StackTrace(error);
|
||||
const result = new privateUnderTest.StackTrace(error);
|
||||
|
||||
expect(result.message).toBeFalsy();
|
||||
expect(result.style).toEqual('webkit');
|
||||
@@ -150,7 +150,7 @@ describe('StackTrace', function() {
|
||||
'@http://localhost:8888/__spec__/core/FooSpec.js:164:24\n' +
|
||||
'attempt@http://localhost:8888/__jasmine__/jasmine.js:8074:44\n'
|
||||
};
|
||||
const result = new jasmineUnderTest.StackTrace(error);
|
||||
const result = new privateUnderTest.StackTrace(error);
|
||||
|
||||
expect(result.message).toBeFalsy();
|
||||
expect(result.style).toEqual('webkit');
|
||||
@@ -175,7 +175,7 @@ describe('StackTrace', function() {
|
||||
message: 'nope',
|
||||
stack: 'randomcharsnotincludingwhitespace'
|
||||
};
|
||||
const result = new jasmineUnderTest.StackTrace(error);
|
||||
const result = new privateUnderTest.StackTrace(error);
|
||||
expect(result.style).toBeNull();
|
||||
expect(result.frames).toEqual([{ raw: error.stack }]);
|
||||
});
|
||||
@@ -187,7 +187,7 @@ describe('StackTrace', function() {
|
||||
' at UserContext.<anonymous> (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)\n'
|
||||
};
|
||||
|
||||
const result = new jasmineUnderTest.StackTrace(error);
|
||||
const result = new privateUnderTest.StackTrace(error);
|
||||
|
||||
expect(result.frames).toEqual([
|
||||
{
|
||||
@@ -209,7 +209,7 @@ describe('StackTrace', function() {
|
||||
' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)'
|
||||
};
|
||||
|
||||
const result = new jasmineUnderTest.StackTrace(error);
|
||||
const result = new privateUnderTest.StackTrace(error);
|
||||
expect(result.style).toEqual('v8');
|
||||
expect(result.frames).toEqual([
|
||||
{
|
||||
@@ -241,7 +241,7 @@ describe('StackTrace', function() {
|
||||
' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)'
|
||||
};
|
||||
|
||||
const result = new jasmineUnderTest.StackTrace(error);
|
||||
const result = new privateUnderTest.StackTrace(error);
|
||||
|
||||
expect(result.message).toEqual('TypeError: nope');
|
||||
expect(result.frames).toEqual([
|
||||
@@ -269,7 +269,7 @@ describe('StackTrace', function() {
|
||||
' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)'
|
||||
};
|
||||
|
||||
const result_no_error = new jasmineUnderTest.StackTrace(no_error);
|
||||
const result_no_error = new privateUnderTest.StackTrace(no_error);
|
||||
|
||||
expect(result_no_error.message).not.toEqual(jasmine.anything());
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
describe('SuiteBuilder', function() {
|
||||
beforeEach(function() {
|
||||
// Rethrow exceptions to ease debugging
|
||||
spyOn(jasmineUnderTest.Suite.prototype, 'handleException').and.callFake(
|
||||
spyOn(privateUnderTest.Suite.prototype, 'handleException').and.callFake(
|
||||
function(e) {
|
||||
throw e;
|
||||
}
|
||||
);
|
||||
spyOn(jasmineUnderTest.Spec.prototype, 'handleException').and.callFake(
|
||||
spyOn(privateUnderTest.Spec.prototype, 'handleException').and.callFake(
|
||||
function(e) {
|
||||
throw e;
|
||||
}
|
||||
@@ -15,9 +15,9 @@ describe('SuiteBuilder', function() {
|
||||
|
||||
it('creates the top suite', function() {
|
||||
const env = { configuration: () => ({}) };
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
|
||||
expect(suiteBuilder.topSuite).toBeInstanceOf(jasmineUnderTest.Suite);
|
||||
expect(suiteBuilder.topSuite).toBeInstanceOf(privateUnderTest.Suite);
|
||||
expect(suiteBuilder.topSuite.description).toEqual(
|
||||
'Jasmine__TopLevel__Suite'
|
||||
);
|
||||
@@ -33,7 +33,7 @@ describe('SuiteBuilder', function() {
|
||||
|
||||
it('focuses the suite', function() {
|
||||
const env = { configuration: () => ({}) };
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
|
||||
const suite = suiteBuilder.fdescribe('a suite', function() {
|
||||
suiteBuilder.it('a spec');
|
||||
@@ -45,7 +45,7 @@ describe('SuiteBuilder', function() {
|
||||
|
||||
it('unfocuses any focused ancestor suite', function() {
|
||||
const env = { configuration: () => ({}) };
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
|
||||
const grandparent = suiteBuilder.fdescribe('a suite', function() {
|
||||
suiteBuilder.describe('another suite', function() {
|
||||
@@ -64,7 +64,7 @@ describe('SuiteBuilder', function() {
|
||||
|
||||
it('excludes the suite', function() {
|
||||
const env = { configuration: () => ({}) };
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
|
||||
const suite = suiteBuilder.xdescribe('a suite', function() {
|
||||
suiteBuilder.it('a spec');
|
||||
@@ -75,7 +75,7 @@ describe('SuiteBuilder', function() {
|
||||
|
||||
it('causes child suites to be marked excluded', function() {
|
||||
const env = { configuration: () => ({}) };
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
|
||||
let suite;
|
||||
suiteBuilder.xdescribe('a suite', function() {
|
||||
@@ -103,7 +103,7 @@ describe('SuiteBuilder', function() {
|
||||
function definesSuites(fnName) {
|
||||
it('links suites to their parents and children', function() {
|
||||
const env = { configuration: () => ({}) };
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
|
||||
let child;
|
||||
const parent = suiteBuilder[fnName]('parent', function() {
|
||||
@@ -120,7 +120,7 @@ describe('SuiteBuilder', function() {
|
||||
|
||||
it('gives each suite a unique ID', function() {
|
||||
const env = { configuration: () => ({}) };
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
|
||||
let child;
|
||||
const parent = suiteBuilder[fnName]('parent', function() {
|
||||
@@ -142,7 +142,7 @@ describe('SuiteBuilder', function() {
|
||||
function definesSpecs(fnName) {
|
||||
it('adds the spec to its suite', function() {
|
||||
const env = { configuration: () => ({}) };
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
|
||||
let spec;
|
||||
const suite = suiteBuilder.describe('a suite', function() {
|
||||
@@ -154,7 +154,7 @@ describe('SuiteBuilder', function() {
|
||||
|
||||
it('gives each spec a unique ID', function() {
|
||||
const env = { configuration: () => ({}) };
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
|
||||
const spec1 = suiteBuilder[fnName]('a spec', function() {});
|
||||
const spec2 = suiteBuilder[fnName]('another spec', function() {});
|
||||
@@ -166,7 +166,7 @@ describe('SuiteBuilder', function() {
|
||||
|
||||
it('gives each spec a full path', function() {
|
||||
const env = { configuration: () => ({}) };
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
let spec;
|
||||
|
||||
suiteBuilder.describe('a suite', function() {
|
||||
@@ -199,7 +199,7 @@ describe('SuiteBuilder', function() {
|
||||
});
|
||||
|
||||
it('forbids duplicate spec names', function() {
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
|
||||
expect(function() {
|
||||
suiteBuilder.describe('a suite', function() {
|
||||
@@ -214,7 +214,7 @@ describe('SuiteBuilder', function() {
|
||||
});
|
||||
|
||||
it('forbids duplicate spec names in the top suite', function() {
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
|
||||
expect(function() {
|
||||
suiteBuilder.it('another spec');
|
||||
@@ -225,7 +225,7 @@ describe('SuiteBuilder', function() {
|
||||
});
|
||||
|
||||
it('forbids duplicate suite names', function() {
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
|
||||
expect(function() {
|
||||
suiteBuilder.describe('a suite', function() {
|
||||
@@ -244,7 +244,7 @@ describe('SuiteBuilder', function() {
|
||||
});
|
||||
|
||||
it('forbids duplicate suite names in the top suite', function() {
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
|
||||
expect(function() {
|
||||
suiteBuilder.describe('a suite', function() {
|
||||
@@ -257,7 +257,7 @@ describe('SuiteBuilder', function() {
|
||||
});
|
||||
|
||||
it('allows spec and suite names to be duplicated in different suites', function() {
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
|
||||
expect(function() {
|
||||
suiteBuilder.describe('suite a', function() {
|
||||
@@ -285,7 +285,7 @@ describe('SuiteBuilder', function() {
|
||||
});
|
||||
|
||||
it('allows duplicate spec and suite names', function() {
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
|
||||
expect(function() {
|
||||
suiteBuilder.describe('dupe suite', function() {
|
||||
@@ -303,18 +303,19 @@ describe('SuiteBuilder', function() {
|
||||
|
||||
describe('#parallelReset', function() {
|
||||
it('resets the top suite result', function() {
|
||||
jasmineUnderTest.Suite.prototype.handleException.and.callThrough();
|
||||
privateUnderTest.Suite.prototype.handleException.and.callThrough();
|
||||
|
||||
const env = { configuration: () => ({}) };
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
|
||||
suiteBuilder.topSuite.handleException(new Error('nope'));
|
||||
suiteBuilder.parallelReset();
|
||||
|
||||
expect(suiteBuilder.topSuite.result).toEqual({
|
||||
expect(suiteBuilder.topSuite.doneEvent()).toEqual({
|
||||
id: suiteBuilder.topSuite.id,
|
||||
description: 'Jasmine__TopLevel__Suite',
|
||||
fullName: '',
|
||||
status: 'passed',
|
||||
failedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
duration: null,
|
||||
@@ -326,7 +327,7 @@ describe('SuiteBuilder', function() {
|
||||
|
||||
it('removes children of the top suite', function() {
|
||||
const env = { configuration: () => ({}) };
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
suiteBuilder.describe('a suite', function() {
|
||||
suiteBuilder.it('a nested spec');
|
||||
});
|
||||
@@ -339,7 +340,7 @@ describe('SuiteBuilder', function() {
|
||||
|
||||
it('preserves top suite befores and afters', function() {
|
||||
const env = { configuration: () => ({}) };
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
|
||||
function beforeAll() {}
|
||||
function beforeEach() {}
|
||||
@@ -369,7 +370,7 @@ describe('SuiteBuilder', function() {
|
||||
|
||||
it('resets totalSpecsDefined', function() {
|
||||
const env = { configuration: () => ({}) };
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
suiteBuilder.it('a spec');
|
||||
|
||||
suiteBuilder.parallelReset();
|
||||
@@ -379,7 +380,7 @@ describe('SuiteBuilder', function() {
|
||||
|
||||
it('resets focusedRunables', function() {
|
||||
const env = { configuration: () => ({}) };
|
||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||
const suiteBuilder = new privateUnderTest.SuiteBuilder({ env });
|
||||
suiteBuilder.fit('a spec', function() {});
|
||||
|
||||
suiteBuilder.parallelReset();
|
||||
|
||||
@@ -2,7 +2,7 @@ describe('Suite', function() {
|
||||
let env;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
@@ -10,7 +10,7 @@ describe('Suite', function() {
|
||||
});
|
||||
|
||||
it('keeps its id', function() {
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const suite = new privateUnderTest.Suite({
|
||||
env: env,
|
||||
id: 456,
|
||||
description: 'I am a suite'
|
||||
@@ -20,7 +20,7 @@ describe('Suite', function() {
|
||||
});
|
||||
|
||||
it('returns blank full name for top level suite', function() {
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const suite = new privateUnderTest.Suite({
|
||||
env: env,
|
||||
description: 'I am a suite'
|
||||
});
|
||||
@@ -29,12 +29,12 @@ describe('Suite', function() {
|
||||
});
|
||||
|
||||
it('returns its full name when it has parent suites', function() {
|
||||
const parentSuite = new jasmineUnderTest.Suite({
|
||||
const parentSuite = new privateUnderTest.Suite({
|
||||
env: env,
|
||||
description: 'I am a parent suite',
|
||||
parentSuite: jasmine.createSpy('pretend top level suite')
|
||||
}),
|
||||
suite = new jasmineUnderTest.Suite({
|
||||
suite = new privateUnderTest.Suite({
|
||||
env: env,
|
||||
description: 'I am a suite',
|
||||
parentSuite: parentSuite
|
||||
@@ -44,7 +44,7 @@ describe('Suite', function() {
|
||||
});
|
||||
|
||||
it('adds beforeEach functions in order of needed execution', function() {
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const suite = new privateUnderTest.Suite({
|
||||
env: env,
|
||||
description: 'I am a suite'
|
||||
}),
|
||||
@@ -61,7 +61,7 @@ describe('Suite', function() {
|
||||
});
|
||||
|
||||
it('adds beforeAll functions in order of needed execution', function() {
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const suite = new privateUnderTest.Suite({
|
||||
env: env,
|
||||
description: 'I am a suite'
|
||||
}),
|
||||
@@ -78,7 +78,7 @@ describe('Suite', function() {
|
||||
});
|
||||
|
||||
it('adds afterEach functions in order of needed execution', function() {
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const suite = new privateUnderTest.Suite({
|
||||
env: env,
|
||||
description: 'I am a suite'
|
||||
}),
|
||||
@@ -95,7 +95,7 @@ describe('Suite', function() {
|
||||
});
|
||||
|
||||
it('adds afterAll functions in order of needed execution', function() {
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const suite = new privateUnderTest.Suite({
|
||||
env: env,
|
||||
description: 'I am a suite'
|
||||
}),
|
||||
@@ -112,51 +112,51 @@ describe('Suite', function() {
|
||||
});
|
||||
|
||||
it('has a status of failed if any expectations have failed', function() {
|
||||
const suite = new jasmineUnderTest.Suite({});
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
|
||||
suite.addExpectationResult(false, {});
|
||||
expect(suite.getResult().status).toBe('failed');
|
||||
expect(suite.doneEvent().status).toBe('failed');
|
||||
});
|
||||
|
||||
it('retrieves a result with updated status', function() {
|
||||
const suite = new jasmineUnderTest.Suite({});
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
|
||||
expect(suite.getResult().status).toBe('passed');
|
||||
expect(suite.doneEvent().status).toBe('passed');
|
||||
});
|
||||
|
||||
it('retrieves a result with pending status', function() {
|
||||
const suite = new jasmineUnderTest.Suite({});
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
suite.pend();
|
||||
|
||||
expect(suite.getResult().status).toBe('pending');
|
||||
expect(suite.doneEvent().status).toBe('pending');
|
||||
});
|
||||
|
||||
it('throws an ExpectationFailed when receiving a failed expectation when throwOnExpectationFailure is set', function() {
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const suite = new privateUnderTest.Suite({
|
||||
throwOnExpectationFailure: true
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
suite.addExpectationResult(false, { message: 'failed' });
|
||||
}).toThrowError(jasmineUnderTest.errors.ExpectationFailed);
|
||||
}).toThrowError(privateUnderTest.errors.ExpectationFailed);
|
||||
|
||||
expect(suite.getResult().status).toBe('failed');
|
||||
expect(suite.result.failedExpectations).toEqual([
|
||||
expect(suite.doneEvent().status).toBe('failed');
|
||||
expect(suite.doneEvent().failedExpectations).toEqual([
|
||||
jasmine.objectContaining({ message: 'failed' })
|
||||
]);
|
||||
});
|
||||
|
||||
it('does not add an additional failure when an expectation fails', function() {
|
||||
const suite = new jasmineUnderTest.Suite({});
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
|
||||
suite.handleException(new jasmineUnderTest.errors.ExpectationFailed());
|
||||
suite.handleException(new privateUnderTest.errors.ExpectationFailed());
|
||||
|
||||
expect(suite.getResult().failedExpectations).toEqual([]);
|
||||
expect(suite.doneEvent().failedExpectations).toEqual([]);
|
||||
});
|
||||
|
||||
it('forwards late expectation failures to onLateError', function() {
|
||||
const onLateError = jasmine.createSpy('onLateError');
|
||||
const suite = new jasmineUnderTest.Suite({ onLateError });
|
||||
const suite = new privateUnderTest.Suite({ onLateError });
|
||||
const data = {
|
||||
matcherName: '',
|
||||
passed: false,
|
||||
@@ -173,12 +173,12 @@ describe('Suite', function() {
|
||||
message: jasmine.stringMatching(/^Error: nope/)
|
||||
})
|
||||
);
|
||||
expect(suite.result.failedExpectations).toEqual([]);
|
||||
expect(suite.doneEvent().failedExpectations).toEqual([]);
|
||||
});
|
||||
|
||||
it('does not forward non-late expectation failures to onLateError', function() {
|
||||
const onLateError = jasmine.createSpy('onLateError');
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const suite = new privateUnderTest.Suite({
|
||||
onLateError
|
||||
});
|
||||
const data = {
|
||||
@@ -192,12 +192,12 @@ describe('Suite', function() {
|
||||
suite.addExpectationResult(false, data, true);
|
||||
|
||||
expect(onLateError).not.toHaveBeenCalled();
|
||||
expect(suite.result.failedExpectations.length).toEqual(1);
|
||||
expect(suite.doneEvent().failedExpectations.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('forwards late handleException calls to onLateError', function() {
|
||||
const onLateError = jasmine.createSpy('onLateError');
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const suite = new privateUnderTest.Suite({
|
||||
onLateError
|
||||
});
|
||||
const error = new Error('oops');
|
||||
@@ -210,12 +210,12 @@ describe('Suite', function() {
|
||||
message: jasmine.stringMatching(/^Error: oops/)
|
||||
})
|
||||
);
|
||||
expect(suite.result.failedExpectations).toEqual([]);
|
||||
expect(suite.doneEvent().failedExpectations).toEqual([]);
|
||||
});
|
||||
|
||||
it('does not forward non-late handleException calls to onLateError', function() {
|
||||
const onLateError = jasmine.createSpy('onLateError');
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const suite = new privateUnderTest.Suite({
|
||||
onLateError
|
||||
});
|
||||
const error = new Error('oops');
|
||||
@@ -223,11 +223,11 @@ describe('Suite', function() {
|
||||
suite.handleException(error);
|
||||
|
||||
expect(onLateError).not.toHaveBeenCalled();
|
||||
expect(suite.result.failedExpectations.length).toEqual(1);
|
||||
expect(suite.doneEvent().failedExpectations.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('clears the reportedDone flag when reset', function() {
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const suite = new privateUnderTest.Suite({
|
||||
queueableFn: { fn: function() {} }
|
||||
});
|
||||
suite.reportedDone = true;
|
||||
@@ -238,7 +238,7 @@ describe('Suite', function() {
|
||||
});
|
||||
|
||||
it('calls timer to compute duration', function() {
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const suite = new privateUnderTest.Suite({
|
||||
env: env,
|
||||
id: 456,
|
||||
description: 'I am a suite',
|
||||
@@ -246,24 +246,24 @@ describe('Suite', function() {
|
||||
});
|
||||
suite.startTimer();
|
||||
suite.endTimer();
|
||||
expect(suite.getResult().duration).toEqual(77000);
|
||||
expect(suite.doneEvent().duration).toEqual(77000);
|
||||
});
|
||||
|
||||
describe('#sharedUserContext', function() {
|
||||
beforeEach(function() {
|
||||
this.suite = new jasmineUnderTest.Suite({});
|
||||
this.suite = new privateUnderTest.Suite({});
|
||||
});
|
||||
|
||||
it('returns a UserContext', function() {
|
||||
expect(this.suite.sharedUserContext().constructor).toBe(
|
||||
jasmineUnderTest.UserContext
|
||||
privateUnderTest.UserContext
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('attr.autoCleanClosures', function() {
|
||||
function arrangeSuite(attrs) {
|
||||
const suite = new jasmineUnderTest.Suite(attrs);
|
||||
const suite = new privateUnderTest.Suite(attrs);
|
||||
suite.beforeAll(function() {});
|
||||
suite.beforeEach(function() {});
|
||||
suite.afterEach(function() {});
|
||||
@@ -301,21 +301,21 @@ describe('Suite', function() {
|
||||
|
||||
describe('#reset', function() {
|
||||
it('should reset the "pending" status', function() {
|
||||
const suite = new jasmineUnderTest.Suite({});
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
suite.pend();
|
||||
suite.reset();
|
||||
expect(suite.getResult().status).toBe('passed');
|
||||
expect(suite.doneEvent().status).toBe('passed');
|
||||
});
|
||||
|
||||
it('should not reset the "pending" status when the suite was excluded', function() {
|
||||
const suite = new jasmineUnderTest.Suite({});
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
suite.exclude();
|
||||
suite.reset();
|
||||
expect(suite.getResult().status).toBe('pending');
|
||||
expect(suite.doneEvent().status).toBe('pending');
|
||||
});
|
||||
|
||||
it('should also reset the children', function() {
|
||||
const suite = new jasmineUnderTest.Suite({});
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
const child1 = jasmine.createSpyObj(['reset']);
|
||||
const child2 = jasmine.createSpyObj(['reset']);
|
||||
suite.addChild(child1);
|
||||
@@ -328,12 +328,12 @@ describe('Suite', function() {
|
||||
});
|
||||
|
||||
it('should reset the failedExpectations', function() {
|
||||
const suite = new jasmineUnderTest.Suite({});
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
suite.handleException(new Error());
|
||||
|
||||
suite.reset();
|
||||
|
||||
const result = suite.getResult();
|
||||
const result = suite.doneEvent();
|
||||
expect(result.status).toBe('passed');
|
||||
expect(result.failedExpectations).toHaveSize(0);
|
||||
});
|
||||
@@ -342,7 +342,7 @@ describe('Suite', function() {
|
||||
describe('#onMultipleDone', function() {
|
||||
it('reports a special error when it is the top suite', function() {
|
||||
const onLateError = jasmine.createSpy('onLateError');
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const suite = new privateUnderTest.Suite({
|
||||
onLateError,
|
||||
parentSuite: null
|
||||
});
|
||||
@@ -359,7 +359,7 @@ describe('Suite', function() {
|
||||
|
||||
it('reports an error including the suite name when it is a normal suite', function() {
|
||||
const onLateError = jasmine.createSpy('onLateError');
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const suite = new privateUnderTest.Suite({
|
||||
onLateError,
|
||||
description: 'the suite',
|
||||
parentSuite: {
|
||||
@@ -381,7 +381,7 @@ describe('Suite', function() {
|
||||
|
||||
describe('#hasChildWithDescription', function() {
|
||||
it('returns true if there is a child with the given description', function() {
|
||||
const subject = new jasmineUnderTest.Suite({});
|
||||
const subject = new privateUnderTest.Suite({});
|
||||
const description = 'a spec';
|
||||
subject.addChild({ description });
|
||||
|
||||
@@ -389,15 +389,15 @@ describe('Suite', function() {
|
||||
});
|
||||
|
||||
it('returns false if there is no child with the given description', function() {
|
||||
const subject = new jasmineUnderTest.Suite({});
|
||||
const subject = new privateUnderTest.Suite({});
|
||||
subject.addChild({ description: 'a different spec' });
|
||||
|
||||
expect(subject.hasChildWithDescription('a spec')).toBeFalse();
|
||||
});
|
||||
|
||||
it('does not recurse into child suites', function() {
|
||||
const subject = new jasmineUnderTest.Suite({});
|
||||
const childSuite = new jasmineUnderTest.Suite({});
|
||||
const subject = new privateUnderTest.Suite({});
|
||||
const childSuite = new privateUnderTest.Suite({});
|
||||
subject.addChild(childSuite);
|
||||
const description = 'a spec';
|
||||
childSuite.addChild(description);
|
||||
@@ -405,4 +405,62 @@ describe('Suite', function() {
|
||||
expect(subject.hasChildWithDescription('a spec')).toBeFalse();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setSuiteProperty', function() {
|
||||
it('throws if the key is not a string', function() {
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
|
||||
expect(function() {
|
||||
suite.setSuiteProperty({}, '');
|
||||
}).toThrowError('Key must be a string');
|
||||
});
|
||||
|
||||
it('throws if the value is not structured-cloneable', function() {
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
|
||||
expect(function() {
|
||||
suite.setSuiteProperty('k', new Promise(() => {}));
|
||||
}).toThrowError("Value can't be cloned");
|
||||
});
|
||||
|
||||
it('throws if the value is not JSON-serializable', function() {
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
|
||||
expect(function() {
|
||||
const v = {};
|
||||
v.self = v;
|
||||
suite.setSuiteProperty('k', v);
|
||||
}).toThrowError("Value can't be cloned");
|
||||
});
|
||||
});
|
||||
|
||||
describe('#startedEvent', function() {
|
||||
it('includes only properties that are known before execution', function() {
|
||||
const topSuite = new privateUnderTest.Suite({});
|
||||
const parentSuite = new privateUnderTest.Suite({
|
||||
id: 'suite1',
|
||||
parentSuite: topSuite,
|
||||
description: 'a parent suite'
|
||||
});
|
||||
const suite = new privateUnderTest.Suite({
|
||||
id: 'suite2',
|
||||
parentSuite,
|
||||
reportedParentSuiteId: parentSuite.id,
|
||||
description: 'a suite',
|
||||
filename: 'somefile.js',
|
||||
getPath() {
|
||||
return ['a parent suite', 'a spec'];
|
||||
},
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
expect(suite.startedEvent()).toEqual({
|
||||
id: 'suite2',
|
||||
parentSuiteId: 'suite1',
|
||||
description: 'a suite',
|
||||
fullName: 'a parent suite a suite',
|
||||
filename: 'somefile.js'
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -30,4 +30,8 @@ describe('Timer', function() {
|
||||
expect(timer.elapsed()).toEqual(jasmine.any(Number));
|
||||
});
|
||||
});
|
||||
|
||||
isNonMonkeyPatchableClass(jasmineUnderTest.Timer, function() {
|
||||
return new jasmineUnderTest.Timer();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,9 +6,6 @@ describe('TreeProcessor', function() {
|
||||
attrs = attrs || {};
|
||||
this.id = 'node' + nodeNumber++;
|
||||
this.children = attrs.children || [];
|
||||
this.canBeReentered = function() {
|
||||
return !attrs.noReenter;
|
||||
};
|
||||
this.markedPending = attrs.markedPending || false;
|
||||
this.sharedUserContext = function() {
|
||||
return attrs.userContext || {};
|
||||
@@ -28,7 +25,7 @@ describe('TreeProcessor', function() {
|
||||
|
||||
it('processes a single leaf', function() {
|
||||
const leaf = new Leaf(),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
processor = new privateUnderTest.TreeProcessor({
|
||||
tree: leaf,
|
||||
runnableIds: [leaf.id]
|
||||
});
|
||||
@@ -40,7 +37,7 @@ describe('TreeProcessor', function() {
|
||||
|
||||
it('processes a single pending leaf', function() {
|
||||
const leaf = new Leaf({ markedPending: true }),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
processor = new privateUnderTest.TreeProcessor({
|
||||
tree: leaf,
|
||||
runnableIds: [leaf.id]
|
||||
});
|
||||
@@ -52,7 +49,7 @@ describe('TreeProcessor', function() {
|
||||
|
||||
it('processes a single non-specified leaf', function() {
|
||||
const leaf = new Leaf(),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
processor = new privateUnderTest.TreeProcessor({
|
||||
tree: leaf,
|
||||
runnableIds: []
|
||||
});
|
||||
@@ -64,7 +61,7 @@ describe('TreeProcessor', function() {
|
||||
|
||||
it('processes a single excluded leaf', function() {
|
||||
const leaf = new Leaf(),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
processor = new privateUnderTest.TreeProcessor({
|
||||
tree: leaf,
|
||||
runnableIds: [leaf.id],
|
||||
excludeNode: function() {
|
||||
@@ -80,7 +77,7 @@ describe('TreeProcessor', function() {
|
||||
it('processes a tree with a single leaf with the root specified', function() {
|
||||
const leaf = new Leaf(),
|
||||
parent = new Node({ children: [leaf] }),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
processor = new privateUnderTest.TreeProcessor({
|
||||
tree: parent,
|
||||
runnableIds: [parent.id]
|
||||
});
|
||||
@@ -95,7 +92,7 @@ describe('TreeProcessor', function() {
|
||||
it('processes a tree with a single pending leaf, with the root specified', function() {
|
||||
const leaf = new Leaf({ markedPending: true }),
|
||||
parent = new Node({ children: [leaf] }),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
processor = new privateUnderTest.TreeProcessor({
|
||||
tree: parent,
|
||||
runnableIds: [parent.id]
|
||||
});
|
||||
@@ -111,7 +108,7 @@ describe('TreeProcessor', function() {
|
||||
const specified = new Leaf();
|
||||
const nonSpecified = new Leaf();
|
||||
const root = new Node({ children: [nonSpecified, specified] });
|
||||
const processor = new jasmineUnderTest.TreeProcessor({
|
||||
const processor = new privateUnderTest.TreeProcessor({
|
||||
tree: root,
|
||||
runnableIds: [specified.id]
|
||||
});
|
||||
@@ -128,18 +125,16 @@ describe('TreeProcessor', function() {
|
||||
const leaf1 = new Leaf();
|
||||
const node = new Node({ children: [leaf1] });
|
||||
const root = new Node({ children: [node] });
|
||||
const processor = new jasmineUnderTest.TreeProcessor({
|
||||
const processor = new privateUnderTest.TreeProcessor({
|
||||
tree: root,
|
||||
runnableIds: []
|
||||
});
|
||||
|
||||
const result = processor.processTree();
|
||||
|
||||
expect(result.childrenOfTopSuite()).toEqual([
|
||||
{ suite: node, segmentNumber: 0 }
|
||||
]);
|
||||
expect(result.childrenOfTopSuite()).toEqual([{ suite: node }]);
|
||||
expect(result.isExcluded(node)).toEqual(true);
|
||||
expect(result.childrenOfSuiteSegment(node, 0)).toEqual([{ spec: leaf1 }]);
|
||||
expect(result.childrenOfSuite(node)).toEqual([{ spec: leaf1 }]);
|
||||
expect(result.isExcluded(node)).toEqual(true);
|
||||
});
|
||||
|
||||
@@ -158,7 +153,7 @@ describe('TreeProcessor', function() {
|
||||
children: [childless, pendingNode]
|
||||
}),
|
||||
root = new Node({ children: [parent, parentOfPendings] }),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
processor = new privateUnderTest.TreeProcessor({
|
||||
tree: root,
|
||||
runnableIds: [root.id]
|
||||
});
|
||||
@@ -167,99 +162,36 @@ describe('TreeProcessor', function() {
|
||||
|
||||
expect(result.isExcluded(parent)).toEqual(false);
|
||||
expect(result.childrenOfTopSuite()).toEqual([
|
||||
{ suite: parent, segmentNumber: 0 },
|
||||
{ suite: parentOfPendings, segmentNumber: 0 }
|
||||
{ suite: parent },
|
||||
{ suite: parentOfPendings }
|
||||
]);
|
||||
|
||||
expect(result.isExcluded(parentOfPendings)).toEqual(true);
|
||||
expect(result.childrenOfSuiteSegment(parentOfPendings, 0)).toEqual([
|
||||
{ suite: childless, segmentNumber: 0 },
|
||||
{ suite: pendingNode, segmentNumber: 0 }
|
||||
expect(result.childrenOfSuite(parentOfPendings)).toEqual([
|
||||
{ suite: childless },
|
||||
{ suite: pendingNode }
|
||||
]);
|
||||
|
||||
expect(result.isExcluded(childless)).toEqual(true);
|
||||
expect(result.childrenOfSuiteSegment(childless, 0)).toEqual([]);
|
||||
expect(result.childrenOfSuite(childless)).toEqual([]);
|
||||
|
||||
expect(result.isExcluded(pendingLeaf)).toEqual(false);
|
||||
expect(result.isExcluded(executableLeaf)).toEqual(false);
|
||||
|
||||
expect(result.isExcluded(parent)).toEqual(false);
|
||||
expect(result.childrenOfSuiteSegment(parent, 0)).toEqual([
|
||||
expect(result.childrenOfSuite(parent)).toEqual([
|
||||
{ spec: pendingLeaf },
|
||||
{ spec: executableLeaf }
|
||||
]);
|
||||
|
||||
expect(result.isExcluded(pendingNode)).toEqual(true);
|
||||
expect(result.childrenOfSuiteSegment(pendingNode, 0)).toEqual([
|
||||
expect(result.childrenOfSuite(pendingNode)).toEqual([
|
||||
{ spec: childOfPending }
|
||||
]);
|
||||
|
||||
expect(result.isExcluded(childOfPending)).toEqual(false);
|
||||
});
|
||||
|
||||
it('throws if the specified order would re-enter a node that does not allow re-entry', function() {
|
||||
const leaf1 = new Leaf(),
|
||||
leaf2 = new Leaf(),
|
||||
leaf3 = new Leaf(),
|
||||
reentered = new Node({ noReenter: true, children: [leaf1, leaf2] }),
|
||||
root = new Node({ children: [reentered, leaf3] }),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
tree: root,
|
||||
runnableIds: [leaf1.id, leaf3.id, leaf2.id]
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
processor.processTree();
|
||||
}).toThrowError(
|
||||
'Invalid order: would cause a beforeAll or afterAll to be run multiple times'
|
||||
);
|
||||
});
|
||||
|
||||
it('does not throw if a node being re-entered allows re-entry', function() {
|
||||
const leaf1 = new Leaf();
|
||||
const leaf2 = new Leaf();
|
||||
const leaf3 = new Leaf();
|
||||
const reentered = new Node({ children: [leaf1, leaf2] });
|
||||
const root = new Node({ children: [reentered, leaf3] });
|
||||
const processor = new jasmineUnderTest.TreeProcessor({
|
||||
tree: root,
|
||||
runnableIds: [leaf1.id, leaf3.id, leaf2.id]
|
||||
});
|
||||
const env = jasmineUnderTest.getEnv();
|
||||
spyOn(env, 'deprecated');
|
||||
|
||||
processor.processTree();
|
||||
|
||||
expect(env.deprecated).toHaveBeenCalledWith(
|
||||
'The specified spec/suite order splits up a suite, running unrelated specs in the middle of it. This will become an error in a future release.'
|
||||
);
|
||||
});
|
||||
|
||||
it("does not throw if a node which can't be re-entered is only entered once", function() {
|
||||
const leaf1 = new Leaf(),
|
||||
leaf2 = new Leaf(),
|
||||
leaf3 = new Leaf(),
|
||||
noReentry = new Node({ noReenter: true }),
|
||||
root = new Node({ children: [noReentry] }),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
tree: root,
|
||||
runnableIds: [leaf2.id, leaf1.id, leaf3.id]
|
||||
});
|
||||
|
||||
processor.processTree();
|
||||
});
|
||||
|
||||
it("does not throw if a node which can't be re-entered is run directly", function() {
|
||||
const noReentry = new Node({ noReenter: true }),
|
||||
root = new Node({ children: [noReentry] }),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
tree: root,
|
||||
runnableIds: [root.id]
|
||||
});
|
||||
|
||||
processor.processTree();
|
||||
});
|
||||
|
||||
it('orders children according to orderChildren when specified', function() {
|
||||
const leaf1 = new Leaf();
|
||||
const leaf2 = new Leaf();
|
||||
@@ -288,7 +220,7 @@ describe('TreeProcessor', function() {
|
||||
]
|
||||
});
|
||||
const runQueue = jasmine.createSpy('runQueue');
|
||||
const processor = new jasmineUnderTest.TreeProcessor({
|
||||
const processor = new privateUnderTest.TreeProcessor({
|
||||
tree: root,
|
||||
runnableIds: [root.id],
|
||||
runQueue,
|
||||
@@ -314,4 +246,53 @@ describe('TreeProcessor', function() {
|
||||
{ spec: leaf1 }
|
||||
]);
|
||||
});
|
||||
|
||||
describe("The returned ExecutionTree's numExcludedSpecs method", function() {
|
||||
it('counts filtered-out specs', function() {
|
||||
const included = new Leaf();
|
||||
const excluded1 = new Leaf();
|
||||
const excluded2 = new Leaf();
|
||||
const excluded3 = new Leaf();
|
||||
const topSuite = new Node({
|
||||
children: [
|
||||
excluded1,
|
||||
new Node({
|
||||
children: [included, excluded2, new Node({ children: [excluded3] })]
|
||||
})
|
||||
]
|
||||
});
|
||||
const processor = new privateUnderTest.TreeProcessor({
|
||||
tree: topSuite,
|
||||
runnableIds: [topSuite.id],
|
||||
excludeNode(node) {
|
||||
return node.id !== included.id;
|
||||
}
|
||||
});
|
||||
|
||||
const executionTree = processor.processTree();
|
||||
expect(executionTree.numExcludedSpecs()).toEqual(3);
|
||||
});
|
||||
|
||||
it("counts specs that aren't in or descendants of runnableIds", function() {
|
||||
const includedSuite = new Node({
|
||||
children: [new Node({ children: [new Leaf()] }), new Leaf()]
|
||||
});
|
||||
const directlyIncludedSpec = new Leaf();
|
||||
const topSuite = new Node({
|
||||
children: [
|
||||
includedSuite,
|
||||
new Node({
|
||||
children: [new Leaf(), directlyIncludedSpec]
|
||||
})
|
||||
]
|
||||
});
|
||||
const processor = new privateUnderTest.TreeProcessor({
|
||||
tree: topSuite,
|
||||
runnableIds: [includedSuite.id, directlyIncludedSpec.id]
|
||||
});
|
||||
|
||||
const executionTree = processor.processTree();
|
||||
expect(executionTree.numExcludedSpecs()).toEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ describe('TreeRunner', function() {
|
||||
describe('spec execution', function() {
|
||||
it('starts the timer, reports the spec started, and updates run state at the start of the queue', async function() {
|
||||
const timer = jasmine.createSpyObj('timer', ['start']);
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
id: 'spec1',
|
||||
queueableFn: {},
|
||||
timer
|
||||
@@ -28,7 +28,9 @@ describe('TreeRunner', function() {
|
||||
spec.id,
|
||||
spec.parentSuiteId
|
||||
);
|
||||
expect(reportDispatcher.specStarted).toHaveBeenCalledWith(spec.result);
|
||||
expect(reportDispatcher.specStarted).toHaveBeenCalledWith(
|
||||
spec.startedEvent()
|
||||
);
|
||||
await Promise.resolve();
|
||||
expect(reportDispatcher.specStarted).toHaveBeenCalledBefore(next);
|
||||
await expectAsync(executePromise).toBePending();
|
||||
@@ -36,7 +38,7 @@ describe('TreeRunner', function() {
|
||||
|
||||
it('stops the timer, updates run state, and reports the spec done at the end of the queue', async function() {
|
||||
const timer = jasmine.createSpyObj('timer', ['start', 'elapsed']);
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
id: 'spec1',
|
||||
queueableFn: {},
|
||||
timer
|
||||
@@ -61,8 +63,8 @@ describe('TreeRunner', function() {
|
||||
|
||||
expect(currentRunableTracker.currentSpec()).toBeFalsy();
|
||||
expect(runableResources.clearForRunable).toHaveBeenCalledWith(spec.id);
|
||||
expect(reportDispatcher.specDone).toHaveBeenCalledWith(spec.result);
|
||||
expect(spec.result.duration).toEqual('the elapsed time');
|
||||
expect(reportDispatcher.specDone).toHaveBeenCalledWith(spec.doneEvent());
|
||||
expect(spec.doneEvent().duration).toEqual('the elapsed time');
|
||||
expect(spec.reportedDone).toEqual(true);
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
@@ -80,7 +82,7 @@ describe('TreeRunner', function() {
|
||||
expect(after).not.toHaveBeenCalled();
|
||||
})
|
||||
};
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: queueableFn,
|
||||
beforeAndAfterFns: function() {
|
||||
return { befores: [before], afters: [after] };
|
||||
@@ -104,7 +106,7 @@ describe('TreeRunner', function() {
|
||||
spec.pend();
|
||||
}
|
||||
};
|
||||
spec = new jasmineUnderTest.Spec({ queueableFn });
|
||||
spec = new privateUnderTest.Spec({ queueableFn });
|
||||
|
||||
const { runQueue, suiteRunQueueArgs } = runSingleSpecSuite(spec);
|
||||
suiteRunQueueArgs.queueableFns[0].fn();
|
||||
@@ -114,8 +116,8 @@ describe('TreeRunner', function() {
|
||||
expect(specRunQueueArgs.queueableFns[1]).toEqual(queueableFn);
|
||||
queueableFn.fn();
|
||||
|
||||
expect(spec.getResult().status).toEqual('pending');
|
||||
expect(spec.getResult().pendingReason).toEqual('');
|
||||
expect(spec.doneEvent().status).toEqual('pending');
|
||||
expect(spec.doneEvent().pendingReason).toEqual('');
|
||||
});
|
||||
|
||||
it('marks specs pending at runtime with a message', function() {
|
||||
@@ -125,7 +127,7 @@ describe('TreeRunner', function() {
|
||||
spec.pend('some reason');
|
||||
}
|
||||
};
|
||||
spec = new jasmineUnderTest.Spec({ queueableFn });
|
||||
spec = new privateUnderTest.Spec({ queueableFn });
|
||||
|
||||
const { runQueue, suiteRunQueueArgs } = runSingleSpecSuite(spec);
|
||||
suiteRunQueueArgs.queueableFns[0].fn();
|
||||
@@ -135,12 +137,12 @@ describe('TreeRunner', function() {
|
||||
expect(specRunQueueArgs.queueableFns[1]).toEqual(queueableFn);
|
||||
queueableFn.fn();
|
||||
|
||||
expect(spec.getResult().status).toEqual('pending');
|
||||
expect(spec.getResult().pendingReason).toEqual('some reason');
|
||||
expect(spec.doneEvent().status).toEqual('pending');
|
||||
expect(spec.doneEvent().pendingReason).toEqual('some reason');
|
||||
});
|
||||
|
||||
it('passes failSpecWithNoExp to Spec#executionFinished', async function() {
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
id: 'spec1',
|
||||
queueableFn: {}
|
||||
});
|
||||
@@ -166,8 +168,8 @@ describe('TreeRunner', function() {
|
||||
describe('Suite execution', function() {
|
||||
it('reports the duration of the suite', async function() {
|
||||
const timer = jasmine.createSpyObj('timer', ['start', 'elapsed']);
|
||||
const topSuite = new jasmineUnderTest.Suite({ id: 'topSuite' });
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const topSuite = new privateUnderTest.Suite({ id: 'topSuite' });
|
||||
const suite = new privateUnderTest.Suite({
|
||||
id: 'suite1',
|
||||
parentSuite: topSuite,
|
||||
timer
|
||||
@@ -178,7 +180,7 @@ describe('TreeRunner', function() {
|
||||
childrenOfTopSuite() {
|
||||
return [{ suite }];
|
||||
},
|
||||
childrenOfSuiteSegment() {
|
||||
childrenOfSuite() {
|
||||
return [];
|
||||
},
|
||||
isExcluded() {
|
||||
@@ -187,13 +189,13 @@ describe('TreeRunner', function() {
|
||||
};
|
||||
const runQueue = jasmine.createSpy('runQueue');
|
||||
const reportDispatcher = mockReportDispatcher();
|
||||
const subject = new jasmineUnderTest.TreeRunner({
|
||||
const subject = new privateUnderTest.TreeRunner({
|
||||
executionTree,
|
||||
runQueue,
|
||||
globalErrors: mockGlobalErrors(),
|
||||
runableResources: mockRunableResources(),
|
||||
reportDispatcher,
|
||||
currentRunableTracker: new jasmineUnderTest.CurrentRunableTracker(),
|
||||
currentRunableTracker: new privateUnderTest.CurrentRunableTracker(),
|
||||
getConfig() {
|
||||
return {};
|
||||
},
|
||||
@@ -216,7 +218,7 @@ describe('TreeRunner', function() {
|
||||
timer.elapsed.and.returnValue('the duration');
|
||||
suiteRunQueueOpts.onComplete();
|
||||
expect(timer.elapsed).toHaveBeenCalled();
|
||||
const result = suite.getResult();
|
||||
const result = suite.doneEvent();
|
||||
expect(result.duration).toEqual('the duration');
|
||||
expect(reportDispatcher.suiteDone).toHaveBeenCalledWith(result);
|
||||
|
||||
@@ -224,12 +226,12 @@ describe('TreeRunner', function() {
|
||||
});
|
||||
|
||||
it('returns false if a suite failed', async function() {
|
||||
const topSuite = new jasmineUnderTest.Suite({ id: 'topSuite' });
|
||||
const failingSuite = new jasmineUnderTest.Suite({
|
||||
const topSuite = new privateUnderTest.Suite({ id: 'topSuite' });
|
||||
const failingSuite = new privateUnderTest.Suite({
|
||||
id: 'failingSuite',
|
||||
parentSuite: topSuite
|
||||
});
|
||||
const passingSuite = new jasmineUnderTest.Suite({
|
||||
const passingSuite = new privateUnderTest.Suite({
|
||||
id: 'passingSuite',
|
||||
parentSuite: topSuite
|
||||
});
|
||||
@@ -238,7 +240,7 @@ describe('TreeRunner', function() {
|
||||
childrenOfTopSuite() {
|
||||
return [{ suite: failingSuite }, { suite: passingSuite }];
|
||||
},
|
||||
childrenOfSuiteSegment() {
|
||||
childrenOfSuite() {
|
||||
return [];
|
||||
},
|
||||
isExcluded() {
|
||||
@@ -247,13 +249,13 @@ describe('TreeRunner', function() {
|
||||
};
|
||||
const runQueue = jasmine.createSpy('runQueue');
|
||||
const reportDispatcher = mockReportDispatcher();
|
||||
const subject = new jasmineUnderTest.TreeRunner({
|
||||
const subject = new privateUnderTest.TreeRunner({
|
||||
executionTree,
|
||||
runQueue,
|
||||
globalErrors: mockGlobalErrors(),
|
||||
runableResources: mockRunableResources(),
|
||||
reportDispatcher,
|
||||
currentRunableTracker: new jasmineUnderTest.CurrentRunableTracker(),
|
||||
currentRunableTracker: new privateUnderTest.CurrentRunableTracker(),
|
||||
getConfig() {
|
||||
return {};
|
||||
},
|
||||
@@ -288,13 +290,13 @@ describe('TreeRunner', function() {
|
||||
});
|
||||
|
||||
it('reports children when there is a beforeAll failure', async function() {
|
||||
const topSuite = new jasmineUnderTest.Suite({ id: 'topSuite' });
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const topSuite = new privateUnderTest.Suite({ id: 'topSuite' });
|
||||
const suite = new privateUnderTest.Suite({
|
||||
id: 'suite',
|
||||
parentSuite: topSuite
|
||||
});
|
||||
suite.beforeAll({ fn() {} });
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
id: 'spec',
|
||||
parentSuite: suite,
|
||||
queueableFn: { fn() {} }
|
||||
@@ -306,7 +308,7 @@ describe('TreeRunner', function() {
|
||||
childrenOfTopSuite() {
|
||||
return [{ suite }];
|
||||
},
|
||||
childrenOfSuiteSegment() {
|
||||
childrenOfSuite() {
|
||||
return [{ spec }];
|
||||
},
|
||||
isExcluded() {
|
||||
@@ -318,13 +320,13 @@ describe('TreeRunner', function() {
|
||||
const reportChildrenOfBeforeAllFailure = jasmine
|
||||
.createSpy('reportChildrenOfBeforeAllFailure')
|
||||
.and.returnValue(Promise.resolve());
|
||||
const subject = new jasmineUnderTest.TreeRunner({
|
||||
const subject = new privateUnderTest.TreeRunner({
|
||||
executionTree,
|
||||
runQueue,
|
||||
globalErrors: mockGlobalErrors(),
|
||||
runableResources: mockRunableResources(),
|
||||
reportDispatcher,
|
||||
currentRunableTracker: new jasmineUnderTest.CurrentRunableTracker(),
|
||||
currentRunableTracker: new privateUnderTest.CurrentRunableTracker(),
|
||||
reportChildrenOfBeforeAllFailure,
|
||||
getConfig() {
|
||||
return {};
|
||||
@@ -354,12 +356,12 @@ describe('TreeRunner', function() {
|
||||
});
|
||||
|
||||
it('throws if the wrong suite is completed', async function() {
|
||||
const topSuite = new jasmineUnderTest.Suite({ id: 'topSuite' });
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const topSuite = new privateUnderTest.Suite({ id: 'topSuite' });
|
||||
const suite = new privateUnderTest.Suite({
|
||||
id: 'suite',
|
||||
parentSuite: topSuite
|
||||
});
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
id: 'spec',
|
||||
parentSuite: suite,
|
||||
queueableFn: { fn() {} }
|
||||
@@ -369,7 +371,7 @@ describe('TreeRunner', function() {
|
||||
childrenOfTopSuite() {
|
||||
return [{ suite }];
|
||||
},
|
||||
childrenOfSuiteSegment() {
|
||||
childrenOfSuite() {
|
||||
return [{ spec }];
|
||||
},
|
||||
isExcluded() {
|
||||
@@ -378,13 +380,13 @@ describe('TreeRunner', function() {
|
||||
};
|
||||
const runQueue = jasmine.createSpy('runQueue');
|
||||
const reportDispatcher = mockReportDispatcher();
|
||||
const subject = new jasmineUnderTest.TreeRunner({
|
||||
const subject = new privateUnderTest.TreeRunner({
|
||||
executionTree,
|
||||
runQueue,
|
||||
globalErrors: mockGlobalErrors(),
|
||||
runableResources: mockRunableResources(),
|
||||
reportDispatcher,
|
||||
currentRunableTracker: new jasmineUnderTest.CurrentRunableTracker(),
|
||||
currentRunableTracker: new privateUnderTest.CurrentRunableTracker(),
|
||||
getConfig() {
|
||||
return {};
|
||||
},
|
||||
@@ -410,7 +412,7 @@ describe('TreeRunner', function() {
|
||||
});
|
||||
|
||||
it('does not remove before and after fns from the top suite', async function() {
|
||||
const topSuite = new jasmineUnderTest.Suite({ id: 'topSuite' });
|
||||
const topSuite = new privateUnderTest.Suite({ id: 'topSuite' });
|
||||
spyOn(topSuite, 'cleanupBeforeAfter');
|
||||
const executionTree = {
|
||||
topSuite,
|
||||
@@ -422,13 +424,13 @@ describe('TreeRunner', function() {
|
||||
}
|
||||
};
|
||||
const runQueue = jasmine.createSpy('runQueue');
|
||||
const subject = new jasmineUnderTest.TreeRunner({
|
||||
const subject = new privateUnderTest.TreeRunner({
|
||||
executionTree,
|
||||
runQueue,
|
||||
globalErrors: mockGlobalErrors(),
|
||||
runableResources: mockRunableResources(),
|
||||
reportDispatcher: mockReportDispatcher(),
|
||||
currentRunableTracker: new jasmineUnderTest.CurrentRunableTracker(),
|
||||
currentRunableTracker: new privateUnderTest.CurrentRunableTracker(),
|
||||
getConfig() {
|
||||
return {};
|
||||
}
|
||||
@@ -458,7 +460,7 @@ describe('TreeRunner', function() {
|
||||
expect(after).not.toHaveBeenCalled();
|
||||
})
|
||||
};
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn,
|
||||
beforeAndAfterFns: function() {
|
||||
return { befores: [before], afters: [after] };
|
||||
@@ -502,13 +504,13 @@ describe('TreeRunner', function() {
|
||||
});
|
||||
|
||||
it('works for beforeAll when the detectLateRejectionHandling param is true', async function() {
|
||||
const topSuite = new jasmineUnderTest.Suite({ id: 'topSuite' });
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const topSuite = new privateUnderTest.Suite({ id: 'topSuite' });
|
||||
const suite = new privateUnderTest.Suite({
|
||||
id: 'suite',
|
||||
parentSuite: topSuite
|
||||
});
|
||||
suite.beforeAll(function() {});
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn() {} },
|
||||
parentSuite: suite
|
||||
});
|
||||
@@ -517,7 +519,7 @@ describe('TreeRunner', function() {
|
||||
childrenOfTopSuite() {
|
||||
return [{ suite }];
|
||||
},
|
||||
childrenOfSuiteSegment() {
|
||||
childrenOfSuite() {
|
||||
return [{ spec }];
|
||||
},
|
||||
isExcluded() {
|
||||
@@ -528,14 +530,14 @@ describe('TreeRunner', function() {
|
||||
const reportDispatcher = mockReportDispatcher();
|
||||
const globalErrors = mockGlobalErrors();
|
||||
const setTimeout = jasmine.createSpy('setTimeout');
|
||||
const subject = new jasmineUnderTest.TreeRunner({
|
||||
const subject = new privateUnderTest.TreeRunner({
|
||||
executionTree,
|
||||
runQueue,
|
||||
globalErrors,
|
||||
runableResources: mockRunableResources(),
|
||||
reportDispatcher,
|
||||
setTimeout,
|
||||
currentRunableTracker: new jasmineUnderTest.CurrentRunableTracker(),
|
||||
currentRunableTracker: new privateUnderTest.CurrentRunableTracker(),
|
||||
getConfig() {
|
||||
return { detectLateRejectionHandling: true };
|
||||
},
|
||||
@@ -571,13 +573,13 @@ describe('TreeRunner', function() {
|
||||
});
|
||||
|
||||
it('works for afterAll when the detectLateRejectionHandling param is true', async function() {
|
||||
const topSuite = new jasmineUnderTest.Suite({ id: 'topSuite' });
|
||||
const suite = new jasmineUnderTest.Suite({
|
||||
const topSuite = new privateUnderTest.Suite({ id: 'topSuite' });
|
||||
const suite = new privateUnderTest.Suite({
|
||||
id: 'suite',
|
||||
parentSuite: topSuite
|
||||
});
|
||||
suite.afterAll(function() {});
|
||||
const spec = new jasmineUnderTest.Spec({
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn() {} },
|
||||
parentSuite: suite
|
||||
});
|
||||
@@ -586,7 +588,7 @@ describe('TreeRunner', function() {
|
||||
childrenOfTopSuite() {
|
||||
return [{ suite }];
|
||||
},
|
||||
childrenOfSuiteSegment() {
|
||||
childrenOfSuite() {
|
||||
return [{ spec }];
|
||||
},
|
||||
isExcluded() {
|
||||
@@ -597,14 +599,14 @@ describe('TreeRunner', function() {
|
||||
const reportDispatcher = mockReportDispatcher();
|
||||
const globalErrors = mockGlobalErrors();
|
||||
const setTimeout = jasmine.createSpy('setTimeout');
|
||||
const subject = new jasmineUnderTest.TreeRunner({
|
||||
const subject = new privateUnderTest.TreeRunner({
|
||||
executionTree,
|
||||
runQueue,
|
||||
globalErrors,
|
||||
runableResources: mockRunableResources(),
|
||||
reportDispatcher,
|
||||
setTimeout,
|
||||
currentRunableTracker: new jasmineUnderTest.CurrentRunableTracker(),
|
||||
currentRunableTracker: new privateUnderTest.CurrentRunableTracker(),
|
||||
getConfig() {
|
||||
return { detectLateRejectionHandling: true };
|
||||
},
|
||||
@@ -643,7 +645,7 @@ describe('TreeRunner', function() {
|
||||
function runSingleSpecSuite(spec, optionalConfig) {
|
||||
const topSuiteId = 'suite1';
|
||||
spec.parentSuiteId = topSuiteId;
|
||||
const topSuite = new jasmineUnderTest.Suite({ id: topSuiteId });
|
||||
const topSuite = new privateUnderTest.Suite({ id: topSuiteId });
|
||||
topSuite.addChild(spec);
|
||||
const executionTree = {
|
||||
topSuite,
|
||||
@@ -659,8 +661,8 @@ describe('TreeRunner', function() {
|
||||
const runableResources = mockRunableResources();
|
||||
const globalErrors = mockGlobalErrors();
|
||||
const setTimeout = jasmine.createSpy('setTimeout');
|
||||
const currentRunableTracker = new jasmineUnderTest.CurrentRunableTracker();
|
||||
const subject = new jasmineUnderTest.TreeRunner({
|
||||
const currentRunableTracker = new privateUnderTest.CurrentRunableTracker();
|
||||
const subject = new privateUnderTest.TreeRunner({
|
||||
executionTree,
|
||||
runQueue,
|
||||
globalErrors,
|
||||
@@ -694,10 +696,10 @@ describe('TreeRunner', function() {
|
||||
function mockReportDispatcher() {
|
||||
const reportDispatcher = jasmine.createSpyObj(
|
||||
'reportDispatcher',
|
||||
jasmineUnderTest.reporterEvents
|
||||
privateUnderTest.reporterEvents
|
||||
);
|
||||
|
||||
for (const k of jasmineUnderTest.reporterEvents) {
|
||||
for (const k of privateUnderTest.reporterEvents) {
|
||||
reportDispatcher[k].and.returnValue(Promise.resolve());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
describe('UserContext', function() {
|
||||
it('Behaves just like an plain object', function() {
|
||||
const context = new jasmineUnderTest.UserContext(),
|
||||
const context = new privateUnderTest.UserContext(),
|
||||
properties = [];
|
||||
|
||||
for (const prop in context) {
|
||||
@@ -15,9 +15,9 @@ describe('UserContext', function() {
|
||||
describe('.fromExisting', function() {
|
||||
describe('when using an already built context as model', function() {
|
||||
beforeEach(function() {
|
||||
this.context = new jasmineUnderTest.UserContext();
|
||||
this.context = new privateUnderTest.UserContext();
|
||||
this.context.key = 'value';
|
||||
this.cloned = jasmineUnderTest.UserContext.fromExisting(this.context);
|
||||
this.cloned = privateUnderTest.UserContext.fromExisting(this.context);
|
||||
});
|
||||
|
||||
it('returns a cloned object', function() {
|
||||
@@ -34,7 +34,7 @@ describe('UserContext', function() {
|
||||
this.context = {};
|
||||
this.value = 'value';
|
||||
this.context.key = this.value;
|
||||
this.cloned = jasmineUnderTest.UserContext.fromExisting(this.context);
|
||||
this.cloned = privateUnderTest.UserContext.fromExisting(this.context);
|
||||
});
|
||||
|
||||
it('returns an object with the same attributes', function() {
|
||||
@@ -46,7 +46,7 @@ describe('UserContext', function() {
|
||||
});
|
||||
|
||||
it('returns an UserContext', function() {
|
||||
expect(this.cloned.constructor).toBe(jasmineUnderTest.UserContext);
|
||||
expect(this.cloned.constructor).toBe(privateUnderTest.UserContext);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,33 +1,17 @@
|
||||
describe('util', function() {
|
||||
describe('isArray_', function() {
|
||||
it('should return true if the argument is an array', function() {
|
||||
expect(jasmineUnderTest.isArray_([])).toBe(true);
|
||||
expect(jasmineUnderTest.isArray_(['a'])).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false if the argument is not an array', function() {
|
||||
expect(jasmineUnderTest.isArray_(undefined)).toBe(false);
|
||||
expect(jasmineUnderTest.isArray_({})).toBe(false);
|
||||
expect(jasmineUnderTest.isArray_(function() {})).toBe(false);
|
||||
expect(jasmineUnderTest.isArray_('foo')).toBe(false);
|
||||
expect(jasmineUnderTest.isArray_(5)).toBe(false);
|
||||
expect(jasmineUnderTest.isArray_(null)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isObject_', function() {
|
||||
describe('isObject', function() {
|
||||
it('should return true if the argument is an object', function() {
|
||||
expect(jasmineUnderTest.isObject_({})).toBe(true);
|
||||
expect(jasmineUnderTest.isObject_({ an: 'object' })).toBe(true);
|
||||
expect(privateUnderTest.isObject({})).toBe(true);
|
||||
expect(privateUnderTest.isObject({ an: 'object' })).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false if the argument is not an object', function() {
|
||||
expect(jasmineUnderTest.isObject_(undefined)).toBe(false);
|
||||
expect(jasmineUnderTest.isObject_([])).toBe(false);
|
||||
expect(jasmineUnderTest.isObject_(function() {})).toBe(false);
|
||||
expect(jasmineUnderTest.isObject_('foo')).toBe(false);
|
||||
expect(jasmineUnderTest.isObject_(5)).toBe(false);
|
||||
expect(jasmineUnderTest.isObject_(null)).toBe(false);
|
||||
expect(privateUnderTest.isObject(undefined)).toBe(false);
|
||||
expect(privateUnderTest.isObject([])).toBe(false);
|
||||
expect(privateUnderTest.isObject(function() {})).toBe(false);
|
||||
expect(privateUnderTest.isObject('foo')).toBe(false);
|
||||
expect(privateUnderTest.isObject(5)).toBe(false);
|
||||
expect(privateUnderTest.isObject(null)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -45,119 +29,121 @@ describe('util', function() {
|
||||
|
||||
describe('isPromise', function() {
|
||||
it('should return true when passed a native promise', function() {
|
||||
expect(jasmineUnderTest.isPromise(mockNativePromise)).toBe(true);
|
||||
expect(privateUnderTest.isPromise(mockNativePromise)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for promise like objects', function() {
|
||||
expect(jasmineUnderTest.isPromise(mockPromiseLikeObject)).toBe(false);
|
||||
expect(privateUnderTest.isPromise(mockPromiseLikeObject)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for strings', function() {
|
||||
expect(jasmineUnderTest.isPromise('hello')).toBe(false);
|
||||
expect(privateUnderTest.isPromise('hello')).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for numbers', function() {
|
||||
expect(jasmineUnderTest.isPromise(3)).toBe(false);
|
||||
expect(privateUnderTest.isPromise(3)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for null', function() {
|
||||
expect(jasmineUnderTest.isPromise(null)).toBe(false);
|
||||
expect(privateUnderTest.isPromise(null)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for undefined', function() {
|
||||
expect(jasmineUnderTest.isPromise(undefined)).toBe(false);
|
||||
expect(privateUnderTest.isPromise(undefined)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for arrays', function() {
|
||||
expect(jasmineUnderTest.isPromise([])).toBe(false);
|
||||
expect(privateUnderTest.isPromise([])).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for objects', function() {
|
||||
expect(jasmineUnderTest.isPromise({})).toBe(false);
|
||||
expect(privateUnderTest.isPromise({})).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for boolean values', function() {
|
||||
expect(jasmineUnderTest.isPromise(true)).toBe(false);
|
||||
expect(privateUnderTest.isPromise(true)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isPromiseLike', function() {
|
||||
it('should return true when passed a native promise', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike(mockNativePromise)).toBe(true);
|
||||
expect(privateUnderTest.isPromiseLike(mockNativePromise)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true for promise like objects', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike(mockPromiseLikeObject)).toBe(
|
||||
expect(privateUnderTest.isPromiseLike(mockPromiseLikeObject)).toBe(
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
it('should return false if then is not a function', function() {
|
||||
expect(
|
||||
jasmineUnderTest.isPromiseLike({ then: { its: 'Not a function :O' } })
|
||||
privateUnderTest.isPromiseLike({
|
||||
then: { its: 'Not a function :O' }
|
||||
})
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for strings', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike('hello')).toBe(false);
|
||||
expect(privateUnderTest.isPromiseLike('hello')).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for numbers', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike(3)).toBe(false);
|
||||
expect(privateUnderTest.isPromiseLike(3)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for null', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike(null)).toBe(false);
|
||||
expect(privateUnderTest.isPromiseLike(null)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for undefined', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike(undefined)).toBe(false);
|
||||
expect(privateUnderTest.isPromiseLike(undefined)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for arrays', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike([])).toBe(false);
|
||||
expect(privateUnderTest.isPromiseLike([])).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for objects', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike({})).toBe(false);
|
||||
expect(privateUnderTest.isPromiseLike({})).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for boolean values', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike(true)).toBe(false);
|
||||
expect(privateUnderTest.isPromiseLike(true)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('cloneArgs', function() {
|
||||
it('clones primitives as-is', function() {
|
||||
expect(jasmineUnderTest.util.cloneArgs([true, false])).toEqual([
|
||||
expect(privateUnderTest.util.cloneArgs([true, false])).toEqual([
|
||||
true,
|
||||
false
|
||||
]);
|
||||
expect(jasmineUnderTest.util.cloneArgs([0, 1])).toEqual([0, 1]);
|
||||
expect(jasmineUnderTest.util.cloneArgs(['str'])).toEqual(['str']);
|
||||
expect(privateUnderTest.util.cloneArgs([0, 1])).toEqual([0, 1]);
|
||||
expect(privateUnderTest.util.cloneArgs(['str'])).toEqual(['str']);
|
||||
});
|
||||
|
||||
it('clones Regexp objects as-is', function() {
|
||||
const regex = /match/;
|
||||
expect(jasmineUnderTest.util.cloneArgs([regex])).toEqual([regex]);
|
||||
expect(privateUnderTest.util.cloneArgs([regex])).toEqual([regex]);
|
||||
});
|
||||
|
||||
it('clones Date objects as-is', function() {
|
||||
const date = new Date(2022, 1, 1);
|
||||
expect(jasmineUnderTest.util.cloneArgs([date])).toEqual([date]);
|
||||
expect(privateUnderTest.util.cloneArgs([date])).toEqual([date]);
|
||||
});
|
||||
|
||||
it('clones null and undefined', function() {
|
||||
expect(jasmineUnderTest.util.cloneArgs([null])).toEqual([null]);
|
||||
expect(jasmineUnderTest.util.cloneArgs([undefined])).toEqual([undefined]);
|
||||
expect(privateUnderTest.util.cloneArgs([null])).toEqual([null]);
|
||||
expect(privateUnderTest.util.cloneArgs([undefined])).toEqual([undefined]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getPropertyDescriptor', function() {
|
||||
it('get property descriptor from object', function() {
|
||||
const obj = { prop: 1 },
|
||||
actual = jasmineUnderTest.util.getPropertyDescriptor(obj, 'prop'),
|
||||
actual = privateUnderTest.util.getPropertyDescriptor(obj, 'prop'),
|
||||
expected = Object.getOwnPropertyDescriptor(obj, 'prop');
|
||||
|
||||
expect(actual).toEqual(expected);
|
||||
@@ -165,7 +151,7 @@ describe('util', function() {
|
||||
|
||||
it('get property descriptor from object property', function() {
|
||||
const proto = { prop: 1 },
|
||||
actual = jasmineUnderTest.util.getPropertyDescriptor(proto, 'prop'),
|
||||
actual = privateUnderTest.util.getPropertyDescriptor(proto, 'prop'),
|
||||
expected = Object.getOwnPropertyDescriptor(proto, 'prop');
|
||||
|
||||
expect(actual).toEqual(expected);
|
||||
@@ -176,8 +162,7 @@ describe('util', function() {
|
||||
it('returns the file containing jasmine.util', function() {
|
||||
// Chrome sometimes reports foo.js as foo.js/, so tolerate
|
||||
// a trailing slash if present.
|
||||
expect(jasmineUnderTest.util.jasmineFile()).toMatch(/util.js\/?$/);
|
||||
expect(jasmine.util.jasmineFile()).toMatch(/jasmine.js\/?$/);
|
||||
expect(privateUnderTest.util.jasmineFile()).toMatch(/util.js\/?$/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
63
spec/core/asymmetric_equality/AllOfSpec.js
Normal file
63
spec/core/asymmetric_equality/AllOfSpec.js
Normal file
@@ -0,0 +1,63 @@
|
||||
describe('AllOf', function() {
|
||||
it('matches a single value', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const allOf = new privateUnderTest.AllOf('foo');
|
||||
|
||||
expect(allOf.asymmetricMatch('foo', matchersUtil)).toBeTrue();
|
||||
});
|
||||
|
||||
it('matches a single matcher', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const allOf = new privateUnderTest.AllOf(
|
||||
new privateUnderTest.StringContaining('oo')
|
||||
);
|
||||
|
||||
expect(allOf.asymmetricMatch('foo', matchersUtil)).toBeTrue();
|
||||
});
|
||||
|
||||
it('matches multiple matchers', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const allOf = new privateUnderTest.AllOf(
|
||||
new privateUnderTest.StringContaining('o'),
|
||||
new privateUnderTest.StringContaining('f')
|
||||
);
|
||||
|
||||
expect(allOf.asymmetricMatch('foo', matchersUtil)).toBeTrue();
|
||||
});
|
||||
|
||||
it('does not match when value does not match', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const allOf = new privateUnderTest.AllOf('bar');
|
||||
|
||||
expect(allOf.asymmetricMatch('foo', matchersUtil)).toBeFalse();
|
||||
});
|
||||
|
||||
it('does not match when any matchers fail', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const allOf = new privateUnderTest.AllOf(
|
||||
new privateUnderTest.StringContaining('o'),
|
||||
new privateUnderTest.StringContaining('x')
|
||||
);
|
||||
|
||||
expect(allOf.asymmetricMatch('foo', matchersUtil)).toBeFalse();
|
||||
});
|
||||
|
||||
it('jasmineToStrings itself', function() {
|
||||
const matcher = new privateUnderTest.AllOf('o');
|
||||
const pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||
|
||||
expect(matcher.jasmineToString(pp)).toEqual('<jasmine.allOf(sample)>');
|
||||
expect(pp).toHaveBeenCalledWith(['o']);
|
||||
});
|
||||
|
||||
describe('when called without an argument', function() {
|
||||
it('tells the user to pass a constructor argument', function() {
|
||||
expect(function() {
|
||||
new privateUnderTest.AllOf();
|
||||
}).toThrowError(
|
||||
TypeError,
|
||||
'jasmine.allOf() expects at least one argument to be passed.'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,73 +1,73 @@
|
||||
describe('Any', function() {
|
||||
it('matches a string', function() {
|
||||
const any = new jasmineUnderTest.Any(String);
|
||||
const any = new privateUnderTest.Any(String);
|
||||
|
||||
expect(any.asymmetricMatch('foo')).toBe(true);
|
||||
});
|
||||
|
||||
it('matches a number', function() {
|
||||
const any = new jasmineUnderTest.Any(Number);
|
||||
const any = new privateUnderTest.Any(Number);
|
||||
|
||||
expect(any.asymmetricMatch(1)).toBe(true);
|
||||
});
|
||||
|
||||
it('matches a function', function() {
|
||||
const any = new jasmineUnderTest.Any(Function);
|
||||
const any = new privateUnderTest.Any(Function);
|
||||
|
||||
expect(any.asymmetricMatch(function() {})).toBe(true);
|
||||
});
|
||||
|
||||
it('matches an Object', function() {
|
||||
const any = new jasmineUnderTest.Any(Object);
|
||||
const any = new privateUnderTest.Any(Object);
|
||||
|
||||
expect(any.asymmetricMatch({})).toBe(true);
|
||||
});
|
||||
|
||||
it('matches a Boolean', function() {
|
||||
const any = new jasmineUnderTest.Any(Boolean);
|
||||
const any = new privateUnderTest.Any(Boolean);
|
||||
|
||||
expect(any.asymmetricMatch(true)).toBe(true);
|
||||
});
|
||||
|
||||
it('matches a Map', function() {
|
||||
const any = new jasmineUnderTest.Any(Map);
|
||||
const any = new privateUnderTest.Any(Map);
|
||||
|
||||
expect(any.asymmetricMatch(new Map())).toBe(true);
|
||||
});
|
||||
|
||||
it('matches a Set', function() {
|
||||
const any = new jasmineUnderTest.Any(Set);
|
||||
const any = new privateUnderTest.Any(Set);
|
||||
|
||||
expect(any.asymmetricMatch(new Set())).toBe(true);
|
||||
});
|
||||
|
||||
it('matches a TypedArray', function() {
|
||||
const any = new jasmineUnderTest.Any(Uint32Array);
|
||||
const any = new privateUnderTest.Any(Uint32Array);
|
||||
|
||||
expect(any.asymmetricMatch(new Uint32Array([]))).toBe(true);
|
||||
});
|
||||
|
||||
it('matches a Symbol', function() {
|
||||
const any = new jasmineUnderTest.Any(Symbol);
|
||||
const any = new privateUnderTest.Any(Symbol);
|
||||
|
||||
expect(any.asymmetricMatch(Symbol())).toBe(true);
|
||||
});
|
||||
|
||||
it('matches another constructed object', function() {
|
||||
const Thing = function() {},
|
||||
any = new jasmineUnderTest.Any(Thing);
|
||||
any = new privateUnderTest.Any(Thing);
|
||||
|
||||
expect(any.asymmetricMatch(new Thing())).toBe(true);
|
||||
});
|
||||
|
||||
it('does not treat null as an Object', function() {
|
||||
const any = new jasmineUnderTest.Any(Object);
|
||||
const any = new privateUnderTest.Any(Object);
|
||||
|
||||
expect(any.asymmetricMatch(null)).toBe(false);
|
||||
});
|
||||
|
||||
it("jasmineToString's itself", function() {
|
||||
const any = new jasmineUnderTest.Any(Number);
|
||||
const any = new privateUnderTest.Any(Number);
|
||||
|
||||
expect(any.jasmineToString()).toEqual('<jasmine.any(Number)>');
|
||||
expect(any.jasmineToString()).toEqual('<jasmine.any(Number)>');
|
||||
@@ -76,7 +76,7 @@ describe('Any', function() {
|
||||
describe('when called without an argument', function() {
|
||||
it('tells the user to pass a constructor or use jasmine.anything()', function() {
|
||||
expect(function() {
|
||||
new jasmineUnderTest.Any();
|
||||
new privateUnderTest.Any();
|
||||
}).toThrowError(TypeError, /constructor.*anything/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,67 +1,67 @@
|
||||
describe('Anything', function() {
|
||||
it('matches a string', function() {
|
||||
const anything = new jasmineUnderTest.Anything();
|
||||
const anything = new privateUnderTest.Anything();
|
||||
|
||||
expect(anything.asymmetricMatch('foo')).toBe(true);
|
||||
});
|
||||
|
||||
it('matches a number', function() {
|
||||
const anything = new jasmineUnderTest.Anything();
|
||||
const anything = new privateUnderTest.Anything();
|
||||
|
||||
expect(anything.asymmetricMatch(42)).toBe(true);
|
||||
});
|
||||
|
||||
it('matches an object', function() {
|
||||
const anything = new jasmineUnderTest.Anything();
|
||||
const anything = new privateUnderTest.Anything();
|
||||
|
||||
expect(anything.asymmetricMatch({ foo: 'bar' })).toBe(true);
|
||||
});
|
||||
|
||||
it('matches an array', function() {
|
||||
const anything = new jasmineUnderTest.Anything();
|
||||
const anything = new privateUnderTest.Anything();
|
||||
|
||||
expect(anything.asymmetricMatch([1, 2, 3])).toBe(true);
|
||||
});
|
||||
|
||||
it('matches a Map', function() {
|
||||
const anything = new jasmineUnderTest.Anything();
|
||||
const anything = new privateUnderTest.Anything();
|
||||
|
||||
expect(anything.asymmetricMatch(new Map())).toBe(true);
|
||||
});
|
||||
|
||||
it('matches a Set', function() {
|
||||
const anything = new jasmineUnderTest.Anything();
|
||||
const anything = new privateUnderTest.Anything();
|
||||
|
||||
expect(anything.asymmetricMatch(new Set())).toBe(true);
|
||||
});
|
||||
|
||||
it('matches a TypedArray', function() {
|
||||
const anything = new jasmineUnderTest.Anything();
|
||||
const anything = new privateUnderTest.Anything();
|
||||
|
||||
expect(anything.asymmetricMatch(new Uint32Array([]))).toBe(true);
|
||||
});
|
||||
|
||||
it('matches a Symbol', function() {
|
||||
const anything = new jasmineUnderTest.Anything();
|
||||
const anything = new privateUnderTest.Anything();
|
||||
|
||||
expect(anything.asymmetricMatch(Symbol())).toBe(true);
|
||||
});
|
||||
|
||||
it("doesn't match undefined", function() {
|
||||
const anything = new jasmineUnderTest.Anything();
|
||||
const anything = new privateUnderTest.Anything();
|
||||
|
||||
expect(anything.asymmetricMatch()).toBe(false);
|
||||
expect(anything.asymmetricMatch(undefined)).toBe(false);
|
||||
});
|
||||
|
||||
it("doesn't match null", function() {
|
||||
const anything = new jasmineUnderTest.Anything();
|
||||
const anything = new privateUnderTest.Anything();
|
||||
|
||||
expect(anything.asymmetricMatch(null)).toBe(false);
|
||||
});
|
||||
|
||||
it("jasmineToString's itself", function() {
|
||||
const anything = new jasmineUnderTest.Anything();
|
||||
const anything = new privateUnderTest.Anything();
|
||||
|
||||
expect(anything.jasmineToString()).toEqual('<jasmine.anything>');
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
describe('ArrayContaining', function() {
|
||||
it('matches any actual to an empty array', function() {
|
||||
const containing = new jasmineUnderTest.ArrayContaining([]);
|
||||
const containing = new privateUnderTest.ArrayContaining([]);
|
||||
|
||||
expect(containing.asymmetricMatch('foo')).toBe(true);
|
||||
});
|
||||
|
||||
it('does not work when not passed an array', function() {
|
||||
const containing = new jasmineUnderTest.ArrayContaining('foo');
|
||||
const containing = new privateUnderTest.ArrayContaining('foo');
|
||||
|
||||
expect(function() {
|
||||
containing.asymmetricMatch([]);
|
||||
@@ -14,36 +14,36 @@ describe('ArrayContaining', function() {
|
||||
});
|
||||
|
||||
it('matches when the item is in the actual', function() {
|
||||
const containing = new jasmineUnderTest.ArrayContaining(['foo']);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.ArrayContaining(['foo']);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch(['foo'], matchersUtil)).toBe(true);
|
||||
});
|
||||
|
||||
it('matches when additional items are in the actual', function() {
|
||||
const containing = new jasmineUnderTest.ArrayContaining(['foo']);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.ArrayContaining(['foo']);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch(['foo', 'bar'], matchersUtil)).toBe(true);
|
||||
});
|
||||
|
||||
it('does not match when the item is not in the actual', function() {
|
||||
const containing = new jasmineUnderTest.ArrayContaining(['foo']);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.ArrayContaining(['foo']);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch(['bar'], matchersUtil)).toBe(false);
|
||||
});
|
||||
|
||||
it('does not match when the actual is not an array', function() {
|
||||
const containing = new jasmineUnderTest.ArrayContaining(['foo']);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.ArrayContaining(['foo']);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch('foo', matchersUtil)).toBe(false);
|
||||
});
|
||||
|
||||
it('jasmineToStrings itself', function() {
|
||||
const sample = [],
|
||||
matcher = new jasmineUnderTest.ArrayContaining(sample),
|
||||
matcher = new privateUnderTest.ArrayContaining(sample),
|
||||
pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||
|
||||
expect(matcher.jasmineToString(pp)).toEqual(
|
||||
@@ -64,8 +64,8 @@ describe('ArrayContaining', function() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
const containing = new jasmineUnderTest.ArrayContaining(['fooVal']);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
const containing = new privateUnderTest.ArrayContaining(['fooVal']);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
customTesters: [tester]
|
||||
});
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
describe('ArrayWithExactContents', function() {
|
||||
it('matches an array with the same items in a different order', function() {
|
||||
const matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const matcher = new privateUnderTest.ArrayWithExactContents(['a', 2, /a/]);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(matcher.asymmetricMatch([2, 'a', /a/], matchersUtil)).toBe(true);
|
||||
});
|
||||
|
||||
it('does not work when not passed an array', function() {
|
||||
const matcher = new jasmineUnderTest.ArrayWithExactContents('foo');
|
||||
const matcher = new privateUnderTest.ArrayWithExactContents('foo');
|
||||
|
||||
expect(function() {
|
||||
matcher.asymmetricMatch([]);
|
||||
@@ -15,8 +15,8 @@ describe('ArrayWithExactContents', function() {
|
||||
});
|
||||
|
||||
it('does not match when an item is missing', function() {
|
||||
const matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const matcher = new privateUnderTest.ArrayWithExactContents(['a', 2, /a/]);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(matcher.asymmetricMatch(['a', 2], matchersUtil)).toBe(false);
|
||||
expect(matcher.asymmetricMatch(['a', 2, undefined], matchersUtil)).toBe(
|
||||
@@ -25,15 +25,15 @@ describe('ArrayWithExactContents', function() {
|
||||
});
|
||||
|
||||
it('does not match when there is an extra item', function() {
|
||||
const matcher = new jasmineUnderTest.ArrayWithExactContents(['a']);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const matcher = new privateUnderTest.ArrayWithExactContents(['a']);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(matcher.asymmetricMatch(['a', 2], matchersUtil)).toBe(false);
|
||||
});
|
||||
|
||||
it('jasmineToStrings itself', function() {
|
||||
const sample = [],
|
||||
matcher = new jasmineUnderTest.ArrayWithExactContents(sample),
|
||||
matcher = new privateUnderTest.ArrayWithExactContents(sample),
|
||||
pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||
|
||||
expect(matcher.jasmineToString(pp)).toEqual(
|
||||
@@ -54,8 +54,8 @@ describe('ArrayWithExactContents', function() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
const matcher = new jasmineUnderTest.ArrayWithExactContents(['fooVal']);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
const matcher = new privateUnderTest.ArrayWithExactContents(['fooVal']);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
customTesters: [tester]
|
||||
});
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
describe('Empty', function() {
|
||||
it('matches an empty object', function() {
|
||||
const empty = new jasmineUnderTest.Empty();
|
||||
const empty = new privateUnderTest.Empty();
|
||||
|
||||
expect(empty.asymmetricMatch({})).toBe(true);
|
||||
expect(empty.asymmetricMatch({ undefined: false })).toBe(false);
|
||||
});
|
||||
|
||||
it('matches an empty array', function() {
|
||||
const empty = new jasmineUnderTest.Empty();
|
||||
const empty = new privateUnderTest.Empty();
|
||||
|
||||
expect(empty.asymmetricMatch([])).toBe(true);
|
||||
expect(empty.asymmetricMatch([1, 12, 3])).toBe(false);
|
||||
});
|
||||
|
||||
it('matches an empty string', function() {
|
||||
const empty = new jasmineUnderTest.Empty();
|
||||
const empty = new privateUnderTest.Empty();
|
||||
|
||||
expect(empty.asymmetricMatch('')).toBe(true);
|
||||
expect(empty.asymmetricMatch('')).toBe(true);
|
||||
@@ -22,7 +22,7 @@ describe('Empty', function() {
|
||||
});
|
||||
|
||||
it('matches an empty map', function() {
|
||||
const empty = new jasmineUnderTest.Empty();
|
||||
const empty = new privateUnderTest.Empty();
|
||||
const fullMap = new Map();
|
||||
fullMap.set('thing', 2);
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('Empty', function() {
|
||||
});
|
||||
|
||||
it('matches an empty set', function() {
|
||||
const empty = new jasmineUnderTest.Empty();
|
||||
const empty = new privateUnderTest.Empty();
|
||||
const fullSet = new Set();
|
||||
fullSet.add(3);
|
||||
|
||||
@@ -40,7 +40,7 @@ describe('Empty', function() {
|
||||
});
|
||||
|
||||
it('matches an empty typed array', function() {
|
||||
const empty = new jasmineUnderTest.Empty();
|
||||
const empty = new privateUnderTest.Empty();
|
||||
|
||||
expect(empty.asymmetricMatch(new Int16Array())).toBe(true);
|
||||
expect(empty.asymmetricMatch(new Int16Array([1, 2]))).toBe(false);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
describe('Falsy', function() {
|
||||
it('is true for an empty string', function() {
|
||||
const falsy = new jasmineUnderTest.Falsy();
|
||||
const falsy = new privateUnderTest.Falsy();
|
||||
|
||||
expect(falsy.asymmetricMatch('')).toBe(true);
|
||||
expect(falsy.asymmetricMatch('')).toBe(true);
|
||||
@@ -8,7 +8,7 @@ describe('Falsy', function() {
|
||||
});
|
||||
|
||||
it('is false for a number that is 0', function() {
|
||||
const falsy = new jasmineUnderTest.Falsy(Number);
|
||||
const falsy = new privateUnderTest.Falsy(Number);
|
||||
|
||||
expect(falsy.asymmetricMatch(1)).toBe(false);
|
||||
expect(falsy.asymmetricMatch(0)).toBe(true);
|
||||
@@ -17,20 +17,20 @@ describe('Falsy', function() {
|
||||
});
|
||||
|
||||
it('is true for a null or undefined', function() {
|
||||
const falsy = new jasmineUnderTest.Falsy(Function);
|
||||
const falsy = new privateUnderTest.Falsy(Function);
|
||||
|
||||
expect(falsy.asymmetricMatch(null)).toBe(true);
|
||||
expect(falsy.asymmetricMatch(undefined)).toBe(true);
|
||||
});
|
||||
|
||||
it('is true for NaN', function() {
|
||||
const falsy = new jasmineUnderTest.Falsy(Object);
|
||||
const falsy = new privateUnderTest.Falsy(Object);
|
||||
|
||||
expect(falsy.asymmetricMatch(NaN)).toBe(true);
|
||||
});
|
||||
|
||||
it('is true for a false Boolean', function() {
|
||||
const falsy = new jasmineUnderTest.Falsy(Boolean);
|
||||
const falsy = new privateUnderTest.Falsy(Boolean);
|
||||
|
||||
expect(falsy.asymmetricMatch(false)).toBe(true);
|
||||
expect(falsy.asymmetricMatch(true)).toBe(false);
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
describe('Is', function() {
|
||||
it('passes for primitives that are ===', function() {
|
||||
const exactly = new jasmineUnderTest.Is(17);
|
||||
const exactly = new privateUnderTest.Is(17);
|
||||
expect(exactly.asymmetricMatch(17)).toBeTrue();
|
||||
});
|
||||
|
||||
it('fails for primitives that are not ===', function() {
|
||||
const exactly = new jasmineUnderTest.Is(42);
|
||||
const exactly = new privateUnderTest.Is(42);
|
||||
expect(exactly.asymmetricMatch('42')).toBeFalse();
|
||||
});
|
||||
|
||||
it('passes for the same object instance', function() {
|
||||
const obj = {};
|
||||
const exactly = new jasmineUnderTest.Is(obj);
|
||||
const exactly = new privateUnderTest.Is(obj);
|
||||
expect(exactly.asymmetricMatch(obj)).toBeTrue();
|
||||
});
|
||||
|
||||
it('fails for different object instances, even if they are deep value equal', function() {
|
||||
const exactly = new jasmineUnderTest.Is({});
|
||||
const exactly = new privateUnderTest.Is({});
|
||||
expect(exactly.asymmetricMatch({})).toBeFalse();
|
||||
});
|
||||
|
||||
it('describes itself for use in diffs and pretty printing', function() {
|
||||
const exactly = new jasmineUnderTest.Is({ foo: ['bar'] });
|
||||
const pp = jasmineUnderTest.basicPrettyPrinter_;
|
||||
const exactly = new privateUnderTest.Is({ foo: ['bar'] });
|
||||
const pp = privateUnderTest.basicPrettyPrinter;
|
||||
expect(exactly.jasmineToString(pp)).toEqual(
|
||||
"<jasmine.is(Object({ foo: [ 'bar' ] }))>"
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('MapContaining', function() {
|
||||
it('matches any actual map to an empty map', function() {
|
||||
const actualMap = new Map([['foo', 'bar']]);
|
||||
const containing = new jasmineUnderTest.MapContaining(new Map());
|
||||
const containing = new privateUnderTest.MapContaining(new Map());
|
||||
|
||||
expect(containing.asymmetricMatch(actualMap)).toBe(true);
|
||||
});
|
||||
@@ -17,8 +17,8 @@ describe('MapContaining', function() {
|
||||
[{ foo: 'bar' }, 'baz'],
|
||||
['foo', [1, 2, 3]]
|
||||
]);
|
||||
const containing = new jasmineUnderTest.MapContaining(containingMap);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.MapContaining(containingMap);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(true);
|
||||
});
|
||||
@@ -33,8 +33,8 @@ describe('MapContaining', function() {
|
||||
[{ foo: 'bar' }, 'baz'],
|
||||
['foo', [1, 2, 3]]
|
||||
]);
|
||||
const containing = new jasmineUnderTest.MapContaining(containingMap);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.MapContaining(containingMap);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(false);
|
||||
});
|
||||
@@ -43,8 +43,8 @@ describe('MapContaining', function() {
|
||||
const actualMap = new Map([['foo', [1, 2, 3]], [{ foo: 'bar' }, 'baz']]);
|
||||
|
||||
const containingMap = new Map([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2]]]);
|
||||
const containing = new jasmineUnderTest.MapContaining(containingMap);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.MapContaining(containingMap);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(false);
|
||||
});
|
||||
@@ -60,8 +60,8 @@ describe('MapContaining', function() {
|
||||
[jasmineUnderTest.stringMatching(/^foo\d/), 'bar'],
|
||||
['baz', jasmineUnderTest.arrayContaining([2, 3])]
|
||||
]);
|
||||
const containing = new jasmineUnderTest.MapContaining(containingMap);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.MapContaining(containingMap);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(true);
|
||||
});
|
||||
@@ -73,8 +73,8 @@ describe('MapContaining', function() {
|
||||
[jasmineUnderTest.stringMatching(/^foo\d/), 'bar'],
|
||||
['baz', jasmineUnderTest.arrayContaining([2, 3])]
|
||||
]);
|
||||
const containing = new jasmineUnderTest.MapContaining(containingMap);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.MapContaining(containingMap);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(false);
|
||||
});
|
||||
@@ -86,8 +86,8 @@ describe('MapContaining', function() {
|
||||
[jasmineUnderTest.stringMatching(/^foo\d/), 'bar'],
|
||||
['baz', jasmineUnderTest.arrayContaining([4, 5])]
|
||||
]);
|
||||
const containing = new jasmineUnderTest.MapContaining(containingMap);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.MapContaining(containingMap);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(false);
|
||||
});
|
||||
@@ -100,11 +100,11 @@ describe('MapContaining', function() {
|
||||
]);
|
||||
|
||||
const containingMap = new Map([
|
||||
['foo', new jasmineUnderTest.MapContaining(new Map([['foo1', 1]]))],
|
||||
[new jasmineUnderTest.MapContaining(new Map([[2, 'bar2']])), 'bar']
|
||||
['foo', new privateUnderTest.MapContaining(new Map([['foo1', 1]]))],
|
||||
[new privateUnderTest.MapContaining(new Map([[2, 'bar2']])), 'bar']
|
||||
]);
|
||||
const containing = new jasmineUnderTest.MapContaining(containingMap);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.MapContaining(containingMap);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(true);
|
||||
});
|
||||
@@ -117,10 +117,10 @@ describe('MapContaining', function() {
|
||||
: a === b;
|
||||
}
|
||||
const actualMap = new Map([['foo', -1]]);
|
||||
const containing = new jasmineUnderTest.MapContaining(
|
||||
const containing = new privateUnderTest.MapContaining(
|
||||
new Map([['foo', -2]])
|
||||
);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
customTesters: [tester]
|
||||
});
|
||||
|
||||
@@ -130,13 +130,13 @@ describe('MapContaining', function() {
|
||||
it('does not match when actual is not a map', function() {
|
||||
const containingMap = new Map([['foo', 'bar']]);
|
||||
expect(
|
||||
new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch('foo')
|
||||
new privateUnderTest.MapContaining(containingMap).asymmetricMatch('foo')
|
||||
).toBe(false);
|
||||
expect(
|
||||
new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch(-1)
|
||||
new privateUnderTest.MapContaining(containingMap).asymmetricMatch(-1)
|
||||
).toBe(false);
|
||||
expect(
|
||||
new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch({
|
||||
new privateUnderTest.MapContaining(containingMap).asymmetricMatch({
|
||||
foo: 'bar'
|
||||
})
|
||||
).toBe(false);
|
||||
@@ -144,7 +144,7 @@ describe('MapContaining', function() {
|
||||
|
||||
it('throws an error when sample is not a map', function() {
|
||||
expect(function() {
|
||||
new jasmineUnderTest.MapContaining({ foo: 'bar' }).asymmetricMatch(
|
||||
new privateUnderTest.MapContaining({ foo: 'bar' }).asymmetricMatch(
|
||||
new Map()
|
||||
);
|
||||
}).toThrowError(/You must provide a map/);
|
||||
@@ -152,7 +152,7 @@ describe('MapContaining', function() {
|
||||
|
||||
it('defines a `jasmineToString` method', function() {
|
||||
const sample = new Map(),
|
||||
containing = new jasmineUnderTest.MapContaining(sample),
|
||||
containing = new privateUnderTest.MapContaining(sample),
|
||||
pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||
|
||||
expect(containing.jasmineToString(pp)).toEqual(
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
describe('NotEmpty', function() {
|
||||
it('matches a non empty object', function() {
|
||||
const notEmpty = new jasmineUnderTest.NotEmpty();
|
||||
const notEmpty = new privateUnderTest.NotEmpty();
|
||||
|
||||
expect(notEmpty.asymmetricMatch({ undefined: false })).toBe(true);
|
||||
expect(notEmpty.asymmetricMatch({})).toBe(false);
|
||||
});
|
||||
|
||||
it('matches a non empty array', function() {
|
||||
const notEmpty = new jasmineUnderTest.NotEmpty();
|
||||
const notEmpty = new privateUnderTest.NotEmpty();
|
||||
|
||||
expect(notEmpty.asymmetricMatch([1, 12, 3])).toBe(true);
|
||||
expect(notEmpty.asymmetricMatch([])).toBe(false);
|
||||
});
|
||||
|
||||
it('matches a non empty string', function() {
|
||||
const notEmpty = new jasmineUnderTest.NotEmpty();
|
||||
const notEmpty = new privateUnderTest.NotEmpty();
|
||||
|
||||
expect(notEmpty.asymmetricMatch('12312')).toBe(true);
|
||||
expect(notEmpty.asymmetricMatch('')).toBe(false);
|
||||
@@ -22,7 +22,7 @@ describe('NotEmpty', function() {
|
||||
});
|
||||
|
||||
it('matches a non empty map', function() {
|
||||
const notEmpty = new jasmineUnderTest.NotEmpty();
|
||||
const notEmpty = new privateUnderTest.NotEmpty();
|
||||
const fullMap = new Map();
|
||||
fullMap.set('one', 1);
|
||||
const emptyMap = new Map();
|
||||
@@ -32,7 +32,7 @@ describe('NotEmpty', function() {
|
||||
});
|
||||
|
||||
it('matches a non empty set', function() {
|
||||
const notEmpty = new jasmineUnderTest.NotEmpty();
|
||||
const notEmpty = new privateUnderTest.NotEmpty();
|
||||
const filledSet = new Set();
|
||||
filledSet.add(1);
|
||||
const emptySet = new Set();
|
||||
@@ -42,7 +42,7 @@ describe('NotEmpty', function() {
|
||||
});
|
||||
|
||||
it('matches a non empty typed array', function() {
|
||||
const notEmpty = new jasmineUnderTest.NotEmpty();
|
||||
const notEmpty = new privateUnderTest.NotEmpty();
|
||||
|
||||
expect(notEmpty.asymmetricMatch(new Int16Array([1, 2, 3]))).toBe(true);
|
||||
expect(notEmpty.asymmetricMatch(new Int16Array())).toBe(false);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
describe('ObjectContaining', function() {
|
||||
it('matches any object actual to an empty object', function() {
|
||||
const containing = new jasmineUnderTest.ObjectContaining({});
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.ObjectContaining({});
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch({ foo: 1 }, matchersUtil)).toBe(true);
|
||||
});
|
||||
|
||||
it('does not match when the actual is not an object', function() {
|
||||
const containing = new jasmineUnderTest.ObjectContaining({});
|
||||
const containing = new privateUnderTest.ObjectContaining({});
|
||||
|
||||
[1, true, undefined, 'a string'].forEach(function(actual) {
|
||||
expect(containing.asymmetricMatch(actual)).toBe(false);
|
||||
@@ -15,7 +15,7 @@ describe('ObjectContaining', function() {
|
||||
});
|
||||
|
||||
it('does not match an empty object actual', function() {
|
||||
const containing = new jasmineUnderTest.ObjectContaining('foo');
|
||||
const containing = new privateUnderTest.ObjectContaining('foo');
|
||||
|
||||
expect(function() {
|
||||
containing.asymmetricMatch({});
|
||||
@@ -23,8 +23,8 @@ describe('ObjectContaining', function() {
|
||||
});
|
||||
|
||||
it('matches when the key/value pair is present in the actual', function() {
|
||||
const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' });
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.ObjectContaining({ foo: 'fooVal' });
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(
|
||||
containing.asymmetricMatch({ foo: 'fooVal', bar: 'barVal' }, matchersUtil)
|
||||
@@ -32,8 +32,8 @@ describe('ObjectContaining', function() {
|
||||
});
|
||||
|
||||
it('does not match when the key/value pair is not present in the actual', function() {
|
||||
const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' });
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.ObjectContaining({ foo: 'fooVal' });
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(
|
||||
containing.asymmetricMatch(
|
||||
@@ -44,8 +44,8 @@ describe('ObjectContaining', function() {
|
||||
});
|
||||
|
||||
it('does not match when the key is present but the value is different in the actual', function() {
|
||||
const containing = new jasmineUnderTest.ObjectContaining({ foo: 'other' });
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.ObjectContaining({ foo: 'other' });
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(
|
||||
containing.asymmetricMatch({ foo: 'fooVal', bar: 'barVal' }, matchersUtil)
|
||||
@@ -54,7 +54,7 @@ describe('ObjectContaining', function() {
|
||||
|
||||
it("jasmineToString's itself", function() {
|
||||
const sample = {},
|
||||
matcher = new jasmineUnderTest.ObjectContaining(sample),
|
||||
matcher = new privateUnderTest.ObjectContaining(sample),
|
||||
pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||
|
||||
expect(matcher.jasmineToString(pp)).toEqual(
|
||||
@@ -64,10 +64,10 @@ describe('ObjectContaining', function() {
|
||||
});
|
||||
|
||||
it('matches recursively', function() {
|
||||
const containing = new jasmineUnderTest.ObjectContaining({
|
||||
one: new jasmineUnderTest.ObjectContaining({ two: {} })
|
||||
const containing = new privateUnderTest.ObjectContaining({
|
||||
one: new privateUnderTest.ObjectContaining({ two: {} })
|
||||
});
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch({ one: { two: {} } }, matchersUtil)).toBe(
|
||||
true
|
||||
@@ -75,10 +75,10 @@ describe('ObjectContaining', function() {
|
||||
});
|
||||
|
||||
it('matches when key is present with undefined value', function() {
|
||||
const containing = new jasmineUnderTest.ObjectContaining({
|
||||
const containing = new privateUnderTest.ObjectContaining({
|
||||
one: undefined
|
||||
});
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch({ one: undefined }, matchersUtil)).toBe(
|
||||
true
|
||||
@@ -86,17 +86,17 @@ describe('ObjectContaining', function() {
|
||||
});
|
||||
|
||||
it('does not match when key with undefined value is not present', function() {
|
||||
const containing = new jasmineUnderTest.ObjectContaining({
|
||||
const containing = new privateUnderTest.ObjectContaining({
|
||||
one: undefined
|
||||
});
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch({}, matchersUtil)).toBe(false);
|
||||
});
|
||||
|
||||
it('matches defined properties', function() {
|
||||
const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' });
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.ObjectContaining({ foo: 'fooVal' });
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
const definedPropertyObject = {};
|
||||
Object.defineProperty(definedPropertyObject, 'foo', {
|
||||
@@ -110,8 +110,8 @@ describe('ObjectContaining', function() {
|
||||
});
|
||||
|
||||
it('matches prototype properties', function() {
|
||||
const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' });
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.ObjectContaining({ foo: 'fooVal' });
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
const prototypeObject = { foo: 'fooVal' };
|
||||
const obj = Object.create(prototypeObject);
|
||||
@@ -131,8 +131,8 @@ describe('ObjectContaining', function() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' });
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
const containing = new privateUnderTest.ObjectContaining({ foo: 'fooVal' });
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
customTesters: [tester]
|
||||
});
|
||||
|
||||
@@ -144,8 +144,8 @@ describe('ObjectContaining', function() {
|
||||
describe('valuesForDiff_', function() {
|
||||
describe('when other is not an object', function() {
|
||||
it('sets self to jasmineToString()', function() {
|
||||
const containing = new jasmineUnderTest.ObjectContaining({}),
|
||||
pp = jasmineUnderTest.makePrettyPrinter(),
|
||||
const containing = new privateUnderTest.ObjectContaining({}),
|
||||
pp = privateUnderTest.makePrettyPrinter(),
|
||||
result = containing.valuesForDiff_('a', pp);
|
||||
|
||||
expect(result).toEqual({
|
||||
@@ -159,11 +159,11 @@ describe('ObjectContaining', function() {
|
||||
it('includes keys that are present in both other and sample', function() {
|
||||
const sample = { a: 1, b: 2 },
|
||||
other = { a: 3, b: 4 },
|
||||
containing = new jasmineUnderTest.ObjectContaining(sample),
|
||||
containing = new privateUnderTest.ObjectContaining(sample),
|
||||
result = containing.valuesForDiff_(other);
|
||||
|
||||
expect(result.self).not.toBeInstanceOf(
|
||||
jasmineUnderTest.ObjectContaining
|
||||
privateUnderTest.ObjectContaining
|
||||
);
|
||||
expect(result).toEqual({
|
||||
self: sample,
|
||||
@@ -174,11 +174,11 @@ describe('ObjectContaining', function() {
|
||||
it('includes keys that are present only in sample', function() {
|
||||
const sample = { a: 1, b: 2 },
|
||||
other = { a: 3 },
|
||||
containing = new jasmineUnderTest.ObjectContaining(sample),
|
||||
containing = new privateUnderTest.ObjectContaining(sample),
|
||||
result = containing.valuesForDiff_(other);
|
||||
|
||||
expect(result.self).not.toBeInstanceOf(
|
||||
jasmineUnderTest.ObjectContaining
|
||||
privateUnderTest.ObjectContaining
|
||||
);
|
||||
expect(containing.valuesForDiff_(other)).toEqual({
|
||||
self: sample,
|
||||
@@ -192,11 +192,11 @@ describe('ObjectContaining', function() {
|
||||
it('omits keys that are present only in other', function() {
|
||||
const sample = { a: 1, b: 2 },
|
||||
other = { a: 3, b: 4, c: 5 },
|
||||
containing = new jasmineUnderTest.ObjectContaining(sample),
|
||||
containing = new privateUnderTest.ObjectContaining(sample),
|
||||
result = containing.valuesForDiff_(other);
|
||||
|
||||
expect(result.self).not.toBeInstanceOf(
|
||||
jasmineUnderTest.ObjectContaining
|
||||
privateUnderTest.ObjectContaining
|
||||
);
|
||||
expect(result).toEqual({
|
||||
self: sample,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('SetContaining', function() {
|
||||
it('matches any actual set to an empty set', function() {
|
||||
const actualSet = new Set(['foo', 'bar']);
|
||||
const containing = new jasmineUnderTest.SetContaining(new Set());
|
||||
const containing = new privateUnderTest.SetContaining(new Set());
|
||||
|
||||
expect(containing.asymmetricMatch(actualSet)).toBe(true);
|
||||
});
|
||||
@@ -10,8 +10,8 @@ describe('SetContaining', function() {
|
||||
const actualSet = new Set([{ foo: 'bar' }, 'baz', [1, 2, 3]]);
|
||||
|
||||
const containingSet = new Set([[1, 2, 3], { foo: 'bar' }]);
|
||||
const containing = new jasmineUnderTest.SetContaining(containingSet);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.SetContaining(containingSet);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(true);
|
||||
});
|
||||
@@ -20,8 +20,8 @@ describe('SetContaining', function() {
|
||||
const actualSet = new Set([{ foo: 'bar' }, 'baz', [1, 2, 3]]);
|
||||
|
||||
const containingSet = new Set([[1, 2], { foo: 'bar' }]);
|
||||
const containing = new jasmineUnderTest.SetContaining(containingSet);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.SetContaining(containingSet);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(false);
|
||||
});
|
||||
@@ -33,8 +33,8 @@ describe('SetContaining', function() {
|
||||
jasmineUnderTest.stringMatching(/^foo\d/),
|
||||
jasmineUnderTest.arrayContaining([2, 3])
|
||||
]);
|
||||
const containing = new jasmineUnderTest.SetContaining(containingSet);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.SetContaining(containingSet);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(true);
|
||||
});
|
||||
@@ -46,8 +46,8 @@ describe('SetContaining', function() {
|
||||
jasmine.stringMatching(/^foo\d/),
|
||||
jasmine.arrayContaining([2, 3])
|
||||
]);
|
||||
const containing = new jasmineUnderTest.SetContaining(containingSet);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.SetContaining(containingSet);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(false);
|
||||
});
|
||||
@@ -56,11 +56,11 @@ describe('SetContaining', function() {
|
||||
const actualSet = new Set(['foo', new Set([1, 'bar', 2]), 'other']);
|
||||
|
||||
const containingSet = new Set([
|
||||
new jasmineUnderTest.SetContaining(new Set(['bar'])),
|
||||
new privateUnderTest.SetContaining(new Set(['bar'])),
|
||||
'foo'
|
||||
]);
|
||||
const containing = new jasmineUnderTest.SetContaining(containingSet);
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil();
|
||||
const containing = new privateUnderTest.SetContaining(containingSet);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(true);
|
||||
});
|
||||
@@ -73,8 +73,8 @@ describe('SetContaining', function() {
|
||||
: a === b;
|
||||
}
|
||||
const actualSet = new Set(['foo', -1]);
|
||||
const containing = new jasmineUnderTest.SetContaining(new Set([-2, 'foo']));
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
const containing = new privateUnderTest.SetContaining(new Set([-2, 'foo']));
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
customTesters: [tester]
|
||||
});
|
||||
|
||||
@@ -84,19 +84,19 @@ describe('SetContaining', function() {
|
||||
it('does not match when actual is not a set', function() {
|
||||
const containingSet = new Set(['foo']);
|
||||
expect(
|
||||
new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch('foo')
|
||||
new privateUnderTest.SetContaining(containingSet).asymmetricMatch('foo')
|
||||
).toBe(false);
|
||||
expect(
|
||||
new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch(1)
|
||||
new privateUnderTest.SetContaining(containingSet).asymmetricMatch(1)
|
||||
).toBe(false);
|
||||
expect(
|
||||
new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch(['foo'])
|
||||
new privateUnderTest.SetContaining(containingSet).asymmetricMatch(['foo'])
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('throws an error when sample is not a set', function() {
|
||||
expect(function() {
|
||||
new jasmineUnderTest.SetContaining({ foo: 'bar' }).asymmetricMatch(
|
||||
new privateUnderTest.SetContaining({ foo: 'bar' }).asymmetricMatch(
|
||||
new Set()
|
||||
);
|
||||
}).toThrowError(/You must provide a set/);
|
||||
@@ -104,7 +104,7 @@ describe('SetContaining', function() {
|
||||
|
||||
it('defines a `jasmineToString` method', function() {
|
||||
const sample = new Set(),
|
||||
containing = new jasmineUnderTest.SetContaining(sample),
|
||||
containing = new privateUnderTest.SetContaining(sample),
|
||||
pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||
|
||||
expect(containing.jasmineToString(pp)).toEqual(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
describe('StringContaining', function() {
|
||||
it('searches for a provided substring when the expected is a String', function() {
|
||||
const matcher = new jasmineUnderTest.StringContaining('foo');
|
||||
const matcher = new privateUnderTest.StringContaining('foo');
|
||||
|
||||
expect(matcher.asymmetricMatch('barfoobaz')).toBe(true);
|
||||
expect(matcher.asymmetricMatch('barbaz')).toBe(false);
|
||||
@@ -8,17 +8,17 @@ describe('StringContaining', function() {
|
||||
|
||||
it('raises an Error when the expected is not a String', function() {
|
||||
expect(function() {
|
||||
new jasmineUnderTest.StringContaining(/foo/);
|
||||
new privateUnderTest.StringContaining(/foo/);
|
||||
}).toThrowError(/not a String/);
|
||||
});
|
||||
|
||||
it('fails when the actual is not a String', function() {
|
||||
const matcher = new jasmineUnderTest.StringContaining('x');
|
||||
const matcher = new privateUnderTest.StringContaining('x');
|
||||
expect(matcher.asymmetricMatch(['x'])).toBe(false);
|
||||
});
|
||||
|
||||
it("jasmineToString's itself", function() {
|
||||
const matching = new jasmineUnderTest.StringContaining('foo');
|
||||
const matching = new privateUnderTest.StringContaining('foo');
|
||||
|
||||
expect(matching.jasmineToString()).toEqual(
|
||||
'<jasmine.stringContaining("foo")>'
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
describe('StringMatching', function() {
|
||||
it('matches a string against a provided regexp', function() {
|
||||
const matcher = new jasmineUnderTest.StringMatching(/foo/);
|
||||
const matcher = new privateUnderTest.StringMatching(/foo/);
|
||||
|
||||
expect(matcher.asymmetricMatch('barfoobaz')).toBe(true);
|
||||
expect(matcher.asymmetricMatch('barbaz')).toBe(false);
|
||||
});
|
||||
|
||||
it('matches a string against provided string', function() {
|
||||
const matcher = new jasmineUnderTest.StringMatching('foo');
|
||||
const matcher = new privateUnderTest.StringMatching('foo');
|
||||
|
||||
expect(matcher.asymmetricMatch('barfoobaz')).toBe(true);
|
||||
expect(matcher.asymmetricMatch('barbaz')).toBe(false);
|
||||
@@ -15,12 +15,12 @@ describe('StringMatching', function() {
|
||||
|
||||
it('raises an Error when the expected is not a String or RegExp', function() {
|
||||
expect(function() {
|
||||
new jasmineUnderTest.StringMatching({});
|
||||
new privateUnderTest.StringMatching({});
|
||||
}).toThrowError(/not a String or a RegExp/);
|
||||
});
|
||||
|
||||
it("jasmineToString's itself", function() {
|
||||
const matching = new jasmineUnderTest.StringMatching(/^foo/);
|
||||
const matching = new privateUnderTest.StringMatching(/^foo/);
|
||||
|
||||
expect(matching.jasmineToString()).toEqual(
|
||||
'<jasmine.stringMatching(/^foo/)>'
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
describe('Truthy', function() {
|
||||
it('is true for a non empty string', function() {
|
||||
const truthy = new jasmineUnderTest.Truthy();
|
||||
const truthy = new privateUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch('foo')).toBe(true);
|
||||
expect(truthy.asymmetricMatch('')).toBe(false);
|
||||
});
|
||||
|
||||
it('is true for a number that is not 0', function() {
|
||||
const truthy = new jasmineUnderTest.Truthy();
|
||||
const truthy = new privateUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch(1)).toBe(true);
|
||||
expect(truthy.asymmetricMatch(0)).toBe(false);
|
||||
@@ -16,44 +16,44 @@ describe('Truthy', function() {
|
||||
});
|
||||
|
||||
it('is true for a function', function() {
|
||||
const truthy = new jasmineUnderTest.Truthy();
|
||||
const truthy = new privateUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch(function() {})).toBe(true);
|
||||
});
|
||||
|
||||
it('is true for an Object', function() {
|
||||
const truthy = new jasmineUnderTest.Truthy();
|
||||
const truthy = new privateUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch({})).toBe(true);
|
||||
});
|
||||
|
||||
it('is true for a truthful Boolean', function() {
|
||||
const truthy = new jasmineUnderTest.Truthy();
|
||||
const truthy = new privateUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch(true)).toBe(true);
|
||||
expect(truthy.asymmetricMatch(false)).toBe(false);
|
||||
});
|
||||
|
||||
it('is true for an empty object', function() {
|
||||
const truthy = new jasmineUnderTest.Truthy();
|
||||
const truthy = new privateUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch({})).toBe(true);
|
||||
});
|
||||
|
||||
it('is true for an empty array', function() {
|
||||
const truthy = new jasmineUnderTest.Truthy();
|
||||
const truthy = new privateUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch([])).toBe(true);
|
||||
});
|
||||
|
||||
it('is true for a date', function() {
|
||||
const truthy = new jasmineUnderTest.Truthy();
|
||||
const truthy = new privateUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch(new Date())).toBe(true);
|
||||
});
|
||||
|
||||
it('is true for a infiniti', function() {
|
||||
const truthy = new jasmineUnderTest.Truthy();
|
||||
const truthy = new privateUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch(Infinity)).toBe(true);
|
||||
expect(truthy.asymmetricMatch(-Infinity)).toBe(true);
|
||||
|
||||
@@ -1,42 +1,13 @@
|
||||
describe('base helpers', function() {
|
||||
describe('isError_', function() {
|
||||
it('correctly handles WebSocket events', function(done) {
|
||||
if (typeof jasmine.getGlobal().WebSocket === 'undefined') {
|
||||
pending('Environment does not provide WebSocket');
|
||||
}
|
||||
|
||||
const obj = (function() {
|
||||
const sock = new WebSocket('ws://localhost');
|
||||
let event;
|
||||
sock.onerror = function(e) {
|
||||
event = e;
|
||||
};
|
||||
return function() {
|
||||
return event;
|
||||
};
|
||||
})();
|
||||
let left = 20;
|
||||
|
||||
const int = setInterval(function() {
|
||||
if (obj() || left === 0) {
|
||||
const result = jasmineUnderTest.isError_(obj());
|
||||
expect(result).toBe(false);
|
||||
clearInterval(int);
|
||||
done();
|
||||
} else {
|
||||
left--;
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
|
||||
describe('isError', function() {
|
||||
it('returns true for an Error subclass', function() {
|
||||
function MyError() {}
|
||||
MyError.prototype = new Error();
|
||||
expect(jasmineUnderTest.isError_(new MyError())).toBe(true);
|
||||
expect(privateUnderTest.isError(new MyError())).toBe(true);
|
||||
});
|
||||
|
||||
it('returns true for an un-thrown Error with no message in this environment', function() {
|
||||
expect(jasmineUnderTest.isError_(new Error())).toBe(true);
|
||||
expect(privateUnderTest.isError(new Error())).toBe(true);
|
||||
});
|
||||
|
||||
it('returns true for an Error that originated from another frame', function() {
|
||||
@@ -50,102 +21,102 @@ describe('base helpers', function() {
|
||||
|
||||
try {
|
||||
const error = iframe.contentWindow.eval('new Error()');
|
||||
expect(jasmineUnderTest.isError_(error)).toBe(true);
|
||||
expect(privateUnderTest.isError(error)).toBe(true);
|
||||
} finally {
|
||||
document.body.removeChild(iframe);
|
||||
}
|
||||
});
|
||||
|
||||
it('returns false for a falsy value', function() {
|
||||
expect(jasmineUnderTest.isError_(undefined)).toBe(false);
|
||||
expect(privateUnderTest.isError(undefined)).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false for a non-Error object', function() {
|
||||
expect(jasmineUnderTest.isError_({})).toBe(false);
|
||||
expect(privateUnderTest.isError({})).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isAsymmetricEqualityTester_', function() {
|
||||
it('returns false when the argument is falsy', function() {
|
||||
expect(jasmineUnderTest.isAsymmetricEqualityTester_(null)).toBe(false);
|
||||
expect(privateUnderTest.isAsymmetricEqualityTester(null)).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false when the argument does not have a asymmetricMatch property', function() {
|
||||
const obj = {};
|
||||
expect(jasmineUnderTest.isAsymmetricEqualityTester_(obj)).toBe(false);
|
||||
expect(privateUnderTest.isAsymmetricEqualityTester(obj)).toBe(false);
|
||||
});
|
||||
|
||||
it("returns false when the argument's asymmetricMatch is not a function", function() {
|
||||
const obj = { asymmetricMatch: 'yes' };
|
||||
expect(jasmineUnderTest.isAsymmetricEqualityTester_(obj)).toBe(false);
|
||||
expect(privateUnderTest.isAsymmetricEqualityTester(obj)).toBe(false);
|
||||
});
|
||||
|
||||
it("returns true when the argument's asymmetricMatch is a function", function() {
|
||||
const obj = { asymmetricMatch: function() {} };
|
||||
expect(jasmineUnderTest.isAsymmetricEqualityTester_(obj)).toBe(true);
|
||||
expect(privateUnderTest.isAsymmetricEqualityTester(obj)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isSet', function() {
|
||||
it('returns true when the object is a Set', function() {
|
||||
expect(jasmineUnderTest.isSet(new Set())).toBe(true);
|
||||
expect(privateUnderTest.isSet(new Set())).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false when the object is not a Set', function() {
|
||||
expect(jasmineUnderTest.isSet({})).toBe(false);
|
||||
expect(privateUnderTest.isSet({})).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isURL', function() {
|
||||
it('returns true when the object is a URL', function() {
|
||||
expect(jasmineUnderTest.isURL(new URL('http://localhost/'))).toBe(true);
|
||||
expect(privateUnderTest.isURL(new URL('http://localhost/'))).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false when the object is not a URL', function() {
|
||||
expect(jasmineUnderTest.isURL({})).toBe(false);
|
||||
expect(privateUnderTest.isURL({})).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isIterable_', function() {
|
||||
describe('isIterable', function() {
|
||||
it('returns true when the object is an Array', function() {
|
||||
expect(jasmineUnderTest.isIterable_([])).toBe(true);
|
||||
expect(privateUnderTest.isIterable([])).toBe(true);
|
||||
});
|
||||
|
||||
it('returns true when the object is a Set', function() {
|
||||
expect(jasmineUnderTest.isIterable_(new Set())).toBe(true);
|
||||
expect(privateUnderTest.isIterable(new Set())).toBe(true);
|
||||
});
|
||||
it('returns true when the object is a Map', function() {
|
||||
expect(jasmineUnderTest.isIterable_(new Map())).toBe(true);
|
||||
expect(privateUnderTest.isIterable(new Map())).toBe(true);
|
||||
});
|
||||
|
||||
it('returns true when the object implements @@iterator', function() {
|
||||
const myIterable = { [Symbol.iterator]: function() {} };
|
||||
expect(jasmineUnderTest.isIterable_(myIterable)).toBe(true);
|
||||
expect(privateUnderTest.isIterable(myIterable)).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false when the object does not implement @@iterator', function() {
|
||||
expect(jasmineUnderTest.isIterable_({})).toBe(false);
|
||||
expect(privateUnderTest.isIterable({})).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isPending_', function() {
|
||||
describe('isPending', function() {
|
||||
it('returns a promise that resolves to true when the promise is pending', function() {
|
||||
const promise = new Promise(function() {});
|
||||
return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo(
|
||||
return expectAsync(privateUnderTest.isPending(promise)).toBeResolvedTo(
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
it('returns a promise that resolves to false when the promise is resolved', function() {
|
||||
const promise = Promise.resolve();
|
||||
return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo(
|
||||
return expectAsync(privateUnderTest.isPending(promise)).toBeResolvedTo(
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
it('returns a promise that resolves to false when the promise is rejected', function() {
|
||||
const promise = Promise.reject(new Error('nope'));
|
||||
return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo(
|
||||
return expectAsync(privateUnderTest.isPending(promise)).toBeResolvedTo(
|
||||
false
|
||||
);
|
||||
});
|
||||
@@ -199,8 +170,15 @@ describe('base helpers', function() {
|
||||
});
|
||||
|
||||
describe('debugLog', function() {
|
||||
beforeEach(function() {
|
||||
privateUnderTest.currentEnv_ = jasmine.createSpyObj('env', ['debugLog']);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
privateUnderTest.currentEnv_ = null;
|
||||
});
|
||||
|
||||
it("forwards to the current env's debugLog function", function() {
|
||||
spyOn(jasmineUnderTest.getEnv(), 'debugLog');
|
||||
jasmineUnderTest.debugLog('a message');
|
||||
expect(jasmineUnderTest.getEnv().debugLog).toHaveBeenCalledWith(
|
||||
'a message'
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
describe('buildExpectationResult', function() {
|
||||
it('defaults to passed', function() {
|
||||
const result = jasmineUnderTest.buildExpectationResult({
|
||||
const result = privateUnderTest.buildExpectationResult({
|
||||
passed: 'some-value'
|
||||
});
|
||||
expect(result.passed).toBe('some-value');
|
||||
});
|
||||
|
||||
it('message defaults to Passed for passing specs', function() {
|
||||
const result = jasmineUnderTest.buildExpectationResult({
|
||||
const result = privateUnderTest.buildExpectationResult({
|
||||
passed: true,
|
||||
message: 'some-value'
|
||||
});
|
||||
@@ -15,7 +15,7 @@ describe('buildExpectationResult', function() {
|
||||
});
|
||||
|
||||
it('message returns the message for failing expectations', function() {
|
||||
const result = jasmineUnderTest.buildExpectationResult({
|
||||
const result = privateUnderTest.buildExpectationResult({
|
||||
passed: false,
|
||||
message: 'some-value'
|
||||
});
|
||||
@@ -24,7 +24,7 @@ describe('buildExpectationResult', function() {
|
||||
|
||||
describe('When the error property is provided', function() {
|
||||
it('sets the message to the formatted error', function() {
|
||||
const result = jasmineUnderTest.buildExpectationResult({
|
||||
const result = privateUnderTest.buildExpectationResult({
|
||||
passed: false,
|
||||
error: { message: 'foo', fileName: 'somefile.js' }
|
||||
});
|
||||
@@ -33,7 +33,7 @@ describe('buildExpectationResult', function() {
|
||||
});
|
||||
|
||||
it('delegates stack formatting to the provided formatter', function() {
|
||||
const result = jasmineUnderTest.buildExpectationResult({
|
||||
const result = privateUnderTest.buildExpectationResult({
|
||||
passed: false,
|
||||
error: { stack: 'foo', extra: 'wombat' }
|
||||
});
|
||||
@@ -46,7 +46,7 @@ describe('buildExpectationResult', function() {
|
||||
|
||||
describe('When the errorForStack property is provided', function() {
|
||||
it('builds the stack trace using errorForStack instead of Error', function() {
|
||||
const result = jasmineUnderTest.buildExpectationResult({
|
||||
const result = privateUnderTest.buildExpectationResult({
|
||||
passed: false,
|
||||
errorForStack: { stack: 'foo' },
|
||||
error: { stack: 'bar' }
|
||||
@@ -57,56 +57,34 @@ describe('buildExpectationResult', function() {
|
||||
});
|
||||
|
||||
it('matcherName returns passed matcherName', function() {
|
||||
const result = jasmineUnderTest.buildExpectationResult({
|
||||
const result = privateUnderTest.buildExpectationResult({
|
||||
matcherName: 'some-value'
|
||||
});
|
||||
expect(result.matcherName).toBe('some-value');
|
||||
});
|
||||
|
||||
it('expected returns passed expected', function() {
|
||||
const result = jasmineUnderTest.buildExpectationResult({
|
||||
expected: 'some-value'
|
||||
});
|
||||
expect(result.expected).toBe('some-value');
|
||||
});
|
||||
|
||||
it('actual returns passed actual', function() {
|
||||
const result = jasmineUnderTest.buildExpectationResult({
|
||||
actual: 'some-value'
|
||||
});
|
||||
expect(result.actual).toBe('some-value');
|
||||
});
|
||||
|
||||
it('handles nodejs assertions', function() {
|
||||
if (typeof require === 'undefined') {
|
||||
pending('This test only runs in Node');
|
||||
}
|
||||
const assert = require('assert');
|
||||
const value = 8421;
|
||||
const expectedValue = 'JasmineExpectationTestValue';
|
||||
let error;
|
||||
try {
|
||||
assert.equal(value, expectedValue);
|
||||
assert.equal('a', 'b');
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.code).toEqual('ERR_ASSERTION');
|
||||
expect(error.actual).toEqual(value);
|
||||
expect(error.expected).toEqual(expectedValue);
|
||||
expect(error.operator).toEqual('==');
|
||||
|
||||
const result = jasmineUnderTest.buildExpectationResult({
|
||||
const result = privateUnderTest.buildExpectationResult({
|
||||
passed: false,
|
||||
matcherName: '',
|
||||
expected: '',
|
||||
actual: '',
|
||||
error: error
|
||||
});
|
||||
|
||||
expect(result.code).toEqual('ERR_ASSERTION');
|
||||
expect(result.actual).toEqual(value);
|
||||
expect(result.expected).toEqual(expectedValue);
|
||||
expect(result.matcherName).toEqual('assert ==');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
describe('formatErrorMsg', function() {
|
||||
it('should format an error with a domain', function() {
|
||||
const formator = jasmineUnderTest.formatErrorMsg('api');
|
||||
const formator = privateUnderTest.formatErrorMsg('api');
|
||||
expect(formator('message')).toBe('api : message');
|
||||
expect(formator('message2')).toBe('api : message2');
|
||||
});
|
||||
|
||||
it('should format an error with a domain and usage', function() {
|
||||
const formator = jasmineUnderTest.formatErrorMsg('api', 'with a param');
|
||||
const formator = privateUnderTest.formatErrorMsg('api', 'with a param');
|
||||
expect(formator('message')).toBe('api : message\nUsage: with a param');
|
||||
expect(formator('message2')).toBe('api : message2\nUsage: with a param');
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('Asymmetric equality testers (Integration)', function() {
|
||||
function verifyPasses(expectations) {
|
||||
it('passes', async function() {
|
||||
const env = new jasmineUnderTest.Env();
|
||||
const env = new privateUnderTest.Env();
|
||||
env.it('a spec', function() {
|
||||
expectations(env);
|
||||
});
|
||||
@@ -30,7 +30,7 @@ describe('Asymmetric equality testers (Integration)', function() {
|
||||
|
||||
function verifyFails(expectations) {
|
||||
it('fails', async function() {
|
||||
const env = new jasmineUnderTest.Env();
|
||||
const env = new privateUnderTest.Env();
|
||||
env.it('a spec', function() {
|
||||
expectations(env);
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ describe('Custom Async Matchers (Integration)', function() {
|
||||
let env;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
env.configure({ random: false });
|
||||
});
|
||||
|
||||
@@ -107,7 +107,7 @@ describe('Custom Async Matchers (Integration)', function() {
|
||||
|
||||
const specExpectations = function() {
|
||||
expect(matcherFactorySpy).toHaveBeenCalledWith(
|
||||
jasmine.any(jasmineUnderTest.MatchersUtil)
|
||||
jasmine.any(privateUnderTest.MatchersUtil)
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ describe('Custom Matchers (Integration)', function() {
|
||||
let env;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
env.configure({ random: false });
|
||||
});
|
||||
|
||||
@@ -230,7 +230,7 @@ describe('Custom Matchers (Integration)', function() {
|
||||
|
||||
await env.execute();
|
||||
expect(matcherFactorySpy).toHaveBeenCalledWith(
|
||||
jasmine.any(jasmineUnderTest.MatchersUtil)
|
||||
jasmine.any(privateUnderTest.MatchersUtil)
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ describe('Custom object formatters', function() {
|
||||
let env;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
env.configure({ random: false });
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ describe('Custom Spy Strategies (Integration)', function() {
|
||||
let env;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
env.configure({ random: false });
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ describe('Default Spy Strategy (Integration)', function() {
|
||||
let env;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
env.configure({ random: false });
|
||||
});
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ describe('Deprecation (integration)', function() {
|
||||
let env;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
|
||||
@@ -4,7 +4,7 @@ describe('Env integration', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
specHelpers.registerIntegrationMatchers();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
@@ -199,7 +199,7 @@ describe('Env integration', function() {
|
||||
} else {
|
||||
secondSpecContext = this;
|
||||
}
|
||||
expect(this).toEqual(new jasmineUnderTest.UserContext());
|
||||
expect(this).toEqual(new privateUnderTest.UserContext());
|
||||
});
|
||||
|
||||
env.it('sync spec', function() {
|
||||
@@ -229,7 +229,7 @@ describe('Env integration', function() {
|
||||
|
||||
env.beforeEach(function() {
|
||||
specContext = this;
|
||||
expect(this).toEqual(new jasmineUnderTest.UserContext());
|
||||
expect(this).toEqual(new privateUnderTest.UserContext());
|
||||
});
|
||||
|
||||
env.it('sync spec', function(underTestCallback) {
|
||||
@@ -913,6 +913,7 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
env.configure({
|
||||
random: false,
|
||||
specFilter: function(spec) {
|
||||
return /^first suite/.test(spec.getFullName());
|
||||
}
|
||||
@@ -920,10 +921,7 @@ describe('Env integration', function() {
|
||||
|
||||
await env.execute();
|
||||
|
||||
expect(calls.length).toEqual(2);
|
||||
expect(calls).toEqual(
|
||||
jasmine.arrayContaining(['first spec', 'second spec'])
|
||||
);
|
||||
expect(calls).toEqual(['first spec', 'second spec']);
|
||||
expect(suiteCallback).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -1112,12 +1110,21 @@ describe('Env integration', function() {
|
||||
);
|
||||
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env({
|
||||
env = new privateUnderTest.Env({
|
||||
global: {
|
||||
setTimeout: globalSetTimeout,
|
||||
clearTimeout: clearTimeout,
|
||||
addEventListener() {},
|
||||
removeEventListener() {},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
},
|
||||
// Enough Node globals to make getStackClearer() return the microtask
|
||||
// implementation, which is the easiest to mock
|
||||
process: {
|
||||
versions: {
|
||||
node: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1177,11 +1184,11 @@ describe('Env integration', function() {
|
||||
env.cleanup_();
|
||||
// explicitly pass in timing functions so we can make sure that clear stack always works
|
||||
// no matter how long the suite in the spec is
|
||||
env = new jasmineUnderTest.Env({
|
||||
env = new privateUnderTest.Env({
|
||||
global: {
|
||||
setTimeout: function(cb, t) {
|
||||
const stack = new Error().stack;
|
||||
if (stack.indexOf('ClearStack') >= 0) {
|
||||
if (stack.indexOf('clearStack') >= 0) {
|
||||
return realSetTimeout(cb, t);
|
||||
} else {
|
||||
return setTimeout(cb, t);
|
||||
@@ -1190,8 +1197,17 @@ describe('Env integration', function() {
|
||||
clearTimeout: clearTimeout,
|
||||
setInterval: setInterval,
|
||||
clearInterval: clearInterval,
|
||||
addEventListener() {},
|
||||
removeEventListener() {},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
},
|
||||
// Enough Node globals to make getStackClearer() return the microtask
|
||||
// implementation, which is the easiest to mock
|
||||
process: {
|
||||
versions: {
|
||||
node: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1273,7 +1289,7 @@ describe('Env integration', function() {
|
||||
await env.execute();
|
||||
expect(reporter.specDone).toHaveBeenCalledTimes(1);
|
||||
const event = reporter.specDone.calls.argsFor(0)[0];
|
||||
jasmine.debugLog('Spec result: ' + jasmine.basicPrettyPrinter_(event));
|
||||
jasmine.debugLog('Spec result: ' + jasmine.pp(event));
|
||||
expect(event).toEqual(jasmine.objectContaining({ status: 'passed' }));
|
||||
jasmine.clock().tick(1);
|
||||
|
||||
@@ -1539,7 +1555,8 @@ describe('Env integration', function() {
|
||||
|
||||
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
||||
totalSpecsDefined: 1,
|
||||
order: jasmine.any(jasmineUnderTest.Order),
|
||||
numExcludedSpecs: 0,
|
||||
order: { random: true, seed: jasmine.any(String) },
|
||||
parallel: false
|
||||
});
|
||||
|
||||
@@ -1574,7 +1591,8 @@ describe('Env integration', function() {
|
||||
|
||||
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
||||
totalSpecsDefined: 1,
|
||||
order: jasmine.any(jasmineUnderTest.Order),
|
||||
numExcludedSpecs: 0,
|
||||
order: { random: true, seed: jasmine.any(String) },
|
||||
parallel: false
|
||||
});
|
||||
|
||||
@@ -1600,15 +1618,6 @@ describe('Env integration', function() {
|
||||
suiteFullNameToId[e.fullName] = e.id;
|
||||
});
|
||||
|
||||
// Clone args to work around Jasmine mutating the result after passing it
|
||||
// to the reporter event.
|
||||
// TODO: remove this once Jasmine no longer does that
|
||||
const clone = structuredClone.bind(globalThis);
|
||||
reporter.specStarted.calls.saveArgumentsByValue(clone);
|
||||
reporter.specDone.calls.saveArgumentsByValue(clone);
|
||||
reporter.specStarted.calls.saveArgumentsByValue(clone);
|
||||
reporter.suiteDone.calls.saveArgumentsByValue(clone);
|
||||
|
||||
env.configure({ random: false });
|
||||
env.addReporter(reporter);
|
||||
|
||||
@@ -1639,7 +1648,8 @@ describe('Env integration', function() {
|
||||
|
||||
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
||||
totalSpecsDefined: 6,
|
||||
order: jasmine.any(jasmineUnderTest.Order),
|
||||
numExcludedSpecs: 3,
|
||||
order: { random: false },
|
||||
parallel: false
|
||||
});
|
||||
|
||||
@@ -1647,15 +1657,18 @@ describe('Env integration', function() {
|
||||
expect(reporter.specDone.calls.count()).toBe(6);
|
||||
|
||||
const baseSpecEvent = {
|
||||
id: jasmine.any(String),
|
||||
filename: jasmine.any(String)
|
||||
};
|
||||
const baseSpecDoneEvent = {
|
||||
...baseSpecEvent,
|
||||
passedExpectations: [],
|
||||
failedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
pendingReason: '',
|
||||
duration: null,
|
||||
properties: null,
|
||||
debugLogs: null,
|
||||
id: jasmine.any(String),
|
||||
filename: jasmine.any(String)
|
||||
debugLogs: null
|
||||
};
|
||||
|
||||
expect(reporter.specStarted.calls.argsFor(0)[0]).toEqual({
|
||||
@@ -1665,7 +1678,7 @@ describe('Env integration', function() {
|
||||
parentSuiteId: null
|
||||
});
|
||||
expect(reporter.specDone.calls.argsFor(0)[0]).toEqual({
|
||||
...baseSpecEvent,
|
||||
...baseSpecDoneEvent,
|
||||
description: 'a top level spec',
|
||||
fullName: 'a top level spec',
|
||||
status: 'passed',
|
||||
@@ -1679,13 +1692,19 @@ describe('Env integration', function() {
|
||||
parentSuiteId: suiteFullNameToId['A Suite']
|
||||
});
|
||||
expect(reporter.specDone.calls.argsFor(1)[0]).toEqual({
|
||||
...baseSpecEvent,
|
||||
...baseSpecDoneEvent,
|
||||
description: 'with a spec',
|
||||
fullName: 'A Suite with a spec',
|
||||
status: 'passed',
|
||||
parentSuiteId: suiteFullNameToId['A Suite'],
|
||||
passedExpectations: [
|
||||
{ matcherName: 'toBe', message: 'Passed.', stack: '', passed: true }
|
||||
{
|
||||
matcherName: 'toBe',
|
||||
message: 'Passed.',
|
||||
stack: '',
|
||||
passed: true,
|
||||
globalErrorType: undefined
|
||||
}
|
||||
],
|
||||
duration: jasmine.any(Number)
|
||||
});
|
||||
@@ -1694,11 +1713,10 @@ describe('Env integration', function() {
|
||||
...baseSpecEvent,
|
||||
description: "with an x'ed spec",
|
||||
fullName: "A Suite with a nested suite with an x'ed spec",
|
||||
parentSuiteId: suiteFullNameToId['A Suite with a nested suite'],
|
||||
pendingReason: 'Temporarily disabled with xit'
|
||||
parentSuiteId: suiteFullNameToId['A Suite with a nested suite']
|
||||
});
|
||||
expect(reporter.specDone.calls.argsFor(2)[0]).toEqual({
|
||||
...baseSpecEvent,
|
||||
...baseSpecDoneEvent,
|
||||
description: "with an x'ed spec",
|
||||
fullName: "A Suite with a nested suite with an x'ed spec",
|
||||
status: 'pending',
|
||||
@@ -1714,7 +1732,7 @@ describe('Env integration', function() {
|
||||
parentSuiteId: suiteFullNameToId['A Suite with a nested suite']
|
||||
});
|
||||
expect(reporter.specDone.calls.argsFor(3)[0]).toEqual({
|
||||
...baseSpecEvent,
|
||||
...baseSpecDoneEvent,
|
||||
description: 'with a spec',
|
||||
fullName: 'A Suite with a nested suite with a spec',
|
||||
status: 'failed',
|
||||
@@ -1735,7 +1753,7 @@ describe('Env integration', function() {
|
||||
parentSuiteId: suiteFullNameToId['A Suite with only non-executable specs']
|
||||
});
|
||||
expect(reporter.specDone.calls.argsFor(4)[0]).toEqual({
|
||||
...baseSpecEvent,
|
||||
...baseSpecDoneEvent,
|
||||
description: 'is pending',
|
||||
status: 'pending',
|
||||
fullName: 'A Suite with only non-executable specs is pending',
|
||||
@@ -1748,12 +1766,10 @@ describe('Env integration', function() {
|
||||
...baseSpecEvent,
|
||||
description: 'is xed',
|
||||
fullName: 'A Suite with only non-executable specs is xed',
|
||||
parentSuiteId:
|
||||
suiteFullNameToId['A Suite with only non-executable specs'],
|
||||
pendingReason: 'Temporarily disabled with xit'
|
||||
parentSuiteId: suiteFullNameToId['A Suite with only non-executable specs']
|
||||
});
|
||||
expect(reporter.specDone.calls.argsFor(5)[0]).toEqual({
|
||||
...baseSpecEvent,
|
||||
...baseSpecDoneEvent,
|
||||
description: 'is xed',
|
||||
status: 'pending',
|
||||
fullName: 'A Suite with only non-executable specs is xed',
|
||||
@@ -1768,10 +1784,12 @@ describe('Env integration', function() {
|
||||
|
||||
const baseSuiteEvent = {
|
||||
id: jasmine.any(String),
|
||||
filename: jasmine.any(String),
|
||||
filename: jasmine.any(String)
|
||||
};
|
||||
const baseSuiteDoneEvent = {
|
||||
...baseSuiteEvent,
|
||||
failedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
duration: null,
|
||||
properties: null
|
||||
};
|
||||
|
||||
@@ -1782,7 +1800,7 @@ describe('Env integration', function() {
|
||||
parentSuiteId: null
|
||||
});
|
||||
expect(reporter.suiteDone.calls.argsFor(2)[0]).toEqual({
|
||||
...baseSuiteEvent,
|
||||
...baseSuiteDoneEvent,
|
||||
description: 'A Suite',
|
||||
fullName: 'A Suite',
|
||||
status: 'passed',
|
||||
@@ -1797,7 +1815,7 @@ describe('Env integration', function() {
|
||||
parentSuiteId: suiteFullNameToId['A Suite']
|
||||
});
|
||||
expect(reporter.suiteDone.calls.argsFor(0)[0]).toEqual({
|
||||
...baseSuiteEvent,
|
||||
...baseSuiteDoneEvent,
|
||||
description: 'with a nested suite',
|
||||
status: 'passed',
|
||||
fullName: 'A Suite with a nested suite',
|
||||
@@ -1812,7 +1830,7 @@ describe('Env integration', function() {
|
||||
parentSuiteId: suiteFullNameToId['A Suite']
|
||||
});
|
||||
expect(reporter.suiteDone.calls.argsFor(1)[0]).toEqual({
|
||||
...baseSuiteEvent,
|
||||
...baseSuiteDoneEvent,
|
||||
description: 'with only non-executable specs',
|
||||
status: 'passed',
|
||||
fullName: 'A Suite with only non-executable specs',
|
||||
@@ -1921,12 +1939,10 @@ describe('Env integration', function() {
|
||||
|
||||
expect(reporter.jasmineStarted).toHaveBeenCalled();
|
||||
const startedArg = reporter.jasmineStarted.calls.argsFor(0)[0];
|
||||
expect(startedArg.order.random).toEqual(true);
|
||||
expect(startedArg.order.seed).toEqual('123456');
|
||||
expect(startedArg.order).toEqual({ random: true, seed: '123456' });
|
||||
|
||||
const doneArg = reporter.jasmineDone.calls.argsFor(0)[0];
|
||||
expect(doneArg.order.random).toEqual(true);
|
||||
expect(doneArg.order.seed).toEqual('123456');
|
||||
expect(doneArg.order).toEqual({ random: true, seed: '123456' });
|
||||
});
|
||||
|
||||
it('coerces the random seed to a string if it is a number', async function() {
|
||||
@@ -2046,7 +2062,8 @@ describe('Env integration', function() {
|
||||
|
||||
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
||||
totalSpecsDefined: 1,
|
||||
order: jasmine.any(jasmineUnderTest.Order),
|
||||
numExcludedSpecs: 1,
|
||||
order: { random: true, seed: jasmine.any(String) },
|
||||
parallel: false
|
||||
});
|
||||
|
||||
@@ -2277,6 +2294,34 @@ describe('Env integration', function() {
|
||||
await env.execute();
|
||||
});
|
||||
|
||||
it('Custom matchers set in top-level beforeAll should be available to all specs and suites', async function() {
|
||||
const matchers = {
|
||||
toFoo: function() {}
|
||||
};
|
||||
|
||||
env.beforeAll(function() {
|
||||
env.addMatchers(matchers);
|
||||
});
|
||||
|
||||
env.describe('suite - top-level', function() {
|
||||
env.it('has access to the custom matcher', function() {
|
||||
expect(env.expect().toFoo).toBeDefined();
|
||||
});
|
||||
|
||||
env.describe('suite - nested', function() {
|
||||
env.it('has access to the custom matcher', function() {
|
||||
expect(env.expect().toFoo).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.it('spec - top-level - has access to the custom matcher', function() {
|
||||
expect(env.expect().toFoo).toBeDefined();
|
||||
});
|
||||
|
||||
await env.execute();
|
||||
});
|
||||
|
||||
it('throws an exception if you try to create a spy outside of a runnable', async function() {
|
||||
const obj = { fn: function() {} };
|
||||
let exception;
|
||||
@@ -2342,7 +2387,7 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('throws an exception if you try to getSpecProperty outside of a spec', async function() {
|
||||
const env = new jasmineUnderTest.Env();
|
||||
const env = new privateUnderTest.Env();
|
||||
let exception;
|
||||
|
||||
env.describe('a suite', function() {
|
||||
@@ -2363,7 +2408,7 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('reports test properties on specs', async function() {
|
||||
const env = new jasmineUnderTest.Env(),
|
||||
const env = new privateUnderTest.Env(),
|
||||
reporter = jasmine.createSpyObj('reporter', ['suiteDone', 'specDone']);
|
||||
|
||||
reporter.specDone.and.callFake(function(e) {
|
||||
@@ -2396,7 +2441,7 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('throws an exception if you try to setSpecProperty outside of a spec', async function() {
|
||||
const env = new jasmineUnderTest.Env();
|
||||
const env = new privateUnderTest.Env();
|
||||
let exception;
|
||||
|
||||
env.describe('a suite', function() {
|
||||
@@ -2417,7 +2462,7 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('reports test properties on suites', async function() {
|
||||
const env = new jasmineUnderTest.Env(),
|
||||
const env = new privateUnderTest.Env(),
|
||||
reporter = jasmine.createSpyObj('reporter', [
|
||||
'jasmineDone',
|
||||
'suiteDone',
|
||||
@@ -2444,7 +2489,7 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('throws an exception if you try to setSuiteProperty outside of a suite', function(done) {
|
||||
const env = new jasmineUnderTest.Env();
|
||||
const env = new privateUnderTest.Env();
|
||||
|
||||
try {
|
||||
env.setSuiteProperty('a', 'Bee');
|
||||
@@ -2778,12 +2823,18 @@ describe('Env integration', function() {
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
},
|
||||
// Enough Node globals to make getStackClearer() return the microtask
|
||||
// implementation, which is the easiest to mock
|
||||
process: {
|
||||
versions: {
|
||||
node: ''
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
const reporter = jasmine.createSpyObj('reporter', [
|
||||
'jasmineDone',
|
||||
'suiteDone',
|
||||
@@ -2884,7 +2935,7 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('should report deprecation stack with an error object', async function() {
|
||||
const exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
||||
const exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
||||
reporter = jasmine.createSpyObj('reporter', [
|
||||
'jasmineDone',
|
||||
'suiteDone',
|
||||
@@ -3158,7 +3209,7 @@ describe('Env integration', function() {
|
||||
|
||||
const result = jasmineDone.calls.argsFor(0)[0];
|
||||
expect(result.failedExpectations).toEqual([
|
||||
jasmine.objectContaining({
|
||||
{
|
||||
passed: false,
|
||||
globalErrorType: 'lateExpectation',
|
||||
message:
|
||||
@@ -3167,13 +3218,14 @@ describe('Env integration', function() {
|
||||
'1. Did you forget to return or await the result of expectAsync?\n' +
|
||||
'2. Was done() invoked before an async operation completed?\n' +
|
||||
'3. Did an expectation follow a call to done()?',
|
||||
matcherName: 'toBeResolved'
|
||||
})
|
||||
matcherName: 'toBeResolved',
|
||||
stack: jasmine.any(String)
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('supports asymmetric equality testers that take a matchersUtil', async function() {
|
||||
const env = new jasmineUnderTest.Env();
|
||||
const env = new privateUnderTest.Env();
|
||||
|
||||
env.it('spec using custom asymmetric equality tester', function() {
|
||||
const customEqualityFn = function(a, b) {
|
||||
@@ -3230,27 +3282,25 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('is resolved after the stack is cleared', function(done) {
|
||||
const realClearStack = jasmineUnderTest.getClearStack(
|
||||
jasmineUnderTest.getGlobal()
|
||||
),
|
||||
clearStackSpy = jasmine
|
||||
.createSpy('clearStack')
|
||||
.and.callFake(realClearStack);
|
||||
spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(clearStackSpy);
|
||||
const stackClearer = privateUnderTest.getStackClearer(
|
||||
jasmineUnderTest.getGlobal()
|
||||
);
|
||||
spyOn(stackClearer, 'clearStack').and.callThrough();
|
||||
spyOn(privateUnderTest, 'getStackClearer').and.returnValue(stackClearer);
|
||||
|
||||
// Create a new env that has the clearStack defined above
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
|
||||
env.describe('suite', function() {
|
||||
env.it('spec', function() {});
|
||||
});
|
||||
|
||||
env.execute(null).then(function() {
|
||||
expect(clearStackSpy).toHaveBeenCalled(); // (many times)
|
||||
clearStackSpy.calls.reset();
|
||||
expect(stackClearer.clearStack).toHaveBeenCalled(); // (many times)
|
||||
stackClearer.clearStack.calls.reset();
|
||||
setTimeout(function() {
|
||||
expect(clearStackSpy).not.toHaveBeenCalled();
|
||||
expect(stackClearer.clearStack).not.toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -3268,7 +3318,7 @@ describe('Env integration', function() {
|
||||
|
||||
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = 123456; // a distinctive value
|
||||
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
|
||||
env.describe('suite', function() {
|
||||
env.it('spec', function() {});
|
||||
@@ -3339,17 +3389,15 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('is called after the stack is cleared', async function() {
|
||||
const realClearStack = jasmineUnderTest.getClearStack(
|
||||
jasmineUnderTest.getGlobal()
|
||||
),
|
||||
clearStackSpy = jasmine
|
||||
.createSpy('clearStack')
|
||||
.and.callFake(realClearStack);
|
||||
spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(clearStackSpy);
|
||||
const stackClearer = privateUnderTest.getStackClearer(
|
||||
jasmineUnderTest.getGlobal()
|
||||
);
|
||||
spyOn(stackClearer, 'clearStack').and.callThrough();
|
||||
spyOn(privateUnderTest, 'getStackClearer').and.returnValue(stackClearer);
|
||||
|
||||
// Create a new env that has the clearStack defined above
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
|
||||
env.describe('suite', function() {
|
||||
env.it('spec', function() {});
|
||||
@@ -3357,12 +3405,12 @@ describe('Env integration', function() {
|
||||
|
||||
await env.execute();
|
||||
|
||||
expect(clearStackSpy).toHaveBeenCalled(); // (many times)
|
||||
clearStackSpy.calls.reset();
|
||||
expect(stackClearer.clearStack).toHaveBeenCalled(); // (many times)
|
||||
stackClearer.clearStack.calls.reset();
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve));
|
||||
|
||||
expect(clearStackSpy).not.toHaveBeenCalled();
|
||||
expect(stackClearer.clearStack).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('is called after QueueRunner timeouts are cleared', async function() {
|
||||
@@ -3377,7 +3425,7 @@ describe('Env integration', function() {
|
||||
|
||||
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = 123456; // a distinctive value
|
||||
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
|
||||
env.describe('suite', function() {
|
||||
env.it('spec', function() {});
|
||||
@@ -3703,11 +3751,8 @@ describe('Env integration', function() {
|
||||
|
||||
await env.execute();
|
||||
expect(thrown).toBeInstanceOf(Error);
|
||||
expect(thrown.passed).toEqual(false);
|
||||
expect(thrown.matcherName).toEqual('toEqual');
|
||||
expect(thrown.message).toEqual('Expected 1 to equal 2.');
|
||||
expect(thrown.actual).toEqual(1);
|
||||
expect(thrown.expected).toEqual(2);
|
||||
});
|
||||
|
||||
it('does not throw when the matcher passes', async function() {
|
||||
@@ -3759,13 +3804,10 @@ describe('Env integration', function() {
|
||||
|
||||
await env.execute();
|
||||
expect(thrown).toBeInstanceOf(Error);
|
||||
expect(thrown.passed).toEqual(false);
|
||||
expect(thrown.matcherName).toEqual('toBeResolvedTo');
|
||||
expect(thrown.message).toEqual(
|
||||
"Expected a promise to be resolved to 'b' but it was resolved to 'a'."
|
||||
);
|
||||
expect(thrown.actual).toBe(promise);
|
||||
expect(thrown.expected).toEqual('b');
|
||||
});
|
||||
|
||||
it('does not throw when the matcher passes', async function() {
|
||||
@@ -3802,6 +3844,34 @@ describe('Env integration', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('pp', function() {
|
||||
it("pretty-prints using the current runable's custom object formatters", async function() {
|
||||
env.it('a spec', function() {
|
||||
env.addCustomObjectFormatter(function(x) {
|
||||
if (x === 1) {
|
||||
return 'hi!';
|
||||
}
|
||||
});
|
||||
env.expect(env.pp(1)).toEqual('hi!');
|
||||
});
|
||||
|
||||
const reporter = jasmine.createSpyObj('reporter', ['specDone']);
|
||||
env.addReporter(reporter);
|
||||
|
||||
await env.execute();
|
||||
|
||||
expect(reporter.specDone).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
failedExpectations: []
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('works when there is no current runable', function() {
|
||||
expect(env.pp({ some: 'thing' })).toEqual("Object({ some: 'thing' })");
|
||||
});
|
||||
});
|
||||
|
||||
it('forbids duplicates when forbidDuplicateNames is true', function() {
|
||||
env.configure({ forbidDuplicateNames: true });
|
||||
env.it('a spec');
|
||||
|
||||
@@ -4,15 +4,15 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
specHelpers.registerIntegrationMatchers();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
env.cleanup_();
|
||||
});
|
||||
|
||||
it('reports errors that occur during loading', async function() {
|
||||
const global = {
|
||||
function mockGlobal() {
|
||||
return {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
@@ -23,12 +23,21 @@ describe('Global error handling (integration)', function() {
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
},
|
||||
onerror: function() {}
|
||||
onerror: function() {},
|
||||
// Enough Node globals to make getStackClearer() return the microtask
|
||||
// implementation, which is the easiest to mock
|
||||
process: {
|
||||
versions: {
|
||||
node: ''
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
}
|
||||
|
||||
it('reports errors that occur during loading', async function() {
|
||||
const global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
const reporter = jasmine.createSpyObj('reporter', [
|
||||
'jasmineDone',
|
||||
'suiteDone',
|
||||
@@ -53,45 +62,34 @@ describe('Global error handling (integration)', function() {
|
||||
passed: false,
|
||||
globalErrorType: 'load',
|
||||
message: 'Uncaught SyntaxError: Unexpected end of input',
|
||||
stack: undefined,
|
||||
filename: 'borkenSpec.js',
|
||||
lineno: 42
|
||||
lineno: 42,
|
||||
matcherName: undefined,
|
||||
stack: jasmine.any(String)
|
||||
},
|
||||
{
|
||||
passed: false,
|
||||
globalErrorType: 'load',
|
||||
message: 'ENOCHEESE',
|
||||
stack: error.stack,
|
||||
filename: undefined,
|
||||
lineno: undefined
|
||||
matcherName: undefined,
|
||||
stack: jasmine.any(String)
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
describe('If suppressLoadErrors: true was passed', function() {
|
||||
it('does not install a global error handler during loading', async function() {
|
||||
const global = mockGlobal();
|
||||
const originalOnerror = jasmine.createSpy('original onerror');
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
},
|
||||
onerror: originalOnerror
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
const globalErrors = new jasmineUnderTest.GlobalErrors(global);
|
||||
global.onerror = originalOnerror;
|
||||
const globalErrors = new privateUnderTest.GlobalErrors(global);
|
||||
const onerror = jasmine.createSpy('onerror');
|
||||
globalErrors.pushListener(onerror);
|
||||
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env({
|
||||
env = new privateUnderTest.Env({
|
||||
suppressLoadErrors: true,
|
||||
global,
|
||||
GlobalErrors: function() {
|
||||
return globalErrors;
|
||||
}
|
||||
@@ -115,21 +113,9 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe('Handling unhandled exceptions', function() {
|
||||
it('routes unhandled exceptions to the running spec', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
const global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
const reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
'specDone',
|
||||
'suiteDone'
|
||||
@@ -156,24 +142,12 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe('When the most recently running spec has reported specDone', function() {
|
||||
it('routes unhandled exceptions to an ancestor suite', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn) {
|
||||
clearTimeout(fn);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
|
||||
const realClearStack = jasmineUnderTest.getClearStack(global);
|
||||
const global = mockGlobal();
|
||||
const stackClearer = privateUnderTest.getStackClearer(global);
|
||||
const realClearStack = stackClearer.clearStack;
|
||||
const clearStackCallbacks = {};
|
||||
let clearStackCallCount = 0;
|
||||
spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(function(fn) {
|
||||
spyOn(stackClearer, 'clearStack').and.callFake(function(fn) {
|
||||
clearStackCallCount++;
|
||||
|
||||
if (clearStackCallbacks[clearStackCallCount]) {
|
||||
@@ -182,9 +156,12 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
realClearStack(fn);
|
||||
});
|
||||
spyOn(privateUnderTest, 'getStackClearer').and.returnValue(
|
||||
stackClearer
|
||||
);
|
||||
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
|
||||
let suiteErrors = [];
|
||||
env.addReporter({
|
||||
@@ -220,21 +197,9 @@ describe('Global error handling (integration)', function() {
|
||||
});
|
||||
|
||||
it('routes unhandled exceptions to the running suite', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
const global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
const reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
'specDone',
|
||||
'suiteDone'
|
||||
@@ -273,24 +238,12 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe('When the most recently suite has reported suiteDone', function() {
|
||||
it('routes unhandled exceptions to an ancestor suite', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
|
||||
const realClearStack = jasmineUnderTest.getClearStack(global);
|
||||
const global = mockGlobal();
|
||||
const stackClearer = privateUnderTest.getStackClearer(global);
|
||||
const realClearStack = stackClearer.clearStack;
|
||||
const clearStackCallbacks = {};
|
||||
let clearStackCallCount = 0;
|
||||
spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(function(fn) {
|
||||
spyOn(stackClearer, 'clearStack').and.callFake(function(fn) {
|
||||
clearStackCallCount++;
|
||||
|
||||
if (clearStackCallbacks[clearStackCallCount]) {
|
||||
@@ -299,9 +252,12 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
realClearStack(fn);
|
||||
});
|
||||
spyOn(privateUnderTest, 'getStackClearer').and.returnValue(
|
||||
stackClearer
|
||||
);
|
||||
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
|
||||
let suiteErrors = [];
|
||||
env.addReporter({
|
||||
@@ -341,21 +297,9 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe('When the env has started reporting jasmineDone', function() {
|
||||
it('logs the error to the console', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
const global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
|
||||
spyOn(console, 'error');
|
||||
|
||||
@@ -384,26 +328,14 @@ describe('Global error handling (integration)', function() {
|
||||
});
|
||||
|
||||
it('routes all errors that occur during stack clearing somewhere', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn) {
|
||||
clearTimeout(fn);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
|
||||
const realClearStack = jasmineUnderTest.getClearStack(global);
|
||||
const global = mockGlobal();
|
||||
const stackClearer = privateUnderTest.getStackClearer(global);
|
||||
const realClearStack = stackClearer.clearStack;
|
||||
let clearStackCallCount = 0;
|
||||
let jasmineDone = false;
|
||||
const expectedErrors = [];
|
||||
const expectedErrorsAfterJasmineDone = [];
|
||||
spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(function(fn) {
|
||||
spyOn(stackClearer, 'clearStack').and.callFake(function(fn) {
|
||||
clearStackCallCount++;
|
||||
const msg = `Error in clearStack #${clearStackCallCount}`;
|
||||
|
||||
@@ -416,10 +348,11 @@ describe('Global error handling (integration)', function() {
|
||||
dispatchErrorEvent(global, 'error', { error: msg });
|
||||
realClearStack(fn);
|
||||
});
|
||||
spyOn(privateUnderTest, 'getStackClearer').and.returnValue(stackClearer);
|
||||
spyOn(console, 'error');
|
||||
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
|
||||
const receivedErrors = [];
|
||||
function logErrors(event) {
|
||||
@@ -459,21 +392,9 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe('Handling unhandled promise rejections', function() {
|
||||
it('routes unhandled promise rejections to the running spec', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
const global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
const reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
'specDone',
|
||||
'suiteDone'
|
||||
@@ -502,24 +423,12 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe('When the most recently running spec has reported specDone', function() {
|
||||
it('routes unhandled promise rejections to an ancestor suite', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn) {
|
||||
clearTimeout(fn);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
|
||||
const realClearStack = jasmineUnderTest.getClearStack(global);
|
||||
const global = mockGlobal();
|
||||
const stackClearer = privateUnderTest.getStackClearer(global);
|
||||
const realClearStack = stackClearer.clearStack;
|
||||
const clearStackCallbacks = {};
|
||||
let clearStackCallCount = 0;
|
||||
spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(function(fn) {
|
||||
spyOn(stackClearer, 'clearStack').and.callFake(function(fn) {
|
||||
clearStackCallCount++;
|
||||
|
||||
if (clearStackCallbacks[clearStackCallCount]) {
|
||||
@@ -528,9 +437,12 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
realClearStack(fn);
|
||||
});
|
||||
spyOn(privateUnderTest, 'getStackClearer').and.returnValue(
|
||||
stackClearer
|
||||
);
|
||||
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
|
||||
let suiteErrors = [];
|
||||
env.addReporter({
|
||||
@@ -566,21 +478,9 @@ describe('Global error handling (integration)', function() {
|
||||
});
|
||||
|
||||
it('routes unhandled promise rejections to the running suite', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
const global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
const reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
'specDone',
|
||||
'suiteDone'
|
||||
@@ -621,24 +521,12 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe('When the most recently suite has reported suiteDone', function() {
|
||||
it('routes unhandled promise rejections to an ancestor suite', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
|
||||
const realClearStack = jasmineUnderTest.getClearStack(global);
|
||||
const global = mockGlobal();
|
||||
const stackClearer = privateUnderTest.getStackClearer(global);
|
||||
const realClearStack = stackClearer.clearStack;
|
||||
const clearStackCallbacks = {};
|
||||
let clearStackCallCount = 0;
|
||||
spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(function(fn) {
|
||||
spyOn(stackClearer, 'clearStack').and.callFake(function(fn) {
|
||||
clearStackCallCount++;
|
||||
|
||||
if (clearStackCallbacks[clearStackCallCount]) {
|
||||
@@ -647,9 +535,12 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
realClearStack(fn);
|
||||
});
|
||||
spyOn(privateUnderTest, 'getStackClearer').and.returnValue(
|
||||
stackClearer
|
||||
);
|
||||
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
|
||||
let suiteErrors = [];
|
||||
env.addReporter({
|
||||
@@ -689,21 +580,9 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe('When the env has started reporting jasmineDone', function() {
|
||||
it('logs the rejection to the console', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
const global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
|
||||
spyOn(console, 'error');
|
||||
|
||||
@@ -734,26 +613,14 @@ describe('Global error handling (integration)', function() {
|
||||
});
|
||||
|
||||
it('routes all unhandled promise rejections that occur during stack clearing somewhere', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn) {
|
||||
clearTimeout(fn);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
|
||||
const realClearStack = jasmineUnderTest.getClearStack(global);
|
||||
const global = mockGlobal();
|
||||
const stackClearer = privateUnderTest.getStackClearer(global);
|
||||
const realClearStack = stackClearer.clearStack;
|
||||
let clearStackCallCount = 0;
|
||||
let jasmineDone = false;
|
||||
const expectedErrors = [];
|
||||
const expectedErrorsAfterJasmineDone = [];
|
||||
spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(function(fn) {
|
||||
spyOn(stackClearer, 'clearStack').and.callFake(function(fn) {
|
||||
clearStackCallCount++;
|
||||
const reason = `Error in clearStack #${clearStackCallCount}`;
|
||||
const expectedMsg = `Unhandled promise rejection: ${reason} thrown`;
|
||||
@@ -767,10 +634,11 @@ describe('Global error handling (integration)', function() {
|
||||
dispatchErrorEvent(global, 'unhandledrejection', { reason });
|
||||
realClearStack(fn);
|
||||
});
|
||||
spyOn(privateUnderTest, 'getStackClearer').and.returnValue(stackClearer);
|
||||
spyOn(console, 'error');
|
||||
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
|
||||
const receivedErrors = [];
|
||||
function logErrors(event) {
|
||||
@@ -819,21 +687,9 @@ describe('Global error handling (integration)', function() {
|
||||
let global, reporter;
|
||||
|
||||
beforeEach(function() {
|
||||
global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
env.configure({ detectLateRejectionHandling: true });
|
||||
|
||||
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
@@ -966,21 +822,8 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe("When the unhandled rejection event doesn't have a promise", function() {
|
||||
it('reports the rejection', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
const global = mockGlobal();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
env.configure({ detectLateRejectionHandling: true });
|
||||
const reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
'specDone',
|
||||
@@ -1012,21 +855,9 @@ describe('Global error handling (integration)', function() {
|
||||
});
|
||||
|
||||
it('works when the suite is run multiple times', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
const global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
env.configure({ autoCleanClosures: false });
|
||||
const reporter = jasmine.createSpyObj('fakeReporter', ['specDone']);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ describe('Matchers (Integration)', function() {
|
||||
let env;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
@@ -143,7 +143,7 @@ describe('Matchers (Integration)', function() {
|
||||
|
||||
function verifyFailsWithCustomObjectFormattersAsync(config) {
|
||||
it('uses custom object formatters', async function() {
|
||||
const env = new jasmineUnderTest.Env();
|
||||
const env = new privateUnderTest.Env();
|
||||
env.it('a spec', function() {
|
||||
env.addCustomObjectFormatter(config.formatter);
|
||||
return config.expectations(env);
|
||||
|
||||
@@ -2,7 +2,7 @@ describe('Support for parallel execution', function() {
|
||||
let env;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
|
||||
@@ -3,7 +3,7 @@ describe('spec running', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
specHelpers.registerIntegrationMatchers();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env = new privateUnderTest.Env();
|
||||
env.configure({ random: false });
|
||||
});
|
||||
|
||||
@@ -40,7 +40,7 @@ describe('spec running', function() {
|
||||
env.it('should run nested suites', function() {
|
||||
foo++;
|
||||
});
|
||||
env.it('should run nested suites', function() {
|
||||
env.it('should run nested suites 2', function() {
|
||||
bar++;
|
||||
});
|
||||
});
|
||||
@@ -601,37 +601,7 @@ describe('spec running', function() {
|
||||
]);
|
||||
});
|
||||
|
||||
it('re-enters suites that have no *Alls', async function() {
|
||||
const actions = [];
|
||||
let spec1;
|
||||
let spec2;
|
||||
let spec3;
|
||||
|
||||
env.describe('top', function() {
|
||||
spec1 = env.it('spec1', function() {
|
||||
actions.push('spec1');
|
||||
});
|
||||
|
||||
spec2 = env.it('spec2', function() {
|
||||
actions.push('spec2');
|
||||
});
|
||||
});
|
||||
|
||||
spec3 = env.it('spec3', function() {
|
||||
actions.push('spec3');
|
||||
});
|
||||
|
||||
spyOn(jasmineUnderTest.getEnv(), 'deprecated');
|
||||
|
||||
await env.execute([spec2.id, spec3.id, spec1.id]);
|
||||
|
||||
expect(actions).toEqual(['spec2', 'spec3', 'spec1']);
|
||||
expect(jasmineUnderTest.getEnv().deprecated).toHaveBeenCalledWith(
|
||||
'The specified spec/suite order splits up a suite, running unrelated specs in the middle of it. This will become an error in a future release.'
|
||||
);
|
||||
});
|
||||
|
||||
it('refuses to re-enter suites with a beforeAll', async function() {
|
||||
it('refuses to re-enter suites', async function() {
|
||||
const actions = [];
|
||||
let spec1;
|
||||
let spec2;
|
||||
@@ -654,34 +624,9 @@ describe('spec running', function() {
|
||||
});
|
||||
|
||||
const promise = env.execute([spec2.id, spec3.id, spec1.id]);
|
||||
await expectAsync(promise).toBeRejectedWithError(/beforeAll/);
|
||||
expect(actions).toEqual([]);
|
||||
});
|
||||
|
||||
it('refuses to re-enter suites with a afterAll', async function() {
|
||||
const actions = [];
|
||||
let spec1;
|
||||
let spec2;
|
||||
let spec3;
|
||||
|
||||
env.describe('top', function() {
|
||||
env.afterAll(function() {});
|
||||
|
||||
spec1 = env.it('spec1', function() {
|
||||
actions.push('spec1');
|
||||
});
|
||||
|
||||
spec2 = env.it('spec2', function() {
|
||||
actions.push('spec2');
|
||||
});
|
||||
});
|
||||
|
||||
spec3 = env.it('spec3', function() {
|
||||
actions.push('spec3');
|
||||
});
|
||||
|
||||
const promise = env.execute([spec2.id, spec3.id, spec1.id]);
|
||||
await expectAsync(promise).toBeRejectedWithError(/afterAll/);
|
||||
await expectAsync(promise).toBeRejectedWithError(
|
||||
'Invalid order: would split up a suite'
|
||||
);
|
||||
expect(actions).toEqual([]);
|
||||
});
|
||||
|
||||
|
||||
124
spec/core/jasmineNamespaceSpec.js
Normal file
124
spec/core/jasmineNamespaceSpec.js
Normal file
@@ -0,0 +1,124 @@
|
||||
describe('The jasmine namespace', function() {
|
||||
it('includes all expected properties', function() {
|
||||
const actualKeys = new Set(Object.keys(jasmineUnderTest));
|
||||
// toEqual doesn't generate diffs for set comparisons. Check this way
|
||||
// instead so we get readable failure output.
|
||||
expect(setDifference(expectedKeys(), actualKeys)).toEqual(new Set());
|
||||
});
|
||||
|
||||
it('does not include any unexpected properties', function() {
|
||||
const actualKeys = new Set(Object.keys(jasmineUnderTest));
|
||||
// toEqual doesn't generate diffs for set comparisons. Check this way
|
||||
// instead so we get readable failure output.
|
||||
expect(setDifference(actualKeys, expectedKeys())).toEqual(new Set());
|
||||
});
|
||||
|
||||
describe('Preventing monkey patching', function() {
|
||||
const mutable = mutableKeys();
|
||||
|
||||
for (const key of expectedKeys()) {
|
||||
if (mutable.includes(key)) {
|
||||
it(`allows overwriting of jasmine.${key}`, function() {
|
||||
const existingVal = jasmineUnderTest[key];
|
||||
|
||||
try {
|
||||
jasmineUnderTest[key] = 'new value';
|
||||
expect(jasmineUnderTest[key]).toEqual('new value');
|
||||
} finally {
|
||||
jasmineUnderTest[key] = existingVal;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
it(`prevents overwriting of jasmine.${key}`, function() {
|
||||
const existingVal = jasmineUnderTest[key];
|
||||
|
||||
try {
|
||||
jasmineUnderTest[key] = 'monkey patch';
|
||||
expect(jasmineUnderTest[key]).toBe(existingVal);
|
||||
} finally {
|
||||
// This will be a no-op if the test passed, but will prevent state
|
||||
// leakage if it failed.
|
||||
jasmineUnderTest[key] = existingVal;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
it('allows additions', function() {
|
||||
try {
|
||||
jasmineUnderTest.Ajax = 'it worked';
|
||||
expect(jasmineUnderTest.Ajax).toEqual('it worked');
|
||||
} finally {
|
||||
delete jasmineUnderTest.Ajax;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function mutableKeys() {
|
||||
return [
|
||||
'MAX_PRETTY_PRINT_ARRAY_LENGTH',
|
||||
'MAX_PRETTY_PRINT_CHARS',
|
||||
'MAX_PRETTY_PRINT_DEPTH',
|
||||
'DEFAULT_TIMEOUT_INTERVAL'
|
||||
];
|
||||
}
|
||||
|
||||
function expectedKeys() {
|
||||
// Does not include properties added by requireInterface(), since that isn't
|
||||
// called by defineJasmineUnderTest.js/nodeDefineJasmineUnderTest.js.
|
||||
const result = new Set([
|
||||
...mutableKeys(),
|
||||
'debugLog',
|
||||
'getEnv',
|
||||
'isSpy',
|
||||
'ParallelReportDispatcher',
|
||||
'spyOnGlobalErrorsAsync',
|
||||
'Timer',
|
||||
'version',
|
||||
|
||||
// Asymmetric equality testers
|
||||
'allOf',
|
||||
'any',
|
||||
'anything',
|
||||
'arrayContaining',
|
||||
'arrayWithExactContents',
|
||||
'empty',
|
||||
'falsy',
|
||||
'is',
|
||||
'mapContaining',
|
||||
'notEmpty',
|
||||
'objectContaining',
|
||||
'setContaining',
|
||||
'stringContaining',
|
||||
'stringMatching',
|
||||
'truthy',
|
||||
|
||||
// Currently undocumented but used in browser boot files, so it's
|
||||
// effectively public
|
||||
'getGlobal'
|
||||
]);
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
// jasmine-html.js
|
||||
result.add('HtmlReporterV2');
|
||||
result.add('HtmlReporterV2Urls');
|
||||
result.add('QueryString');
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Can't use Set#difference yet because it isn't available in Node <22,
|
||||
// Firefox <108, or Safari <17.
|
||||
function setDifference(a, b) {
|
||||
const result = new Set();
|
||||
|
||||
for (const v of a) {
|
||||
if (!b.has(v)) {
|
||||
result.add(v);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
describe('DiffBuilder', function() {
|
||||
it('records the actual and expected objects', function() {
|
||||
const diffBuilder = new jasmineUnderTest.DiffBuilder();
|
||||
const diffBuilder = new privateUnderTest.DiffBuilder();
|
||||
diffBuilder.setRoots({ x: 'actual' }, { x: 'expected' });
|
||||
diffBuilder.recordMismatch();
|
||||
|
||||
@@ -10,7 +10,7 @@ describe('DiffBuilder', function() {
|
||||
});
|
||||
|
||||
it('prints the path at which the difference was found', function() {
|
||||
const diffBuilder = new jasmineUnderTest.DiffBuilder();
|
||||
const diffBuilder = new privateUnderTest.DiffBuilder();
|
||||
diffBuilder.setRoots({ foo: { x: 'actual' } }, { foo: { x: 'expected' } });
|
||||
|
||||
diffBuilder.withPath('foo', function() {
|
||||
@@ -23,7 +23,7 @@ describe('DiffBuilder', function() {
|
||||
});
|
||||
|
||||
it('prints multiple messages, separated by newlines', function() {
|
||||
const diffBuilder = new jasmineUnderTest.DiffBuilder();
|
||||
const diffBuilder = new privateUnderTest.DiffBuilder();
|
||||
diffBuilder.setRoots({ foo: 1, bar: 3 }, { foo: 2, bar: 4 });
|
||||
|
||||
diffBuilder.withPath('foo', function() {
|
||||
@@ -40,7 +40,7 @@ describe('DiffBuilder', function() {
|
||||
});
|
||||
|
||||
it('allows customization of the message', function() {
|
||||
const diffBuilder = new jasmineUnderTest.DiffBuilder();
|
||||
const diffBuilder = new privateUnderTest.DiffBuilder();
|
||||
diffBuilder.setRoots({ x: 'bar' }, { x: 'foo' });
|
||||
|
||||
function darthVaderFormatter(actual, expected, path) {
|
||||
@@ -68,7 +68,7 @@ describe('DiffBuilder', function() {
|
||||
const prettyPrinter = function(val) {
|
||||
return '|' + val + '|';
|
||||
},
|
||||
diffBuilder = new jasmineUnderTest.DiffBuilder({
|
||||
diffBuilder = new privateUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
});
|
||||
prettyPrinter.customFormat_ = function() {};
|
||||
@@ -86,7 +86,7 @@ describe('DiffBuilder', function() {
|
||||
it('passes the injected pretty-printer to the diff formatter', function() {
|
||||
const diffFormatter = jasmine.createSpy('diffFormatter'),
|
||||
prettyPrinter = function() {},
|
||||
diffBuilder = new jasmineUnderTest.DiffBuilder({
|
||||
diffBuilder = new privateUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
});
|
||||
prettyPrinter.customFormat_ = function() {};
|
||||
@@ -112,8 +112,8 @@ describe('DiffBuilder', function() {
|
||||
return '[number:' + x + ']';
|
||||
}
|
||||
};
|
||||
const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]);
|
||||
const diffBuilder = new jasmineUnderTest.DiffBuilder({
|
||||
const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]);
|
||||
const diffBuilder = new privateUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
});
|
||||
|
||||
@@ -131,8 +131,8 @@ describe('DiffBuilder', function() {
|
||||
return '[thing with a=' + x.a + ', b=' + JSON.stringify(x.b) + ']';
|
||||
}
|
||||
};
|
||||
const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]);
|
||||
const diffBuilder = new jasmineUnderTest.DiffBuilder({
|
||||
const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]);
|
||||
const diffBuilder = new privateUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
});
|
||||
const expectedMsg =
|
||||
@@ -167,8 +167,8 @@ describe('DiffBuilder', function() {
|
||||
return '[number:' + x + ']';
|
||||
}
|
||||
};
|
||||
const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]);
|
||||
const diffBuilder = new jasmineUnderTest.DiffBuilder({
|
||||
const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]);
|
||||
const diffBuilder = new privateUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
});
|
||||
|
||||
@@ -186,8 +186,8 @@ describe('DiffBuilder', function() {
|
||||
return '[number:' + x + ']';
|
||||
}
|
||||
};
|
||||
const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]);
|
||||
const diffBuilder = new jasmineUnderTest.DiffBuilder({
|
||||
const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]);
|
||||
const diffBuilder = new privateUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
});
|
||||
|
||||
@@ -205,8 +205,8 @@ describe('DiffBuilder', function() {
|
||||
return '[number:' + x + ']';
|
||||
}
|
||||
};
|
||||
const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]);
|
||||
const diffBuilder = new jasmineUnderTest.DiffBuilder({
|
||||
const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]);
|
||||
const diffBuilder = new privateUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
});
|
||||
|
||||
@@ -219,8 +219,8 @@ describe('DiffBuilder', function() {
|
||||
});
|
||||
|
||||
it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ at the root', function() {
|
||||
const prettyPrinter = jasmineUnderTest.makePrettyPrinter([]),
|
||||
diffBuilder = new jasmineUnderTest.DiffBuilder({
|
||||
const prettyPrinter = privateUnderTest.makePrettyPrinter([]),
|
||||
diffBuilder = new privateUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
}),
|
||||
expectedMsg =
|
||||
@@ -243,8 +243,8 @@ describe('DiffBuilder', function() {
|
||||
});
|
||||
|
||||
it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ below the root', function() {
|
||||
const prettyPrinter = jasmineUnderTest.makePrettyPrinter([]),
|
||||
diffBuilder = new jasmineUnderTest.DiffBuilder({
|
||||
const prettyPrinter = privateUnderTest.makePrettyPrinter([]),
|
||||
diffBuilder = new privateUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
}),
|
||||
expectedMsg =
|
||||
|
||||
@@ -2,25 +2,25 @@ describe('MismatchTree', function() {
|
||||
describe('#add', function() {
|
||||
describe('When the path is empty', function() {
|
||||
it('flags the root node as mismatched', function() {
|
||||
const tree = new jasmineUnderTest.MismatchTree();
|
||||
tree.add(new jasmineUnderTest.ObjectPath([]));
|
||||
const tree = new privateUnderTest.MismatchTree();
|
||||
tree.add(new privateUnderTest.ObjectPath([]));
|
||||
expect(tree.isMismatch).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the path is not empty', function() {
|
||||
it('flags the node as mismatched', function() {
|
||||
const tree = new jasmineUnderTest.MismatchTree();
|
||||
const tree = new privateUnderTest.MismatchTree();
|
||||
|
||||
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']));
|
||||
tree.add(new privateUnderTest.ObjectPath(['a', 'b']));
|
||||
|
||||
expect(tree.child('a').child('b').isMismatch).toBe(true);
|
||||
});
|
||||
|
||||
it('does not flag ancestors as mismatched', function() {
|
||||
const tree = new jasmineUnderTest.MismatchTree();
|
||||
const tree = new privateUnderTest.MismatchTree();
|
||||
|
||||
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']));
|
||||
tree.add(new privateUnderTest.ObjectPath(['a', 'b']));
|
||||
|
||||
expect(tree.isMismatch).toBe(false);
|
||||
expect(tree.child('a').isMismatch).toBe(false);
|
||||
@@ -28,9 +28,9 @@ describe('MismatchTree', function() {
|
||||
});
|
||||
|
||||
it('stores the formatter on only the target node', function() {
|
||||
const tree = new jasmineUnderTest.MismatchTree();
|
||||
const tree = new privateUnderTest.MismatchTree();
|
||||
|
||||
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']), formatter);
|
||||
tree.add(new privateUnderTest.ObjectPath(['a', 'b']), formatter);
|
||||
|
||||
expect(tree.formatter).toBeFalsy();
|
||||
expect(tree.child('a').formatter).toBeFalsy();
|
||||
@@ -38,9 +38,9 @@ describe('MismatchTree', function() {
|
||||
});
|
||||
|
||||
it('stores the path to the node', function() {
|
||||
const tree = new jasmineUnderTest.MismatchTree();
|
||||
const tree = new privateUnderTest.MismatchTree();
|
||||
|
||||
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']), formatter);
|
||||
tree.add(new privateUnderTest.ObjectPath(['a', 'b']), formatter);
|
||||
|
||||
expect(tree.child('a').child('b').path.components).toEqual(['a', 'b']);
|
||||
});
|
||||
@@ -48,37 +48,37 @@ describe('MismatchTree', function() {
|
||||
|
||||
describe('#traverse', function() {
|
||||
it('calls the callback for all nodes that are or contain mismatches', function() {
|
||||
const tree = new jasmineUnderTest.MismatchTree();
|
||||
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']), formatter);
|
||||
tree.add(new jasmineUnderTest.ObjectPath(['c']));
|
||||
const tree = new privateUnderTest.MismatchTree();
|
||||
tree.add(new privateUnderTest.ObjectPath(['a', 'b']), formatter);
|
||||
tree.add(new privateUnderTest.ObjectPath(['c']));
|
||||
const visit = jasmine.createSpy('visit').and.returnValue(true);
|
||||
|
||||
tree.traverse(visit);
|
||||
|
||||
expect(visit).toHaveBeenCalledWith(
|
||||
new jasmineUnderTest.ObjectPath([]),
|
||||
new privateUnderTest.ObjectPath([]),
|
||||
false,
|
||||
undefined
|
||||
);
|
||||
expect(visit).toHaveBeenCalledWith(
|
||||
new jasmineUnderTest.ObjectPath(['a']),
|
||||
new privateUnderTest.ObjectPath(['a']),
|
||||
false,
|
||||
undefined
|
||||
);
|
||||
expect(visit).toHaveBeenCalledWith(
|
||||
new jasmineUnderTest.ObjectPath(['a', 'b']),
|
||||
new privateUnderTest.ObjectPath(['a', 'b']),
|
||||
true,
|
||||
formatter
|
||||
);
|
||||
expect(visit).toHaveBeenCalledWith(
|
||||
new jasmineUnderTest.ObjectPath(['c']),
|
||||
new privateUnderTest.ObjectPath(['c']),
|
||||
true,
|
||||
undefined
|
||||
);
|
||||
});
|
||||
|
||||
it('does not call the callback if there are no mismatches', function() {
|
||||
const tree = new jasmineUnderTest.MismatchTree();
|
||||
const tree = new privateUnderTest.MismatchTree();
|
||||
const visit = jasmine.createSpy('visit');
|
||||
|
||||
tree.traverse(visit);
|
||||
@@ -87,8 +87,8 @@ describe('MismatchTree', function() {
|
||||
});
|
||||
|
||||
it('visits parents before children', function() {
|
||||
const tree = new jasmineUnderTest.MismatchTree();
|
||||
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']));
|
||||
const tree = new privateUnderTest.MismatchTree();
|
||||
tree.add(new privateUnderTest.ObjectPath(['a', 'b']));
|
||||
const visited = [];
|
||||
|
||||
tree.traverse(function(path) {
|
||||
@@ -97,16 +97,16 @@ describe('MismatchTree', function() {
|
||||
});
|
||||
|
||||
expect(visited).toEqual([
|
||||
new jasmineUnderTest.ObjectPath([]),
|
||||
new jasmineUnderTest.ObjectPath(['a']),
|
||||
new jasmineUnderTest.ObjectPath(['a', 'b'])
|
||||
new privateUnderTest.ObjectPath([]),
|
||||
new privateUnderTest.ObjectPath(['a']),
|
||||
new privateUnderTest.ObjectPath(['a', 'b'])
|
||||
]);
|
||||
});
|
||||
|
||||
it('visits children in the order they were recorded', function() {
|
||||
const tree = new jasmineUnderTest.MismatchTree();
|
||||
tree.add(new jasmineUnderTest.ObjectPath(['length']));
|
||||
tree.add(new jasmineUnderTest.ObjectPath([1]));
|
||||
const tree = new privateUnderTest.MismatchTree();
|
||||
tree.add(new privateUnderTest.ObjectPath(['length']));
|
||||
tree.add(new privateUnderTest.ObjectPath([1]));
|
||||
const visited = [];
|
||||
|
||||
tree.traverse(function(path) {
|
||||
@@ -115,15 +115,15 @@ describe('MismatchTree', function() {
|
||||
});
|
||||
|
||||
expect(visited).toEqual([
|
||||
new jasmineUnderTest.ObjectPath([]),
|
||||
new jasmineUnderTest.ObjectPath(['length']),
|
||||
new jasmineUnderTest.ObjectPath([1])
|
||||
new privateUnderTest.ObjectPath([]),
|
||||
new privateUnderTest.ObjectPath(['length']),
|
||||
new privateUnderTest.ObjectPath([1])
|
||||
]);
|
||||
});
|
||||
|
||||
it('does not visit children if the callback returns falsy', function() {
|
||||
const tree = new jasmineUnderTest.MismatchTree();
|
||||
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']));
|
||||
const tree = new privateUnderTest.MismatchTree();
|
||||
tree.add(new privateUnderTest.ObjectPath(['a', 'b']));
|
||||
const visited = [];
|
||||
|
||||
tree.traverse(function(path) {
|
||||
@@ -132,8 +132,8 @@ describe('MismatchTree', function() {
|
||||
});
|
||||
|
||||
expect(visited).toEqual([
|
||||
new jasmineUnderTest.ObjectPath([]),
|
||||
new jasmineUnderTest.ObjectPath(['a'])
|
||||
new privateUnderTest.ObjectPath([]),
|
||||
new privateUnderTest.ObjectPath(['a'])
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('NullDiffBuilder', function() {
|
||||
it('responds to withPath() by calling the passed function', function() {
|
||||
const spy = jasmine.createSpy('callback');
|
||||
jasmineUnderTest.NullDiffBuilder().withPath('does not matter', spy);
|
||||
privateUnderTest.NullDiffBuilder().withPath('does not matter', spy);
|
||||
expect(spy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
describe('ObjectPath', function() {
|
||||
const ObjectPath = jasmineUnderTest.ObjectPath;
|
||||
const ObjectPath = privateUnderTest.ObjectPath;
|
||||
|
||||
it('represents the path to a node in an object tree', function() {
|
||||
expect(new ObjectPath(['foo', 'bar']).toString()).toEqual('$.foo.bar');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('toBePending', function() {
|
||||
it('passes if the actual promise is pending', function() {
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil),
|
||||
actual = new Promise(function() {});
|
||||
|
||||
return matcher.compare(actual).then(function(result) {
|
||||
@@ -10,8 +10,8 @@ describe('toBePending', function() {
|
||||
});
|
||||
|
||||
it('fails if the actual promise is resolved', function() {
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil),
|
||||
actual = Promise.resolve();
|
||||
|
||||
return matcher.compare(actual).then(function(result) {
|
||||
@@ -20,8 +20,8 @@ describe('toBePending', function() {
|
||||
});
|
||||
|
||||
it('fails if the actual promise is rejected', function() {
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil),
|
||||
actual = Promise.reject(new Error('promise was rejected'));
|
||||
|
||||
return matcher.compare(actual).then(function(result) {
|
||||
@@ -30,8 +30,8 @@ describe('toBePending', function() {
|
||||
});
|
||||
|
||||
it('fails if actual is not a promise', function() {
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil),
|
||||
actual = 'not a promise';
|
||||
|
||||
function f() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('toBeRejected', function() {
|
||||
it('passes if the actual is rejected', function() {
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil),
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil),
|
||||
actual = Promise.reject('AsyncExpectationSpec rejection');
|
||||
|
||||
return matcher.compare(actual).then(function(result) {
|
||||
@@ -10,8 +10,8 @@ describe('toBeRejected', function() {
|
||||
});
|
||||
|
||||
it('fails if the actual is resolved', function() {
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil),
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil),
|
||||
actual = Promise.resolve();
|
||||
|
||||
return matcher.compare(actual).then(function(result) {
|
||||
@@ -20,8 +20,8 @@ describe('toBeRejected', function() {
|
||||
});
|
||||
|
||||
it('fails if actual is not a promise', function() {
|
||||
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil),
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil),
|
||||
actual = 'not a promise';
|
||||
|
||||
function f() {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user