Removed support for Internet Explorer
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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'));
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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()
|
||||
}),
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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([])
|
||||
}),
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user