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

View File

@@ -92,6 +92,7 @@ Or, How to make a successful pull request
without test-driving it.
* _Write code in the style of the rest of the repo_ - Jasmine should look like
a cohesive whole.
* **Exception**: Prefer `const` or `let` over `var`.
* _Ensure the *entire* test suite is green_ in all the big browsers, Node, and
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
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
Explorer if you've touched code in `src/html`, if your change involves newer
JavaScript language/runtime features, or if you're unfamiliar with writing code
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`.
couple of supported 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
CI tooling:
$ 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
1. Ensure all specs are green in browser *and* node.

View File

@@ -267,25 +267,8 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
if (value instanceof Error) {
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 true;
}
}
return false;
return typeof value.stack === 'string' && typeof value.message === 'string';
};
j$.isAsymmetricEqualityTester_ = function(obj) {
@@ -327,7 +310,6 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return (
obj !== null &&
typeof obj !== 'undefined' &&
typeof jasmineGlobal.WeakMap !== 'undefined' &&
obj.constructor === jasmineGlobal.WeakMap
);
};
@@ -336,7 +318,6 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return (
obj !== null &&
typeof obj !== 'undefined' &&
typeof jasmineGlobal.URL !== 'undefined' &&
obj.constructor === jasmineGlobal.URL
);
};
@@ -345,17 +326,12 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return (
obj !== null &&
typeof obj !== 'undefined' &&
typeof jasmineGlobal.DataView !== 'undefined' &&
obj.constructor === jasmineGlobal.DataView
);
};
j$.isPromise = function(obj) {
return (
typeof jasmineGlobal.Promise !== 'undefined' &&
!!obj &&
obj.constructor === jasmineGlobal.Promise
);
return !!obj && obj.constructor === jasmineGlobal.Promise;
};
j$.isPromiseLike = function(obj) {
@@ -376,7 +352,6 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
j$.isPending_ = function(promise) {
var sentinel = {};
// eslint-disable-next-line compat/compat
return Promise.race([promise, Promise.resolve(sentinel)]).then(
function(result) {
return result === sentinel;
@@ -676,21 +651,6 @@ getJasmineRequireObj().util = function(j$) {
StopIteration.prototype = Object.create(Error.prototype);
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;
};
@@ -2559,27 +2519,26 @@ getJasmineRequireObj().MapContaining = function(j$) {
MapContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!j$.isMap(other)) return false;
var hasAllMatches = true;
j$.util.forEachBreakable(this.sample, function(breakLoop, value, key) {
for (const [key, value] of this.sample) {
// for each key/value pair in `sample`
// there should be at least one pair in `other` whose key and value both match
var hasMatch = false;
j$.util.forEachBreakable(other, function(oBreakLoop, oValue, oKey) {
for (const [oKey, oValue] of other) {
if (
matchersUtil.equals(oKey, key) &&
matchersUtil.equals(oValue, value)
) {
hasMatch = true;
oBreakLoop();
break;
}
});
if (!hasMatch) {
hasAllMatches = false;
breakLoop();
}
});
return hasAllMatches;
if (!hasMatch) {
return false;
}
}
return true;
};
MapContaining.prototype.jasmineToString = function(pp) {
@@ -2711,25 +2670,24 @@ getJasmineRequireObj().SetContaining = function(j$) {
SetContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!j$.isSet(other)) return false;
var hasAllMatches = true;
j$.util.forEachBreakable(this.sample, function(breakLoop, item) {
for (const item of this.sample) {
// 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 by deep value equality)
var hasMatch = false;
j$.util.forEachBreakable(other, function(oBreakLoop, oItem) {
for (const oItem of other) {
if (matchersUtil.equals(oItem, item)) {
hasMatch = true;
oBreakLoop();
break;
}
});
if (!hasMatch) {
hasAllMatches = false;
breakLoop();
}
});
return hasAllMatches;
if (!hasMatch) {
return false;
}
}
return true;
};
SetContaining.prototype.jasmineToString = function(pp) {
@@ -3670,15 +3628,8 @@ getJasmineRequireObj().Expectation = function(j$) {
* @namespace async-matchers
*/
function AsyncExpectation(options) {
var global = options.global || j$.getGlobal();
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 || {};
for (var matcherName in customAsyncMatchers) {
this[matcherName] = wrapAsyncCompare(
@@ -4233,7 +4184,6 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
return GlobalErrors;
};
/* eslint-disable compat/compat */
getJasmineRequireObj().toBePending = function(j$) {
/**
* 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) {
return (
typeof value == 'number' &&
@@ -7019,11 +6969,7 @@ getJasmineRequireObj().MockDate = function() {
FakeDate.prototype = GlobalDate.prototype;
FakeDate.now = function() {
if (GlobalDate.now) {
return currentTime;
} else {
throw new Error('Browser does not support Date.now()');
}
return currentTime;
};
FakeDate.toSource = GlobalDate.toSource;
@@ -8970,7 +8916,7 @@ getJasmineRequireObj().StackTrace = function(j$) {
}
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)"
// Note that the "function name" can include a surprisingly large set of
// characters, including angle brackets and square brackets.

View File

@@ -60,8 +60,10 @@
"extends": [
"plugin:compat/recommended"
],
"parserOptions": {
"ecmaVersion": 5
"env": {
"browser": true,
"node": true,
"es2017": true
},
"rules": {
"quotes": [
@@ -94,11 +96,10 @@
}
},
"browserslist": [
"Safari >= 9",
"Safari >= 13",
"last 2 Chrome versions",
"last 2 Firefox versions",
"Firefox 68",
"last 2 Edge versions",
"IE >= 11"
"Firefox >= 68",
"last 2 Edge versions"
]
}

View File

@@ -23,7 +23,6 @@ run_browser() {
passfile=`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 firefox latest
run_browser firefox 78

