Removed support for Internet Explorer

This commit is contained in:
Steve Gravrock
2021-07-23 19:48:53 -07:00
parent 623eecdcec
commit fe0a83ba87
51 changed files with 137 additions and 707 deletions
+4 -15
View File
@@ -92,6 +92,7 @@ Or, How to make a successful pull request
without test-driving it. without test-driving it.
* _Write code in the style of the rest of the repo_ - Jasmine should look like * _Write code in the style of the rest of the repo_ - Jasmine should look like
a cohesive whole. a cohesive whole.
* **Exception**: Prefer `const` or `let` over `var`.
* _Ensure the *entire* test suite is green_ in all the big browsers, Node, and * _Ensure the *entire* test suite is green_ in all the big browsers, Node, and
ESLint. Your contribution shouldn't break Jasmine for other users. ESLint. Your contribution shouldn't break Jasmine for other users.
@@ -100,27 +101,15 @@ Follow these tips and your pull request, patch, or suggestion is much more likel
### Running Specs ### Running Specs
Be sure to run the tests in at least one supported Node version and at least a Be sure to run the tests in at least one supported Node version and at least a
couple of supported browsers. It's also a good idea to run the tests in Internet couple of supported browsers. To run the tests in Node, simply use `npm test`
Explorer if you've touched code in `src/html`, if your change involves newer as described above. To run the tests in a browser, run `npm run serve` and then
JavaScript language/runtime features, or if you're unfamiliar with writing code visit `http://localhost:8888`.
for older browsers. To run the tests in Node, simply use `npm test` as described
above. To run the tests in a browser, run `npm run serve` and then visit
`http://localhost:8888`.
If you have the necessary Selenium drivers installed, you can also use Jasmine's If you have the necessary Selenium drivers installed, you can also use Jasmine's
CI tooling: CI tooling:
$ JASMINE_BROWSER=<name of browser> node spec/support/ci.js $ JASMINE_BROWSER=<name of browser> node spec/support/ci.js
The easiest way to run the tests in **Internet Explorer** is to run a VM that has IE installed. It's easy to do this with VirtualBox.
1. Download and install [VirtualBox](https://www.virtualbox.org/wiki/Downloads).
1. Download a VM image [from Microsoft](https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/). Select "VirtualBox" as the platform.
1. Unzip the downloaded archive. There should be an OVA file inside.
1. In VirtualBox, choose `File > Import Appliance` and select the OVA file. Accept the default settings in the dialog that appears. Now you have a Windows VM!
1. Run the VM and start IE.
1. With `npm run serve` running on your host machine, navigate to `http://<your IP address>:8888` in IE.
## Before Committing or Submitting a Pull Request ## Before Committing or Submitting a Pull Request
1. Ensure all specs are green in browser *and* node. 1. Ensure all specs are green in browser *and* node.
+23 -77
View File
@@ -267,25 +267,8 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
if (value instanceof Error) { if (value instanceof Error) {
return true; return true;
} }
if (
typeof window !== 'undefined' &&
typeof window.trustedTypes !== 'undefined'
) {
return (
typeof value.stack === 'string' && typeof value.message === 'string'
);
}
if (value && value.constructor && value.constructor.constructor) {
var valueGlobal = value.constructor.constructor('return this');
if (j$.isFunction_(valueGlobal)) {
valueGlobal = valueGlobal();
}
if (valueGlobal.Error && value instanceof valueGlobal.Error) { return typeof value.stack === 'string' && typeof value.message === 'string';
return true;
}
}
return false;
}; };
j$.isAsymmetricEqualityTester_ = function(obj) { j$.isAsymmetricEqualityTester_ = function(obj) {
@@ -327,7 +310,6 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return ( return (
obj !== null && obj !== null &&
typeof obj !== 'undefined' && typeof obj !== 'undefined' &&
typeof jasmineGlobal.WeakMap !== 'undefined' &&
obj.constructor === jasmineGlobal.WeakMap obj.constructor === jasmineGlobal.WeakMap
); );
}; };
@@ -336,7 +318,6 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return ( return (
obj !== null && obj !== null &&
typeof obj !== 'undefined' && typeof obj !== 'undefined' &&
typeof jasmineGlobal.URL !== 'undefined' &&
obj.constructor === jasmineGlobal.URL obj.constructor === jasmineGlobal.URL
); );
}; };
@@ -345,17 +326,12 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return ( return (
obj !== null && obj !== null &&
typeof obj !== 'undefined' && typeof obj !== 'undefined' &&
typeof jasmineGlobal.DataView !== 'undefined' &&
obj.constructor === jasmineGlobal.DataView obj.constructor === jasmineGlobal.DataView
); );
}; };
j$.isPromise = function(obj) { j$.isPromise = function(obj) {
return ( return !!obj && obj.constructor === jasmineGlobal.Promise;
typeof jasmineGlobal.Promise !== 'undefined' &&
!!obj &&
obj.constructor === jasmineGlobal.Promise
);
}; };
j$.isPromiseLike = function(obj) { j$.isPromiseLike = function(obj) {
@@ -376,7 +352,6 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
j$.isPending_ = function(promise) { j$.isPending_ = function(promise) {
var sentinel = {}; var sentinel = {};
// eslint-disable-next-line compat/compat
return Promise.race([promise, Promise.resolve(sentinel)]).then( return Promise.race([promise, Promise.resolve(sentinel)]).then(
function(result) { function(result) {
return result === sentinel; return result === sentinel;
@@ -676,21 +651,6 @@ getJasmineRequireObj().util = function(j$) {
StopIteration.prototype = Object.create(Error.prototype); StopIteration.prototype = Object.create(Error.prototype);
StopIteration.prototype.constructor = StopIteration; StopIteration.prototype.constructor = StopIteration;
// useful for maps and sets since `forEach` is the only IE11-compatible way to iterate them
util.forEachBreakable = function(iterable, iteratee) {
function breakLoop() {
throw new StopIteration();
}
try {
iterable.forEach(function(value, key) {
iteratee(breakLoop, value, key, iterable);
});
} catch (error) {
if (!(error instanceof StopIteration)) throw error;
}
};
return util; return util;
}; };
@@ -2559,27 +2519,26 @@ getJasmineRequireObj().MapContaining = function(j$) {
MapContaining.prototype.asymmetricMatch = function(other, matchersUtil) { MapContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!j$.isMap(other)) return false; if (!j$.isMap(other)) return false;
var hasAllMatches = true; for (const [key, value] of this.sample) {
j$.util.forEachBreakable(this.sample, function(breakLoop, value, key) {
// for each key/value pair in `sample` // for each key/value pair in `sample`
// there should be at least one pair in `other` whose key and value both match // there should be at least one pair in `other` whose key and value both match
var hasMatch = false; var hasMatch = false;
j$.util.forEachBreakable(other, function(oBreakLoop, oValue, oKey) { for (const [oKey, oValue] of other) {
if ( if (
matchersUtil.equals(oKey, key) && matchersUtil.equals(oKey, key) &&
matchersUtil.equals(oValue, value) matchersUtil.equals(oValue, value)
) { ) {
hasMatch = true; hasMatch = true;
oBreakLoop(); break;
} }
});
if (!hasMatch) {
hasAllMatches = false;
breakLoop();
} }
});
return hasAllMatches; if (!hasMatch) {
return false;
}
}
return true;
}; };
MapContaining.prototype.jasmineToString = function(pp) { MapContaining.prototype.jasmineToString = function(pp) {
@@ -2711,25 +2670,24 @@ getJasmineRequireObj().SetContaining = function(j$) {
SetContaining.prototype.asymmetricMatch = function(other, matchersUtil) { SetContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!j$.isSet(other)) return false; if (!j$.isSet(other)) return false;
var hasAllMatches = true; for (const item of this.sample) {
j$.util.forEachBreakable(this.sample, function(breakLoop, item) {
// for each item in `sample` there should be at least one matching item in `other` // for each item in `sample` there should be at least one matching item in `other`
// (not using `matchersUtil.contains` because it compares set members by reference, // (not using `matchersUtil.contains` because it compares set members by reference,
// not by deep value equality) // not by deep value equality)
var hasMatch = false; var hasMatch = false;
j$.util.forEachBreakable(other, function(oBreakLoop, oItem) { for (const oItem of other) {
if (matchersUtil.equals(oItem, item)) { if (matchersUtil.equals(oItem, item)) {
hasMatch = true; hasMatch = true;
oBreakLoop(); break;
} }
});
if (!hasMatch) {
hasAllMatches = false;
breakLoop();
} }
});
return hasAllMatches; if (!hasMatch) {
return false;
}
}
return true;
}; };
SetContaining.prototype.jasmineToString = function(pp) { SetContaining.prototype.jasmineToString = function(pp) {
@@ -3670,15 +3628,8 @@ getJasmineRequireObj().Expectation = function(j$) {
* @namespace async-matchers * @namespace async-matchers
*/ */
function AsyncExpectation(options) { function AsyncExpectation(options) {
var global = options.global || j$.getGlobal();
this.expector = new j$.Expector(options); this.expector = new j$.Expector(options);
if (!global.Promise) {
throw new Error(
'expectAsync is unavailable because the environment does not support promises.'
);
}
var customAsyncMatchers = options.customAsyncMatchers || {}; var customAsyncMatchers = options.customAsyncMatchers || {};
for (var matcherName in customAsyncMatchers) { for (var matcherName in customAsyncMatchers) {
this[matcherName] = wrapAsyncCompare( this[matcherName] = wrapAsyncCompare(
@@ -4233,7 +4184,6 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
return GlobalErrors; return GlobalErrors;
}; };
/* eslint-disable compat/compat */
getJasmineRequireObj().toBePending = function(j$) { getJasmineRequireObj().toBePending = function(j$) {
/** /**
* Expect a promise to be pending, i.e. the promise is neither resolved nor rejected. * Expect a promise to be pending, i.e. the promise is neither resolved nor rejected.
@@ -6518,7 +6468,7 @@ getJasmineRequireObj().toHaveSize = function(j$) {
}; };
} }
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // eslint-disable-line compat/compat var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
function isLength(value) { function isLength(value) {
return ( return (
typeof value == 'number' && typeof value == 'number' &&
@@ -7019,11 +6969,7 @@ getJasmineRequireObj().MockDate = function() {
FakeDate.prototype = GlobalDate.prototype; FakeDate.prototype = GlobalDate.prototype;
FakeDate.now = function() { FakeDate.now = function() {
if (GlobalDate.now) { return currentTime;
return currentTime;
} else {
throw new Error('Browser does not support Date.now()');
}
}; };
FakeDate.toSource = GlobalDate.toSource; FakeDate.toSource = GlobalDate.toSource;
@@ -8970,7 +8916,7 @@ getJasmineRequireObj().StackTrace = function(j$) {
} }
var framePatterns = [ var framePatterns = [
// PhantomJS on Linux, Node, Chrome, IE, Edge // Node, Chrome, Edge
// e.g. " at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)" // e.g. " at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)"
// Note that the "function name" can include a surprisingly large set of // Note that the "function name" can include a surprisingly large set of
// characters, including angle brackets and square brackets. // characters, including angle brackets and square brackets.
+7 -6
View File
@@ -60,8 +60,10 @@
"extends": [ "extends": [
"plugin:compat/recommended" "plugin:compat/recommended"
], ],
"parserOptions": { "env": {
"ecmaVersion": 5 "browser": true,
"node": true,
"es2017": true
}, },
"rules": { "rules": {
"quotes": [ "quotes": [
@@ -94,11 +96,10 @@
} }
}, },
"browserslist": [ "browserslist": [
"Safari >= 9", "Safari >= 13",
"last 2 Chrome versions", "last 2 Chrome versions",
"last 2 Firefox versions", "last 2 Firefox versions",
"Firefox 68", "Firefox >= 68",
"last 2 Edge versions", "last 2 Edge versions"
"IE >= 11"
] ]
} }
-1
View File
@@ -23,7 +23,6 @@ run_browser() {
passfile=`mktemp -t jasmine-results.XXXXXX` || exit 1 passfile=`mktemp -t jasmine-results.XXXXXX` || exit 1
failfile=`mktemp -t jasmine-results.XXXXXX` || exit 1 failfile=`mktemp -t jasmine-results.XXXXXX` || exit 1
run_browser "internet explorer" 11
run_browser chrome latest run_browser chrome latest
run_browser firefox latest run_browser firefox latest
run_browser firefox 78 run_browser firefox 78
-58
View File
@@ -1,4 +1,3 @@
/* eslint-disable compat/compat */
describe('AsyncExpectation', function() { describe('AsyncExpectation', function() {
beforeEach(function() { beforeEach(function() {
jasmineUnderTest.Expectation.addAsyncCoreMatchers( jasmineUnderTest.Expectation.addAsyncCoreMatchers(
@@ -6,23 +5,8 @@ describe('AsyncExpectation', function() {
); );
}); });
describe('Factory', function() {
it('throws an Error if promises are not available', function() {
var thenable = { then: function() {} },
options = { global: {}, actual: thenable };
function f() {
jasmineUnderTest.Expectation.asyncFactory(options);
}
expect(f).toThrowError(
'expectAsync is unavailable because the environment does not support promises.'
);
});
});
describe('#not', function() { describe('#not', function() {
it('converts a pass to a fail', function() { it('converts a pass to a fail', function() {
jasmine.getEnv().requirePromises();
var addExpectationResult = jasmine.createSpy('addExpectationResult'), var addExpectationResult = jasmine.createSpy('addExpectationResult'),
actual = Promise.resolve(), actual = Promise.resolve(),
pp = jasmineUnderTest.makePrettyPrinter(), pp = jasmineUnderTest.makePrettyPrinter(),
@@ -44,8 +28,6 @@ describe('AsyncExpectation', function() {
}); });
it('converts a fail to a pass', function() { it('converts a fail to a pass', function() {
jasmine.getEnv().requirePromises();
var addExpectationResult = jasmine.createSpy('addExpectationResult'), var addExpectationResult = jasmine.createSpy('addExpectationResult'),
actual = Promise.reject(), actual = Promise.reject(),
expectation = jasmineUnderTest.Expectation.asyncFactory({ expectation = jasmineUnderTest.Expectation.asyncFactory({
@@ -69,7 +51,6 @@ describe('AsyncExpectation', function() {
}); });
it('propagates rejections from the comparison function', function() { it('propagates rejections from the comparison function', function() {
jasmine.getEnv().requirePromises();
var error = new Error('ExpectationSpec failure'); var error = new Error('ExpectationSpec failure');
var addExpectationResult = jasmine.createSpy('addExpectationResult'), var addExpectationResult = jasmine.createSpy('addExpectationResult'),
@@ -93,8 +74,6 @@ describe('AsyncExpectation', function() {
describe('#withContext', function() { describe('#withContext', function() {
it('prepends the context to the generated failure message', function() { it('prepends the context to the generated failure message', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = { var matchersUtil = {
pp: function(val) { pp: function(val) {
return val.toString(); return val.toString();
@@ -122,8 +101,6 @@ describe('AsyncExpectation', function() {
}); });
it('prepends the context to a custom failure message', function() { it('prepends the context to a custom failure message', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = { var matchersUtil = {
buildFailureMessage: function() { buildFailureMessage: function() {
return 'failure message'; return 'failure message';
@@ -154,7 +131,6 @@ describe('AsyncExpectation', function() {
it('prepends the context to a custom failure message from a function', function() { it('prepends the context to a custom failure message from a function', function() {
pending('should actually work, but no custom matchers for async yet'); pending('should actually work, but no custom matchers for async yet');
jasmine.getEnv().requirePromises();
var matchersUtil = { var matchersUtil = {
buildFailureMessage: function() { buildFailureMessage: function() {
@@ -183,8 +159,6 @@ describe('AsyncExpectation', function() {
}); });
it('works with #not', function() { it('works with #not', function() {
jasmine.getEnv().requirePromises();
var addExpectationResult = jasmine.createSpy('addExpectationResult'), var addExpectationResult = jasmine.createSpy('addExpectationResult'),
actual = Promise.resolve(), actual = Promise.resolve(),
pp = jasmineUnderTest.makePrettyPrinter(), pp = jasmineUnderTest.makePrettyPrinter(),
@@ -209,8 +183,6 @@ describe('AsyncExpectation', function() {
}); });
it('works with #not and a custom message', function() { it('works with #not and a custom message', function() {
jasmine.getEnv().requirePromises();
var addExpectationResult = jasmine.createSpy('addExpectationResult'), var addExpectationResult = jasmine.createSpy('addExpectationResult'),
actual = Promise.resolve('a'), actual = Promise.resolve('a'),
expectation = jasmineUnderTest.Expectation.asyncFactory({ expectation = jasmineUnderTest.Expectation.asyncFactory({
@@ -238,8 +210,6 @@ describe('AsyncExpectation', function() {
describe('async matchers', function() { describe('async matchers', function() {
it('makes custom matchers available to this expectation', function() { it('makes custom matchers available to this expectation', function() {
jasmine.getEnv().requirePromises();
var asyncMatchers = { var asyncMatchers = {
toFoo: function() {}, toFoo: function() {},
toBar: function() {} toBar: function() {}
@@ -255,8 +225,6 @@ describe('AsyncExpectation', function() {
}); });
it("wraps matchers's compare functions, passing in matcher dependencies", function() { it("wraps matchers's compare functions, passing in matcher dependencies", function() {
jasmine.getEnv().requirePromises();
var fakeCompare = function() { var fakeCompare = function() {
return Promise.resolve({ pass: true }); return Promise.resolve({ pass: true });
}, },
@@ -285,8 +253,6 @@ describe('AsyncExpectation', function() {
}); });
it("wraps matchers's compare functions, passing the actual and expected", function() { it("wraps matchers's compare functions, passing the actual and expected", function() {
jasmine.getEnv().requirePromises();
var fakeCompare = jasmine var fakeCompare = jasmine
.createSpy('fake-compare') .createSpy('fake-compare')
.and.returnValue(Promise.resolve({ pass: true })), .and.returnValue(Promise.resolve({ pass: true })),
@@ -316,8 +282,6 @@ describe('AsyncExpectation', function() {
}); });
it('reports a passing result to the spec when the comparison passes', function() { it('reports a passing result to the spec when the comparison passes', function() {
jasmine.getEnv().requirePromises();
var matchers = { var matchers = {
toFoo: function() { toFoo: function() {
return { return {
@@ -359,8 +323,6 @@ describe('AsyncExpectation', function() {
}); });
it('reports a failing result to the spec when the comparison fails', function() { it('reports a failing result to the spec when the comparison fails', function() {
jasmine.getEnv().requirePromises();
var matchers = { var matchers = {
toFoo: function() { toFoo: function() {
return { return {
@@ -404,8 +366,6 @@ describe('AsyncExpectation', function() {
}); });
it('reports a failing result and a custom fail message to the spec when the comparison fails', function() { it('reports a failing result and a custom fail message to the spec when the comparison fails', function() {
jasmine.getEnv().requirePromises();
var matchers = { var matchers = {
toFoo: function() { toFoo: function() {
return { return {
@@ -446,8 +406,6 @@ describe('AsyncExpectation', function() {
}); });
it('reports a failing result with a custom fail message function to the spec when the comparison fails', function() { it('reports a failing result with a custom fail message function to the spec when the comparison fails', function() {
jasmine.getEnv().requirePromises();
var matchers = { var matchers = {
toFoo: function() { toFoo: function() {
return { return {
@@ -490,8 +448,6 @@ describe('AsyncExpectation', function() {
}); });
it('reports a passing result to the spec when the comparison fails for a negative expectation', function() { it('reports a passing result to the spec when the comparison fails for a negative expectation', function() {
jasmine.getEnv().requirePromises();
var matchers = { var matchers = {
toFoo: function() { toFoo: function() {
return { return {
@@ -530,8 +486,6 @@ describe('AsyncExpectation', function() {
}); });
it('reports a failing result to the spec when the comparison passes for a negative expectation', function() { it('reports a failing result to the spec when the comparison passes for a negative expectation', function() {
jasmine.getEnv().requirePromises();
var matchers = { var matchers = {
toFoo: function() { toFoo: function() {
return { return {
@@ -576,8 +530,6 @@ describe('AsyncExpectation', function() {
}); });
it('reports a failing result and a custom fail message to the spec when the comparison passes for a negative expectation', function() { it('reports a failing result and a custom fail message to the spec when the comparison passes for a negative expectation', function() {
jasmine.getEnv().requirePromises();
var matchers = { var matchers = {
toFoo: function() { toFoo: function() {
return { return {
@@ -619,8 +571,6 @@ describe('AsyncExpectation', function() {
}); });
it("reports a passing result to the spec when the 'not' comparison passes, given a negativeCompare", function() { it("reports a passing result to the spec when the 'not' comparison passes, given a negativeCompare", function() {
jasmine.getEnv().requirePromises();
var matchers = { var matchers = {
toFoo: function() { toFoo: function() {
return { return {
@@ -662,8 +612,6 @@ describe('AsyncExpectation', function() {
}); });
it("reports a failing result and a custom fail message to the spec when the 'not' comparison fails, given a negativeCompare", function() { it("reports a failing result and a custom fail message to the spec when the 'not' comparison fails, given a negativeCompare", function() {
jasmine.getEnv().requirePromises();
var matchers = { var matchers = {
toFoo: function() { toFoo: function() {
return { return {
@@ -708,8 +656,6 @@ describe('AsyncExpectation', function() {
}); });
it('reports errorWithStack when a custom error message is returned', function() { it('reports errorWithStack when a custom error message is returned', function() {
jasmine.getEnv().requirePromises();
var customError = new Error('I am a custom error'); var customError = new Error('I am a custom error');
var matchers = { var matchers = {
toFoo: function() { toFoo: function() {
@@ -752,8 +698,6 @@ describe('AsyncExpectation', function() {
}); });
it("reports a custom message to the spec when a 'not' comparison fails", function() { it("reports a custom message to the spec when a 'not' comparison fails", function() {
jasmine.getEnv().requirePromises();
var matchers = { var matchers = {
toFoo: function() { toFoo: function() {
return { return {
@@ -794,8 +738,6 @@ describe('AsyncExpectation', function() {
}); });
it("reports a custom message func to the spec when a 'not' comparison fails", function() { it("reports a custom message func to the spec when a 'not' comparison fails", function() {
jasmine.getEnv().requirePromises();
var matchers = { var matchers = {
toFoo: function() { toFoo: function() {
return { return {
+6 -12
View File
@@ -223,9 +223,8 @@ describe('Env', function() {
}); });
it('accepts an async function', function() { it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() { expect(function() {
env.it('async', jasmine.getEnv().makeAsyncAwaitFunction()); env.it('async', async function() {});
}).not.toThrow(); }).not.toThrow();
}); });
}); });
@@ -255,9 +254,8 @@ describe('Env', function() {
}); });
it('accepts an async function', function() { it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() { expect(function() {
env.xit('async', jasmine.getEnv().makeAsyncAwaitFunction()); env.xit('async', async function() {});
}).not.toThrow(); }).not.toThrow();
}); });
}); });
@@ -282,9 +280,8 @@ describe('Env', function() {
}); });
it('accepts an async function', function() { it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() { expect(function() {
env.beforeEach(jasmine.getEnv().makeAsyncAwaitFunction()); env.beforeEach(async function() {});
}).not.toThrow(); }).not.toThrow();
}); });
}); });
@@ -299,9 +296,8 @@ describe('Env', function() {
}); });
it('accepts an async function', function() { it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() { expect(function() {
env.beforeAll(jasmine.getEnv().makeAsyncAwaitFunction()); env.beforeAll(async function() {});
}).not.toThrow(); }).not.toThrow();
}); });
}); });
@@ -316,9 +312,8 @@ describe('Env', function() {
}); });
it('accepts an async function', function() { it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() { expect(function() {
env.afterEach(jasmine.getEnv().makeAsyncAwaitFunction()); env.afterEach(async function() {});
}).not.toThrow(); }).not.toThrow();
}); });
}); });
@@ -333,9 +328,8 @@ describe('Env', function() {
}); });
it('accepts an async function', function() { it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() { expect(function() {
env.afterAll(jasmine.getEnv().makeAsyncAwaitFunction()); env.afterAll(async function() {});
}).not.toThrow(); }).not.toThrow();
}); });
}); });
-18
View File
@@ -96,24 +96,6 @@ describe('FakeDate', function() {
expect(fakeGlobal.Date.now()).toEqual(1000); expect(fakeGlobal.Date.now()).toEqual(1000);
}); });
it("does not stub Date.now() if it doesn't already exist", function() {
var globalDate = jasmine.createSpy('global Date').and.callFake(function() {
return {
getTime: function() {
return 1000;
}
};
}),
fakeGlobal = { Date: globalDate },
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
mockDate.install();
expect(fakeGlobal.Date.now).toThrowError(
'Browser does not support Date.now()'
);
});
it('makes time passes using tick', function() { it('makes time passes using tick', function() {
var globalDate = jasmine.createSpy('global Date').and.callFake(function() { var globalDate = jasmine.createSpy('global Date').and.callFake(function() {
return { return {
+8 -13
View File
@@ -295,20 +295,15 @@ describe('PrettyPrinter', function() {
it('should indicate getters on objects as such', function() { it('should indicate getters on objects as such', function() {
var pp = jasmineUnderTest.makePrettyPrinter(); var pp = jasmineUnderTest.makePrettyPrinter();
var sampleValue = { id: 1 }; var sampleValue = {
if (sampleValue.__defineGetter__) { id: 1,
//not supported in IE! get calculatedValue() {
sampleValue.__defineGetter__('calculatedValue', function() {
throw new Error("don't call me!"); throw new Error("don't call me!");
}); }
} };
if (sampleValue.__defineGetter__) { expect(pp(sampleValue)).toEqual(
expect(pp(sampleValue)).toEqual( 'Object({ id: 1, calculatedValue: <getter> })'
'Object({ id: 1, calculatedValue: <getter> })' );
);
} else {
expect(pp(sampleValue)).toEqual('Object({ id: 1 })');
}
}); });
it('should not do HTML escaping of strings', function() { it('should not do HTML escaping of strings', function() {
-1
View File
@@ -538,7 +538,6 @@ describe('QueueRunner', function() {
}); });
it('issues a more specific error if the function is `async`', function() { it('issues a more specific error if the function is `async`', function() {
jasmine.getEnv().requireAsyncAwait();
eval('var fn = async function(done){};'); eval('var fn = async function(done){};');
var onException = jasmine.createSpy('onException'), var onException = jasmine.createSpy('onException'),
queueRunner = new jasmineUnderTest.QueueRunner({ queueRunner = new jasmineUnderTest.QueueRunner({
-4
View File
@@ -61,10 +61,6 @@ describe('Spec', function() {
spec.execute(); spec.execute();
fakeQueueRunner.calls.mostRecent().args[0].queueableFns[0].fn(); fakeQueueRunner.calls.mostRecent().args[0].queueableFns[0].fn();
// TODO: due to some issue with the Pretty Printer, this line fails, but the other two pass.
// This means toHaveBeenCalledWith on IE8 will always be broken.
// expect(startCallback).toHaveBeenCalledWith(spec);
expect(startCallback).toHaveBeenCalled(); expect(startCallback).toHaveBeenCalled();
expect(startCallback.calls.first().object).toEqual(spec); expect(startCallback.calls.first().object).toEqual(spec);
}); });
+1 -8
View File
@@ -31,12 +31,7 @@ describe('Spies', function() {
var fn = function test() {}; var fn = function test() {};
var spy = env.createSpy(fn); var spy = env.createSpy(fn);
// IE doesn't do `.name` expect(spy.and.identity).toEqual('test');
if (fn.name === 'test') {
expect(spy.and.identity).toEqual('test');
} else {
expect(spy.and.identity).toEqual('unknown');
}
}); });
it('warns the user that we intend to overwrite an existing property', function() { it('warns the user that we intend to overwrite an existing property', function() {
@@ -254,8 +249,6 @@ describe('Spies', function() {
describe('any promise-based strategy', function() { describe('any promise-based strategy', function() {
it('works with global Promise library when available', function(done) { it('works with global Promise library when available', function(done) {
jasmine.getEnv().requirePromises();
var spy = env.createSpy('foo').and.resolveTo(42); var spy = env.createSpy('foo').and.resolveTo(42);
spy() spy()
.then(function(result) { .then(function(result) {
+3 -14
View File
@@ -108,7 +108,6 @@ describe('SpyStrategy', function() {
}); });
it('allows a fake async function to be called instead', function(done) { it('allows a fake async function to be called instead', function(done) {
jasmine.getEnv().requireAsyncAwait();
var originalFn = jasmine.createSpy('original'), var originalFn = jasmine.createSpy('original'),
fakeFn = jasmine fakeFn = jasmine
.createSpy('fake') .createSpy('fake')
@@ -131,8 +130,6 @@ describe('SpyStrategy', function() {
describe('#resolveTo', function() { describe('#resolveTo', function() {
it('allows a resolved promise to be returned', function(done) { it('allows a resolved promise to be returned', function(done) {
jasmine.getEnv().requirePromises();
var originalFn = jasmine.createSpy('original'), var originalFn = jasmine.createSpy('original'),
getPromise = function() { getPromise = function() {
return Promise; return Promise;
@@ -153,8 +150,6 @@ describe('SpyStrategy', function() {
}); });
it('allows an empty resolved promise to be returned', function(done) { it('allows an empty resolved promise to be returned', function(done) {
jasmine.getEnv().requirePromises();
var originalFn = jasmine.createSpy('original'), var originalFn = jasmine.createSpy('original'),
getPromise = function() { getPromise = function() {
return Promise; return Promise;
@@ -188,8 +183,6 @@ describe('SpyStrategy', function() {
describe('#rejectWith', function() { describe('#rejectWith', function() {
it('allows a rejected promise to be returned', function(done) { it('allows a rejected promise to be returned', function(done) {
jasmine.getEnv().requirePromises();
var originalFn = jasmine.createSpy('original'), var originalFn = jasmine.createSpy('original'),
getPromise = function() { getPromise = function() {
return Promise; return Promise;
@@ -211,8 +204,6 @@ describe('SpyStrategy', function() {
}); });
it('allows an empty rejected promise to be returned', function(done) { it('allows an empty rejected promise to be returned', function(done) {
jasmine.getEnv().requirePromises();
var originalFn = jasmine.createSpy('original'), var originalFn = jasmine.createSpy('original'),
getPromise = function() { getPromise = function() {
return Promise; return Promise;
@@ -234,8 +225,6 @@ describe('SpyStrategy', function() {
}); });
it('allows a non-Error to be rejected', function(done) { it('allows a non-Error to be rejected', function(done) {
jasmine.getEnv().requirePromises();
var originalFn = jasmine.createSpy('original'), var originalFn = jasmine.createSpy('original'),
getPromise = function() { getPromise = function() {
return Promise; return Promise;
@@ -335,9 +324,9 @@ describe('SpyStrategy', function() {
}); });
it('allows generator functions to be passed to callFake strategy', function() { it('allows generator functions to be passed to callFake strategy', function() {
jasmine.getEnv().requireGeneratorFunctions(); var generator = function*() {
yield 'ok';
var generator = jasmine.getEnv().makeGeneratorFunction('yield "ok";'), },
spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: function() {} }); spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: function() {} });
spyStrategy.callFake(generator); spyStrategy.callFake(generator);
+2 -2
View File
@@ -1,5 +1,5 @@
describe('StackTrace', function() { describe('StackTrace', function() {
it('understands Chrome/IE/Edge style traces', function() { it('understands Chrome/Edge style traces', function() {
var error = { var error = {
message: 'nope', message: 'nope',
stack: stack:
@@ -30,7 +30,7 @@ describe('StackTrace', function() {
]); ]);
}); });
it('understands Chrome/IE/Edge style traces with multiline messages', function() { it('understands Chrome/Edge style traces with multiline messages', function() {
var error = { var error = {
message: 'line 1\nline 2', message: 'line 1\nline 2',
stack: stack:
+1 -2
View File
@@ -39,8 +39,7 @@ describe('jasmineUnderTest.util', function() {
}; };
beforeEach(function() { beforeEach(function() {
jasmine.getEnv().requirePromises(); mockNativePromise = new Promise(function(res, rej) {});
mockNativePromise = new Promise(function(res, rej) {}); // eslint-disable-line compat/compat
mockPromiseLikeObject = new mockPromiseLike(); mockPromiseLikeObject = new mockPromiseLike();
}); });
+2 -4
View File
@@ -48,11 +48,9 @@ describe('Any', function() {
}); });
it('matches a Symbol', function() { it('matches a Symbol', function() {
jasmine.getEnv().requireFunctioningSymbols(); var any = new jasmineUnderTest.Any(Symbol);
var any = new jasmineUnderTest.Any(Symbol); // eslint-disable-line compat/compat expect(any.asymmetricMatch(Symbol())).toBe(true);
expect(any.asymmetricMatch(Symbol())).toBe(true); // eslint-disable-line compat/compat
}); });
it('matches another constructed object', function() { it('matches another constructed object', function() {
@@ -42,11 +42,9 @@ describe('Anything', function() {
}); });
it('matches a Symbol', function() { it('matches a Symbol', function() {
jasmine.getEnv().requireFunctioningSymbols();
var anything = new jasmineUnderTest.Anything(); var anything = new jasmineUnderTest.Anything();
expect(anything.asymmetricMatch(Symbol())).toBe(true); // eslint-disable-line compat/compat expect(anything.asymmetricMatch(Symbol())).toBe(true);
}); });
it("doesn't match undefined", function() { it("doesn't match undefined", function() {
@@ -1,28 +1,19 @@
describe('MapContaining', function() { describe('MapContaining', function() {
function MapI(iterable) {
// for IE11
var map = new Map();
iterable.forEach(function(kv) {
map.set(kv[0], kv[1]);
});
return map;
}
it('matches any actual map to an empty map', function() { it('matches any actual map to an empty map', function() {
var actualMap = new MapI([['foo', 'bar']]); var actualMap = new Map([['foo', 'bar']]);
var containing = new jasmineUnderTest.MapContaining(new Map()); var containing = new jasmineUnderTest.MapContaining(new Map());
expect(containing.asymmetricMatch(actualMap)).toBe(true); expect(containing.asymmetricMatch(actualMap)).toBe(true);
}); });
it('matches when all the key/value pairs in sample have matches in actual', function() { it('matches when all the key/value pairs in sample have matches in actual', function() {
var actualMap = new MapI([ var actualMap = new Map([
['foo', [1, 2, 3]], ['foo', [1, 2, 3]],
[{ foo: 'bar' }, 'baz'], [{ foo: 'bar' }, 'baz'],
['other', 'any'] ['other', 'any']
]); ]);
var containingMap = new MapI([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2, 3]]]); var containingMap = new Map([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2, 3]]]);
var containing = new jasmineUnderTest.MapContaining(containingMap); var containing = new jasmineUnderTest.MapContaining(containingMap);
var matchersUtil = new jasmineUnderTest.MatchersUtil(); var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -30,12 +21,12 @@ describe('MapContaining', function() {
}); });
it('does not match when a key is not in actual', function() { it('does not match when a key is not in actual', function() {
var actualMap = new MapI([ var actualMap = new Map([
['foo', [1, 2, 3]], ['foo', [1, 2, 3]],
[{ foo: 'not a bar' }, 'baz'] [{ foo: 'not a bar' }, 'baz']
]); ]);
var containingMap = new MapI([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2, 3]]]); var containingMap = new Map([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2, 3]]]);
var containing = new jasmineUnderTest.MapContaining(containingMap); var containing = new jasmineUnderTest.MapContaining(containingMap);
var matchersUtil = new jasmineUnderTest.MatchersUtil(); var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -43,9 +34,9 @@ describe('MapContaining', function() {
}); });
it('does not match when a value is not in actual', function() { it('does not match when a value is not in actual', function() {
var actualMap = new MapI([['foo', [1, 2, 3]], [{ foo: 'bar' }, 'baz']]); var actualMap = new Map([['foo', [1, 2, 3]], [{ foo: 'bar' }, 'baz']]);
var containingMap = new MapI([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2]]]); var containingMap = new Map([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2]]]);
var containing = new jasmineUnderTest.MapContaining(containingMap); var containing = new jasmineUnderTest.MapContaining(containingMap);
var matchersUtil = new jasmineUnderTest.MatchersUtil(); var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -53,13 +44,13 @@ describe('MapContaining', function() {
}); });
it('matches when all the key/value pairs in sample have asymmetric matches in actual', function() { it('matches when all the key/value pairs in sample have asymmetric matches in actual', function() {
var actualMap = new MapI([ var actualMap = new Map([
['foo1', 'not a bar'], ['foo1', 'not a bar'],
['foo2', 'bar'], ['foo2', 'bar'],
['baz', [1, 2, 3, 4]] ['baz', [1, 2, 3, 4]]
]); ]);
var containingMap = new MapI([ var containingMap = new Map([
[jasmineUnderTest.stringMatching(/^foo\d/), 'bar'], [jasmineUnderTest.stringMatching(/^foo\d/), 'bar'],
['baz', jasmineUnderTest.arrayContaining([2, 3])] ['baz', jasmineUnderTest.arrayContaining([2, 3])]
]); ]);
@@ -70,9 +61,9 @@ describe('MapContaining', function() {
}); });
it('does not match when a key in sample has no asymmetric matches in actual', function() { it('does not match when a key in sample has no asymmetric matches in actual', function() {
var actualMap = new MapI([['a-foo1', 'bar'], ['baz', [1, 2, 3, 4]]]); var actualMap = new Map([['a-foo1', 'bar'], ['baz', [1, 2, 3, 4]]]);
var containingMap = new MapI([ var containingMap = new Map([
[jasmineUnderTest.stringMatching(/^foo\d/), 'bar'], [jasmineUnderTest.stringMatching(/^foo\d/), 'bar'],
['baz', jasmineUnderTest.arrayContaining([2, 3])] ['baz', jasmineUnderTest.arrayContaining([2, 3])]
]); ]);
@@ -83,9 +74,9 @@ describe('MapContaining', function() {
}); });
it('does not match when a value in sample has no asymmetric matches in actual', function() { it('does not match when a value in sample has no asymmetric matches in actual', function() {
var actualMap = new MapI([['foo1', 'bar'], ['baz', [1, 2, 3, 4]]]); var actualMap = new Map([['foo1', 'bar'], ['baz', [1, 2, 3, 4]]]);
var containingMap = new MapI([ var containingMap = new Map([
[jasmineUnderTest.stringMatching(/^foo\d/), 'bar'], [jasmineUnderTest.stringMatching(/^foo\d/), 'bar'],
['baz', jasmineUnderTest.arrayContaining([4, 5])] ['baz', jasmineUnderTest.arrayContaining([4, 5])]
]); ]);
@@ -96,15 +87,15 @@ describe('MapContaining', function() {
}); });
it('matches recursively', function() { it('matches recursively', function() {
var actualMap = new MapI([ var actualMap = new Map([
['foo', new MapI([['foo1', 1], ['foo2', 2]])], ['foo', new Map([['foo1', 1], ['foo2', 2]])],
[new MapI([[1, 'bar1'], [2, 'bar2']]), 'bar'], [new Map([[1, 'bar1'], [2, 'bar2']]), 'bar'],
['other', 'any'] ['other', 'any']
]); ]);
var containingMap = new MapI([ var containingMap = new Map([
['foo', new jasmineUnderTest.MapContaining(new MapI([['foo1', 1]]))], ['foo', new jasmineUnderTest.MapContaining(new Map([['foo1', 1]]))],
[new jasmineUnderTest.MapContaining(new MapI([[2, 'bar2']])), 'bar'] [new jasmineUnderTest.MapContaining(new Map([[2, 'bar2']])), 'bar']
]); ]);
var containing = new jasmineUnderTest.MapContaining(containingMap); var containing = new jasmineUnderTest.MapContaining(containingMap);
var matchersUtil = new jasmineUnderTest.MatchersUtil(); var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -119,10 +110,8 @@ describe('MapContaining', function() {
? a < 0 && b < 0 ? a < 0 && b < 0
: a === b; : a === b;
} }
var actualMap = new MapI([['foo', -1]]); var actualMap = new Map([['foo', -1]]);
var containing = new jasmineUnderTest.MapContaining( var containing = new jasmineUnderTest.MapContaining(new Map([['foo', -2]]));
new MapI([['foo', -2]])
);
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
customTesters: [tester] customTesters: [tester]
}); });
@@ -131,7 +120,7 @@ describe('MapContaining', function() {
}); });
it('does not match when actual is not a map', function() { it('does not match when actual is not a map', function() {
var containingMap = new MapI([['foo', 'bar']]); var containingMap = new Map([['foo', 'bar']]);
expect( expect(
new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch('foo') new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch('foo')
).toBe(false); ).toBe(false);
@@ -1,24 +1,15 @@
describe('SetContaining', function() { describe('SetContaining', function() {
function SetI(iterable) {
// for IE11
var set = new Set();
iterable.forEach(function(v) {
set.add(v);
});
return set;
}
it('matches any actual set to an empty set', function() { it('matches any actual set to an empty set', function() {
var actualSet = new SetI(['foo', 'bar']); var actualSet = new Set(['foo', 'bar']);
var containing = new jasmineUnderTest.SetContaining(new Set()); var containing = new jasmineUnderTest.SetContaining(new Set());
expect(containing.asymmetricMatch(actualSet)).toBe(true); expect(containing.asymmetricMatch(actualSet)).toBe(true);
}); });
it('matches when all the values in sample have matches in actual', function() { it('matches when all the values in sample have matches in actual', function() {
var actualSet = new SetI([{ foo: 'bar' }, 'baz', [1, 2, 3]]); var actualSet = new Set([{ foo: 'bar' }, 'baz', [1, 2, 3]]);
var containingSet = new SetI([[1, 2, 3], { foo: 'bar' }]); var containingSet = new Set([[1, 2, 3], { foo: 'bar' }]);
var containing = new jasmineUnderTest.SetContaining(containingSet); var containing = new jasmineUnderTest.SetContaining(containingSet);
var matchersUtil = new jasmineUnderTest.MatchersUtil(); var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -26,9 +17,9 @@ describe('SetContaining', function() {
}); });
it('does not match when a value is not in actual', function() { it('does not match when a value is not in actual', function() {
var actualSet = new SetI([{ foo: 'bar' }, 'baz', [1, 2, 3]]); var actualSet = new Set([{ foo: 'bar' }, 'baz', [1, 2, 3]]);
var containingSet = new SetI([[1, 2], { foo: 'bar' }]); var containingSet = new Set([[1, 2], { foo: 'bar' }]);
var containing = new jasmineUnderTest.SetContaining(containingSet); var containing = new jasmineUnderTest.SetContaining(containingSet);
var matchersUtil = new jasmineUnderTest.MatchersUtil(); var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -36,9 +27,9 @@ describe('SetContaining', function() {
}); });
it('matches when all the values in sample have asymmetric matches in actual', function() { it('matches when all the values in sample have asymmetric matches in actual', function() {
var actualSet = new SetI([[1, 2, 3, 4], 'other', 'foo1']); var actualSet = new Set([[1, 2, 3, 4], 'other', 'foo1']);
var containingSet = new SetI([ var containingSet = new Set([
jasmineUnderTest.stringMatching(/^foo\d/), jasmineUnderTest.stringMatching(/^foo\d/),
jasmineUnderTest.arrayContaining([2, 3]) jasmineUnderTest.arrayContaining([2, 3])
]); ]);
@@ -49,9 +40,9 @@ describe('SetContaining', function() {
}); });
it('does not match when a value in sample has no asymmetric matches in actual', function() { it('does not match when a value in sample has no asymmetric matches in actual', function() {
var actualSet = new SetI(['a-foo1', [1, 2, 3, 4], 'other']); var actualSet = new Set(['a-foo1', [1, 2, 3, 4], 'other']);
var containingSet = new SetI([ var containingSet = new Set([
jasmine.stringMatching(/^foo\d/), jasmine.stringMatching(/^foo\d/),
jasmine.arrayContaining([2, 3]) jasmine.arrayContaining([2, 3])
]); ]);
@@ -62,10 +53,10 @@ describe('SetContaining', function() {
}); });
it('matches recursively', function() { it('matches recursively', function() {
var actualSet = new SetI(['foo', new SetI([1, 'bar', 2]), 'other']); var actualSet = new Set(['foo', new Set([1, 'bar', 2]), 'other']);
var containingSet = new SetI([ var containingSet = new Set([
new jasmineUnderTest.SetContaining(new SetI(['bar'])), new jasmineUnderTest.SetContaining(new Set(['bar'])),
'foo' 'foo'
]); ]);
var containing = new jasmineUnderTest.SetContaining(containingSet); var containing = new jasmineUnderTest.SetContaining(containingSet);
@@ -81,8 +72,8 @@ describe('SetContaining', function() {
? a < 0 && b < 0 ? a < 0 && b < 0
: a === b; : a === b;
} }
var actualSet = new SetI(['foo', -1]); var actualSet = new Set(['foo', -1]);
var containing = new jasmineUnderTest.SetContaining(new SetI([-2, 'foo'])); var containing = new jasmineUnderTest.SetContaining(new Set([-2, 'foo']));
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
customTesters: [tester] customTesters: [tester]
}); });
@@ -91,7 +82,7 @@ describe('SetContaining', function() {
}); });
it('does not match when actual is not a set', function() { it('does not match when actual is not a set', function() {
var containingSet = new SetI(['foo']); var containingSet = new Set(['foo']);
expect( expect(
new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch('foo') new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch('foo')
).toBe(false); ).toBe(false);
-9
View File
@@ -101,21 +101,16 @@ describe('base helpers', function() {
describe('isURL', function() { describe('isURL', function() {
it('returns true when the object is a URL', function() { it('returns true when the object is a URL', function() {
jasmine.getEnv().requireUrls();
// eslint-disable-next-line compat/compat
expect(jasmineUnderTest.isURL(new URL('http://localhost/'))).toBe(true); expect(jasmineUnderTest.isURL(new URL('http://localhost/'))).toBe(true);
}); });
it('returns false when the object is not a URL', function() { it('returns false when the object is not a URL', function() {
jasmine.getEnv().requireUrls();
expect(jasmineUnderTest.isURL({})).toBe(false); expect(jasmineUnderTest.isURL({})).toBe(false);
}); });
}); });
describe('isPending_', function() { describe('isPending_', function() {
it('returns a promise that resolves to true when the promise is pending', function() { it('returns a promise that resolves to true when the promise is pending', function() {
jasmine.getEnv().requirePromises();
// eslint-disable-next-line compat/compat
var promise = new Promise(function() {}); var promise = new Promise(function() {});
return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo( return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo(
true true
@@ -123,8 +118,6 @@ describe('base helpers', function() {
}); });
it('returns a promise that resolves to false when the promise is resolved', function() { it('returns a promise that resolves to false when the promise is resolved', function() {
jasmine.getEnv().requirePromises();
// eslint-disable-next-line compat/compat
var promise = Promise.resolve(); var promise = Promise.resolve();
return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo( return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo(
false false
@@ -132,8 +125,6 @@ describe('base helpers', function() {
}); });
it('returns a promise that resolves to false when the promise is rejected', function() { it('returns a promise that resolves to false when the promise is rejected', function() {
jasmine.getEnv().requirePromises();
// eslint-disable-next-line compat/compat
var promise = Promise.reject(); var promise = Promise.reject();
return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo( return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo(
false false
@@ -1,4 +1,3 @@
/* eslint-disable compat/compat */
describe('Custom Async Matchers (Integration)', function() { describe('Custom Async Matchers (Integration)', function() {
var env; var env;
@@ -12,8 +11,6 @@ describe('Custom Async Matchers (Integration)', function() {
}); });
it('passes the spec if the custom async matcher passes', function(done) { it('passes the spec if the custom async matcher passes', function(done) {
jasmine.getEnv().requirePromises();
env.it('spec using custom async matcher', function() { env.it('spec using custom async matcher', function() {
env.addAsyncMatchers({ env.addAsyncMatchers({
toBeReal: function() { toBeReal: function() {
@@ -37,8 +34,6 @@ describe('Custom Async Matchers (Integration)', function() {
}); });
it('uses the negative compare function for a negative comparison, if provided', function(done) { it('uses the negative compare function for a negative comparison, if provided', function(done) {
jasmine.getEnv().requirePromises();
env.it('spec with custom negative comparison matcher', function() { env.it('spec with custom negative comparison matcher', function() {
env.addAsyncMatchers({ env.addAsyncMatchers({
toBeReal: function() { toBeReal: function() {
@@ -65,8 +60,6 @@ describe('Custom Async Matchers (Integration)', function() {
}); });
it('generates messages with the same rules as built in matchers absent a custom message', function(done) { it('generates messages with the same rules as built in matchers absent a custom message', function(done) {
jasmine.getEnv().requirePromises();
env.it('spec with an expectation', function() { env.it('spec with an expectation', function() {
env.addAsyncMatchers({ env.addAsyncMatchers({
toBeReal: function() { toBeReal: function() {
@@ -92,8 +85,6 @@ describe('Custom Async Matchers (Integration)', function() {
}); });
it('passes the jasmine utility to the matcher factory', function(done) { it('passes the jasmine utility to the matcher factory', function(done) {
jasmine.getEnv().requirePromises();
var matcherFactory = function(util) { var matcherFactory = function(util) {
return { return {
compare: function() { compare: function() {
@@ -125,8 +116,6 @@ describe('Custom Async Matchers (Integration)', function() {
}); });
it('provides custom equality testers to the matcher factory via matchersUtil', function(done) { it('provides custom equality testers to the matcher factory via matchersUtil', function(done) {
jasmine.getEnv().requirePromises();
var matcherFactory = function(matchersUtil) { var matcherFactory = function(matchersUtil) {
return { return {
compare: function(actual, expected) { compare: function(actual, expected) {
+2 -19
View File
@@ -156,10 +156,6 @@ describe('Env integration', function() {
message: 'Failed: error message', message: 'Failed: error message',
stack: { stack: {
asymmetricMatch: function(other) { asymmetricMatch: function(other) {
if (!other) {
// IE doesn't give us a stacktrace so just ignore it.
return true;
}
var split = other.split('\n'), var split = other.split('\n'),
firstLine = split[0]; firstLine = split[0];
if (firstLine.indexOf('error message') >= 0) { if (firstLine.indexOf('error message') >= 0) {
@@ -2709,8 +2705,6 @@ describe('Env integration', function() {
}); });
it('supports async matchers', function(done) { it('supports async matchers', function(done) {
jasmine.getEnv().requirePromises();
var specDone = jasmine.createSpy('specDone'), var specDone = jasmine.createSpy('specDone'),
suiteDone = jasmine.createSpy('suiteDone'), suiteDone = jasmine.createSpy('suiteDone'),
jasmineDone = jasmine.createSpy('jasmineDone'); jasmineDone = jasmine.createSpy('jasmineDone');
@@ -2723,7 +2717,6 @@ describe('Env integration', function() {
function fail(innerDone) { function fail(innerDone) {
var resolve; var resolve;
// eslint-disable-next-line compat/compat
var p = new Promise(function(res, rej) { var p = new Promise(function(res, rej) {
resolve = res; resolve = res;
}); });
@@ -2779,8 +2772,6 @@ describe('Env integration', function() {
jasmine.getEnv().skipBrowserFlake(); jasmine.getEnv().skipBrowserFlake();
} }
jasmine.getEnv().requirePromises();
var specDone = jasmine.createSpy('specDone'); var specDone = jasmine.createSpy('specDone');
env.addReporter({ specDone: specDone }); env.addReporter({ specDone: specDone });
@@ -2789,7 +2780,7 @@ describe('Env integration', function() {
env.addCustomEqualityTester(function() { env.addCustomEqualityTester(function() {
return true; return true;
}); });
var p = Promise.resolve('something'); // eslint-disable-line compat/compat var p = Promise.resolve('something');
return env.expectAsync(p).toBeResolvedTo('something else'); return env.expectAsync(p).toBeResolvedTo('something else');
}); });
@@ -2805,8 +2796,6 @@ describe('Env integration', function() {
}); });
it('includes useful stack frames in async matcher failures', function(done) { it('includes useful stack frames in async matcher failures', function(done) {
jasmine.getEnv().requirePromises();
var specDone = jasmine.createSpy('specDone'); var specDone = jasmine.createSpy('specDone');
env.addReporter({ specDone: specDone }); env.addReporter({ specDone: specDone });
@@ -2815,7 +2804,7 @@ describe('Env integration', function() {
env.addCustomEqualityTester(function() { env.addCustomEqualityTester(function() {
return true; return true;
}); });
var p = Promise.resolve(); // eslint-disable-line compat/compat var p = Promise.resolve();
return env.expectAsync(p).toBeRejected(); return env.expectAsync(p).toBeRejected();
}); });
@@ -2834,11 +2823,8 @@ describe('Env integration', function() {
}); });
it('reports an error when an async expectation occurs after the spec finishes', function(done) { it('reports an error when an async expectation occurs after the spec finishes', function(done) {
jasmine.getEnv().requirePromises();
var resolve, var resolve,
jasmineDone = jasmine.createSpy('jasmineDone'), jasmineDone = jasmine.createSpy('jasmineDone'),
// eslint-disable-next-line compat/compat
promise = new Promise(function(res) { promise = new Promise(function(res) {
resolve = res; resolve = res;
}); });
@@ -2897,11 +2883,8 @@ describe('Env integration', function() {
}); });
it('reports an error when an async expectation occurs after the suite finishes', function(done) { it('reports an error when an async expectation occurs after the suite finishes', function(done) {
jasmine.getEnv().requirePromises();
var resolve, var resolve,
jasmineDone = jasmine.createSpy('jasmineDone'), jasmineDone = jasmine.createSpy('jasmineDone'),
// eslint-disable-next-line compat/compat
promise = new Promise(function(res) { promise = new Promise(function(res) {
resolve = res; resolve = res;
}); });
+9 -42
View File
@@ -90,8 +90,6 @@ describe('Matchers (Integration)', function() {
function verifyPassesAsync(expectations) { function verifyPassesAsync(expectations) {
it('passes', function(done) { it('passes', function(done) {
jasmine.getEnv().requirePromises();
env.it('a spec', function() { env.it('a spec', function() {
return expectations(env); return expectations(env);
}); });
@@ -118,8 +116,6 @@ describe('Matchers (Integration)', function() {
function verifyFailsAsync(expectations) { function verifyFailsAsync(expectations) {
it('fails', function(done) { it('fails', function(done) {
jasmine.getEnv().requirePromises();
env.it('a spec', function() { env.it('a spec', function() {
return expectations(env); return expectations(env);
}); });
@@ -147,7 +143,6 @@ describe('Matchers (Integration)', function() {
function verifyFailsWithCustomObjectFormattersAsync(config) { function verifyFailsWithCustomObjectFormattersAsync(config) {
it('uses custom object formatters', function(done) { it('uses custom object formatters', function(done) {
var env = new jasmineUnderTest.Env(); var env = new jasmineUnderTest.Env();
jasmine.getEnv().requirePromises();
env.it('a spec', function() { env.it('a spec', function() {
env.addCustomObjectFormatter(config.formatter); env.addCustomObjectFormatter(config.formatter);
return config.expectations(env); return config.expectations(env);
@@ -348,12 +343,10 @@ describe('Matchers (Integration)', function() {
describe('toBeResolved', function() { describe('toBeResolved', function() {
verifyPassesAsync(function(env) { verifyPassesAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve()).toBeResolved(); return env.expectAsync(Promise.resolve()).toBeResolved();
}); });
verifyFailsAsync(function(env) { verifyFailsAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.reject()).toBeResolved(); return env.expectAsync(Promise.reject()).toBeResolved();
}); });
}); });
@@ -363,12 +356,10 @@ describe('Matchers (Integration)', function() {
env.addCustomEqualityTester(function(a, b) { env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString(); return a.toString() === b.toString();
}); });
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve('5')).toBeResolvedTo(5); return env.expectAsync(Promise.resolve('5')).toBeResolvedTo(5);
}); });
verifyFailsAsync(function(env) { verifyFailsAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve('foo')).toBeResolvedTo('bar'); return env.expectAsync(Promise.resolve('foo')).toBeResolvedTo('bar');
}); });
@@ -377,7 +368,6 @@ describe('Matchers (Integration)', function() {
return '|' + val + '|'; return '|' + val + '|';
}, },
expectations: function(env) { expectations: function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve('x')).toBeResolvedTo('y'); return env.expectAsync(Promise.resolve('x')).toBeResolvedTo('y');
}, },
expectedMessage: expectedMessage:
@@ -388,12 +378,10 @@ describe('Matchers (Integration)', function() {
describe('toBeRejected', function() { describe('toBeRejected', function() {
verifyPassesAsync(function(env) { verifyPassesAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.reject('nope')).toBeRejected(); return env.expectAsync(Promise.reject('nope')).toBeRejected();
}); });
verifyFailsAsync(function(env) { verifyFailsAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve()).toBeRejected(); return env.expectAsync(Promise.resolve()).toBeRejected();
}); });
}); });
@@ -403,12 +391,10 @@ describe('Matchers (Integration)', function() {
env.addCustomEqualityTester(function(a, b) { env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString(); return a.toString() === b.toString();
}); });
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.reject('5')).toBeRejectedWith(5); return env.expectAsync(Promise.reject('5')).toBeRejectedWith(5);
}); });
verifyFailsAsync(function(env) { verifyFailsAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve()).toBeRejectedWith('nope'); return env.expectAsync(Promise.resolve()).toBeRejectedWith('nope');
}); });
@@ -417,7 +403,6 @@ describe('Matchers (Integration)', function() {
return '|' + val + '|'; return '|' + val + '|';
}, },
expectations: function(env) { expectations: function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.reject('x')).toBeRejectedWith('y'); return env.expectAsync(Promise.reject('x')).toBeRejectedWith('y');
}, },
expectedMessage: expectedMessage:
@@ -428,16 +413,12 @@ describe('Matchers (Integration)', function() {
describe('toBeRejectedWithError', function() { describe('toBeRejectedWithError', function() {
verifyPassesAsync(function(env) { verifyPassesAsync(function(env) {
return ( return env
env .expectAsync(Promise.reject(new Error()))
// eslint-disable-next-line compat/compat .toBeRejectedWithError(Error);
.expectAsync(Promise.reject(new Error()))
.toBeRejectedWithError(Error)
);
}); });
verifyFailsAsync(function(env) { verifyFailsAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve()).toBeRejectedWithError(Error); return env.expectAsync(Promise.resolve()).toBeRejectedWithError(Error);
}); });
@@ -446,12 +427,9 @@ describe('Matchers (Integration)', function() {
return '|' + val + '|'; return '|' + val + '|';
}, },
expectations: function(env) { expectations: function(env) {
return ( return env
env .expectAsync(Promise.reject('foo'))
// eslint-disable-next-line compat/compat .toBeRejectedWithError('foo');
.expectAsync(Promise.reject('foo'))
.toBeRejectedWithError('foo')
);
}, },
expectedMessage: expectedMessage:
'Expected a promise to be rejected with Error: |foo| ' + 'Expected a promise to be rejected with Error: |foo| ' +
@@ -757,10 +735,7 @@ describe('Matchers (Integration)', function() {
describe('When an async matcher is used with .already()', function() { describe('When an async matcher is used with .already()', function() {
it('propagates the matcher result when the promise is resolved', function(done) { it('propagates the matcher result when the promise is resolved', function(done) {
jasmine.getEnv().requirePromises();
env.it('a spec', function() { env.it('a spec', function() {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve()).already.toBeRejected(); return env.expectAsync(Promise.resolve()).already.toBeRejected();
}); });
@@ -782,15 +757,10 @@ describe('Matchers (Integration)', function() {
}); });
it('propagates the matcher result when the promise is rejected', function(done) { it('propagates the matcher result when the promise is rejected', function(done) {
jasmine.getEnv().requirePromises();
env.it('a spec', function() { env.it('a spec', function() {
return ( return env
env .expectAsync(Promise.reject(new Error('nope')))
// eslint-disable-next-line compat/compat .already.toBeResolved();
.expectAsync(Promise.reject(new Error('nope')))
.already.toBeResolved()
);
}); });
var specExpectations = function(result) { var specExpectations = function(result) {
@@ -812,9 +782,6 @@ describe('Matchers (Integration)', function() {
}); });
it('fails when the promise is pending', function(done) { it('fails when the promise is pending', function(done) {
jasmine.getEnv().requirePromises();
// eslint-disable-next-line compat/compat
var promise = new Promise(function() {}); var promise = new Promise(function() {});
env.it('a spec', function() { env.it('a spec', function() {
@@ -1,8 +1,5 @@
/* eslint-disable compat/compat */
describe('toBePending', function() { describe('toBePending', function() {
it('passes if the actual promise is pending', function() { it('passes if the actual promise is pending', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(), var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil), matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
actual = new Promise(function() {}); actual = new Promise(function() {});
@@ -13,8 +10,6 @@ describe('toBePending', function() {
}); });
it('fails if the actual promise is resolved', function() { it('fails if the actual promise is resolved', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(), var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil), matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
actual = Promise.resolve(); actual = Promise.resolve();
@@ -25,8 +20,6 @@ describe('toBePending', function() {
}); });
it('fails if the actual promise is rejected', function() { it('fails if the actual promise is rejected', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(), var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil), matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
actual = Promise.reject(new Error('promise was rejected')); actual = Promise.reject(new Error('promise was rejected'));
@@ -1,8 +1,5 @@
/* eslint-disable compat/compat */
describe('toBeRejected', function() { describe('toBeRejected', function() {
it('passes if the actual is rejected', function() { it('passes if the actual is rejected', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(), var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil), matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil),
actual = Promise.reject('AsyncExpectationSpec rejection'); actual = Promise.reject('AsyncExpectationSpec rejection');
@@ -13,8 +10,6 @@ describe('toBeRejected', function() {
}); });
it('fails if the actual is resolved', function() { it('fails if the actual is resolved', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(), var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil), matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil),
actual = Promise.resolve(); actual = Promise.resolve();
@@ -1,8 +1,5 @@
/* eslint-disable compat/compat */
describe('#toBeRejectedWithError', function() { describe('#toBeRejectedWithError', function() {
it('passes when Error type matches', function() { it('passes when Error type matches', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter() pp: jasmineUnderTest.makePrettyPrinter()
}), }),
@@ -23,8 +20,6 @@ describe('#toBeRejectedWithError', function() {
}); });
it('passes when Error type and message matches', function() { it('passes when Error type and message matches', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter() pp: jasmineUnderTest.makePrettyPrinter()
}), }),
@@ -45,8 +40,6 @@ describe('#toBeRejectedWithError', function() {
}); });
it('passes when Error matches and is exactly Error', function() { it('passes when Error matches and is exactly Error', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter() pp: jasmineUnderTest.makePrettyPrinter()
}), }),
@@ -67,8 +60,6 @@ describe('#toBeRejectedWithError', function() {
}); });
it('passes when Error message matches a string', function() { it('passes when Error message matches a string', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter() pp: jasmineUnderTest.makePrettyPrinter()
}), }),
@@ -89,8 +80,6 @@ describe('#toBeRejectedWithError', function() {
}); });
it('passes when Error message matches a RegExp', function() { it('passes when Error message matches a RegExp', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter() pp: jasmineUnderTest.makePrettyPrinter()
}), }),
@@ -111,8 +100,6 @@ describe('#toBeRejectedWithError', function() {
}); });
it('passes when Error message is empty', function() { it('passes when Error message is empty', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter() pp: jasmineUnderTest.makePrettyPrinter()
}), }),
@@ -133,8 +120,6 @@ describe('#toBeRejectedWithError', function() {
}); });
it('passes when no arguments', function() { it('passes when no arguments', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter() pp: jasmineUnderTest.makePrettyPrinter()
}), }),
@@ -155,8 +140,6 @@ describe('#toBeRejectedWithError', function() {
}); });
it('fails when resolved', function() { it('fails when resolved', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter() pp: jasmineUnderTest.makePrettyPrinter()
}), }),
@@ -176,8 +159,6 @@ describe('#toBeRejectedWithError', function() {
}); });
it('fails when rejected with non Error type', function() { it('fails when rejected with non Error type', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter() pp: jasmineUnderTest.makePrettyPrinter()
}), }),
@@ -198,8 +179,6 @@ describe('#toBeRejectedWithError', function() {
}); });
it('fails when Error type mismatches', function() { it('fails when Error type mismatches', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter() pp: jasmineUnderTest.makePrettyPrinter()
}), }),
@@ -220,8 +199,6 @@ describe('#toBeRejectedWithError', function() {
}); });
it('fails when Error message mismatches', function() { it('fails when Error message mismatches', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter() pp: jasmineUnderTest.makePrettyPrinter()
}), }),
@@ -1,8 +1,5 @@
/* eslint-disable compat/compat */
describe('#toBeRejectedWith', function() { describe('#toBeRejectedWith', function() {
it('should return true if the promise is rejected with the expected value', function() { it('should return true if the promise is rejected with the expected value', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(), var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
actual = Promise.reject({ error: 'PEBCAK' }); actual = Promise.reject({ error: 'PEBCAK' });
@@ -13,8 +10,6 @@ describe('#toBeRejectedWith', function() {
}); });
it('should fail if the promise resolves', function() { it('should fail if the promise resolves', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(), var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
actual = Promise.resolve(); actual = Promise.resolve();
@@ -25,8 +20,6 @@ describe('#toBeRejectedWith', function() {
}); });
it('should fail if the promise is rejected with a different value', function() { it('should fail if the promise is rejected with a different value', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter() pp: jasmineUnderTest.makePrettyPrinter()
}), }),
@@ -45,8 +38,6 @@ describe('#toBeRejectedWith', function() {
}); });
it('should build its error correctly when negated', function() { it('should build its error correctly when negated', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter() pp: jasmineUnderTest.makePrettyPrinter()
}), }),
@@ -64,8 +55,6 @@ describe('#toBeRejectedWith', function() {
}); });
it('should support custom equality testers', function() { it('should support custom equality testers', function() {
jasmine.getEnv().requirePromises();
var customEqualityTesters = [ var customEqualityTesters = [
function() { function() {
return true; return true;
@@ -1,8 +1,5 @@
/* eslint-disable compat/compat */
describe('toBeResolved', function() { describe('toBeResolved', function() {
it('passes if the actual is resolved', function() { it('passes if the actual is resolved', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(), var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeResolved(matchersUtil), matcher = jasmineUnderTest.asyncMatchers.toBeResolved(matchersUtil),
actual = Promise.resolve(); actual = Promise.resolve();
@@ -13,8 +10,6 @@ describe('toBeResolved', function() {
}); });
it('fails if the actual is rejected', function() { it('fails if the actual is rejected', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter([]) pp: jasmineUnderTest.makePrettyPrinter([])
}), }),
@@ -1,8 +1,5 @@
/* eslint-disable compat/compat */
describe('#toBeResolvedTo', function() { describe('#toBeResolvedTo', function() {
it('passes if the promise is resolved to the expected value', function() { it('passes if the promise is resolved to the expected value', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(), var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
actual = Promise.resolve({ foo: 42 }); actual = Promise.resolve({ foo: 42 });
@@ -13,8 +10,6 @@ describe('#toBeResolvedTo', function() {
}); });
it('fails if the promise is rejected', function() { it('fails if the promise is rejected', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter() pp: jasmineUnderTest.makePrettyPrinter()
}), }),
@@ -34,8 +29,6 @@ describe('#toBeResolvedTo', function() {
}); });
it('fails if the promise is resolved to a different value', function() { it('fails if the promise is resolved to a different value', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter() pp: jasmineUnderTest.makePrettyPrinter()
}), }),
@@ -54,8 +47,6 @@ describe('#toBeResolvedTo', function() {
}); });
it('builds its message correctly when negated', function() { it('builds its message correctly when negated', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter() pp: jasmineUnderTest.makePrettyPrinter()
}), }),
@@ -73,8 +64,6 @@ describe('#toBeResolvedTo', function() {
}); });
it('supports custom equality testers', function() { it('supports custom equality testers', function() {
jasmine.getEnv().requirePromises();
var customEqualityTesters = [ var customEqualityTesters = [
function() { function() {
return true; return true;
+3 -32
View File
@@ -232,8 +232,8 @@ describe('matchersUtil', function() {
return; return;
} }
var p1 = new Promise(function() {}), // eslint-disable-line compat/compat var p1 = new Promise(function() {}),
p2 = new Promise(function() {}), // eslint-disable-line compat/compat p2 = new Promise(function() {}),
matchersUtil = new jasmineUnderTest.MatchersUtil(); matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(p1, p1)).toBe(true); expect(matchersUtil.equals(p1, p1)).toBe(true);
@@ -655,48 +655,35 @@ describe('matchersUtil', function() {
}); });
it('passes when comparing two identical URLs', function() { it('passes when comparing two identical URLs', function() {
jasmine.getEnv().requireUrls();
var matchersUtil = new jasmineUnderTest.MatchersUtil(); var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect( expect(
matchersUtil.equals( matchersUtil.equals(
// eslint-disable-next-line compat/compat
new URL('http://localhost/1'), new URL('http://localhost/1'),
// eslint-disable-next-line compat/compat
new URL('http://localhost/1') new URL('http://localhost/1')
) )
).toBe(true); ).toBe(true);
}); });
it('fails when comparing two different URLs', function() { it('fails when comparing two different URLs', function() {
jasmine.getEnv().requireUrls();
var matchersUtil = new jasmineUnderTest.MatchersUtil(), var matchersUtil = new jasmineUnderTest.MatchersUtil(),
// eslint-disable-next-line compat/compat
url1 = new URL('http://localhost/1'); url1 = new URL('http://localhost/1');
// eslint-disable-next-line compat/compat
expect(matchersUtil.equals(url1, new URL('http://localhost/2'))).toBe( expect(matchersUtil.equals(url1, new URL('http://localhost/2'))).toBe(
false false
); );
// eslint-disable-next-line compat/compat
expect(matchersUtil.equals(url1, new URL('http://localhost/1?foo'))).toBe( expect(matchersUtil.equals(url1, new URL('http://localhost/1?foo'))).toBe(
false false
); );
// eslint-disable-next-line compat/compat
expect(matchersUtil.equals(url1, new URL('http://localhost/1#foo'))).toBe( expect(matchersUtil.equals(url1, new URL('http://localhost/1#foo'))).toBe(
false false
); );
// eslint-disable-next-line compat/compat
expect(matchersUtil.equals(url1, new URL('https://localhost/1'))).toBe( expect(matchersUtil.equals(url1, new URL('https://localhost/1'))).toBe(
false false
); );
expect( expect(
// eslint-disable-next-line compat/compat
matchersUtil.equals(url1, new URL('http://localhost:8080/1')) matchersUtil.equals(url1, new URL('http://localhost:8080/1'))
).toBe(false); ).toBe(false);
// eslint-disable-next-line compat/compat
expect(matchersUtil.equals(url1, new URL('http://example.com/1'))).toBe( expect(matchersUtil.equals(url1, new URL('http://example.com/1'))).toBe(
false false
); );
@@ -721,15 +708,12 @@ describe('matchersUtil', function() {
describe('Typed arrays', function() { describe('Typed arrays', function() {
it('fails for typed arrays of same length and contents but different types', function() { it('fails for typed arrays of same length and contents but different types', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(); var matchersUtil = new jasmineUnderTest.MatchersUtil();
// eslint-disable-next-line compat/compat
var a1 = new Int8Array(1); var a1 = new Int8Array(1);
// eslint-disable-next-line compat/compat
var a2 = new Uint8Array(1); var a2 = new Uint8Array(1);
a1[0] = a2[0] = 0; a1[0] = a2[0] = 0;
expect(matchersUtil.equals(a1, a2)).toBe(false); expect(matchersUtil.equals(a1, a2)).toBe(false);
}); });
// eslint-disable-next-line compat/compat
[ [
'Int8Array', 'Int8Array',
'Uint8Array', 'Uint8Array',
@@ -741,20 +725,11 @@ describe('matchersUtil', function() {
'Float32Array', 'Float32Array',
'Float64Array' 'Float64Array'
].forEach(function(typeName) { ].forEach(function(typeName) {
function requireType() { var TypedArrayCtor = jasmine.getGlobal()[typeName];
var TypedArrayCtor = jasmine.getGlobal()[typeName];
if (!TypedArrayCtor) {
pending('Browser does not support ' + typeName);
}
return TypedArrayCtor;
}
it( it(
'passes for ' + typeName + 's with same length and content', 'passes for ' + typeName + 's with same length and content',
function() { function() {
var TypedArrayCtor = requireType();
var matchersUtil = new jasmineUnderTest.MatchersUtil(); var matchersUtil = new jasmineUnderTest.MatchersUtil();
var a1 = new TypedArrayCtor(2); var a1 = new TypedArrayCtor(2);
var a2 = new TypedArrayCtor(2); var a2 = new TypedArrayCtor(2);
@@ -765,7 +740,6 @@ describe('matchersUtil', function() {
); );
it('fails for ' + typeName + 's with different length', function() { it('fails for ' + typeName + 's with different length', function() {
var TypedArrayCtor = requireType();
var matchersUtil = new jasmineUnderTest.MatchersUtil(); var matchersUtil = new jasmineUnderTest.MatchersUtil();
var a1 = new TypedArrayCtor(2); var a1 = new TypedArrayCtor(2);
var a2 = new TypedArrayCtor(1); var a2 = new TypedArrayCtor(1);
@@ -776,7 +750,6 @@ describe('matchersUtil', function() {
it( it(
'fails for ' + typeName + 's with same length but different content', 'fails for ' + typeName + 's with same length but different content',
function() { function() {
var TypedArrayCtor = requireType();
var matchersUtil = new jasmineUnderTest.MatchersUtil(); var matchersUtil = new jasmineUnderTest.MatchersUtil();
var a1 = new TypedArrayCtor(1); var a1 = new TypedArrayCtor(1);
var a2 = new TypedArrayCtor(1); var a2 = new TypedArrayCtor(1);
@@ -787,7 +760,6 @@ describe('matchersUtil', function() {
); );
it('checks nonstandard properties of ' + typeName, function() { it('checks nonstandard properties of ' + typeName, function() {
var TypedArrayCtor = requireType();
var matchersUtil = new jasmineUnderTest.MatchersUtil(); var matchersUtil = new jasmineUnderTest.MatchersUtil();
var a1 = new TypedArrayCtor(1); var a1 = new TypedArrayCtor(1);
var a2 = new TypedArrayCtor(1); var a2 = new TypedArrayCtor(1);
@@ -797,7 +769,6 @@ describe('matchersUtil', function() {
}); });
it('works with custom equality testers with ' + typeName, function() { it('works with custom equality testers with ' + typeName, function() {
var TypedArrayCtor = requireType();
var a1 = new TypedArrayCtor(1); var a1 = new TypedArrayCtor(1);
var a2 = new TypedArrayCtor(1); var a2 = new TypedArrayCtor(1);
var matchersUtil = new jasmineUnderTest.MatchersUtil({ var matchersUtil = new jasmineUnderTest.MatchersUtil({
-2
View File
@@ -104,8 +104,6 @@ describe('toBeInstanceOf', function() {
}); });
it('passes for an async function', function() { it('passes for an async function', function() {
jasmine.getEnv().requireAsyncAwait();
var fn = eval("(async function fn() { return 'foo'; })"); var fn = eval("(async function fn() { return 'foo'; })");
var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
+4 -10
View File
@@ -620,9 +620,7 @@ describe('toEqual', function() {
}); });
it('does not report mismatches when comparing Maps with the same symbol keys', function() { it('does not report mismatches when comparing Maps with the same symbol keys', function() {
jasmine.getEnv().requireFunctioningSymbols(); var key = Symbol();
var key = Symbol(); // eslint-disable-line compat/compat
var actual = new Map(); var actual = new Map();
actual.set(key, 1); actual.set(key, 1);
var expected = new Map(); var expected = new Map();
@@ -632,12 +630,10 @@ describe('toEqual', function() {
}); });
it('reports mismatches between Maps with different symbol keys', function() { it('reports mismatches between Maps with different symbol keys', function() {
jasmine.getEnv().requireFunctioningSymbols();
var actual = new Map(); var actual = new Map();
actual.set(Symbol(), 1); // eslint-disable-line compat/compat actual.set(Symbol(), 1);
var expected = new Map(); var expected = new Map();
expected.set(Symbol(), 1); // eslint-disable-line compat/compat expected.set(Symbol(), 1);
var message = var message =
'Expected Map( [ Symbol(), 1 ] ) to equal Map( [ Symbol(), 1 ] ).'; 'Expected Map( [ Symbol(), 1 ] ) to equal Map( [ Symbol(), 1 ] ).';
@@ -645,10 +641,8 @@ describe('toEqual', function() {
}); });
it('does not report mismatches when comparing Map symbol key to jasmine.anything()', function() { it('does not report mismatches when comparing Map symbol key to jasmine.anything()', function() {
jasmine.getEnv().requireFunctioningSymbols();
var actual = new Map(); var actual = new Map();
actual.set(Symbol(), 1); // eslint-disable-line compat/compat actual.set(Symbol(), 1);
var expected = new Map(); var expected = new Map();
expected.set(jasmineUnderTest.anything(), 1); expected.set(jasmineUnderTest.anything(), 1);
+1 -3
View File
@@ -102,16 +102,14 @@ describe('toHaveSize', function() {
}); });
it('throws an error for WeakSet', function() { it('throws an error for WeakSet', function() {
jasmine.getEnv().requireWeakSets();
var matcher = jasmineUnderTest.matchers.toHaveSize(); var matcher = jasmineUnderTest.matchers.toHaveSize();
expect(function() { expect(function() {
matcher.compare(new WeakSet(), 2); // eslint-disable-line compat/compat matcher.compare(new WeakSet(), 2);
}).toThrowError('Cannot get size of [object WeakSet].'); }).toThrowError('Cannot get size of [object WeakSet].');
}); });
it('throws an error for WeakMap', function() { it('throws an error for WeakMap', function() {
jasmine.getEnv().requireWeakMaps();
var matcher = jasmineUnderTest.matchers.toHaveSize(); var matcher = jasmineUnderTest.matchers.toHaveSize();
expect(function() { expect(function() {
-26
View File
@@ -1,26 +0,0 @@
(function(env) {
function getAsyncCtor() {
try {
eval('var func = async function(){};');
} catch (e) {
return null;
}
return Object.getPrototypeOf(func).constructor;
}
function hasAsyncAwaitSupport() {
return getAsyncCtor() !== null;
}
env.makeAsyncAwaitFunction = function() {
var AsyncFunction = getAsyncCtor();
return new AsyncFunction('');
};
env.requireAsyncAwait = function() {
if (!hasAsyncAwaitSupport()) {
env.pending('Environment does not support async/await functions');
}
};
})(jasmine.getEnv());
-8
View File
@@ -1,8 +0,0 @@
/* eslint-disable compat/compat */
(function(env) {
env.requireWeakMaps = function() {
if (typeof WeakMap === 'undefined') {
env.pending('Browser does not have support for WeakMap');
}
};
})(jasmine.getEnv());
-8
View File
@@ -1,8 +0,0 @@
/* eslint-disable compat/compat */
(function(env) {
env.requireWeakSets = function() {
if (typeof WeakSet === 'undefined') {
env.pending('Browser does not have support for WeakSet');
}
};
})(jasmine.getEnv());
-28
View File
@@ -1,28 +0,0 @@
/* eslint-disable compat/compat */
(function(env) {
function hasFunctioningSymbols() {
if (typeof Symbol === 'undefined') {
return false;
}
try {
var s1 = Symbol();
var s2 = Symbol();
if (typeof s1 !== 'symbol') {
return false;
}
if (s1 === s2) {
return false;
}
return true;
} catch (e) {
return false;
}
}
env.requireFunctioningSymbols = function() {
if (!hasFunctioningSymbols()) {
env.pending('Browser has incomplete or missing support for Symbols');
}
};
})(jasmine.getEnv());
-17
View File
@@ -1,17 +0,0 @@
/* eslint-disable compat/compat */
(function(env) {
function hasUrlConstructor() {
try {
new URL('http://localhost/');
return true;
} catch (e) {
return false;
}
}
env.requireUrls = function() {
if (!hasUrlConstructor()) {
env.pending('Environment does not support URLs');
}
};
})(jasmine.getEnv());
-22
View File
@@ -1,22 +0,0 @@
(function(env) {
function getGeneratorFuncCtor() {
try {
eval('var func = function*() {}');
} catch (e) {
return null;
}
return Object.getPrototypeOf(func).constructor;
}
env.makeGeneratorFunction = function(text) {
var GeneratorFunction = getGeneratorFuncCtor();
return new GeneratorFunction(text || '');
};
env.requireGeneratorFunctions = function() {
if (!getGeneratorFuncCtor()) {
env.pending('Environment does not support generator functions');
}
};
})(jasmine.getEnv());
-7
View File
@@ -1,7 +0,0 @@
(function(env) {
env.requirePromises = function() {
if (typeof Promise !== 'function') {
env.pending('Environment does not support promises');
}
};
})(jasmine.getEnv());
-16
View File
@@ -4,8 +4,6 @@ describe('Spy Registry browser-specific behavior', function() {
} }
it('can spy on and unspy window.onerror', function() { it('can spy on and unspy window.onerror', function() {
requireWriteableOnerror();
var spies = [], var spies = [],
spyRegistry = new jasmineUnderTest.SpyRegistry({ spyRegistry = new jasmineUnderTest.SpyRegistry({
currentSpies: function() { currentSpies: function() {
@@ -24,18 +22,4 @@ describe('Spy Registry browser-specific behavior', function() {
window.onerror = originalHandler; window.onerror = originalHandler;
} }
}); });
function requireWriteableOnerror() {
var descriptor;
try {
descriptor = Object.getOwnPropertyDescriptor(window, 'onerror');
} catch (e) {
// IE 8 doesn't support `definePropery` on non-DOM nodes
}
if (descriptor && !(descriptor.writable || descriptor.set)) {
pending('Browser declares window.onerror to be readonly');
}
}
}); });
-6
View File
@@ -17,16 +17,10 @@ module.exports = {
specDir: 'spec', specDir: 'spec',
specFiles: ['**/*[Ss]pec.js', '!npmPackage/**/*'], specFiles: ['**/*[Ss]pec.js', '!npmPackage/**/*'],
helpers: [ helpers: [
'helpers/asyncAwait.js',
'helpers/generator.js', 'helpers/generator.js',
'helpers/BrowserFlags.js', 'helpers/BrowserFlags.js',
'helpers/checkForMap.js',
'helpers/checkForSet.js',
'helpers/checkForSymbol.js',
'helpers/checkForUrl.js',
'helpers/domHelpers.js', 'helpers/domHelpers.js',
'helpers/integrationMatchers.js', 'helpers/integrationMatchers.js',
'helpers/promises.js',
'helpers/defineJasmineUnderTest.js', 'helpers/defineJasmineUnderTest.js',
'helpers/resetEnv.js' 'helpers/resetEnv.js'
], ],
-7
View File
@@ -5,15 +5,8 @@
"npmPackage/**/*[Ss]pec.js" "npmPackage/**/*[Ss]pec.js"
], ],
"helpers": [ "helpers": [
"helpers/asyncAwait.js",
"helpers/generator.js",
"helpers/checkForMap.js",
"helpers/checkForSet.js",
"helpers/checkForSymbol.js",
"helpers/checkForUrl.js",
"helpers/domHelpers.js", "helpers/domHelpers.js",
"helpers/integrationMatchers.js", "helpers/integrationMatchers.js",
"helpers/promises.js",
"helpers/overrideConsoleLogForCircleCi.js", "helpers/overrideConsoleLogForCircleCi.js",
"helpers/nodeDefineJasmineUnderTest.js", "helpers/nodeDefineJasmineUnderTest.js",
"helpers/resetEnv.js" "helpers/resetEnv.js"
-7
View File
@@ -75,15 +75,8 @@ getJasmineRequireObj().Expectation = function(j$) {
* @namespace async-matchers * @namespace async-matchers
*/ */
function AsyncExpectation(options) { function AsyncExpectation(options) {
var global = options.global || j$.getGlobal();
this.expector = new j$.Expector(options); this.expector = new j$.Expector(options);
if (!global.Promise) {
throw new Error(
'expectAsync is unavailable because the environment does not support promises.'
);
}
var customAsyncMatchers = options.customAsyncMatchers || {}; var customAsyncMatchers = options.customAsyncMatchers || {};
for (var matcherName in customAsyncMatchers) { for (var matcherName in customAsyncMatchers) {
this[matcherName] = wrapAsyncCompare( this[matcherName] = wrapAsyncCompare(
+1 -5
View File
@@ -87,11 +87,7 @@ getJasmineRequireObj().MockDate = function() {
FakeDate.prototype = GlobalDate.prototype; FakeDate.prototype = GlobalDate.prototype;
FakeDate.now = function() { FakeDate.now = function() {
if (GlobalDate.now) { return currentTime;
return currentTime;
} else {
throw new Error('Browser does not support Date.now()');
}
}; };
FakeDate.toSource = GlobalDate.toSource; FakeDate.toSource = GlobalDate.toSource;
+1 -1
View File
@@ -17,7 +17,7 @@ getJasmineRequireObj().StackTrace = function(j$) {
} }
var framePatterns = [ var framePatterns = [
// PhantomJS on Linux, Node, Chrome, IE, Edge // Node, Chrome, Edge
// e.g. " at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)" // e.g. " at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)"
// Note that the "function name" can include a surprisingly large set of // Note that the "function name" can include a surprisingly large set of
// characters, including angle brackets and square brackets. // characters, including angle brackets and square brackets.
+9 -10
View File
@@ -13,27 +13,26 @@ getJasmineRequireObj().MapContaining = function(j$) {
MapContaining.prototype.asymmetricMatch = function(other, matchersUtil) { MapContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!j$.isMap(other)) return false; if (!j$.isMap(other)) return false;
var hasAllMatches = true; for (const [key, value] of this.sample) {
j$.util.forEachBreakable(this.sample, function(breakLoop, value, key) {
// for each key/value pair in `sample` // for each key/value pair in `sample`
// there should be at least one pair in `other` whose key and value both match // there should be at least one pair in `other` whose key and value both match
var hasMatch = false; var hasMatch = false;
j$.util.forEachBreakable(other, function(oBreakLoop, oValue, oKey) { for (const [oKey, oValue] of other) {
if ( if (
matchersUtil.equals(oKey, key) && matchersUtil.equals(oKey, key) &&
matchersUtil.equals(oValue, value) matchersUtil.equals(oValue, value)
) { ) {
hasMatch = true; hasMatch = true;
oBreakLoop(); break;
} }
});
if (!hasMatch) {
hasAllMatches = false;
breakLoop();
} }
});
return hasAllMatches; if (!hasMatch) {
return false;
}
}
return true;
}; };
MapContaining.prototype.jasmineToString = function(pp) { MapContaining.prototype.jasmineToString = function(pp) {
+9 -10
View File
@@ -13,25 +13,24 @@ getJasmineRequireObj().SetContaining = function(j$) {
SetContaining.prototype.asymmetricMatch = function(other, matchersUtil) { SetContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!j$.isSet(other)) return false; if (!j$.isSet(other)) return false;
var hasAllMatches = true; for (const item of this.sample) {
j$.util.forEachBreakable(this.sample, function(breakLoop, item) {
// for each item in `sample` there should be at least one matching item in `other` // for each item in `sample` there should be at least one matching item in `other`
// (not using `matchersUtil.contains` because it compares set members by reference, // (not using `matchersUtil.contains` because it compares set members by reference,
// not by deep value equality) // not by deep value equality)
var hasMatch = false; var hasMatch = false;
j$.util.forEachBreakable(other, function(oBreakLoop, oItem) { for (const oItem of other) {
if (matchersUtil.equals(oItem, item)) { if (matchersUtil.equals(oItem, item)) {
hasMatch = true; hasMatch = true;
oBreakLoop(); break;
} }
});
if (!hasMatch) {
hasAllMatches = false;
breakLoop();
} }
});
return hasAllMatches; if (!hasMatch) {
return false;
}
}
return true;
}; };
SetContaining.prototype.jasmineToString = function(pp) { SetContaining.prototype.jasmineToString = function(pp) {
+2 -27
View File
@@ -106,25 +106,8 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
if (value instanceof Error) { if (value instanceof Error) {
return true; return true;
} }
if (
typeof window !== 'undefined' &&
typeof window.trustedTypes !== 'undefined'
) {
return (
typeof value.stack === 'string' && typeof value.message === 'string'
);
}
if (value && value.constructor && value.constructor.constructor) {
var valueGlobal = value.constructor.constructor('return this');
if (j$.isFunction_(valueGlobal)) {
valueGlobal = valueGlobal();
}
if (valueGlobal.Error && value instanceof valueGlobal.Error) { return typeof value.stack === 'string' && typeof value.message === 'string';
return true;
}
}
return false;
}; };
j$.isAsymmetricEqualityTester_ = function(obj) { j$.isAsymmetricEqualityTester_ = function(obj) {
@@ -166,7 +149,6 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return ( return (
obj !== null && obj !== null &&
typeof obj !== 'undefined' && typeof obj !== 'undefined' &&
typeof jasmineGlobal.WeakMap !== 'undefined' &&
obj.constructor === jasmineGlobal.WeakMap obj.constructor === jasmineGlobal.WeakMap
); );
}; };
@@ -175,7 +157,6 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return ( return (
obj !== null && obj !== null &&
typeof obj !== 'undefined' && typeof obj !== 'undefined' &&
typeof jasmineGlobal.URL !== 'undefined' &&
obj.constructor === jasmineGlobal.URL obj.constructor === jasmineGlobal.URL
); );
}; };
@@ -184,17 +165,12 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return ( return (
obj !== null && obj !== null &&
typeof obj !== 'undefined' && typeof obj !== 'undefined' &&
typeof jasmineGlobal.DataView !== 'undefined' &&
obj.constructor === jasmineGlobal.DataView obj.constructor === jasmineGlobal.DataView
); );
}; };
j$.isPromise = function(obj) { j$.isPromise = function(obj) {
return ( return !!obj && obj.constructor === jasmineGlobal.Promise;
typeof jasmineGlobal.Promise !== 'undefined' &&
!!obj &&
obj.constructor === jasmineGlobal.Promise
);
}; };
j$.isPromiseLike = function(obj) { j$.isPromiseLike = function(obj) {
@@ -215,7 +191,6 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
j$.isPending_ = function(promise) { j$.isPending_ = function(promise) {
var sentinel = {}; var sentinel = {};
// eslint-disable-next-line compat/compat
return Promise.race([promise, Promise.resolve(sentinel)]).then( return Promise.race([promise, Promise.resolve(sentinel)]).then(
function(result) { function(result) {
return result === sentinel; return result === sentinel;
-1
View File
@@ -1,4 +1,3 @@
/* eslint-disable compat/compat */
getJasmineRequireObj().toBePending = function(j$) { getJasmineRequireObj().toBePending = function(j$) {
/** /**
* Expect a promise to be pending, i.e. the promise is neither resolved nor rejected. * Expect a promise to be pending, i.e. the promise is neither resolved nor rejected.
+1 -1
View File
@@ -37,7 +37,7 @@ getJasmineRequireObj().toHaveSize = function(j$) {
}; };
} }
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // eslint-disable-line compat/compat var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
function isLength(value) { function isLength(value) {
return ( return (
typeof value == 'number' && typeof value == 'number' &&
-15
View File
@@ -127,20 +127,5 @@ getJasmineRequireObj().util = function(j$) {
StopIteration.prototype = Object.create(Error.prototype); StopIteration.prototype = Object.create(Error.prototype);
StopIteration.prototype.constructor = StopIteration; StopIteration.prototype.constructor = StopIteration;
// useful for maps and sets since `forEach` is the only IE11-compatible way to iterate them
util.forEachBreakable = function(iterable, iteratee) {
function breakLoop() {
throw new StopIteration();
}
try {
iterable.forEach(function(value, key) {
iteratee(breakLoop, value, key, iterable);
});
} catch (error) {
if (!(error instanceof StopIteration)) throw error;
}
};
return util; return util;
}; };