View File

@@ -1,4 +1,3 @@
/* eslint-disable compat/compat */
describe('AsyncExpectation', function() {
beforeEach(function() {
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() {
it('converts a pass to a fail', function() {
jasmine.getEnv().requirePromises();
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
actual = Promise.resolve(),
pp = jasmineUnderTest.makePrettyPrinter(),
@@ -44,8 +28,6 @@ describe('AsyncExpectation', function() {
});
it('converts a fail to a pass', function() {
jasmine.getEnv().requirePromises();
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
actual = Promise.reject(),
expectation = jasmineUnderTest.Expectation.asyncFactory({
@@ -69,7 +51,6 @@ describe('AsyncExpectation', function() {
});
it('propagates rejections from the comparison function', function() {
jasmine.getEnv().requirePromises();
var error = new Error('ExpectationSpec failure');
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
@@ -93,8 +74,6 @@ describe('AsyncExpectation', function() {
describe('#withContext', function() {
it('prepends the context to the generated failure message', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = {
pp: function(val) {
return val.toString();
@@ -122,8 +101,6 @@ describe('AsyncExpectation', function() {
});
it('prepends the context to a custom failure message', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = {
buildFailureMessage: function() {
return 'failure message';
@@ -154,7 +131,6 @@ describe('AsyncExpectation', 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');
jasmine.getEnv().requirePromises();
var matchersUtil = {
buildFailureMessage: function() {
@@ -183,8 +159,6 @@ describe('AsyncExpectation', function() {
});
it('works with #not', function() {
jasmine.getEnv().requirePromises();
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
actual = Promise.resolve(),
pp = jasmineUnderTest.makePrettyPrinter(),
@@ -209,8 +183,6 @@ describe('AsyncExpectation', function() {
});
it('works with #not and a custom message', function() {
jasmine.getEnv().requirePromises();
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
actual = Promise.resolve('a'),
expectation = jasmineUnderTest.Expectation.asyncFactory({
@@ -238,8 +210,6 @@ describe('AsyncExpectation', function() {
describe('async matchers', function() {
it('makes custom matchers available to this expectation', function() {
jasmine.getEnv().requirePromises();
var asyncMatchers = {
toFoo: function() {},
toBar: function() {}
@@ -255,8 +225,6 @@ describe('AsyncExpectation', function() {
});
it("wraps matchers's compare functions, passing in matcher dependencies", function() {
jasmine.getEnv().requirePromises();
var fakeCompare = function() {
return Promise.resolve({ pass: true });
},
@@ -285,8 +253,6 @@ describe('AsyncExpectation', function() {
});
it("wraps matchers's compare functions, passing the actual and expected", function() {
jasmine.getEnv().requirePromises();
var fakeCompare = jasmine
.createSpy('fake-compare')
.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() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
return {
@@ -359,8 +323,6 @@ describe('AsyncExpectation', function() {
});
it('reports a failing result to the spec when the comparison fails', function() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
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() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
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() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
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() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
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() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
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() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
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() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
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() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
return {
@@ -708,8 +656,6 @@ describe('AsyncExpectation', 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 matchers = {
toFoo: function() {
@@ -752,8 +698,6 @@ describe('AsyncExpectation', function() {
});
it("reports a custom message to the spec when a 'not' comparison fails", function() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
return {
@@ -794,8 +738,6 @@ describe('AsyncExpectation', function() {
});
it("reports a custom message func to the spec when a 'not' comparison fails", function() {
jasmine.getEnv().requirePromises();
var matchers = {
toFoo: function() {
return {

View File

@@ -223,9 +223,8 @@ describe('Env', function() {
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.it('async', jasmine.getEnv().makeAsyncAwaitFunction());
env.it('async', async function() {});
}).not.toThrow();
});
});
@@ -255,9 +254,8 @@ describe('Env', function() {
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.xit('async', jasmine.getEnv().makeAsyncAwaitFunction());
env.xit('async', async function() {});
}).not.toThrow();
});
});
@@ -282,9 +280,8 @@ describe('Env', function() {
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.beforeEach(jasmine.getEnv().makeAsyncAwaitFunction());
env.beforeEach(async function() {});
}).not.toThrow();
});
});
@@ -299,9 +296,8 @@ describe('Env', function() {
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.beforeAll(jasmine.getEnv().makeAsyncAwaitFunction());
env.beforeAll(async function() {});
}).not.toThrow();
});
});
@@ -316,9 +312,8 @@ describe('Env', function() {
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.afterEach(jasmine.getEnv().makeAsyncAwaitFunction());
env.afterEach(async function() {});
}).not.toThrow();
});
});
@@ -333,9 +328,8 @@ describe('Env', function() {
});
it('accepts an async function', function() {
jasmine.getEnv().requireAsyncAwait();
expect(function() {
env.afterAll(jasmine.getEnv().makeAsyncAwaitFunction());
env.afterAll(async function() {});
}).not.toThrow();
});
});

View File

@@ -96,24 +96,6 @@ describe('FakeDate', function() {
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() {
var globalDate = jasmine.createSpy('global Date').and.callFake(function() {
return {

View File

@@ -295,20 +295,15 @@ describe('PrettyPrinter', function() {
it('should indicate getters on objects as such', function() {
var pp = jasmineUnderTest.makePrettyPrinter();
var sampleValue = { id: 1 };
if (sampleValue.__defineGetter__) {
//not supported in IE!
sampleValue.__defineGetter__('calculatedValue', function() {
var sampleValue = {
id: 1,
get calculatedValue() {
throw new Error("don't call me!");
});
}
if (sampleValue.__defineGetter__) {
expect(pp(sampleValue)).toEqual(
'Object({ id: 1, calculatedValue: <getter> })'
);
} else {
expect(pp(sampleValue)).toEqual('Object({ id: 1 })');
}
}
};
expect(pp(sampleValue)).toEqual(
'Object({ id: 1, calculatedValue: <getter> })'
);
});
it('should not do HTML escaping of strings', function() {

View File

@@ -538,7 +538,6 @@ describe('QueueRunner', function() {
});
it('issues a more specific error if the function is `async`', function() {
jasmine.getEnv().requireAsyncAwait();
eval('var fn = async function(done){};');
var onException = jasmine.createSpy('onException'),
queueRunner = new jasmineUnderTest.QueueRunner({

View File

@@ -61,10 +61,6 @@ describe('Spec', function() {
spec.execute();
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.calls.first().object).toEqual(spec);
});

View File

@@ -31,12 +31,7 @@ describe('Spies', function() {
var fn = function test() {};
var spy = env.createSpy(fn);
// IE doesn't do `.name`
if (fn.name === 'test') {
expect(spy.and.identity).toEqual('test');
} else {
expect(spy.and.identity).toEqual('unknown');
}
expect(spy.and.identity).toEqual('test');
});
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() {
it('works with global Promise library when available', function(done) {
jasmine.getEnv().requirePromises();
var spy = env.createSpy('foo').and.resolveTo(42);
spy()
.then(function(result) {

View File

@@ -108,7 +108,6 @@ describe('SpyStrategy', function() {
});
it('allows a fake async function to be called instead', function(done) {
jasmine.getEnv().requireAsyncAwait();
var originalFn = jasmine.createSpy('original'),
fakeFn = jasmine
.createSpy('fake')
@@ -131,8 +130,6 @@ describe('SpyStrategy', function() {
describe('#resolveTo', function() {
it('allows a resolved promise to be returned', function(done) {
jasmine.getEnv().requirePromises();
var originalFn = jasmine.createSpy('original'),
getPromise = function() {
return Promise;
@@ -153,8 +150,6 @@ describe('SpyStrategy', function() {
});
it('allows an empty resolved promise to be returned', function(done) {
jasmine.getEnv().requirePromises();
var originalFn = jasmine.createSpy('original'),
getPromise = function() {
return Promise;
@@ -188,8 +183,6 @@ describe('SpyStrategy', function() {
describe('#rejectWith', function() {
it('allows a rejected promise to be returned', function(done) {
jasmine.getEnv().requirePromises();
var originalFn = jasmine.createSpy('original'),
getPromise = function() {
return Promise;
@@ -211,8 +204,6 @@ describe('SpyStrategy', function() {
});
it('allows an empty rejected promise to be returned', function(done) {
jasmine.getEnv().requirePromises();
var originalFn = jasmine.createSpy('original'),
getPromise = function() {
return Promise;
@@ -234,8 +225,6 @@ describe('SpyStrategy', function() {
});
it('allows a non-Error to be rejected', function(done) {
jasmine.getEnv().requirePromises();
var originalFn = jasmine.createSpy('original'),
getPromise = function() {
return Promise;
@@ -335,9 +324,9 @@ describe('SpyStrategy', function() {
});
it('allows generator functions to be passed to callFake strategy', function() {
jasmine.getEnv().requireGeneratorFunctions();
var generator = jasmine.getEnv().makeGeneratorFunction('yield "ok";'),
var generator = function*() {
yield 'ok';
},
spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: function() {} });
spyStrategy.callFake(generator);

View File

@@ -1,5 +1,5 @@
describe('StackTrace', function() {
it('understands Chrome/IE/Edge style traces', function() {
it('understands Chrome/Edge style traces', function() {
var error = {
message: 'nope',
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 = {
message: 'line 1\nline 2',
stack:

View File

@@ -39,8 +39,7 @@ describe('jasmineUnderTest.util', function() {
};
beforeEach(function() {
jasmine.getEnv().requirePromises();
mockNativePromise = new Promise(function(res, rej) {}); // eslint-disable-line compat/compat
mockNativePromise = new Promise(function(res, rej) {});
mockPromiseLikeObject = new mockPromiseLike();
});

View File

@@ -48,11 +48,9 @@ describe('Any', 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); // eslint-disable-line compat/compat
expect(any.asymmetricMatch(Symbol())).toBe(true);
});
it('matches another constructed object', function() {

View File

@@ -42,11 +42,9 @@ describe('Anything', function() {
});
it('matches a Symbol', function() {
jasmine.getEnv().requireFunctioningSymbols();
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() {

View File

@@ -1,28 +1,19 @@
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() {
var actualMap = new MapI([['foo', 'bar']]);
var actualMap = new Map([['foo', 'bar']]);
var containing = new jasmineUnderTest.MapContaining(new Map());
expect(containing.asymmetricMatch(actualMap)).toBe(true);
});
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: 'bar' }, 'baz'],
['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 matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -30,12 +21,12 @@ describe('MapContaining', 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: '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 matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -43,9 +34,9 @@ describe('MapContaining', 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 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() {
var actualMap = new MapI([
var actualMap = new Map([
['foo1', 'not a bar'],
['foo2', 'bar'],
['baz', [1, 2, 3, 4]]
]);
var containingMap = new MapI([
var containingMap = new Map([
[jasmineUnderTest.stringMatching(/^foo\d/), 'bar'],
['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() {
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'],
['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() {
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'],
['baz', jasmineUnderTest.arrayContaining([4, 5])]
]);
@@ -96,15 +87,15 @@ describe('MapContaining', function() {
});
it('matches recursively', function() {
var actualMap = new MapI([
['foo', new MapI([['foo1', 1], ['foo2', 2]])],
[new MapI([[1, 'bar1'], [2, 'bar2']]), 'bar'],
var actualMap = new Map([
['foo', new Map([['foo1', 1], ['foo2', 2]])],
[new Map([[1, 'bar1'], [2, 'bar2']]), 'bar'],
['other', 'any']
]);
var containingMap = new MapI([
['foo', new jasmineUnderTest.MapContaining(new MapI([['foo1', 1]]))],
[new jasmineUnderTest.MapContaining(new MapI([[2, 'bar2']])), 'bar']
var containingMap = new Map([
['foo', new jasmineUnderTest.MapContaining(new Map([['foo1', 1]]))],
[new jasmineUnderTest.MapContaining(new Map([[2, 'bar2']])), 'bar']
]);
var containing = new jasmineUnderTest.MapContaining(containingMap);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -119,10 +110,8 @@ describe('MapContaining', function() {
? a < 0 && b < 0
: a === b;
}
var actualMap = new MapI([['foo', -1]]);
var containing = new jasmineUnderTest.MapContaining(
new MapI([['foo', -2]])
);
var actualMap = new Map([['foo', -1]]);
var containing = new jasmineUnderTest.MapContaining(new Map([['foo', -2]]));
var matchersUtil = new jasmineUnderTest.MatchersUtil({
customTesters: [tester]
});
@@ -131,7 +120,7 @@ describe('MapContaining', 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(
new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch('foo')
).toBe(false);

View File

@@ -1,24 +1,15 @@
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() {
var actualSet = new SetI(['foo', 'bar']);
var actualSet = new Set(['foo', 'bar']);
var containing = new jasmineUnderTest.SetContaining(new Set());
expect(containing.asymmetricMatch(actualSet)).toBe(true);
});
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 matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -26,9 +17,9 @@ describe('SetContaining', 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 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() {
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.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() {
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.arrayContaining([2, 3])
]);
@@ -62,10 +53,10 @@ describe('SetContaining', 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([
new jasmineUnderTest.SetContaining(new SetI(['bar'])),
var containingSet = new Set([
new jasmineUnderTest.SetContaining(new Set(['bar'])),
'foo'
]);
var containing = new jasmineUnderTest.SetContaining(containingSet);
@@ -81,8 +72,8 @@ describe('SetContaining', function() {
? a < 0 && b < 0
: a === b;
}
var actualSet = new SetI(['foo', -1]);
var containing = new jasmineUnderTest.SetContaining(new SetI([-2, 'foo']));
var actualSet = new Set(['foo', -1]);
var containing = new jasmineUnderTest.SetContaining(new Set([-2, 'foo']));
var matchersUtil = new jasmineUnderTest.MatchersUtil({
customTesters: [tester]
});
@@ -91,7 +82,7 @@ describe('SetContaining', function() {
});
it('does not match when actual is not a set', function() {
var containingSet = new SetI(['foo']);
var containingSet = new Set(['foo']);
expect(
new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch('foo')
).toBe(false);

View File

@@ -101,21 +101,16 @@ describe('base helpers', function() {
describe('isURL', 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);
});
it('returns false when the object is not a URL', function() {
jasmine.getEnv().requireUrls();
expect(jasmineUnderTest.isURL({})).toBe(false);
});
});
describe('isPending_', 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() {});
return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo(
true
@@ -123,8 +118,6 @@ describe('base helpers', 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();
return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo(
false
@@ -132,8 +125,6 @@ describe('base helpers', 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();
return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo(
false

View File

@@ -1,4 +1,3 @@
/* eslint-disable compat/compat */
describe('Custom Async Matchers (Integration)', function() {
var env;
@@ -12,8 +11,6 @@ describe('Custom Async Matchers (Integration)', function() {
});
it('passes the spec if the custom async matcher passes', function(done) {
jasmine.getEnv().requirePromises();
env.it('spec using custom async matcher', function() {
env.addAsyncMatchers({
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) {
jasmine.getEnv().requirePromises();
env.it('spec with custom negative comparison matcher', function() {
env.addAsyncMatchers({
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) {
jasmine.getEnv().requirePromises();
env.it('spec with an expectation', function() {
env.addAsyncMatchers({
toBeReal: function() {
@@ -92,8 +85,6 @@ describe('Custom Async Matchers (Integration)', function() {
});
it('passes the jasmine utility to the matcher factory', function(done) {
jasmine.getEnv().requirePromises();
var matcherFactory = function(util) {
return {
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) {
jasmine.getEnv().requirePromises();
var matcherFactory = function(matchersUtil) {
return {
compare: function(actual, expected) {

View File

@@ -156,10 +156,6 @@ describe('Env integration', function() {
message: 'Failed: error message',
stack: {
asymmetricMatch: function(other) {
if (!other) {
// IE doesn't give us a stacktrace so just ignore it.
return true;
}
var split = other.split('\n'),
firstLine = split[0];
if (firstLine.indexOf('error message') >= 0) {
@@ -2709,8 +2705,6 @@ describe('Env integration', function() {
});
it('supports async matchers', function(done) {
jasmine.getEnv().requirePromises();
var specDone = jasmine.createSpy('specDone'),
suiteDone = jasmine.createSpy('suiteDone'),
jasmineDone = jasmine.createSpy('jasmineDone');
@@ -2723,7 +2717,6 @@ describe('Env integration', function() {
function fail(innerDone) {
var resolve;
// eslint-disable-next-line compat/compat
var p = new Promise(function(res, rej) {
resolve = res;
});
@@ -2779,8 +2772,6 @@ describe('Env integration', function() {
jasmine.getEnv().skipBrowserFlake();
}
jasmine.getEnv().requirePromises();
var specDone = jasmine.createSpy('specDone');
env.addReporter({ specDone: specDone });
@@ -2789,7 +2780,7 @@ describe('Env integration', function() {
env.addCustomEqualityTester(function() {
return true;
});
var p = Promise.resolve('something'); // eslint-disable-line compat/compat
var p = Promise.resolve('something');
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) {
jasmine.getEnv().requirePromises();
var specDone = jasmine.createSpy('specDone');
env.addReporter({ specDone: specDone });
@@ -2815,7 +2804,7 @@ describe('Env integration', function() {
env.addCustomEqualityTester(function() {
return true;
});
var p = Promise.resolve(); // eslint-disable-line compat/compat
var p = Promise.resolve();
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) {
jasmine.getEnv().requirePromises();
var resolve,
jasmineDone = jasmine.createSpy('jasmineDone'),
// eslint-disable-next-line compat/compat
promise = new Promise(function(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) {
jasmine.getEnv().requirePromises();
var resolve,
jasmineDone = jasmine.createSpy('jasmineDone'),
// eslint-disable-next-line compat/compat
promise = new Promise(function(res) {
resolve = res;
});

View File

@@ -90,8 +90,6 @@ describe('Matchers (Integration)', function() {
function verifyPassesAsync(expectations) {
it('passes', function(done) {
jasmine.getEnv().requirePromises();
env.it('a spec', function() {
return expectations(env);
});
@@ -118,8 +116,6 @@ describe('Matchers (Integration)', function() {
function verifyFailsAsync(expectations) {
it('fails', function(done) {
jasmine.getEnv().requirePromises();
env.it('a spec', function() {
return expectations(env);
});
@@ -147,7 +143,6 @@ describe('Matchers (Integration)', function() {
function verifyFailsWithCustomObjectFormattersAsync(config) {
it('uses custom object formatters', function(done) {
var env = new jasmineUnderTest.Env();
jasmine.getEnv().requirePromises();
env.it('a spec', function() {
env.addCustomObjectFormatter(config.formatter);
return config.expectations(env);
@@ -348,12 +343,10 @@ describe('Matchers (Integration)', function() {
describe('toBeResolved', function() {
verifyPassesAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve()).toBeResolved();
});
verifyFailsAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.reject()).toBeResolved();
});
});
@@ -363,12 +356,10 @@ describe('Matchers (Integration)', function() {
env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve('5')).toBeResolvedTo(5);
});
verifyFailsAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve('foo')).toBeResolvedTo('bar');
});
@@ -377,7 +368,6 @@ describe('Matchers (Integration)', function() {
return '|' + val + '|';
},
expectations: function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve('x')).toBeResolvedTo('y');
},
expectedMessage:
@@ -388,12 +378,10 @@ describe('Matchers (Integration)', function() {
describe('toBeRejected', function() {
verifyPassesAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.reject('nope')).toBeRejected();
});
verifyFailsAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve()).toBeRejected();
});
});
@@ -403,12 +391,10 @@ describe('Matchers (Integration)', function() {
env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.reject('5')).toBeRejectedWith(5);
});
verifyFailsAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve()).toBeRejectedWith('nope');
});
@@ -417,7 +403,6 @@ describe('Matchers (Integration)', function() {
return '|' + val + '|';
},
expectations: function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.reject('x')).toBeRejectedWith('y');
},
expectedMessage:
@@ -428,16 +413,12 @@ describe('Matchers (Integration)', function() {
describe('toBeRejectedWithError', function() {
verifyPassesAsync(function(env) {
return (
env
// eslint-disable-next-line compat/compat
.expectAsync(Promise.reject(new Error()))
.toBeRejectedWithError(Error)
);
return env
.expectAsync(Promise.reject(new Error()))
.toBeRejectedWithError(Error);
});
verifyFailsAsync(function(env) {
// eslint-disable-next-line compat/compat
return env.expectAsync(Promise.resolve()).toBeRejectedWithError(Error);
});
@@ -446,12 +427,9 @@ describe('Matchers (Integration)', function() {
return '|' + val + '|';
},
expectations: function(env) {
return (
env
// eslint-disable-next-line compat/compat
.expectAsync(Promise.reject('foo'))
.toBeRejectedWithError('foo')
);
return env
.expectAsync(Promise.reject('foo'))
.toBeRejectedWithError('foo');
},
expectedMessage:
'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() {
it('propagates the matcher result when the promise is resolved', function(done) {
jasmine.getEnv().requirePromises();
env.it('a spec', function() {
// eslint-disable-next-line compat/compat
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) {
jasmine.getEnv().requirePromises();
env.it('a spec', function() {
return (
env
// eslint-disable-next-line compat/compat
.expectAsync(Promise.reject(new Error('nope')))
.already.toBeResolved()
);
return env
.expectAsync(Promise.reject(new Error('nope')))
.already.toBeResolved();
});
var specExpectations = function(result) {
@@ -812,9 +782,6 @@ describe('Matchers (Integration)', function() {
});
it('fails when the promise is pending', function(done) {
jasmine.getEnv().requirePromises();
// eslint-disable-next-line compat/compat
var promise = new Promise(function() {});
env.it('a spec', function() {

View File

@@ -1,8 +1,5 @@
/* eslint-disable compat/compat */
describe('toBePending', function() {
it('passes if the actual promise is pending', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
actual = new Promise(function() {});
@@ -13,8 +10,6 @@ describe('toBePending', function() {
});
it('fails if the actual promise is resolved', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
actual = Promise.resolve();
@@ -25,8 +20,6 @@ describe('toBePending', function() {
});
it('fails if the actual promise is rejected', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
actual = Promise.reject(new Error('promise was rejected'));

View File

@@ -1,8 +1,5 @@
/* eslint-disable compat/compat */
describe('toBeRejected', function() {
it('passes if the actual is rejected', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil),
actual = Promise.reject('AsyncExpectationSpec rejection');
@@ -13,8 +10,6 @@ describe('toBeRejected', function() {
});
it('fails if the actual is resolved', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil),
actual = Promise.resolve();

View File

@@ -1,8 +1,5 @@
/* eslint-disable compat/compat */
describe('#toBeRejectedWithError', function() {
it('passes when Error type matches', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -23,8 +20,6 @@ describe('#toBeRejectedWithError', function() {
});
it('passes when Error type and message matches', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -45,8 +40,6 @@ describe('#toBeRejectedWithError', function() {
});
it('passes when Error matches and is exactly Error', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -67,8 +60,6 @@ describe('#toBeRejectedWithError', function() {
});
it('passes when Error message matches a string', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -89,8 +80,6 @@ describe('#toBeRejectedWithError', function() {
});
it('passes when Error message matches a RegExp', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -111,8 +100,6 @@ describe('#toBeRejectedWithError', function() {
});
it('passes when Error message is empty', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -133,8 +120,6 @@ describe('#toBeRejectedWithError', function() {
});
it('passes when no arguments', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -155,8 +140,6 @@ describe('#toBeRejectedWithError', function() {
});
it('fails when resolved', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -176,8 +159,6 @@ describe('#toBeRejectedWithError', function() {
});
it('fails when rejected with non Error type', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -198,8 +179,6 @@ describe('#toBeRejectedWithError', function() {
});
it('fails when Error type mismatches', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -220,8 +199,6 @@ describe('#toBeRejectedWithError', function() {
});
it('fails when Error message mismatches', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),

View File

@@ -1,8 +1,5 @@
/* eslint-disable compat/compat */
describe('#toBeRejectedWith', function() {
it('should return true if the promise is rejected with the expected value', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
actual = Promise.reject({ error: 'PEBCAK' });
@@ -13,8 +10,6 @@ describe('#toBeRejectedWith', function() {
});
it('should fail if the promise resolves', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
actual = Promise.resolve();
@@ -25,8 +20,6 @@ describe('#toBeRejectedWith', function() {
});
it('should fail if the promise is rejected with a different value', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -45,8 +38,6 @@ describe('#toBeRejectedWith', function() {
});
it('should build its error correctly when negated', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -64,8 +55,6 @@ describe('#toBeRejectedWith', function() {
});
it('should support custom equality testers', function() {
jasmine.getEnv().requirePromises();
var customEqualityTesters = [
function() {
return true;

View File

@@ -1,8 +1,5 @@
/* eslint-disable compat/compat */
describe('toBeResolved', function() {
it('passes if the actual is resolved', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeResolved(matchersUtil),
actual = Promise.resolve();
@@ -13,8 +10,6 @@ describe('toBeResolved', function() {
});
it('fails if the actual is rejected', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter([])
}),

View File

@@ -1,8 +1,5 @@
/* eslint-disable compat/compat */
describe('#toBeResolvedTo', function() {
it('passes if the promise is resolved to the expected value', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
actual = Promise.resolve({ foo: 42 });
@@ -13,8 +10,6 @@ describe('#toBeResolvedTo', function() {
});
it('fails if the promise is rejected', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -34,8 +29,6 @@ describe('#toBeResolvedTo', function() {
});
it('fails if the promise is resolved to a different value', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -54,8 +47,6 @@ describe('#toBeResolvedTo', function() {
});
it('builds its message correctly when negated', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -73,8 +64,6 @@ describe('#toBeResolvedTo', function() {
});
it('supports custom equality testers', function() {
jasmine.getEnv().requirePromises();
var customEqualityTesters = [
function() {
return true;

View File

@@ -232,8 +232,8 @@ describe('matchersUtil', function() {
return;
}
var p1 = new Promise(function() {}), // eslint-disable-line compat/compat
p2 = new Promise(function() {}), // eslint-disable-line compat/compat
var p1 = new Promise(function() {}),
p2 = new Promise(function() {}),
matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(p1, p1)).toBe(true);
@@ -655,48 +655,35 @@ describe('matchersUtil', function() {
});
it('passes when comparing two identical URLs', function() {
jasmine.getEnv().requireUrls();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(
matchersUtil.equals(
// eslint-disable-next-line compat/compat
new URL('http://localhost/1'),
// eslint-disable-next-line compat/compat
new URL('http://localhost/1')
)
).toBe(true);
});
it('fails when comparing two different URLs', function() {
jasmine.getEnv().requireUrls();
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
// eslint-disable-next-line compat/compat
url1 = new URL('http://localhost/1');
// eslint-disable-next-line compat/compat
expect(matchersUtil.equals(url1, new URL('http://localhost/2'))).toBe(
false
);
// eslint-disable-next-line compat/compat
expect(matchersUtil.equals(url1, new URL('http://localhost/1?foo'))).toBe(
false
);
// eslint-disable-next-line compat/compat
expect(matchersUtil.equals(url1, new URL('http://localhost/1#foo'))).toBe(
false
);
// eslint-disable-next-line compat/compat
expect(matchersUtil.equals(url1, new URL('https://localhost/1'))).toBe(
false
);
expect(
// eslint-disable-next-line compat/compat
matchersUtil.equals(url1, new URL('http://localhost:8080/1'))
).toBe(false);
// eslint-disable-next-line compat/compat
expect(matchersUtil.equals(url1, new URL('http://example.com/1'))).toBe(
false
);
@@ -721,15 +708,12 @@ describe('matchersUtil', function() {
describe('Typed arrays', function() {
it('fails for typed arrays of same length and contents but different types', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
// eslint-disable-next-line compat/compat
var a1 = new Int8Array(1);
// eslint-disable-next-line compat/compat
var a2 = new Uint8Array(1);
a1[0] = a2[0] = 0;
expect(matchersUtil.equals(a1, a2)).toBe(false);
});
// eslint-disable-next-line compat/compat
[
'Int8Array',
'Uint8Array',
@@ -741,20 +725,11 @@ describe('matchersUtil', function() {
'Float32Array',
'Float64Array'
].forEach(function(typeName) {
function requireType() {
var TypedArrayCtor = jasmine.getGlobal()[typeName];
if (!TypedArrayCtor) {
pending('Browser does not support ' + typeName);
}
return TypedArrayCtor;
}
var TypedArrayCtor = jasmine.getGlobal()[typeName];
it(
'passes for ' + typeName + 's with same length and content',
function() {
var TypedArrayCtor = requireType();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var a1 = new TypedArrayCtor(2);
var a2 = new TypedArrayCtor(2);
@@ -765,7 +740,6 @@ describe('matchersUtil', function() {
);
it('fails for ' + typeName + 's with different length', function() {
var TypedArrayCtor = requireType();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var a1 = new TypedArrayCtor(2);
var a2 = new TypedArrayCtor(1);
@@ -776,7 +750,6 @@ describe('matchersUtil', function() {
it(
'fails for ' + typeName + 's with same length but different content',
function() {
var TypedArrayCtor = requireType();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var a1 = new TypedArrayCtor(1);
var a2 = new TypedArrayCtor(1);
@@ -787,7 +760,6 @@ describe('matchersUtil', function() {
);
it('checks nonstandard properties of ' + typeName, function() {
var TypedArrayCtor = requireType();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var a1 = new TypedArrayCtor(1);
var a2 = new TypedArrayCtor(1);
@@ -797,7 +769,6 @@ describe('matchersUtil', function() {
});
it('works with custom equality testers with ' + typeName, function() {
var TypedArrayCtor = requireType();
var a1 = new TypedArrayCtor(1);
var a2 = new TypedArrayCtor(1);
var matchersUtil = new jasmineUnderTest.MatchersUtil({

View File

@@ -104,8 +104,6 @@ describe('toBeInstanceOf', function() {
});
it('passes for an async function', function() {
jasmine.getEnv().requireAsyncAwait();
var fn = eval("(async function fn() { return 'foo'; })");
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();

View File

@@ -620,9 +620,7 @@ describe('toEqual', function() {
});
it('does not report mismatches when comparing Maps with the same symbol keys', function() {
jasmine.getEnv().requireFunctioningSymbols();
var key = Symbol(); // eslint-disable-line compat/compat
var key = Symbol();
var actual = new Map();
actual.set(key, 1);
var expected = new Map();
@@ -632,12 +630,10 @@ describe('toEqual', function() {
});
it('reports mismatches between Maps with different symbol keys', function() {
jasmine.getEnv().requireFunctioningSymbols();
var actual = new Map();
actual.set(Symbol(), 1); // eslint-disable-line compat/compat
actual.set(Symbol(), 1);
var expected = new Map();
expected.set(Symbol(), 1); // eslint-disable-line compat/compat
expected.set(Symbol(), 1);
var message =
'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() {
jasmine.getEnv().requireFunctioningSymbols();
var actual = new Map();
actual.set(Symbol(), 1); // eslint-disable-line compat/compat
actual.set(Symbol(), 1);
var expected = new Map();
expected.set(jasmineUnderTest.anything(), 1);

View File

@@ -102,16 +102,14 @@ describe('toHaveSize', function() {
});
it('throws an error for WeakSet', function() {
jasmine.getEnv().requireWeakSets();
var matcher = jasmineUnderTest.matchers.toHaveSize();
expect(function() {
matcher.compare(new WeakSet(), 2); // eslint-disable-line compat/compat
matcher.compare(new WeakSet(), 2);
}).toThrowError('Cannot get size of [object WeakSet].');
});
it('throws an error for WeakMap', function() {
jasmine.getEnv().requireWeakMaps();
var matcher = jasmineUnderTest.matchers.toHaveSize();
expect(function() {

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());

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());

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());

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());

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());

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());

View File

@@ -1,7 +0,0 @@
(function(env) {
env.requirePromises = function() {
if (typeof Promise !== 'function') {
env.pending('Environment does not support promises');
}
};
})(jasmine.getEnv());

View File

@@ -4,8 +4,6 @@ describe('Spy Registry browser-specific behavior', function() {
}
it('can spy on and unspy window.onerror', function() {
requireWriteableOnerror();
var spies = [],
spyRegistry = new jasmineUnderTest.SpyRegistry({
currentSpies: function() {
@@ -24,18 +22,4 @@ describe('Spy Registry browser-specific behavior', function() {
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');
}
}
});

View File

@@ -17,16 +17,10 @@ module.exports = {
specDir: 'spec',
specFiles: ['**/*[Ss]pec.js', '!npmPackage/**/*'],
helpers: [
'helpers/asyncAwait.js',
'helpers/generator.js',
'helpers/BrowserFlags.js',
'helpers/checkForMap.js',
'helpers/checkForSet.js',
'helpers/checkForSymbol.js',
'helpers/checkForUrl.js',
'helpers/domHelpers.js',
'helpers/integrationMatchers.js',
'helpers/promises.js',
'helpers/defineJasmineUnderTest.js',
'helpers/resetEnv.js'
],

View File

@@ -5,15 +5,8 @@
"npmPackage/**/*[Ss]pec.js"
],
"helpers": [
"helpers/asyncAwait.js",
"helpers/generator.js",
"helpers/checkForMap.js",
"helpers/checkForSet.js",
"helpers/checkForSymbol.js",
"helpers/checkForUrl.js",
"helpers/domHelpers.js",
"helpers/integrationMatchers.js",
"helpers/promises.js",
"helpers/overrideConsoleLogForCircleCi.js",
"helpers/nodeDefineJasmineUnderTest.js",
"helpers/resetEnv.js"

View File

@@ -75,15 +75,8 @@ getJasmineRequireObj().Expectation = function(j$) {
* @namespace async-matchers
*/
function AsyncExpectation(options) {
var global = options.global || j$.getGlobal();
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 || {};
for (var matcherName in customAsyncMatchers) {
this[matcherName] = wrapAsyncCompare(

View File

@@ -87,11 +87,7 @@ getJasmineRequireObj().MockDate = function() {
FakeDate.prototype = GlobalDate.prototype;
FakeDate.now = function() {
if (GlobalDate.now) {
return currentTime;
} else {
throw new Error('Browser does not support Date.now()');
}
return currentTime;
};
FakeDate.toSource = GlobalDate.toSource;

View File

@@ -17,7 +17,7 @@ getJasmineRequireObj().StackTrace = function(j$) {
}
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)"
// Note that the "function name" can include a surprisingly large set of
// characters, including angle brackets and square brackets.

View File

@@ -13,27 +13,26 @@ getJasmineRequireObj().MapContaining = function(j$) {
MapContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!j$.isMap(other)) return false;
var hasAllMatches = true;
j$.util.forEachBreakable(this.sample, function(breakLoop, value, key) {
for (const [key, value] of this.sample) {
// for each key/value pair in `sample`
// there should be at least one pair in `other` whose key and value both match
var hasMatch = false;
j$.util.forEachBreakable(other, function(oBreakLoop, oValue, oKey) {
for (const [oKey, oValue] of other) {
if (
matchersUtil.equals(oKey, key) &&
matchersUtil.equals(oValue, value)
) {
hasMatch = true;
oBreakLoop();
break;
}
});
if (!hasMatch) {
hasAllMatches = false;
breakLoop();
}
});
return hasAllMatches;
if (!hasMatch) {
return false;
}
}
return true;
};
MapContaining.prototype.jasmineToString = function(pp) {

View File

@@ -13,25 +13,24 @@ getJasmineRequireObj().SetContaining = function(j$) {
SetContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!j$.isSet(other)) return false;
var hasAllMatches = true;
j$.util.forEachBreakable(this.sample, function(breakLoop, item) {
for (const item of this.sample) {
// 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 by deep value equality)
var hasMatch = false;
j$.util.forEachBreakable(other, function(oBreakLoop, oItem) {
for (const oItem of other) {
if (matchersUtil.equals(oItem, item)) {
hasMatch = true;
oBreakLoop();
break;
}
});
if (!hasMatch) {
hasAllMatches = false;
breakLoop();
}
});
return hasAllMatches;
if (!hasMatch) {
return false;
}
}
return true;
};
SetContaining.prototype.jasmineToString = function(pp) {

View File

@@ -106,25 +106,8 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
if (value instanceof Error) {
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 true;
}
}
return false;
return typeof value.stack === 'string' && typeof value.message === 'string';
};
j$.isAsymmetricEqualityTester_ = function(obj) {
@@ -166,7 +149,6 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return (
obj !== null &&
typeof obj !== 'undefined' &&
typeof jasmineGlobal.WeakMap !== 'undefined' &&
obj.constructor === jasmineGlobal.WeakMap
);
};
@@ -175,7 +157,6 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return (
obj !== null &&
typeof obj !== 'undefined' &&
typeof jasmineGlobal.URL !== 'undefined' &&
obj.constructor === jasmineGlobal.URL
);
};
@@ -184,17 +165,12 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return (
obj !== null &&
typeof obj !== 'undefined' &&
typeof jasmineGlobal.DataView !== 'undefined' &&
obj.constructor === jasmineGlobal.DataView
);
};
j$.isPromise = function(obj) {
return (
typeof jasmineGlobal.Promise !== 'undefined' &&
!!obj &&
obj.constructor === jasmineGlobal.Promise
);
return !!obj && obj.constructor === jasmineGlobal.Promise;
};
j$.isPromiseLike = function(obj) {
@@ -215,7 +191,6 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
j$.isPending_ = function(promise) {
var sentinel = {};
// eslint-disable-next-line compat/compat
return Promise.race([promise, Promise.resolve(sentinel)]).then(
function(result) {
return result === sentinel;

View File

@@ -1,4 +1,3 @@
/* eslint-disable compat/compat */
getJasmineRequireObj().toBePending = function(j$) {
/**
* Expect a promise to be pending, i.e. the promise is neither resolved nor rejected.

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) {
return (
typeof value == 'number' &&

View File

@@ -127,20 +127,5 @@ getJasmineRequireObj().util = function(j$) {
StopIteration.prototype = Object.create(Error.prototype);
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;
};