Use one declaration per statement
The old style of merging all of a function's variable declarations into a single statement made some sense back in the days of var, but there's no reason to keep doing it now that we use const and let.
This commit is contained in:
@@ -7,14 +7,14 @@ describe('AsyncExpectation', function() {
|
|||||||
|
|
||||||
describe('#not', function() {
|
describe('#not', function() {
|
||||||
it('converts a pass to a fail', function() {
|
it('converts a pass to a fail', function() {
|
||||||
const addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
actual = Promise.resolve(),
|
const actual = Promise.resolve();
|
||||||
pp = privateUnderTest.makePrettyPrinter(),
|
const pp = privateUnderTest.makePrettyPrinter();
|
||||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||||
matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp }),
|
matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||||
actual: actual,
|
actual: actual,
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
|
|
||||||
return expectation.not.toBeResolved().then(function() {
|
return expectation.not.toBeResolved().then(function() {
|
||||||
expect(addExpectationResult).toHaveBeenCalledWith(
|
expect(addExpectationResult).toHaveBeenCalledWith(
|
||||||
@@ -28,15 +28,15 @@ describe('AsyncExpectation', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('converts a fail to a pass', function() {
|
it('converts a fail to a pass', function() {
|
||||||
const addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
actual = Promise.reject(new Error('nope')),
|
const actual = Promise.reject(new Error('nope'));
|
||||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||||
matchersUtil: new privateUnderTest.MatchersUtil({
|
matchersUtil: new privateUnderTest.MatchersUtil({
|
||||||
pp: function() {}
|
pp: function() {}
|
||||||
}),
|
}),
|
||||||
actual: actual,
|
actual: actual,
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
|
|
||||||
return expectation.not.toBeResolved().then(function() {
|
return expectation.not.toBeResolved().then(function() {
|
||||||
expect(addExpectationResult).toHaveBeenCalledWith(
|
expect(addExpectationResult).toHaveBeenCalledWith(
|
||||||
@@ -53,12 +53,12 @@ describe('AsyncExpectation', function() {
|
|||||||
it('propagates rejections from the comparison function', function() {
|
it('propagates rejections from the comparison function', function() {
|
||||||
const error = new Error('ExpectationSpec failure');
|
const error = new Error('ExpectationSpec failure');
|
||||||
|
|
||||||
const addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
actual = dummyPromise(),
|
const actual = dummyPromise();
|
||||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||||
actual: actual,
|
actual: actual,
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(expectation, 'toBeResolved').and.returnValue(Promise.reject(error));
|
spyOn(expectation, 'toBeResolved').and.returnValue(Promise.reject(error));
|
||||||
|
|
||||||
@@ -75,16 +75,16 @@ describe('AsyncExpectation', function() {
|
|||||||
describe('#withContext', function() {
|
describe('#withContext', function() {
|
||||||
it('prepends the context to the generated failure message', function() {
|
it('prepends the context to the generated failure message', function() {
|
||||||
const matchersUtil = {
|
const matchersUtil = {
|
||||||
pp: function(val) {
|
pp: function(val) {
|
||||||
return val.toString();
|
return val.toString();
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||||
actual: Promise.reject('rejected'),
|
actual: Promise.reject('rejected'),
|
||||||
addExpectationResult: addExpectationResult,
|
addExpectationResult: addExpectationResult,
|
||||||
matchersUtil: matchersUtil
|
matchersUtil: matchersUtil
|
||||||
});
|
});
|
||||||
|
|
||||||
return expectation
|
return expectation
|
||||||
.withContext('Some context')
|
.withContext('Some context')
|
||||||
@@ -102,17 +102,17 @@ describe('AsyncExpectation', function() {
|
|||||||
|
|
||||||
it('prepends the context to a custom failure message', function() {
|
it('prepends the context to a custom failure message', function() {
|
||||||
const matchersUtil = {
|
const matchersUtil = {
|
||||||
buildFailureMessage: function() {
|
buildFailureMessage: function() {
|
||||||
return 'failure message';
|
return 'failure message';
|
||||||
},
|
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
|
||||||
},
|
},
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
};
|
||||||
actual: Promise.reject('b'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
addExpectationResult: addExpectationResult,
|
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||||
matchersUtil: matchersUtil
|
actual: Promise.reject('b'),
|
||||||
});
|
addExpectationResult: addExpectationResult,
|
||||||
|
matchersUtil: matchersUtil
|
||||||
|
});
|
||||||
|
|
||||||
return expectation
|
return expectation
|
||||||
.withContext('Some context')
|
.withContext('Some context')
|
||||||
@@ -159,14 +159,14 @@ describe('AsyncExpectation', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works with #not', function() {
|
it('works with #not', function() {
|
||||||
const addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
actual = Promise.resolve(),
|
const actual = Promise.resolve();
|
||||||
pp = privateUnderTest.makePrettyPrinter(),
|
const pp = privateUnderTest.makePrettyPrinter();
|
||||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||||
actual: actual,
|
actual: actual,
|
||||||
addExpectationResult: addExpectationResult,
|
addExpectationResult: addExpectationResult,
|
||||||
matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp })
|
matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp })
|
||||||
});
|
});
|
||||||
|
|
||||||
return expectation
|
return expectation
|
||||||
.withContext('Some context')
|
.withContext('Some context')
|
||||||
@@ -183,15 +183,15 @@ describe('AsyncExpectation', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works with #not and a custom message', function() {
|
it('works with #not and a custom message', function() {
|
||||||
const addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
actual = Promise.resolve('a'),
|
const actual = Promise.resolve('a');
|
||||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||||
actual: actual,
|
actual: actual,
|
||||||
addExpectationResult: addExpectationResult,
|
addExpectationResult: addExpectationResult,
|
||||||
matchersUtil: new privateUnderTest.MatchersUtil({
|
matchersUtil: new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
return expectation
|
return expectation
|
||||||
.withContext('Some context')
|
.withContext('Some context')
|
||||||
@@ -211,12 +211,12 @@ describe('AsyncExpectation', function() {
|
|||||||
describe('async matchers', function() {
|
describe('async matchers', function() {
|
||||||
it('makes custom matchers available to this expectation', function() {
|
it('makes custom matchers available to this expectation', function() {
|
||||||
const asyncMatchers = {
|
const asyncMatchers = {
|
||||||
toFoo: function() {},
|
toFoo: function() {},
|
||||||
toBar: function() {}
|
toBar: function() {}
|
||||||
},
|
};
|
||||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||||
customAsyncMatchers: asyncMatchers
|
customAsyncMatchers: asyncMatchers
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(expectation.toFoo).toBeDefined();
|
expect(expectation.toFoo).toBeDefined();
|
||||||
expect(expectation.toBar).toBeDefined();
|
expect(expectation.toBar).toBeDefined();
|
||||||
@@ -224,24 +224,24 @@ describe('AsyncExpectation', function() {
|
|||||||
|
|
||||||
it("wraps matchers's compare functions, passing in matcher dependencies", function() {
|
it("wraps matchers's compare functions, passing in matcher dependencies", function() {
|
||||||
const fakeCompare = function() {
|
const fakeCompare = function() {
|
||||||
return Promise.resolve({ pass: true });
|
return Promise.resolve({ pass: true });
|
||||||
},
|
};
|
||||||
matcherFactory = jasmine
|
const matcherFactory = jasmine
|
||||||
.createSpy('matcher')
|
.createSpy('matcher')
|
||||||
.and.returnValue({ compare: fakeCompare }),
|
.and.returnValue({ compare: fakeCompare });
|
||||||
matchers = {
|
const matchers = {
|
||||||
toFoo: matcherFactory
|
toFoo: matcherFactory
|
||||||
},
|
};
|
||||||
matchersUtil = {
|
const matchersUtil = {
|
||||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||||
matchersUtil: matchersUtil,
|
matchersUtil: matchersUtil,
|
||||||
customAsyncMatchers: matchers,
|
customAsyncMatchers: matchers,
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
|
|
||||||
return expectation.toFoo('hello').then(function() {
|
return expectation.toFoo('hello').then(function() {
|
||||||
expect(matcherFactory).toHaveBeenCalledWith(matchersUtil);
|
expect(matcherFactory).toHaveBeenCalledWith(matchersUtil);
|
||||||
@@ -250,25 +250,25 @@ describe('AsyncExpectation', function() {
|
|||||||
|
|
||||||
it("wraps matchers's compare functions, passing the actual and expected", function() {
|
it("wraps matchers's compare functions, passing the actual and expected", function() {
|
||||||
const fakeCompare = jasmine
|
const fakeCompare = jasmine
|
||||||
.createSpy('fake-compare')
|
.createSpy('fake-compare')
|
||||||
.and.returnValue(Promise.resolve({ pass: true })),
|
.and.returnValue(Promise.resolve({ pass: true }));
|
||||||
matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: fakeCompare
|
compare: fakeCompare
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
matchersUtil = {
|
const matchersUtil = {
|
||||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||||
matchersUtil: matchersUtil,
|
matchersUtil: matchersUtil,
|
||||||
customAsyncMatchers: matchers,
|
customAsyncMatchers: matchers,
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
|
|
||||||
return expectation.toFoo('hello').then(function() {
|
return expectation.toFoo('hello').then(function() {
|
||||||
expect(fakeCompare).toHaveBeenCalledWith('an actual', 'hello');
|
expect(fakeCompare).toHaveBeenCalledWith('an actual', 'hello');
|
||||||
@@ -310,19 +310,19 @@ describe('AsyncExpectation', function() {
|
|||||||
|
|
||||||
it('reports a failing result to the spec when the comparison fails', function() {
|
it('reports a failing result to the spec when the comparison fails', function() {
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return Promise.resolve({ pass: false });
|
return Promise.resolve({ pass: false });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
matchersUtil = {
|
const matchersUtil = {
|
||||||
buildFailureMessage: function() {
|
buildFailureMessage: function() {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
|
|
||||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||||
@@ -440,19 +440,19 @@ describe('AsyncExpectation', function() {
|
|||||||
|
|
||||||
it('reports a failing result to the spec when the comparison passes for a negative expectation', function() {
|
it('reports a failing result to the spec when the comparison passes for a negative expectation', function() {
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return Promise.resolve({ pass: true });
|
return Promise.resolve({ pass: true });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
matchersUtil = {
|
const matchersUtil = {
|
||||||
buildFailureMessage: function() {
|
buildFailureMessage: function() {
|
||||||
return 'default message';
|
return 'default message';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
|
|
||||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ describe('CallTracker', function() {
|
|||||||
it("tracks the 'this' object from each execution", function() {
|
it("tracks the 'this' object from each execution", function() {
|
||||||
const callTracker = new privateUnderTest.CallTracker();
|
const callTracker = new privateUnderTest.CallTracker();
|
||||||
|
|
||||||
const this0 = {},
|
const this0 = {};
|
||||||
this1 = {};
|
const this1 = {};
|
||||||
callTracker.track({ object: this0, args: [] });
|
callTracker.track({ object: this0, args: [] });
|
||||||
callTracker.track({ object: this1, args: [] });
|
callTracker.track({ object: this1, args: [] });
|
||||||
callTracker.track({ args: [] });
|
callTracker.track({ args: [] });
|
||||||
@@ -120,8 +120,8 @@ describe('CallTracker', function() {
|
|||||||
const callTracker = new privateUnderTest.CallTracker();
|
const callTracker = new privateUnderTest.CallTracker();
|
||||||
callTracker.saveArgumentsByValue();
|
callTracker.saveArgumentsByValue();
|
||||||
|
|
||||||
const objectArg = { foo: 'bar' },
|
const objectArg = { foo: 'bar' };
|
||||||
arrayArg = ['foo', 'bar'];
|
const arrayArg = ['foo', 'bar'];
|
||||||
|
|
||||||
callTracker.track({
|
callTracker.track({
|
||||||
object: {},
|
object: {},
|
||||||
@@ -138,8 +138,8 @@ describe('CallTracker', function() {
|
|||||||
const callTracker = new privateUnderTest.CallTracker();
|
const callTracker = new privateUnderTest.CallTracker();
|
||||||
callTracker.saveArgumentsByValue(args => JSON.parse(JSON.stringify(args)));
|
callTracker.saveArgumentsByValue(args => JSON.parse(JSON.stringify(args)));
|
||||||
|
|
||||||
const objectArg = { foo: { bar: { baz: ['qux'] } } },
|
const objectArg = { foo: { bar: { baz: ['qux'] } } };
|
||||||
arrayArg = ['foo', 'bar'];
|
const arrayArg = ['foo', 'bar'];
|
||||||
|
|
||||||
callTracker.track({
|
callTracker.track({
|
||||||
object: {},
|
object: {},
|
||||||
@@ -161,9 +161,9 @@ describe('CallTracker', function() {
|
|||||||
const callTracker = new privateUnderTest.CallTracker();
|
const callTracker = new privateUnderTest.CallTracker();
|
||||||
callTracker.saveArgumentsByValue(JSON.stringify);
|
callTracker.saveArgumentsByValue(JSON.stringify);
|
||||||
|
|
||||||
const objectArg = { foo: { bar: { baz: ['qux'] } } },
|
const objectArg = { foo: { bar: { baz: ['qux'] } } };
|
||||||
arrayArg = ['foo', 'bar'],
|
const arrayArg = ['foo', 'bar'];
|
||||||
args = [objectArg, arrayArg, false, undefined, null, NaN, '', 0, 1.0];
|
const args = [objectArg, arrayArg, false, undefined, null, NaN, '', 0, 1.0];
|
||||||
|
|
||||||
callTracker.track({ object: {}, args });
|
callTracker.track({ object: {}, args });
|
||||||
|
|
||||||
@@ -171,8 +171,8 @@ describe('CallTracker', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('saves primitive arguments by value', function() {
|
it('saves primitive arguments by value', function() {
|
||||||
const callTracker = new privateUnderTest.CallTracker(),
|
const callTracker = new privateUnderTest.CallTracker();
|
||||||
args = [undefined, null, false, '', /\s/, 0, 1.2, NaN];
|
const args = [undefined, null, false, '', /\s/, 0, 1.2, NaN];
|
||||||
|
|
||||||
callTracker.saveArgumentsByValue();
|
callTracker.saveArgumentsByValue();
|
||||||
callTracker.track({ object: {}, args: args });
|
callTracker.track({ object: {}, args: args });
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -2,8 +2,8 @@ describe('DelayedFunctionScheduler', function() {
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
it('schedules a function for later execution', function() {
|
it('schedules a function for later execution', function() {
|
||||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||||
fn = jasmine.createSpy('fn');
|
const fn = jasmine.createSpy('fn');
|
||||||
|
|
||||||
scheduler.scheduleFunction(fn, 0);
|
scheduler.scheduleFunction(fn, 0);
|
||||||
|
|
||||||
@@ -25,8 +25,8 @@ describe('DelayedFunctionScheduler', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('#tick defaults to 0', function() {
|
it('#tick defaults to 0', function() {
|
||||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||||
fn = jasmine.createSpy('fn');
|
const fn = jasmine.createSpy('fn');
|
||||||
|
|
||||||
scheduler.scheduleFunction(fn, 0);
|
scheduler.scheduleFunction(fn, 0);
|
||||||
|
|
||||||
@@ -38,8 +38,8 @@ describe('DelayedFunctionScheduler', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('defaults delay to 0', function() {
|
it('defaults delay to 0', function() {
|
||||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||||
fn = jasmine.createSpy('fn');
|
const fn = jasmine.createSpy('fn');
|
||||||
|
|
||||||
scheduler.scheduleFunction(fn);
|
scheduler.scheduleFunction(fn);
|
||||||
|
|
||||||
@@ -51,8 +51,8 @@ describe('DelayedFunctionScheduler', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('optionally passes params to scheduled functions', function() {
|
it('optionally passes params to scheduled functions', function() {
|
||||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||||
fn = jasmine.createSpy('fn');
|
const fn = jasmine.createSpy('fn');
|
||||||
|
|
||||||
scheduler.scheduleFunction(fn, 0, ['foo', 'bar']);
|
scheduler.scheduleFunction(fn, 0, ['foo', 'bar']);
|
||||||
|
|
||||||
@@ -64,8 +64,8 @@ describe('DelayedFunctionScheduler', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('scheduled fns can optionally reoccur', function() {
|
it('scheduled fns can optionally reoccur', function() {
|
||||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||||
fn = jasmine.createSpy('fn');
|
const fn = jasmine.createSpy('fn');
|
||||||
|
|
||||||
scheduler.scheduleFunction(fn, 20, [], true);
|
scheduler.scheduleFunction(fn, 20, [], true);
|
||||||
|
|
||||||
@@ -97,9 +97,9 @@ describe('DelayedFunctionScheduler', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('#removeFunctionWithId removes a previously scheduled function with a given id', function() {
|
it('#removeFunctionWithId removes a previously scheduled function with a given id', function() {
|
||||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||||
fn = jasmine.createSpy('fn'),
|
const fn = jasmine.createSpy('fn');
|
||||||
timeoutKey = scheduler.scheduleFunction(fn, 0);
|
const timeoutKey = scheduler.scheduleFunction(fn, 0);
|
||||||
|
|
||||||
expect(fn).not.toHaveBeenCalled();
|
expect(fn).not.toHaveBeenCalled();
|
||||||
|
|
||||||
@@ -132,9 +132,9 @@ describe('DelayedFunctionScheduler', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('schedules a function for later execution during a tick', function() {
|
it('schedules a function for later execution during a tick', function() {
|
||||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||||
fn = jasmine.createSpy('fn'),
|
const fn = jasmine.createSpy('fn');
|
||||||
fnDelay = 10;
|
const fnDelay = 10;
|
||||||
|
|
||||||
scheduler.scheduleFunction(function() {
|
scheduler.scheduleFunction(function() {
|
||||||
scheduler.scheduleFunction(fn, fnDelay);
|
scheduler.scheduleFunction(fn, fnDelay);
|
||||||
@@ -148,9 +148,9 @@ describe('DelayedFunctionScheduler', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('#removeFunctionWithId removes a previously scheduled function with a given id during a tick', function() {
|
it('#removeFunctionWithId removes a previously scheduled function with a given id during a tick', function() {
|
||||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||||
fn = jasmine.createSpy('fn'),
|
const fn = jasmine.createSpy('fn');
|
||||||
fnDelay = 10;
|
const fnDelay = 10;
|
||||||
let timeoutKey;
|
let timeoutKey;
|
||||||
|
|
||||||
scheduler.scheduleFunction(function() {
|
scheduler.scheduleFunction(function() {
|
||||||
@@ -199,10 +199,10 @@ describe('DelayedFunctionScheduler', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('executes recurring functions after rescheduling them', function() {
|
it('executes recurring functions after rescheduling them', function() {
|
||||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||||
recurring = function() {
|
const recurring = function() {
|
||||||
expect(scheduler.scheduleFunction).toHaveBeenCalled();
|
expect(scheduler.scheduleFunction).toHaveBeenCalled();
|
||||||
};
|
};
|
||||||
|
|
||||||
scheduler.scheduleFunction(recurring, 10, [], true);
|
scheduler.scheduleFunction(recurring, 10, [], true);
|
||||||
|
|
||||||
@@ -212,10 +212,10 @@ describe('DelayedFunctionScheduler', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('removes functions during a tick that runs the function', function() {
|
it('removes functions during a tick that runs the function', function() {
|
||||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||||
spy = jasmine.createSpy('fn'),
|
const spy = jasmine.createSpy('fn');
|
||||||
spyAndRemove = jasmine.createSpy('fn'),
|
const spyAndRemove = jasmine.createSpy('fn');
|
||||||
fnDelay = 10;
|
const fnDelay = 10;
|
||||||
let timeoutKey;
|
let timeoutKey;
|
||||||
|
|
||||||
spyAndRemove.and.callFake(function() {
|
spyAndRemove.and.callFake(function() {
|
||||||
@@ -233,9 +233,9 @@ describe('DelayedFunctionScheduler', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('removes functions during the first tick that runs the function', function() {
|
it('removes functions during the first tick that runs the function', function() {
|
||||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||||
fn = jasmine.createSpy('fn'),
|
const fn = jasmine.createSpy('fn');
|
||||||
fnDelay = 10;
|
const fnDelay = 10;
|
||||||
let timeoutKey;
|
let timeoutKey;
|
||||||
|
|
||||||
timeoutKey = scheduler.scheduleFunction(fn, fnDelay, [], true);
|
timeoutKey = scheduler.scheduleFunction(fn, fnDelay, [], true);
|
||||||
@@ -252,9 +252,9 @@ describe('DelayedFunctionScheduler', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does not remove a function that hasn't been added yet", function() {
|
it("does not remove a function that hasn't been added yet", function() {
|
||||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||||
fn = jasmine.createSpy('fn'),
|
const fn = jasmine.createSpy('fn');
|
||||||
fnDelay = 10;
|
const fnDelay = 10;
|
||||||
|
|
||||||
scheduler.removeFunctionWithId('foo');
|
scheduler.removeFunctionWithId('foo');
|
||||||
scheduler.scheduleFunction(fn, fnDelay, [], false, 'foo');
|
scheduler.scheduleFunction(fn, fnDelay, [], false, 'foo');
|
||||||
@@ -303,8 +303,8 @@ describe('DelayedFunctionScheduler', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('updates the mockDate per scheduled time', function() {
|
it('updates the mockDate per scheduled time', function() {
|
||||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||||
tickDate = jasmine.createSpy('tickDate');
|
const tickDate = jasmine.createSpy('tickDate');
|
||||||
|
|
||||||
scheduler.scheduleFunction(function() {});
|
scheduler.scheduleFunction(function() {});
|
||||||
scheduler.scheduleFunction(function() {}, 1);
|
scheduler.scheduleFunction(function() {}, 1);
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ describe('ExceptionFormatter', function() {
|
|||||||
describe('#message', function() {
|
describe('#message', function() {
|
||||||
it('formats Firefox exception messages', function() {
|
it('formats Firefox exception messages', function() {
|
||||||
const sampleFirefoxException = {
|
const sampleFirefoxException = {
|
||||||
fileName: 'foo.js',
|
fileName: 'foo.js',
|
||||||
lineNumber: '1978',
|
lineNumber: '1978',
|
||||||
message: 'you got your foo in my bar',
|
message: 'you got your foo in my bar',
|
||||||
name: 'A Classic Mistake'
|
name: 'A Classic Mistake'
|
||||||
},
|
};
|
||||||
exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
const exceptionFormatter = new privateUnderTest.ExceptionFormatter();
|
||||||
message = exceptionFormatter.message(sampleFirefoxException);
|
const message = exceptionFormatter.message(sampleFirefoxException);
|
||||||
|
|
||||||
expect(message).toEqual(
|
expect(message).toEqual(
|
||||||
'A Classic Mistake: you got your foo in my bar in foo.js (line 1978)'
|
'A Classic Mistake: you got your foo in my bar in foo.js (line 1978)'
|
||||||
@@ -17,13 +17,13 @@ describe('ExceptionFormatter', function() {
|
|||||||
|
|
||||||
it('formats Webkit exception messages', function() {
|
it('formats Webkit exception messages', function() {
|
||||||
const sampleWebkitException = {
|
const sampleWebkitException = {
|
||||||
sourceURL: 'foo.js',
|
sourceURL: 'foo.js',
|
||||||
line: '1978',
|
line: '1978',
|
||||||
message: 'you got your foo in my bar',
|
message: 'you got your foo in my bar',
|
||||||
name: 'A Classic Mistake'
|
name: 'A Classic Mistake'
|
||||||
},
|
};
|
||||||
exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
const exceptionFormatter = new privateUnderTest.ExceptionFormatter();
|
||||||
message = exceptionFormatter.message(sampleWebkitException);
|
const message = exceptionFormatter.message(sampleWebkitException);
|
||||||
|
|
||||||
expect(message).toEqual(
|
expect(message).toEqual(
|
||||||
'A Classic Mistake: you got your foo in my bar in foo.js (line 1978)'
|
'A Classic Mistake: you got your foo in my bar in foo.js (line 1978)'
|
||||||
@@ -32,11 +32,11 @@ describe('ExceptionFormatter', function() {
|
|||||||
|
|
||||||
it('formats V8 exception messages', function() {
|
it('formats V8 exception messages', function() {
|
||||||
const sampleV8 = {
|
const sampleV8 = {
|
||||||
message: 'you got your foo in my bar',
|
message: 'you got your foo in my bar',
|
||||||
name: 'A Classic Mistake'
|
name: 'A Classic Mistake'
|
||||||
},
|
};
|
||||||
exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
const exceptionFormatter = new privateUnderTest.ExceptionFormatter();
|
||||||
message = exceptionFormatter.message(sampleV8);
|
const message = exceptionFormatter.message(sampleV8);
|
||||||
|
|
||||||
expect(message).toEqual('A Classic Mistake: you got your foo in my bar');
|
expect(message).toEqual('A Classic Mistake: you got your foo in my bar');
|
||||||
});
|
});
|
||||||
@@ -44,8 +44,8 @@ describe('ExceptionFormatter', function() {
|
|||||||
it('formats unnamed exceptions with message', function() {
|
it('formats unnamed exceptions with message', function() {
|
||||||
const unnamedError = { message: 'This is an unnamed error message.' };
|
const unnamedError = { message: 'This is an unnamed error message.' };
|
||||||
|
|
||||||
const exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
const exceptionFormatter = new privateUnderTest.ExceptionFormatter();
|
||||||
message = exceptionFormatter.message(unnamedError);
|
const message = exceptionFormatter.message(unnamedError);
|
||||||
|
|
||||||
expect(message).toEqual('This is an unnamed error message.');
|
expect(message).toEqual('This is an unnamed error message.');
|
||||||
});
|
});
|
||||||
@@ -57,16 +57,16 @@ describe('ExceptionFormatter', function() {
|
|||||||
};
|
};
|
||||||
const emptyError = new EmptyError();
|
const emptyError = new EmptyError();
|
||||||
|
|
||||||
const exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
const exceptionFormatter = new privateUnderTest.ExceptionFormatter();
|
||||||
message = exceptionFormatter.message(emptyError);
|
const message = exceptionFormatter.message(emptyError);
|
||||||
|
|
||||||
expect(message).toEqual('[EmptyError] thrown');
|
expect(message).toEqual('[EmptyError] thrown');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("formats thrown exceptions that aren't errors", function() {
|
it("formats thrown exceptions that aren't errors", function() {
|
||||||
const thrown = 'crazy error',
|
const thrown = 'crazy error';
|
||||||
exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
const exceptionFormatter = new privateUnderTest.ExceptionFormatter();
|
||||||
message = exceptionFormatter.message(thrown);
|
const message = exceptionFormatter.message(thrown);
|
||||||
|
|
||||||
expect(message).toEqual('crazy error thrown');
|
expect(message).toEqual('crazy error thrown');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
describe('ExpectationFilterChain', function() {
|
describe('ExpectationFilterChain', function() {
|
||||||
describe('#addFilter', function() {
|
describe('#addFilter', function() {
|
||||||
it('returns a new filter chain with the added filter', function() {
|
it('returns a new filter chain with the added filter', function() {
|
||||||
const first = jasmine.createSpy('first'),
|
const first = jasmine.createSpy('first');
|
||||||
second = jasmine.createSpy('second'),
|
const second = jasmine.createSpy('second');
|
||||||
orig = new privateUnderTest.ExpectationFilterChain({
|
const orig = new privateUnderTest.ExpectationFilterChain({
|
||||||
modifyFailureMessage: first
|
modifyFailureMessage: first
|
||||||
}),
|
});
|
||||||
added = orig.addFilter({ selectComparisonFunc: second });
|
const added = orig.addFilter({ selectComparisonFunc: second });
|
||||||
|
|
||||||
added.modifyFailureMessage();
|
added.modifyFailureMessage();
|
||||||
expect(first).toHaveBeenCalled();
|
expect(first).toHaveBeenCalled();
|
||||||
@@ -15,8 +15,8 @@ describe('ExpectationFilterChain', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('does not modify the original filter chain', function() {
|
it('does not modify the original filter chain', function() {
|
||||||
const orig = new privateUnderTest.ExpectationFilterChain({}),
|
const orig = new privateUnderTest.ExpectationFilterChain({});
|
||||||
f = jasmine.createSpy('f');
|
const f = jasmine.createSpy('f');
|
||||||
|
|
||||||
orig.addFilter({ selectComparisonFunc: f });
|
orig.addFilter({ selectComparisonFunc: f });
|
||||||
|
|
||||||
@@ -36,13 +36,13 @@ describe('ExpectationFilterChain', function() {
|
|||||||
|
|
||||||
describe('When some filters have #selectComparisonFunc', function() {
|
describe('When some filters have #selectComparisonFunc', function() {
|
||||||
it('calls the first filter that has #selectComparisonFunc', function() {
|
it('calls the first filter that has #selectComparisonFunc', function() {
|
||||||
const first = jasmine.createSpy('first').and.returnValue('first'),
|
const first = jasmine.createSpy('first').and.returnValue('first');
|
||||||
second = jasmine.createSpy('second').and.returnValue('second'),
|
const second = jasmine.createSpy('second').and.returnValue('second');
|
||||||
chain = new privateUnderTest.ExpectationFilterChain()
|
const chain = new privateUnderTest.ExpectationFilterChain()
|
||||||
.addFilter({ selectComparisonFunc: first })
|
.addFilter({ selectComparisonFunc: first })
|
||||||
.addFilter({ selectComparisonFunc: second }),
|
.addFilter({ selectComparisonFunc: second });
|
||||||
matcher = {},
|
const matcher = {};
|
||||||
result = chain.selectComparisonFunc(matcher);
|
const result = chain.selectComparisonFunc(matcher);
|
||||||
|
|
||||||
expect(first).toHaveBeenCalledWith(matcher);
|
expect(first).toHaveBeenCalledWith(matcher);
|
||||||
expect(second).not.toHaveBeenCalled();
|
expect(second).not.toHaveBeenCalled();
|
||||||
@@ -62,15 +62,15 @@ describe('ExpectationFilterChain', function() {
|
|||||||
|
|
||||||
describe('When some filters have #buildFailureMessage', function() {
|
describe('When some filters have #buildFailureMessage', function() {
|
||||||
it('calls the first filter that has #buildFailureMessage', function() {
|
it('calls the first filter that has #buildFailureMessage', function() {
|
||||||
const first = jasmine.createSpy('first').and.returnValue('first'),
|
const first = jasmine.createSpy('first').and.returnValue('first');
|
||||||
second = jasmine.createSpy('second').and.returnValue('second'),
|
const second = jasmine.createSpy('second').and.returnValue('second');
|
||||||
chain = new privateUnderTest.ExpectationFilterChain()
|
const chain = new privateUnderTest.ExpectationFilterChain()
|
||||||
.addFilter({ buildFailureMessage: first })
|
.addFilter({ buildFailureMessage: first })
|
||||||
.addFilter({ buildFailureMessage: second }),
|
.addFilter({ buildFailureMessage: second });
|
||||||
matcherResult = { pass: false },
|
const matcherResult = { pass: false };
|
||||||
matcherName = 'foo',
|
const matcherName = 'foo';
|
||||||
args = [],
|
const args = [];
|
||||||
matchersUtil = {};
|
const matchersUtil = {};
|
||||||
|
|
||||||
const result = chain.buildFailureMessage(
|
const result = chain.buildFailureMessage(
|
||||||
matcherResult,
|
matcherResult,
|
||||||
@@ -102,12 +102,12 @@ describe('ExpectationFilterChain', function() {
|
|||||||
|
|
||||||
describe('When some filters have #modifyFailureMessage', function() {
|
describe('When some filters have #modifyFailureMessage', function() {
|
||||||
it('calls the first filter that has #modifyFailureMessage', function() {
|
it('calls the first filter that has #modifyFailureMessage', function() {
|
||||||
const first = jasmine.createSpy('first').and.returnValue('first'),
|
const first = jasmine.createSpy('first').and.returnValue('first');
|
||||||
second = jasmine.createSpy('second').and.returnValue('second'),
|
const second = jasmine.createSpy('second').and.returnValue('second');
|
||||||
chain = new privateUnderTest.ExpectationFilterChain()
|
const chain = new privateUnderTest.ExpectationFilterChain()
|
||||||
.addFilter({ modifyFailureMessage: first })
|
.addFilter({ modifyFailureMessage: first })
|
||||||
.addFilter({ modifyFailureMessage: second }),
|
.addFilter({ modifyFailureMessage: second });
|
||||||
result = chain.modifyFailureMessage('original');
|
const result = chain.modifyFailureMessage('original');
|
||||||
|
|
||||||
expect(first).toHaveBeenCalledWith('original');
|
expect(first).toHaveBeenCalledWith('original');
|
||||||
expect(second).not.toHaveBeenCalled();
|
expect(second).not.toHaveBeenCalled();
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
describe('Expectation', function() {
|
describe('Expectation', function() {
|
||||||
it('makes custom matchers available to this expectation', function() {
|
it('makes custom matchers available to this expectation', function() {
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {},
|
toFoo: function() {},
|
||||||
toBar: function() {}
|
toBar: function() {}
|
||||||
},
|
};
|
||||||
expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers
|
customMatchers: matchers
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(expectation.toFoo).toBeDefined();
|
expect(expectation.toFoo).toBeDefined();
|
||||||
expect(expectation.toBar).toBeDefined();
|
expect(expectation.toBar).toBeDefined();
|
||||||
@@ -26,18 +26,18 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
it("wraps matchers's compare functions, passing in matcher dependencies", function() {
|
it("wraps matchers's compare functions, passing in matcher dependencies", function() {
|
||||||
const fakeCompare = function() {
|
const fakeCompare = function() {
|
||||||
return { pass: true };
|
return { pass: true };
|
||||||
},
|
};
|
||||||
matcherFactory = jasmine
|
const matcherFactory = jasmine
|
||||||
.createSpy('matcher')
|
.createSpy('matcher')
|
||||||
.and.returnValue({ compare: fakeCompare }),
|
.and.returnValue({ compare: fakeCompare });
|
||||||
matchers = {
|
const matchers = {
|
||||||
toFoo: matcherFactory
|
toFoo: matcherFactory
|
||||||
},
|
};
|
||||||
matchersUtil = {
|
const matchersUtil = {
|
||||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
|
|
||||||
const expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
matchersUtil: matchersUtil,
|
matchersUtil: matchersUtil,
|
||||||
@@ -53,19 +53,19 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
it("wraps matchers's compare functions, passing the actual and expected", function() {
|
it("wraps matchers's compare functions, passing the actual and expected", function() {
|
||||||
const fakeCompare = jasmine
|
const fakeCompare = jasmine
|
||||||
.createSpy('fake-compare')
|
.createSpy('fake-compare')
|
||||||
.and.returnValue({ pass: true }),
|
.and.returnValue({ pass: true });
|
||||||
matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: fakeCompare
|
compare: fakeCompare
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
matchersUtil = {
|
const matchersUtil = {
|
||||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
|
|
||||||
const expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
matchersUtil: matchersUtil,
|
matchersUtil: matchersUtil,
|
||||||
@@ -81,18 +81,18 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
it('reports a passing result to the spec when the comparison passes', function() {
|
it('reports a passing result to the spec when the comparison passes', function() {
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return { pass: true };
|
return { pass: true };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
matchersUtil = {
|
const matchersUtil = {
|
||||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
|
|
||||||
const expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
@@ -114,20 +114,20 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
it('reports a failing result to the spec when the comparison fails', function() {
|
it('reports a failing result to the spec when the comparison fails', function() {
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return { pass: false };
|
return { pass: false };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
matchersUtil = {
|
const matchersUtil = {
|
||||||
buildFailureMessage: function() {
|
buildFailureMessage: function() {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
|
|
||||||
const expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
@@ -149,18 +149,18 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
it('reports a failing result and a custom fail message to the spec when the comparison fails', function() {
|
it('reports a failing result and a custom fail message to the spec when the comparison fails', function() {
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return {
|
return {
|
||||||
pass: false,
|
pass: false,
|
||||||
message: 'I am a custom message'
|
message: 'I am a custom message'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
|
|
||||||
const expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
@@ -181,20 +181,20 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
it('reports a failing result with a custom fail message function to the spec when the comparison fails', function() {
|
it('reports a failing result with a custom fail message function to the spec when the comparison fails', function() {
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return {
|
return {
|
||||||
pass: false,
|
pass: false,
|
||||||
message: function() {
|
message: function() {
|
||||||
return 'I am a custom message';
|
return 'I am a custom message';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
|
|
||||||
const expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
@@ -215,15 +215,15 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
it('reports a passing result to the spec when the comparison fails for a negative expectation', function() {
|
it('reports a passing result to the spec when the comparison fails for a negative expectation', function() {
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return { pass: false };
|
return { pass: false };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
|
|
||||||
const expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
@@ -244,20 +244,20 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
it('reports a failing result to the spec when the comparison passes for a negative expectation', function() {
|
it('reports a failing result to the spec when the comparison passes for a negative expectation', function() {
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return { pass: true };
|
return { pass: true };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
matchersUtil = {
|
const matchersUtil = {
|
||||||
buildFailureMessage: function() {
|
buildFailureMessage: function() {
|
||||||
return 'default message';
|
return 'default message';
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
|
|
||||||
const expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
@@ -279,18 +279,18 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
it('reports a failing result and a custom fail message to the spec when the comparison passes for a negative expectation', function() {
|
it('reports a failing result and a custom fail message to the spec when the comparison passes for a negative expectation', function() {
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return {
|
return {
|
||||||
pass: true,
|
pass: true,
|
||||||
message: 'I am a custom message'
|
message: 'I am a custom message'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
|
|
||||||
const expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
@@ -311,18 +311,18 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
it("reports a passing result to the spec when the 'not' comparison passes, given a negativeCompare", function() {
|
it("reports a passing result to the spec when the 'not' comparison passes, given a negativeCompare", function() {
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return { pass: true };
|
return { pass: true };
|
||||||
},
|
},
|
||||||
negativeCompare: function() {
|
negativeCompare: function() {
|
||||||
return { pass: true };
|
return { pass: true };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
|
|
||||||
const expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
@@ -343,21 +343,21 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
it("reports a failing result and a custom fail message to the spec when the 'not' comparison fails, given a negativeCompare", function() {
|
it("reports a failing result and a custom fail message to the spec when the 'not' comparison fails, given a negativeCompare", function() {
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return { pass: true };
|
return { pass: true };
|
||||||
},
|
},
|
||||||
negativeCompare: function() {
|
negativeCompare: function() {
|
||||||
return {
|
return {
|
||||||
pass: false,
|
pass: false,
|
||||||
message: "I'm a custom message"
|
message: "I'm a custom message"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
|
|
||||||
const expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
@@ -379,19 +379,19 @@ describe('Expectation', function() {
|
|||||||
it('reports a custom error message to the spec', function() {
|
it('reports a custom error message to the spec', function() {
|
||||||
const customError = new Error('I am a custom error');
|
const customError = new Error('I am a custom error');
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return {
|
return {
|
||||||
pass: false,
|
pass: false,
|
||||||
message: 'I am a custom message',
|
message: 'I am a custom message',
|
||||||
error: customError
|
error: customError
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
|
|
||||||
const expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
@@ -413,19 +413,19 @@ describe('Expectation', function() {
|
|||||||
it("reports a custom message to the spec when a 'not' comparison fails", function() {
|
it("reports a custom message to the spec when a 'not' comparison fails", function() {
|
||||||
const customError = new Error('I am a custom error');
|
const customError = new Error('I am a custom error');
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return {
|
return {
|
||||||
pass: true,
|
pass: true,
|
||||||
message: 'I am a custom message',
|
message: 'I am a custom message',
|
||||||
error: customError
|
error: customError
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
|
|
||||||
const expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
@@ -447,21 +447,21 @@ describe('Expectation', function() {
|
|||||||
it("reports a custom message func to the spec when a 'not' comparison fails", function() {
|
it("reports a custom message func to the spec when a 'not' comparison fails", function() {
|
||||||
const customError = new Error('I am a custom error');
|
const customError = new Error('I am a custom error');
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return {
|
return {
|
||||||
pass: true,
|
pass: true,
|
||||||
message: function() {
|
message: function() {
|
||||||
return 'I am a custom message';
|
return 'I am a custom message';
|
||||||
},
|
},
|
||||||
error: customError
|
error: customError
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
|
|
||||||
const expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
@@ -483,26 +483,26 @@ describe('Expectation', function() {
|
|||||||
describe('#withContext', function() {
|
describe('#withContext', function() {
|
||||||
it('prepends the context to the generated failure message', function() {
|
it('prepends the context to the generated failure message', function() {
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return { pass: false };
|
return { pass: false };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
matchersUtil = {
|
const matchersUtil = {
|
||||||
buildFailureMessage: function() {
|
buildFailureMessage: function() {
|
||||||
return 'failure message';
|
return 'failure message';
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
matchersUtil: matchersUtil,
|
matchersUtil: matchersUtil,
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
|
|
||||||
expectation.withContext('Some context').toFoo('hello');
|
expectation.withContext('Some context').toFoo('hello');
|
||||||
|
|
||||||
@@ -516,20 +516,20 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
it('prepends the context to a custom failure message', function() {
|
it('prepends the context to a custom failure message', function() {
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return { pass: false, message: 'msg' };
|
return { pass: false, message: 'msg' };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
|
|
||||||
expectation.withContext('Some context').toFoo('hello');
|
expectation.withContext('Some context').toFoo('hello');
|
||||||
|
|
||||||
@@ -543,20 +543,20 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
it('indents a multiline failure message', function() {
|
it('indents a multiline failure message', function() {
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return { pass: false, message: 'a\nmultiline\nmessage' };
|
return { pass: false, message: 'a\nmultiline\nmessage' };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
|
|
||||||
expectation.withContext('Some context').toFoo('hello');
|
expectation.withContext('Some context').toFoo('hello');
|
||||||
|
|
||||||
@@ -568,25 +568,25 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
it('prepends the context to a custom failure message from a function', function() {
|
it('prepends the context to a custom failure message from a function', function() {
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return {
|
return {
|
||||||
pass: false,
|
pass: false,
|
||||||
message: function() {
|
message: function() {
|
||||||
return 'msg';
|
return 'msg';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
|
|
||||||
expectation.withContext('Some context').toFoo('hello');
|
expectation.withContext('Some context').toFoo('hello');
|
||||||
|
|
||||||
@@ -600,22 +600,22 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
it('works with #not', function() {
|
it('works with #not', function() {
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return { pass: true };
|
return { pass: true };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
pp = privateUnderTest.makePrettyPrinter(),
|
const pp = privateUnderTest.makePrettyPrinter();
|
||||||
expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp }),
|
matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
|
|
||||||
expectation.withContext('Some context').not.toFoo();
|
expectation.withContext('Some context').not.toFoo();
|
||||||
|
|
||||||
@@ -630,26 +630,26 @@ describe('Expectation', function() {
|
|||||||
it('works with #not and a custom message', function() {
|
it('works with #not and a custom message', function() {
|
||||||
const customError = new Error('I am a custom error');
|
const customError = new Error('I am a custom error');
|
||||||
const matchers = {
|
const matchers = {
|
||||||
toFoo: function() {
|
toFoo: function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return {
|
return {
|
||||||
pass: true,
|
pass: true,
|
||||||
message: function() {
|
message: function() {
|
||||||
return 'I am a custom message';
|
return 'I am a custom message';
|
||||||
},
|
},
|
||||||
error: customError
|
error: customError
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
expectation = privateUnderTest.Expectation.factory({
|
const expectation = privateUnderTest.Expectation.factory({
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
|
|
||||||
expectation.withContext('Some context').not.toFoo('hello');
|
expectation.withContext('Some context').not.toFoo('hello');
|
||||||
|
|
||||||
|
|||||||
@@ -137,20 +137,20 @@ describe('JsApiReporter', function() {
|
|||||||
|
|
||||||
describe('#executionTime', function() {
|
describe('#executionTime', function() {
|
||||||
it('should start the timer when jasmine starts', function() {
|
it('should start the timer when jasmine starts', function() {
|
||||||
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']);
|
||||||
reporter = new privateUnderTest.JsApiReporter({
|
const reporter = new privateUnderTest.JsApiReporter({
|
||||||
timer: timerSpy
|
timer: timerSpy
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.jasmineStarted();
|
reporter.jasmineStarted();
|
||||||
expect(timerSpy.start).toHaveBeenCalled();
|
expect(timerSpy.start).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the time it took the specs to run, in ms', function() {
|
it('should return the time it took the specs to run, in ms', function() {
|
||||||
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']);
|
||||||
reporter = new privateUnderTest.JsApiReporter({
|
const reporter = new privateUnderTest.JsApiReporter({
|
||||||
timer: timerSpy
|
timer: timerSpy
|
||||||
});
|
});
|
||||||
|
|
||||||
timerSpy.elapsed.and.returnValue(1000);
|
timerSpy.elapsed.and.returnValue(1000);
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone();
|
||||||
@@ -159,10 +159,10 @@ describe('JsApiReporter', function() {
|
|||||||
|
|
||||||
describe("when the specs haven't finished being run", function() {
|
describe("when the specs haven't finished being run", function() {
|
||||||
it('should return undefined', function() {
|
it('should return undefined', function() {
|
||||||
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']);
|
||||||
reporter = new privateUnderTest.JsApiReporter({
|
const reporter = new privateUnderTest.JsApiReporter({
|
||||||
timer: timerSpy
|
timer: timerSpy
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(reporter.executionTime()).toBeUndefined();
|
expect(reporter.executionTime()).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
describe('FakeDate', function() {
|
describe('FakeDate', function() {
|
||||||
it('does not fail if no global date is found', function() {
|
it('does not fail if no global date is found', function() {
|
||||||
const fakeGlobal = {},
|
const fakeGlobal = {};
|
||||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
@@ -12,14 +12,14 @@ describe('FakeDate', function() {
|
|||||||
|
|
||||||
it('replaces the global Date when it is installed', function() {
|
it('replaces the global Date when it is installed', function() {
|
||||||
const globalDate = jasmine
|
const globalDate = jasmine
|
||||||
.createSpy('global Date')
|
.createSpy('global Date')
|
||||||
.and.callFake(function() {
|
.and.callFake(function() {
|
||||||
return {
|
return {
|
||||||
getTime: function() {}
|
getTime: function() {}
|
||||||
};
|
};
|
||||||
}),
|
});
|
||||||
fakeGlobal = { Date: globalDate },
|
const fakeGlobal = { Date: globalDate };
|
||||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
expect(fakeGlobal.Date).toEqual(globalDate);
|
expect(fakeGlobal.Date).toEqual(globalDate);
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
@@ -29,14 +29,14 @@ describe('FakeDate', function() {
|
|||||||
|
|
||||||
it('replaces the global Date on uninstall', function() {
|
it('replaces the global Date on uninstall', function() {
|
||||||
const globalDate = jasmine
|
const globalDate = jasmine
|
||||||
.createSpy('global Date')
|
.createSpy('global Date')
|
||||||
.and.callFake(function() {
|
.and.callFake(function() {
|
||||||
return {
|
return {
|
||||||
getTime: function() {}
|
getTime: function() {}
|
||||||
};
|
};
|
||||||
}),
|
});
|
||||||
fakeGlobal = { Date: globalDate },
|
const fakeGlobal = { Date: globalDate };
|
||||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
mockDate.uninstall();
|
mockDate.uninstall();
|
||||||
@@ -46,16 +46,16 @@ describe('FakeDate', function() {
|
|||||||
|
|
||||||
it('takes the current time as the base when installing without parameters', function() {
|
it('takes the current time as the base when installing without parameters', function() {
|
||||||
const globalDate = jasmine
|
const globalDate = jasmine
|
||||||
.createSpy('global Date')
|
.createSpy('global Date')
|
||||||
.and.callFake(function() {
|
.and.callFake(function() {
|
||||||
return {
|
return {
|
||||||
getTime: function() {
|
getTime: function() {
|
||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}),
|
});
|
||||||
fakeGlobal = { Date: globalDate },
|
const fakeGlobal = { Date: globalDate };
|
||||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
|
|
||||||
@@ -65,9 +65,9 @@ describe('FakeDate', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can accept a date as time base when installing', function() {
|
it('can accept a date as time base when installing', function() {
|
||||||
const fakeGlobal = { Date: Date },
|
const fakeGlobal = { Date: Date };
|
||||||
mockDate = new privateUnderTest.MockDate(fakeGlobal),
|
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||||
baseDate = new Date();
|
const baseDate = new Date();
|
||||||
|
|
||||||
spyOn(baseDate, 'getTime').and.returnValue(123);
|
spyOn(baseDate, 'getTime').and.returnValue(123);
|
||||||
mockDate.install(baseDate);
|
mockDate.install(baseDate);
|
||||||
@@ -76,8 +76,8 @@ describe('FakeDate', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('makes real dates', function() {
|
it('makes real dates', function() {
|
||||||
const fakeGlobal = { Date: Date },
|
const fakeGlobal = { Date: Date };
|
||||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
expect(new fakeGlobal.Date()).toEqual(jasmine.any(Date));
|
expect(new fakeGlobal.Date()).toEqual(jasmine.any(Date));
|
||||||
@@ -86,15 +86,15 @@ describe('FakeDate', function() {
|
|||||||
|
|
||||||
it('fakes current time when using Date.now()', function() {
|
it('fakes current time when using Date.now()', function() {
|
||||||
const globalDate = jasmine
|
const globalDate = jasmine
|
||||||
.createSpy('global Date')
|
.createSpy('global Date')
|
||||||
.and.callFake(function() {
|
.and.callFake(function() {
|
||||||
return {
|
return {
|
||||||
getTime: function() {
|
getTime: function() {
|
||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}),
|
});
|
||||||
fakeGlobal = { Date: globalDate };
|
const fakeGlobal = { Date: globalDate };
|
||||||
|
|
||||||
globalDate.now = function() {};
|
globalDate.now = function() {};
|
||||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||||
@@ -106,15 +106,15 @@ describe('FakeDate', function() {
|
|||||||
|
|
||||||
it('makes time passes using tick', function() {
|
it('makes time passes using tick', function() {
|
||||||
const globalDate = jasmine
|
const globalDate = jasmine
|
||||||
.createSpy('global Date')
|
.createSpy('global Date')
|
||||||
.and.callFake(function() {
|
.and.callFake(function() {
|
||||||
return {
|
return {
|
||||||
getTime: function() {
|
getTime: function() {
|
||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}),
|
});
|
||||||
fakeGlobal = { Date: globalDate };
|
const fakeGlobal = { Date: globalDate };
|
||||||
|
|
||||||
globalDate.now = function() {};
|
globalDate.now = function() {};
|
||||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||||
@@ -132,15 +132,15 @@ describe('FakeDate', function() {
|
|||||||
|
|
||||||
it('allows to increase 0 milliseconds using tick', function() {
|
it('allows to increase 0 milliseconds using tick', function() {
|
||||||
const globalDate = jasmine
|
const globalDate = jasmine
|
||||||
.createSpy('global Date')
|
.createSpy('global Date')
|
||||||
.and.callFake(function() {
|
.and.callFake(function() {
|
||||||
return {
|
return {
|
||||||
getTime: function() {
|
getTime: function() {
|
||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}),
|
});
|
||||||
fakeGlobal = { Date: globalDate };
|
const fakeGlobal = { Date: globalDate };
|
||||||
|
|
||||||
globalDate.now = function() {};
|
globalDate.now = function() {};
|
||||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||||
@@ -155,8 +155,8 @@ describe('FakeDate', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows creation of a Date in a different time than the mocked time', function() {
|
it('allows creation of a Date in a different time than the mocked time', function() {
|
||||||
const fakeGlobal = { Date: Date },
|
const fakeGlobal = { Date: Date };
|
||||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
|
|
||||||
@@ -167,8 +167,8 @@ describe('FakeDate', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("allows creation of a Date that isn't fully specified", function() {
|
it("allows creation of a Date that isn't fully specified", function() {
|
||||||
const fakeGlobal = { Date: Date },
|
const fakeGlobal = { Date: Date };
|
||||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
|
|
||||||
@@ -177,9 +177,9 @@ describe('FakeDate', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows creation of a Date with millis', function() {
|
it('allows creation of a Date with millis', function() {
|
||||||
const fakeGlobal = { Date: Date },
|
const fakeGlobal = { Date: Date };
|
||||||
mockDate = new privateUnderTest.MockDate(fakeGlobal),
|
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||||
now = new Date(2014, 3, 15).getTime();
|
const now = new Date(2014, 3, 15).getTime();
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
|
|
||||||
@@ -188,8 +188,8 @@ describe('FakeDate', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('copies all Date properties to the mocked date', function() {
|
it('copies all Date properties to the mocked date', function() {
|
||||||
const fakeGlobal = { Date: Date },
|
const fakeGlobal = { Date: Date };
|
||||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||||
|
|
||||||
mockDate.install();
|
mockDate.install();
|
||||||
|
|
||||||
|
|||||||
@@ -227,26 +227,26 @@ describe('PrettyPrinter', function() {
|
|||||||
|
|
||||||
it('should not serialize more objects after hitting MAX_PRETTY_PRINT_CHARS', function() {
|
it('should not serialize more objects after hitting MAX_PRETTY_PRINT_CHARS', function() {
|
||||||
const a = {
|
const a = {
|
||||||
jasmineToString: function() {
|
jasmineToString: function() {
|
||||||
return 'object a';
|
return 'object a';
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
b = {
|
const b = {
|
||||||
jasmineToString: function() {
|
jasmineToString: function() {
|
||||||
return 'object b';
|
return 'object b';
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
c = {
|
const c = {
|
||||||
jasmineToString: jasmine
|
jasmineToString: jasmine
|
||||||
.createSpy('c jasmineToString')
|
.createSpy('c jasmineToString')
|
||||||
.and.returnValue('')
|
.and.returnValue('')
|
||||||
},
|
};
|
||||||
d = {
|
const d = {
|
||||||
jasmineToString: jasmine
|
jasmineToString: jasmine
|
||||||
.createSpy('d jasmineToString')
|
.createSpy('d jasmineToString')
|
||||||
.and.returnValue('')
|
.and.returnValue('')
|
||||||
},
|
};
|
||||||
pp = privateUnderTest.makePrettyPrinter();
|
const pp = privateUnderTest.makePrettyPrinter();
|
||||||
|
|
||||||
withMaxChars(30, function() {
|
withMaxChars(30, function() {
|
||||||
pp([{ a: a, b: b, c: c }, d]);
|
pp([{ a: a, b: b, c: c }, d]);
|
||||||
@@ -388,10 +388,10 @@ describe('PrettyPrinter', function() {
|
|||||||
|
|
||||||
it('should stringify spyOn toString properly', function() {
|
it('should stringify spyOn toString properly', function() {
|
||||||
const TestObject = {
|
const TestObject = {
|
||||||
someFunction: function() {}
|
someFunction: function() {}
|
||||||
},
|
};
|
||||||
env = new privateUnderTest.Env(),
|
const env = new privateUnderTest.Env();
|
||||||
pp = privateUnderTest.makePrettyPrinter();
|
const pp = privateUnderTest.makePrettyPrinter();
|
||||||
|
|
||||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||||
currentSpies: function() {
|
currentSpies: function() {
|
||||||
@@ -535,30 +535,30 @@ describe('PrettyPrinter', function() {
|
|||||||
describe('Custom object formatters', function() {
|
describe('Custom object formatters', function() {
|
||||||
it('should use the first custom object formatter that does not return undefined', function() {
|
it('should use the first custom object formatter that does not return undefined', function() {
|
||||||
const customObjectFormatters = [
|
const customObjectFormatters = [
|
||||||
function() {
|
function() {
|
||||||
return undefined;
|
return undefined;
|
||||||
},
|
},
|
||||||
function(obj) {
|
function(obj) {
|
||||||
return '2nd: ' + obj.foo;
|
return '2nd: ' + obj.foo;
|
||||||
},
|
},
|
||||||
function(obj) {
|
function(obj) {
|
||||||
return '3rd: ' + obj.foo;
|
return '3rd: ' + obj.foo;
|
||||||
}
|
}
|
||||||
],
|
];
|
||||||
pp = privateUnderTest.makePrettyPrinter(customObjectFormatters),
|
const pp = privateUnderTest.makePrettyPrinter(customObjectFormatters);
|
||||||
obj = { foo: 'bar' };
|
const obj = { foo: 'bar' };
|
||||||
|
|
||||||
expect(pp(obj)).toEqual('2nd: bar');
|
expect(pp(obj)).toEqual('2nd: bar');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fall back to built in logic if all custom object formatters return undefined', function() {
|
it('should fall back to built in logic if all custom object formatters return undefined', function() {
|
||||||
const customObjectFormatters = [
|
const customObjectFormatters = [
|
||||||
function() {
|
function() {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
],
|
];
|
||||||
pp = privateUnderTest.makePrettyPrinter(customObjectFormatters),
|
const pp = privateUnderTest.makePrettyPrinter(customObjectFormatters);
|
||||||
obj = { foo: 'bar' };
|
const obj = { foo: 'bar' };
|
||||||
|
|
||||||
expect(pp(obj)).toEqual("Object({ foo: 'bar' })");
|
expect(pp(obj)).toEqual("Object({ foo: 'bar' })");
|
||||||
});
|
});
|
||||||
@@ -567,30 +567,30 @@ describe('PrettyPrinter', function() {
|
|||||||
describe('#customFormat_', function() {
|
describe('#customFormat_', function() {
|
||||||
it('should use the first custom object formatter that does not return undefined', function() {
|
it('should use the first custom object formatter that does not return undefined', function() {
|
||||||
const customObjectFormatters = [
|
const customObjectFormatters = [
|
||||||
function() {
|
function() {
|
||||||
return undefined;
|
return undefined;
|
||||||
},
|
},
|
||||||
function(obj) {
|
function(obj) {
|
||||||
return '2nd: ' + obj.foo;
|
return '2nd: ' + obj.foo;
|
||||||
},
|
},
|
||||||
function(obj) {
|
function(obj) {
|
||||||
return '3rd: ' + obj.foo;
|
return '3rd: ' + obj.foo;
|
||||||
}
|
}
|
||||||
],
|
];
|
||||||
pp = privateUnderTest.makePrettyPrinter(customObjectFormatters),
|
const pp = privateUnderTest.makePrettyPrinter(customObjectFormatters);
|
||||||
obj = { foo: 'bar' };
|
const obj = { foo: 'bar' };
|
||||||
|
|
||||||
expect(pp.customFormat_(obj)).toEqual('2nd: bar');
|
expect(pp.customFormat_(obj)).toEqual('2nd: bar');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return undefined if all custom object formatters return undefined', function() {
|
it('should return undefined if all custom object formatters return undefined', function() {
|
||||||
const customObjectFormatters = [
|
const customObjectFormatters = [
|
||||||
function() {
|
function() {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
],
|
];
|
||||||
pp = privateUnderTest.makePrettyPrinter(customObjectFormatters),
|
const pp = privateUnderTest.makePrettyPrinter(customObjectFormatters);
|
||||||
obj = { foo: 'bar' };
|
const obj = { foo: 'bar' };
|
||||||
|
|
||||||
expect(pp.customFormat_(obj)).toBeUndefined();
|
expect(pp.customFormat_(obj)).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ describe('QueueRunner', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("runs all the functions it's passed", function() {
|
it("runs all the functions it's passed", function() {
|
||||||
const calls = [],
|
const calls = [];
|
||||||
queueableFn1 = { fn: jasmine.createSpy('fn1') },
|
const queueableFn1 = { fn: jasmine.createSpy('fn1') };
|
||||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
const queueableFn2 = { fn: jasmine.createSpy('fn2') };
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn1, queueableFn2]
|
queueableFns: [queueableFn1, queueableFn2]
|
||||||
});
|
});
|
||||||
queueableFn1.fn.and.callFake(function() {
|
queueableFn1.fn.and.callFake(function() {
|
||||||
calls.push('fn1');
|
calls.push('fn1');
|
||||||
});
|
});
|
||||||
@@ -39,14 +39,14 @@ describe('QueueRunner', function() {
|
|||||||
const queueableFn2 = { fn: jasmine.createSpy('fn2') };
|
const queueableFn2 = { fn: jasmine.createSpy('fn2') };
|
||||||
let asyncContext;
|
let asyncContext;
|
||||||
const queueableFn3 = {
|
const queueableFn3 = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
asyncContext = this;
|
asyncContext = this;
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn1, queueableFn2, queueableFn3]
|
queueableFns: [queueableFn1, queueableFn2, queueableFn3]
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
|
|
||||||
@@ -69,32 +69,32 @@ describe('QueueRunner', function() {
|
|||||||
//TODO: it would be nice if spy arity could match the fake, so we could do something like:
|
//TODO: it would be nice if spy arity could match the fake, so we could do something like:
|
||||||
//createSpy('asyncfn').and.callFake(function(done) {});
|
//createSpy('asyncfn').and.callFake(function(done) {});
|
||||||
|
|
||||||
const onComplete = jasmine.createSpy('onComplete'),
|
const onComplete = jasmine.createSpy('onComplete');
|
||||||
beforeCallback = jasmine.createSpy('beforeCallback'),
|
const beforeCallback = jasmine.createSpy('beforeCallback');
|
||||||
fnCallback = jasmine.createSpy('fnCallback'),
|
const fnCallback = jasmine.createSpy('fnCallback');
|
||||||
afterCallback = jasmine.createSpy('afterCallback'),
|
const afterCallback = jasmine.createSpy('afterCallback');
|
||||||
queueableFn1 = {
|
const queueableFn1 = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
beforeCallback();
|
beforeCallback();
|
||||||
setTimeout(done, 100);
|
setTimeout(done, 100);
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
queueableFn2 = {
|
const queueableFn2 = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
fnCallback();
|
fnCallback();
|
||||||
setTimeout(done, 100);
|
setTimeout(done, 100);
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
queueableFn3 = {
|
const queueableFn3 = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
afterCallback();
|
afterCallback();
|
||||||
setTimeout(done, 100);
|
setTimeout(done, 100);
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn1, queueableFn2, queueableFn3],
|
queueableFns: [queueableFn1, queueableFn2, queueableFn3],
|
||||||
onComplete: onComplete
|
onComplete: onComplete
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
|
|
||||||
@@ -121,18 +121,18 @@ describe('QueueRunner', function() {
|
|||||||
|
|
||||||
it('explicitly fails an async function with a provided fail function and moves to the next function', function() {
|
it('explicitly fails an async function with a provided fail function and moves to the next function', function() {
|
||||||
const queueableFn1 = {
|
const queueableFn1 = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
done.fail('foo');
|
done.fail('foo');
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
const queueableFn2 = { fn: jasmine.createSpy('fn2') };
|
||||||
failFn = jasmine.createSpy('fail'),
|
const failFn = jasmine.createSpy('fail');
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn1, queueableFn2],
|
queueableFns: [queueableFn1, queueableFn2],
|
||||||
fail: failFn
|
fail: failFn
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
|
|
||||||
@@ -147,20 +147,20 @@ describe('QueueRunner', function() {
|
|||||||
|
|
||||||
describe('When next is called with an argument', function() {
|
describe('When next is called with an argument', function() {
|
||||||
it('explicitly fails and moves to the next function', function() {
|
it('explicitly fails and moves to the next function', function() {
|
||||||
const err = 'anything except undefined',
|
const err = 'anything except undefined';
|
||||||
queueableFn1 = {
|
const queueableFn1 = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
done(err);
|
done(err);
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
const queueableFn2 = { fn: jasmine.createSpy('fn2') };
|
||||||
failFn = jasmine.createSpy('fail'),
|
const failFn = jasmine.createSpy('fail');
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn1, queueableFn2],
|
queueableFns: [queueableFn1, queueableFn2],
|
||||||
fail: failFn
|
fail: failFn
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
|
|
||||||
@@ -181,23 +181,23 @@ describe('QueueRunner', function() {
|
|||||||
// except on a major release and with a deprecation warning in
|
// except on a major release and with a deprecation warning in
|
||||||
// advance.
|
// advance.
|
||||||
it('explicitly fails and moves to the next function', function(done) {
|
it('explicitly fails and moves to the next function', function(done) {
|
||||||
const err = new Error('foo'),
|
const err = new Error('foo');
|
||||||
queueableFn1 = {
|
const queueableFn1 = {
|
||||||
fn: function() {
|
fn: function() {
|
||||||
return Promise.resolve(err);
|
return Promise.resolve(err);
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
const queueableFn2 = { fn: jasmine.createSpy('fn2') };
|
||||||
failFn = jasmine.createSpy('fail'),
|
const failFn = jasmine.createSpy('fail');
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn1, queueableFn2],
|
queueableFns: [queueableFn1, queueableFn2],
|
||||||
fail: failFn,
|
fail: failFn,
|
||||||
onComplete: function() {
|
onComplete: function() {
|
||||||
expect(failFn).toHaveBeenCalledWith(err);
|
expect(failFn).toHaveBeenCalledWith(err);
|
||||||
expect(queueableFn2.fn).toHaveBeenCalled();
|
expect(queueableFn2.fn).toHaveBeenCalled();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
});
|
});
|
||||||
@@ -206,19 +206,19 @@ describe('QueueRunner', function() {
|
|||||||
describe('and the argument is not an Error', function() {
|
describe('and the argument is not an Error', function() {
|
||||||
it('does not report a failure', function(done) {
|
it('does not report a failure', function(done) {
|
||||||
const queueableFn1 = {
|
const queueableFn1 = {
|
||||||
fn: function() {
|
fn: function() {
|
||||||
return Promise.resolve('not an error');
|
return Promise.resolve('not an error');
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
failFn = jasmine.createSpy('fail'),
|
const failFn = jasmine.createSpy('fail');
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn1],
|
queueableFns: [queueableFn1],
|
||||||
fail: failFn,
|
fail: failFn,
|
||||||
onComplete: function() {
|
onComplete: function() {
|
||||||
expect(failFn).not.toHaveBeenCalled();
|
expect(failFn).not.toHaveBeenCalled();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
});
|
});
|
||||||
@@ -227,20 +227,20 @@ describe('QueueRunner', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('does not cause an explicit fail if execution is being stopped', function() {
|
it('does not cause an explicit fail if execution is being stopped', function() {
|
||||||
const err = new privateUnderTest.StopExecutionError('foo'),
|
const err = new privateUnderTest.StopExecutionError('foo');
|
||||||
queueableFn1 = {
|
const queueableFn1 = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
done(err);
|
done(err);
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
const queueableFn2 = { fn: jasmine.createSpy('fn2') };
|
||||||
failFn = jasmine.createSpy('fail'),
|
const failFn = jasmine.createSpy('fail');
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn1, queueableFn2],
|
queueableFns: [queueableFn1, queueableFn2],
|
||||||
fail: failFn
|
fail: failFn
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
|
|
||||||
@@ -254,16 +254,20 @@ describe('QueueRunner', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("sets a timeout if requested for asynchronous functions so they don't go on forever", function() {
|
it("sets a timeout if requested for asynchronous functions so they don't go on forever", function() {
|
||||||
const timeout = 3,
|
const timeout = 3;
|
||||||
beforeFn = { fn: function(done) {}, type: 'before', timeout: timeout },
|
const beforeFn = {
|
||||||
queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' },
|
fn: function(done) {},
|
||||||
onComplete = jasmine.createSpy('onComplete'),
|
type: 'before',
|
||||||
onException = jasmine.createSpy('onException'),
|
timeout: timeout
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
};
|
||||||
queueableFns: [beforeFn, queueableFn],
|
const queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' };
|
||||||
onComplete: onComplete,
|
const onComplete = jasmine.createSpy('onComplete');
|
||||||
onException: onException
|
const onException = jasmine.createSpy('onException');
|
||||||
});
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
|
queueableFns: [beforeFn, queueableFn],
|
||||||
|
onComplete: onComplete,
|
||||||
|
onException: onException
|
||||||
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
expect(queueableFn.fn).not.toHaveBeenCalled();
|
expect(queueableFn.fn).not.toHaveBeenCalled();
|
||||||
@@ -302,15 +306,15 @@ describe('QueueRunner', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('by default does not set a timeout for asynchronous functions', function() {
|
it('by default does not set a timeout for asynchronous functions', function() {
|
||||||
const beforeFn = { fn: function(done) {} },
|
const beforeFn = { fn: function(done) {} };
|
||||||
queueableFn = { fn: jasmine.createSpy('fn') },
|
const queueableFn = { fn: jasmine.createSpy('fn') };
|
||||||
onComplete = jasmine.createSpy('onComplete'),
|
const onComplete = jasmine.createSpy('onComplete');
|
||||||
onException = jasmine.createSpy('onException'),
|
const onException = jasmine.createSpy('onException');
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [beforeFn, queueableFn],
|
queueableFns: [beforeFn, queueableFn],
|
||||||
onComplete: onComplete,
|
onComplete: onComplete,
|
||||||
onException: onException
|
onException: onException
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
expect(queueableFn.fn).not.toHaveBeenCalled();
|
expect(queueableFn.fn).not.toHaveBeenCalled();
|
||||||
@@ -324,17 +328,17 @@ describe('QueueRunner', function() {
|
|||||||
|
|
||||||
it('clears the timeout when an async function throws an exception, to prevent additional exception reporting', function() {
|
it('clears the timeout when an async function throws an exception, to prevent additional exception reporting', function() {
|
||||||
const queueableFn = {
|
const queueableFn = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
throw new Error('error!');
|
throw new Error('error!');
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
onComplete = jasmine.createSpy('onComplete'),
|
const onComplete = jasmine.createSpy('onComplete');
|
||||||
onException = jasmine.createSpy('onException'),
|
const onException = jasmine.createSpy('onException');
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn],
|
queueableFns: [queueableFn],
|
||||||
onComplete: onComplete,
|
onComplete: onComplete,
|
||||||
onException: onException
|
onException: onException
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
|
|
||||||
@@ -347,17 +351,17 @@ describe('QueueRunner', function() {
|
|||||||
|
|
||||||
it('clears the timeout when the done callback is called', function() {
|
it('clears the timeout when the done callback is called', function() {
|
||||||
const queueableFn = {
|
const queueableFn = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
onComplete = jasmine.createSpy('onComplete'),
|
const onComplete = jasmine.createSpy('onComplete');
|
||||||
onException = jasmine.createSpy('onException'),
|
const onException = jasmine.createSpy('onException');
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn],
|
queueableFns: [queueableFn],
|
||||||
onComplete: onComplete,
|
onComplete: onComplete,
|
||||||
onException: onException
|
onException: onException
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
|
|
||||||
@@ -370,17 +374,17 @@ describe('QueueRunner', function() {
|
|||||||
|
|
||||||
it('only moves to the next spec the first time you call done', function() {
|
it('only moves to the next spec the first time you call done', function() {
|
||||||
const queueableFn = {
|
const queueableFn = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
done();
|
done();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
nextQueueableFn = { fn: jasmine.createSpy('nextFn') },
|
const nextQueueableFn = { fn: jasmine.createSpy('nextFn') };
|
||||||
onMultipleDone = jasmine.createSpy('onMultipleDone'),
|
const onMultipleDone = jasmine.createSpy('onMultipleDone');
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn, nextQueueableFn],
|
queueableFns: [queueableFn, nextQueueableFn],
|
||||||
onMultipleDone: onMultipleDone
|
onMultipleDone: onMultipleDone
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
jasmine.clock().tick(1);
|
jasmine.clock().tick(1);
|
||||||
@@ -390,15 +394,15 @@ describe('QueueRunner', function() {
|
|||||||
|
|
||||||
it('does not move to the next spec if done is called after an exception has ended the spec', function() {
|
it('does not move to the next spec if done is called after an exception has ended the spec', function() {
|
||||||
const queueableFn = {
|
const queueableFn = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
setTimeout(done, 1);
|
setTimeout(done, 1);
|
||||||
throw new Error('error!');
|
throw new Error('error!');
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
nextQueueableFn = { fn: jasmine.createSpy('nextFn') },
|
const nextQueueableFn = { fn: jasmine.createSpy('nextFn') };
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn, nextQueueableFn]
|
queueableFns: [queueableFn, nextQueueableFn]
|
||||||
});
|
});
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
jasmine.clock().tick(1);
|
jasmine.clock().tick(1);
|
||||||
expect(nextQueueableFn.fn.calls.count()).toEqual(1);
|
expect(nextQueueableFn.fn.calls.count()).toEqual(1);
|
||||||
@@ -422,28 +426,26 @@ describe('QueueRunner', function() {
|
|||||||
|
|
||||||
it('continues running functions when an exception is thrown in async code without timing out', function() {
|
it('continues running functions when an exception is thrown in async code without timing out', function() {
|
||||||
const queueableFn = {
|
const queueableFn = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
throwAsync();
|
throwAsync();
|
||||||
},
|
|
||||||
timeout: 1
|
|
||||||
},
|
},
|
||||||
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
|
timeout: 1
|
||||||
onException = jasmine.createSpy('onException'),
|
};
|
||||||
globalErrors = {
|
const nextQueueableFn = { fn: jasmine.createSpy('nextFunction') };
|
||||||
pushListener: jasmine.createSpy('pushListener'),
|
const onException = jasmine.createSpy('onException');
|
||||||
popListener: jasmine.createSpy('popListener')
|
const globalErrors = {
|
||||||
},
|
pushListener: jasmine.createSpy('pushListener'),
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
popListener: jasmine.createSpy('popListener')
|
||||||
queueableFns: [queueableFn, nextQueueableFn],
|
};
|
||||||
onException: onException,
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
globalErrors: globalErrors
|
queueableFns: [queueableFn, nextQueueableFn],
|
||||||
}),
|
onException: onException,
|
||||||
throwAsync = function() {
|
globalErrors: globalErrors
|
||||||
globalErrors.pushListener.calls
|
});
|
||||||
.mostRecent()
|
const throwAsync = function() {
|
||||||
.args[0](new Error('foo'));
|
globalErrors.pushListener.calls.mostRecent().args[0](new Error('foo'));
|
||||||
jasmine.clock().tick(2);
|
jasmine.clock().tick(2);
|
||||||
};
|
};
|
||||||
|
|
||||||
nextQueueableFn.fn.and.callFake(function() {
|
nextQueueableFn.fn.and.callFake(function() {
|
||||||
// should remove the same function that was added
|
// should remove the same function that was added
|
||||||
@@ -473,28 +475,28 @@ describe('QueueRunner', function() {
|
|||||||
|
|
||||||
it('handles exceptions thrown while waiting for the stack to clear', function() {
|
it('handles exceptions thrown while waiting for the stack to clear', function() {
|
||||||
const queueableFn = {
|
const queueableFn = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
const errorListeners = [];
|
||||||
|
const globalErrors = {
|
||||||
|
pushListener: function(f) {
|
||||||
|
errorListeners.push(f);
|
||||||
},
|
},
|
||||||
errorListeners = [],
|
popListener: function() {
|
||||||
globalErrors = {
|
errorListeners.pop();
|
||||||
pushListener: function(f) {
|
}
|
||||||
errorListeners.push(f);
|
};
|
||||||
},
|
const clearStack = jasmine.createSpyObj('clearStack', ['clearStack']);
|
||||||
popListener: function() {
|
const onException = jasmine.createSpy('onException');
|
||||||
errorListeners.pop();
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
}
|
queueableFns: [queueableFn],
|
||||||
},
|
globalErrors: globalErrors,
|
||||||
clearStack = jasmine.createSpyObj('clearStack', ['clearStack']),
|
clearStack: clearStack,
|
||||||
onException = jasmine.createSpy('onException'),
|
onException: onException
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
});
|
||||||
queueableFns: [queueableFn],
|
const error = new Error('nope');
|
||||||
globalErrors: globalErrors,
|
|
||||||
clearStack: clearStack,
|
|
||||||
onException: onException
|
|
||||||
}),
|
|
||||||
error = new Error('nope');
|
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
jasmine.clock().tick();
|
jasmine.clock().tick();
|
||||||
@@ -523,31 +525,31 @@ describe('QueueRunner', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('runs the function asynchronously, advancing once the promise is settled', function() {
|
it('runs the function asynchronously, advancing once the promise is settled', function() {
|
||||||
const onComplete = jasmine.createSpy('onComplete'),
|
const onComplete = jasmine.createSpy('onComplete');
|
||||||
fnCallback = jasmine.createSpy('fnCallback'),
|
const fnCallback = jasmine.createSpy('fnCallback');
|
||||||
p1 = new StubPromise(),
|
const p1 = new StubPromise();
|
||||||
p2 = new StubPromise(),
|
const p2 = new StubPromise();
|
||||||
queueableFn1 = {
|
const queueableFn1 = {
|
||||||
fn: function() {
|
fn: function() {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
p1.resolveHandler();
|
p1.resolveHandler();
|
||||||
}, 100);
|
}, 100);
|
||||||
return p1;
|
return p1;
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
queueableFn2 = {
|
const queueableFn2 = {
|
||||||
fn: function() {
|
fn: function() {
|
||||||
fnCallback();
|
fnCallback();
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
p2.resolveHandler();
|
p2.resolveHandler();
|
||||||
}, 100);
|
}, 100);
|
||||||
return p2;
|
return p2;
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn1, queueableFn2],
|
queueableFns: [queueableFn1, queueableFn2],
|
||||||
onComplete: onComplete
|
onComplete: onComplete
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
expect(fnCallback).not.toHaveBeenCalled();
|
expect(fnCallback).not.toHaveBeenCalled();
|
||||||
@@ -564,21 +566,21 @@ describe('QueueRunner', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('handles a rejected promise like an unhandled exception', function() {
|
it('handles a rejected promise like an unhandled exception', function() {
|
||||||
const promise = new StubPromise(),
|
const promise = new StubPromise();
|
||||||
queueableFn1 = {
|
const queueableFn1 = {
|
||||||
fn: function() {
|
fn: function() {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
promise.rejectHandler('foo');
|
promise.rejectHandler('foo');
|
||||||
}, 100);
|
}, 100);
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
const queueableFn2 = { fn: jasmine.createSpy('fn2') };
|
||||||
onExceptionCallback = jasmine.createSpy('on exception callback'),
|
const onExceptionCallback = jasmine.createSpy('on exception callback');
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn1, queueableFn2],
|
queueableFns: [queueableFn1, queueableFn2],
|
||||||
onException: onExceptionCallback
|
onException: onExceptionCallback
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
|
|
||||||
@@ -593,15 +595,15 @@ describe('QueueRunner', function() {
|
|||||||
|
|
||||||
it('issues an error if the function also takes a parameter', function() {
|
it('issues an error if the function also takes a parameter', function() {
|
||||||
const queueableFn = {
|
const queueableFn = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
return new StubPromise();
|
return new StubPromise();
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
onException = jasmine.createSpy('onException'),
|
const onException = jasmine.createSpy('onException');
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn],
|
queueableFns: [queueableFn],
|
||||||
onException: onException
|
onException: onException
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
|
|
||||||
@@ -618,11 +620,11 @@ describe('QueueRunner', function() {
|
|||||||
|
|
||||||
it('issues a more specific error if the function is `async`', function() {
|
it('issues a more specific error if the function is `async`', function() {
|
||||||
async function fn(done) {}
|
async function fn(done) {}
|
||||||
const onException = jasmine.createSpy('onException'),
|
const onException = jasmine.createSpy('onException');
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [{ fn: fn }],
|
queueableFns: [{ fn: fn }],
|
||||||
onException: onException
|
onException: onException
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
|
|
||||||
@@ -638,11 +640,11 @@ describe('QueueRunner', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('passes final errors to exception handlers', function() {
|
it('passes final errors to exception handlers', function() {
|
||||||
const error = new Error('fake error'),
|
const error = new Error('fake error');
|
||||||
onExceptionCallback = jasmine.createSpy('on exception callback'),
|
const onExceptionCallback = jasmine.createSpy('on exception callback');
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
onException: onExceptionCallback
|
onException: onExceptionCallback
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
queueRunner.handleFinalError(error);
|
queueRunner.handleFinalError(error);
|
||||||
@@ -652,16 +654,16 @@ describe('QueueRunner', function() {
|
|||||||
|
|
||||||
it('calls exception handlers when an exception is thrown in a fn', function() {
|
it('calls exception handlers when an exception is thrown in a fn', function() {
|
||||||
const queueableFn = {
|
const queueableFn = {
|
||||||
type: 'queueable',
|
type: 'queueable',
|
||||||
fn: function() {
|
fn: function() {
|
||||||
throw new Error('fake error');
|
throw new Error('fake error');
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
onExceptionCallback = jasmine.createSpy('on exception callback'),
|
const onExceptionCallback = jasmine.createSpy('on exception callback');
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn],
|
queueableFns: [queueableFn],
|
||||||
onException: onExceptionCallback
|
onException: onExceptionCallback
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
|
|
||||||
@@ -670,14 +672,14 @@ describe('QueueRunner', function() {
|
|||||||
|
|
||||||
it('continues running the functions even after an exception is thrown in an async spec', function() {
|
it('continues running the functions even after an exception is thrown in an async spec', function() {
|
||||||
const queueableFn = {
|
const queueableFn = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
throw new Error('error');
|
throw new Error('error');
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
|
const nextQueueableFn = { fn: jasmine.createSpy('nextFunction') };
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn, nextQueueableFn]
|
queueableFns: [queueableFn, nextQueueableFn]
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
expect(nextQueueableFn.fn).toHaveBeenCalled();
|
expect(nextQueueableFn.fn).toHaveBeenCalled();
|
||||||
@@ -747,21 +749,21 @@ describe('QueueRunner', function() {
|
|||||||
describe('When configured to complete on first error', function() {
|
describe('When configured to complete on first error', function() {
|
||||||
it('skips to cleanup functions on the first exception', function() {
|
it('skips to cleanup functions on the first exception', function() {
|
||||||
const queueableFn = {
|
const queueableFn = {
|
||||||
fn: function() {
|
fn: function() {
|
||||||
throw new Error('error');
|
throw new Error('error');
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
|
const nextQueueableFn = { fn: jasmine.createSpy('nextFunction') };
|
||||||
cleanupFn = {
|
const cleanupFn = {
|
||||||
fn: jasmine.createSpy('cleanup'),
|
fn: jasmine.createSpy('cleanup'),
|
||||||
type: 'specCleanup'
|
type: 'specCleanup'
|
||||||
},
|
};
|
||||||
onComplete = jasmine.createSpy('onComplete'),
|
const onComplete = jasmine.createSpy('onComplete');
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
|
queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
|
||||||
onComplete: onComplete,
|
onComplete: onComplete,
|
||||||
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
|
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
expect(nextQueueableFn.fn).not.toHaveBeenCalled();
|
expect(nextQueueableFn.fn).not.toHaveBeenCalled();
|
||||||
@@ -772,21 +774,21 @@ describe('QueueRunner', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('does not skip when a cleanup function throws', function() {
|
it('does not skip when a cleanup function throws', function() {
|
||||||
const queueableFn = { fn: function() {} },
|
const queueableFn = { fn: function() {} };
|
||||||
cleanupFn1 = {
|
const cleanupFn1 = {
|
||||||
fn: function() {
|
fn: function() {
|
||||||
throw new Error('error');
|
throw new Error('error');
|
||||||
},
|
|
||||||
type: 'afterEach'
|
|
||||||
},
|
},
|
||||||
cleanupFn2 = {
|
type: 'afterEach'
|
||||||
fn: jasmine.createSpy('cleanupFn2'),
|
};
|
||||||
type: 'afterEach'
|
const cleanupFn2 = {
|
||||||
},
|
fn: jasmine.createSpy('cleanupFn2'),
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
type: 'afterEach'
|
||||||
queueableFns: [queueableFn, cleanupFn1, cleanupFn2],
|
};
|
||||||
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
});
|
queueableFns: [queueableFn, cleanupFn1, cleanupFn2],
|
||||||
|
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||||
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
expect(cleanupFn2.fn).toHaveBeenCalled();
|
expect(cleanupFn2.fn).toHaveBeenCalled();
|
||||||
@@ -837,16 +839,19 @@ describe('QueueRunner', function() {
|
|||||||
|
|
||||||
it('skips to cleanup functions when next.fail is called', function() {
|
it('skips to cleanup functions when next.fail is called', function() {
|
||||||
const queueableFn = {
|
const queueableFn = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
done.fail('nope');
|
done.fail('nope');
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
|
const nextQueueableFn = { fn: jasmine.createSpy('nextFunction') };
|
||||||
cleanupFn = { fn: jasmine.createSpy('cleanup'), type: 'specCleanup' },
|
const cleanupFn = {
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
fn: jasmine.createSpy('cleanup'),
|
||||||
queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
|
type: 'specCleanup'
|
||||||
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
|
};
|
||||||
});
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
|
queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
|
||||||
|
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||||
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
jasmine.clock().tick();
|
jasmine.clock().tick();
|
||||||
@@ -856,19 +861,19 @@ describe('QueueRunner', function() {
|
|||||||
|
|
||||||
it('skips to cleanup functions when next is called with an Error', function() {
|
it('skips to cleanup functions when next is called with an Error', function() {
|
||||||
const queueableFn = {
|
const queueableFn = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
done(new Error('nope'));
|
done(new Error('nope'));
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
|
const nextQueueableFn = { fn: jasmine.createSpy('nextFunction') };
|
||||||
cleanupFn = {
|
const cleanupFn = {
|
||||||
fn: jasmine.createSpy('cleanup'),
|
fn: jasmine.createSpy('cleanup'),
|
||||||
type: 'specCleanup'
|
type: 'specCleanup'
|
||||||
},
|
};
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
|
queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
|
||||||
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
|
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
jasmine.clock().tick();
|
jasmine.clock().tick();
|
||||||
@@ -879,12 +884,12 @@ describe('QueueRunner', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('calls a provided complete callback when done', function() {
|
it('calls a provided complete callback when done', function() {
|
||||||
const queueableFn = { fn: jasmine.createSpy('fn') },
|
const queueableFn = { fn: jasmine.createSpy('fn') };
|
||||||
completeCallback = jasmine.createSpy('completeCallback'),
|
const completeCallback = jasmine.createSpy('completeCallback');
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn],
|
queueableFns: [queueableFn],
|
||||||
onComplete: completeCallback
|
onComplete: completeCallback
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
|
|
||||||
@@ -902,18 +907,18 @@ describe('QueueRunner', function() {
|
|||||||
|
|
||||||
it('calls a provided stack clearing function when done', function() {
|
it('calls a provided stack clearing function when done', function() {
|
||||||
const asyncFn = {
|
const asyncFn = {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
afterFn = { fn: jasmine.createSpy('afterFn') },
|
const afterFn = { fn: jasmine.createSpy('afterFn') };
|
||||||
completeCallback = jasmine.createSpy('completeCallback'),
|
const completeCallback = jasmine.createSpy('completeCallback');
|
||||||
clearStack = jasmine.createSpyObj('clearStack', ['clearStack']),
|
const clearStack = jasmine.createSpyObj('clearStack', ['clearStack']);
|
||||||
queueRunner = new privateUnderTest.QueueRunner({
|
const queueRunner = new privateUnderTest.QueueRunner({
|
||||||
queueableFns: [asyncFn, afterFn],
|
queueableFns: [asyncFn, afterFn],
|
||||||
clearStack: clearStack,
|
clearStack: clearStack,
|
||||||
onComplete: completeCallback
|
onComplete: completeCallback
|
||||||
});
|
});
|
||||||
|
|
||||||
clearStack.clearStack.and.callFake(function(fn) {
|
clearStack.clearStack.and.callFake(function(fn) {
|
||||||
fn();
|
fn();
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ describe('ReportDispatcher', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('dispatches requested methods to added reporters', function() {
|
it('dispatches requested methods to added reporters', function() {
|
||||||
const runQueue = jasmine.createSpy('runQueue'),
|
const runQueue = jasmine.createSpy('runQueue');
|
||||||
dispatcher = new privateUnderTest.ReportDispatcher(
|
const dispatcher = new privateUnderTest.ReportDispatcher(
|
||||||
['foo', 'bar'],
|
['foo', 'bar'],
|
||||||
runQueue
|
runQueue
|
||||||
),
|
);
|
||||||
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']),
|
const reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
||||||
anotherReporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
const anotherReporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
||||||
|
|
||||||
dispatcher.addReporter(reporter);
|
dispatcher.addReporter(reporter);
|
||||||
dispatcher.addReporter(anotherReporter);
|
dispatcher.addReporter(anotherReporter);
|
||||||
@@ -100,9 +100,9 @@ describe('ReportDispatcher', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does not dispatch to a reporter if the reporter doesn't accept the method", function() {
|
it("does not dispatch to a reporter if the reporter doesn't accept the method", function() {
|
||||||
const runQueue = jasmine.createSpy('runQueue'),
|
const runQueue = jasmine.createSpy('runQueue');
|
||||||
dispatcher = new privateUnderTest.ReportDispatcher(['foo'], runQueue),
|
const dispatcher = new privateUnderTest.ReportDispatcher(['foo'], runQueue);
|
||||||
reporter = jasmine.createSpyObj('reporter', ['baz']);
|
const reporter = jasmine.createSpyObj('reporter', ['baz']);
|
||||||
|
|
||||||
dispatcher.addReporter(reporter);
|
dispatcher.addReporter(reporter);
|
||||||
|
|
||||||
@@ -115,12 +115,12 @@ describe('ReportDispatcher', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("allows providing a fallback reporter in case there's no other reporter", function() {
|
it("allows providing a fallback reporter in case there's no other reporter", function() {
|
||||||
const runQueue = jasmine.createSpy('runQueue'),
|
const runQueue = jasmine.createSpy('runQueue');
|
||||||
dispatcher = new privateUnderTest.ReportDispatcher(
|
const dispatcher = new privateUnderTest.ReportDispatcher(
|
||||||
['foo', 'bar'],
|
['foo', 'bar'],
|
||||||
runQueue
|
runQueue
|
||||||
),
|
);
|
||||||
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
const reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
||||||
|
|
||||||
dispatcher.provideFallbackReporter(reporter);
|
dispatcher.provideFallbackReporter(reporter);
|
||||||
dispatcher.foo({ an: 'event' });
|
dispatcher.foo({ an: 'event' });
|
||||||
@@ -138,13 +138,16 @@ describe('ReportDispatcher', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('does not call fallback reporting methods when another reporter is provided', function() {
|
it('does not call fallback reporting methods when another reporter is provided', function() {
|
||||||
const runQueue = jasmine.createSpy('runQueue'),
|
const runQueue = jasmine.createSpy('runQueue');
|
||||||
dispatcher = new privateUnderTest.ReportDispatcher(
|
const dispatcher = new privateUnderTest.ReportDispatcher(
|
||||||
['foo', 'bar'],
|
['foo', 'bar'],
|
||||||
runQueue
|
runQueue
|
||||||
),
|
);
|
||||||
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']),
|
const reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
||||||
fallbackReporter = jasmine.createSpyObj('otherReporter', ['foo', 'bar']);
|
const fallbackReporter = jasmine.createSpyObj('otherReporter', [
|
||||||
|
'foo',
|
||||||
|
'bar'
|
||||||
|
]);
|
||||||
|
|
||||||
dispatcher.provideFallbackReporter(fallbackReporter);
|
dispatcher.provideFallbackReporter(fallbackReporter);
|
||||||
dispatcher.addReporter(reporter);
|
dispatcher.addReporter(reporter);
|
||||||
@@ -164,13 +167,13 @@ describe('ReportDispatcher', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows registered reporters to be cleared', function() {
|
it('allows registered reporters to be cleared', function() {
|
||||||
const runQueue = jasmine.createSpy('runQueue'),
|
const runQueue = jasmine.createSpy('runQueue');
|
||||||
dispatcher = new privateUnderTest.ReportDispatcher(
|
const dispatcher = new privateUnderTest.ReportDispatcher(
|
||||||
['foo', 'bar'],
|
['foo', 'bar'],
|
||||||
runQueue
|
runQueue
|
||||||
),
|
);
|
||||||
reporter1 = jasmine.createSpyObj('reporter1', ['foo', 'bar']),
|
const reporter1 = jasmine.createSpyObj('reporter1', ['foo', 'bar']);
|
||||||
reporter2 = jasmine.createSpyObj('reporter2', ['foo', 'bar']);
|
const reporter2 = jasmine.createSpyObj('reporter2', ['foo', 'bar']);
|
||||||
|
|
||||||
dispatcher.addReporter(reporter1);
|
dispatcher.addReporter(reporter1);
|
||||||
dispatcher.foo({ an: 'event' });
|
dispatcher.foo({ an: 'event' });
|
||||||
|
|||||||
@@ -181,13 +181,13 @@ describe('Spec', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('is "pending" if created without a function body', function() {
|
it('is "pending" if created without a function body', function() {
|
||||||
const startCallback = jasmine.createSpy('startCallback'),
|
const startCallback = jasmine.createSpy('startCallback');
|
||||||
resultCallback = jasmine.createSpy('resultCallback'),
|
const resultCallback = jasmine.createSpy('resultCallback');
|
||||||
spec = new privateUnderTest.Spec({
|
const spec = new privateUnderTest.Spec({
|
||||||
onStart: startCallback,
|
onStart: startCallback,
|
||||||
queueableFn: { fn: null },
|
queueableFn: { fn: null },
|
||||||
resultCallback: resultCallback
|
resultCallback: resultCallback
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(spec.status())
|
expect(spec.status())
|
||||||
.withContext('status()')
|
.withContext('status()')
|
||||||
@@ -389,12 +389,12 @@ describe('Spec', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('does not throw an ExpectationFailed error when handling an error', function() {
|
it('does not throw an ExpectationFailed error when handling an error', function() {
|
||||||
const resultCallback = jasmine.createSpy('resultCallback'),
|
const resultCallback = jasmine.createSpy('resultCallback');
|
||||||
spec = new privateUnderTest.Spec({
|
const spec = new privateUnderTest.Spec({
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} },
|
||||||
resultCallback: resultCallback,
|
resultCallback: resultCallback,
|
||||||
throwOnExpectationFailure: true
|
throwOnExpectationFailure: true
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.handleException('failing exception');
|
spec.handleException('failing exception');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ describe('SpyRegistry', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('checks that a method name was passed', function() {
|
it('checks that a method name was passed', function() {
|
||||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
const spyRegistry = new privateUnderTest.SpyRegistry();
|
||||||
target = {};
|
const target = {};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
spyRegistry.spyOn(target);
|
spyRegistry.spyOn(target);
|
||||||
@@ -30,8 +30,8 @@ describe('SpyRegistry', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('checks that the method name is not `null`', function() {
|
it('checks that the method name is not `null`', function() {
|
||||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
const spyRegistry = new privateUnderTest.SpyRegistry();
|
||||||
target = {};
|
const target = {};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
spyRegistry.spyOn(target, null);
|
spyRegistry.spyOn(target, null);
|
||||||
@@ -39,8 +39,8 @@ describe('SpyRegistry', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('checks for the existence of the method', function() {
|
it('checks for the existence of the method', function() {
|
||||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
const spyRegistry = new privateUnderTest.SpyRegistry();
|
||||||
target = {};
|
const target = {};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
spyRegistry.spyOn(target, 'pants');
|
spyRegistry.spyOn(target, 'pants');
|
||||||
@@ -48,14 +48,14 @@ describe('SpyRegistry', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('checks if it has already been spied upon', function() {
|
it('checks if it has already been spied upon', function() {
|
||||||
const spies = [],
|
const spies = [];
|
||||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||||
currentSpies: function() {
|
currentSpies: function() {
|
||||||
return spies;
|
return spies;
|
||||||
},
|
},
|
||||||
createSpy: createSpy
|
createSpy: createSpy
|
||||||
}),
|
});
|
||||||
target = { spiedFunc: function() {} };
|
const target = { spiedFunc: function() {} };
|
||||||
|
|
||||||
spyRegistry.spyOn(target, 'spiedFunc');
|
spyRegistry.spyOn(target, 'spiedFunc');
|
||||||
|
|
||||||
@@ -77,13 +77,13 @@ describe('SpyRegistry', function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const spies = [],
|
const spies = [];
|
||||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||||
currentSpies: function() {
|
currentSpies: function() {
|
||||||
return spies;
|
return spies;
|
||||||
}
|
}
|
||||||
}),
|
});
|
||||||
target = { spiedFunc: scope.myFunc };
|
const target = { spiedFunc: scope.myFunc };
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
spyRegistry.spyOn(scope, 'myFunc');
|
spyRegistry.spyOn(scope, 'myFunc');
|
||||||
@@ -158,8 +158,8 @@ describe('SpyRegistry', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('checks that a property name was passed', function() {
|
it('checks that a property name was passed', function() {
|
||||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
const spyRegistry = new privateUnderTest.SpyRegistry();
|
||||||
target = {};
|
const target = {};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
spyRegistry.spyOnProperty(target);
|
spyRegistry.spyOnProperty(target);
|
||||||
@@ -167,8 +167,8 @@ describe('SpyRegistry', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('checks for the existence of the method', function() {
|
it('checks for the existence of the method', function() {
|
||||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
const spyRegistry = new privateUnderTest.SpyRegistry();
|
||||||
target = {};
|
const target = {};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
spyRegistry.spyOnProperty(target, 'pants');
|
spyRegistry.spyOnProperty(target, 'pants');
|
||||||
@@ -176,8 +176,8 @@ describe('SpyRegistry', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('checks for the existence of access type', function() {
|
it('checks for the existence of access type', function() {
|
||||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
const spyRegistry = new privateUnderTest.SpyRegistry();
|
||||||
target = {};
|
const target = {};
|
||||||
|
|
||||||
Object.defineProperty(target, 'pants', {
|
Object.defineProperty(target, 'pants', {
|
||||||
get: function() {
|
get: function() {
|
||||||
@@ -216,10 +216,10 @@ describe('SpyRegistry', function() {
|
|||||||
|
|
||||||
it('overrides the property getter on the object and returns the spy', function() {
|
it('overrides the property getter on the object and returns the spy', function() {
|
||||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||||
createSpy: createSpy
|
createSpy: createSpy
|
||||||
}),
|
});
|
||||||
target = {},
|
const target = {};
|
||||||
returnValue = 1;
|
const returnValue = 1;
|
||||||
|
|
||||||
Object.defineProperty(target, 'spiedProperty', {
|
Object.defineProperty(target, 'spiedProperty', {
|
||||||
get: function() {
|
get: function() {
|
||||||
@@ -240,10 +240,10 @@ describe('SpyRegistry', function() {
|
|||||||
|
|
||||||
it('overrides the property setter on the object and returns the spy', function() {
|
it('overrides the property setter on the object and returns the spy', function() {
|
||||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||||
createSpy: createSpy
|
createSpy: createSpy
|
||||||
}),
|
});
|
||||||
target = {},
|
const target = {};
|
||||||
returnValue = 1;
|
const returnValue = 1;
|
||||||
|
|
||||||
Object.defineProperty(target, 'spiedProperty', {
|
Object.defineProperty(target, 'spiedProperty', {
|
||||||
get: function() {
|
get: function() {
|
||||||
@@ -264,9 +264,9 @@ describe('SpyRegistry', function() {
|
|||||||
describe('when the property is already spied upon', function() {
|
describe('when the property is already spied upon', function() {
|
||||||
it('throws an error if respy is not allowed', function() {
|
it('throws an error if respy is not allowed', function() {
|
||||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||||
createSpy: createSpy
|
createSpy: createSpy
|
||||||
}),
|
});
|
||||||
target = {};
|
const target = {};
|
||||||
|
|
||||||
Object.defineProperty(target, 'spiedProp', {
|
Object.defineProperty(target, 'spiedProp', {
|
||||||
get: function() {
|
get: function() {
|
||||||
@@ -284,9 +284,9 @@ describe('SpyRegistry', function() {
|
|||||||
|
|
||||||
it('returns the original spy if respy is allowed', function() {
|
it('returns the original spy if respy is allowed', function() {
|
||||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||||
createSpy: createSpy
|
createSpy: createSpy
|
||||||
}),
|
});
|
||||||
target = {};
|
const target = {};
|
||||||
|
|
||||||
spyRegistry.allowRespy(true);
|
spyRegistry.allowRespy(true);
|
||||||
|
|
||||||
@@ -564,15 +564,15 @@ describe('SpyRegistry', function() {
|
|||||||
|
|
||||||
describe('#clearSpies', function() {
|
describe('#clearSpies', function() {
|
||||||
it('restores the original functions on the spied-upon objects', function() {
|
it('restores the original functions on the spied-upon objects', function() {
|
||||||
const spies = [],
|
const spies = [];
|
||||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||||
currentSpies: function() {
|
currentSpies: function() {
|
||||||
return spies;
|
return spies;
|
||||||
},
|
},
|
||||||
createSpy: createSpy
|
createSpy: createSpy
|
||||||
}),
|
});
|
||||||
originalFunction = function() {},
|
const originalFunction = function() {};
|
||||||
target = { spiedFunc: originalFunction };
|
const target = { spiedFunc: originalFunction };
|
||||||
|
|
||||||
spyRegistry.spyOn(target, 'spiedFunc');
|
spyRegistry.spyOn(target, 'spiedFunc');
|
||||||
spyRegistry.clearSpies();
|
spyRegistry.clearSpies();
|
||||||
@@ -581,15 +581,15 @@ describe('SpyRegistry', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('restores the original functions, even when that spy has been replace and re-spied upon', function() {
|
it('restores the original functions, even when that spy has been replace and re-spied upon', function() {
|
||||||
const spies = [],
|
const spies = [];
|
||||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||||
currentSpies: function() {
|
currentSpies: function() {
|
||||||
return spies;
|
return spies;
|
||||||
},
|
},
|
||||||
createSpy: createSpy
|
createSpy: createSpy
|
||||||
}),
|
});
|
||||||
originalFunction = function() {},
|
const originalFunction = function() {};
|
||||||
target = { spiedFunc: originalFunction };
|
const target = { spiedFunc: originalFunction };
|
||||||
|
|
||||||
spyRegistry.spyOn(target, 'spiedFunc');
|
spyRegistry.spyOn(target, 'spiedFunc');
|
||||||
|
|
||||||
@@ -605,15 +605,15 @@ describe('SpyRegistry', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does not add a property that the spied-upon object didn't originally have", function() {
|
it("does not add a property that the spied-upon object didn't originally have", function() {
|
||||||
const spies = [],
|
const spies = [];
|
||||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||||
currentSpies: function() {
|
currentSpies: function() {
|
||||||
return spies;
|
return spies;
|
||||||
},
|
},
|
||||||
createSpy: createSpy
|
createSpy: createSpy
|
||||||
}),
|
});
|
||||||
originalFunction = function() {},
|
const originalFunction = function() {};
|
||||||
targetParent = { spiedFunc: originalFunction };
|
const targetParent = { spiedFunc: originalFunction };
|
||||||
|
|
||||||
const target = Object.create(targetParent);
|
const target = Object.create(targetParent);
|
||||||
|
|
||||||
@@ -627,15 +627,15 @@ describe('SpyRegistry', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("restores the original function when it's inherited and cannot be deleted", function() {
|
it("restores the original function when it's inherited and cannot be deleted", function() {
|
||||||
const spies = [],
|
const spies = [];
|
||||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||||
currentSpies: function() {
|
currentSpies: function() {
|
||||||
return spies;
|
return spies;
|
||||||
},
|
},
|
||||||
createSpy: createSpy
|
createSpy: createSpy
|
||||||
}),
|
});
|
||||||
originalFunction = function() {},
|
const originalFunction = function() {};
|
||||||
targetParent = { spiedFunc: originalFunction };
|
const targetParent = { spiedFunc: originalFunction };
|
||||||
|
|
||||||
const target = Object.create(targetParent);
|
const target = Object.create(targetParent);
|
||||||
|
|
||||||
@@ -655,15 +655,15 @@ describe('SpyRegistry', function() {
|
|||||||
function FakeWindow() {}
|
function FakeWindow() {}
|
||||||
FakeWindow.prototype.onerror = function() {};
|
FakeWindow.prototype.onerror = function() {};
|
||||||
|
|
||||||
const spies = [],
|
const spies = [];
|
||||||
global = new FakeWindow(),
|
const global = new FakeWindow();
|
||||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||||
currentSpies: function() {
|
currentSpies: function() {
|
||||||
return spies;
|
return spies;
|
||||||
},
|
},
|
||||||
createSpy: createSpy,
|
createSpy: createSpy,
|
||||||
global: global
|
global: global
|
||||||
});
|
});
|
||||||
|
|
||||||
spyRegistry.spyOn(global, 'onerror');
|
spyRegistry.spyOn(global, 'onerror');
|
||||||
spyRegistry.clearSpies();
|
spyRegistry.clearSpies();
|
||||||
@@ -674,15 +674,15 @@ describe('SpyRegistry', function() {
|
|||||||
|
|
||||||
describe('spying on properties', function() {
|
describe('spying on properties', function() {
|
||||||
it('restores the original properties on the spied-upon objects', function() {
|
it('restores the original properties on the spied-upon objects', function() {
|
||||||
const spies = [],
|
const spies = [];
|
||||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||||
currentSpies: function() {
|
currentSpies: function() {
|
||||||
return spies;
|
return spies;
|
||||||
},
|
},
|
||||||
createSpy: createSpy
|
createSpy: createSpy
|
||||||
}),
|
});
|
||||||
originalReturn = 1,
|
const originalReturn = 1;
|
||||||
target = {};
|
const target = {};
|
||||||
|
|
||||||
Object.defineProperty(target, 'spiedProp', {
|
Object.defineProperty(target, 'spiedProp', {
|
||||||
get: function() {
|
get: function() {
|
||||||
@@ -698,15 +698,15 @@ describe('SpyRegistry', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does not add a property that the spied-upon object didn't originally have", function() {
|
it("does not add a property that the spied-upon object didn't originally have", function() {
|
||||||
const spies = [],
|
const spies = [];
|
||||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||||
currentSpies: function() {
|
currentSpies: function() {
|
||||||
return spies;
|
return spies;
|
||||||
},
|
},
|
||||||
createSpy: createSpy
|
createSpy: createSpy
|
||||||
}),
|
});
|
||||||
originalReturn = 1,
|
const originalReturn = 1;
|
||||||
targetParent = {};
|
const targetParent = {};
|
||||||
|
|
||||||
Object.defineProperty(targetParent, 'spiedProp', {
|
Object.defineProperty(targetParent, 'spiedProp', {
|
||||||
get: function() {
|
get: function() {
|
||||||
|
|||||||
@@ -106,8 +106,8 @@ describe('Spies', function() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (let arity = 0; arity < functions.length; arity++) {
|
for (let arity = 0; arity < functions.length; arity++) {
|
||||||
const someFunction = functions[arity],
|
const someFunction = functions[arity];
|
||||||
spy = env.createSpy(someFunction.name, someFunction);
|
const spy = env.createSpy(someFunction.name, someFunction);
|
||||||
|
|
||||||
expect(spy.length).toEqual(arity);
|
expect(spy.length).toEqual(arity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ describe('SpyStrategy', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('stubs an original function, if provided', function() {
|
it('stubs an original function, if provided', function() {
|
||||||
const originalFn = jasmine.createSpy('original'),
|
const originalFn = jasmine.createSpy('original');
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||||
|
|
||||||
spyStrategy.exec();
|
spyStrategy.exec();
|
||||||
|
|
||||||
@@ -21,8 +21,8 @@ describe('SpyStrategy', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("allows an original function to be called, passed through the params and returns it's value", function() {
|
it("allows an original function to be called, passed through the params and returns it's value", function() {
|
||||||
const originalFn = jasmine.createSpy('original').and.returnValue(42),
|
const originalFn = jasmine.createSpy('original').and.returnValue(42);
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||||
|
|
||||||
spyStrategy.callThrough();
|
spyStrategy.callThrough();
|
||||||
const returnValue = spyStrategy.exec(null, ['foo']);
|
const returnValue = spyStrategy.exec(null, ['foo']);
|
||||||
@@ -33,8 +33,8 @@ describe('SpyStrategy', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can return a specified value when executed', function() {
|
it('can return a specified value when executed', function() {
|
||||||
const originalFn = jasmine.createSpy('original'),
|
const originalFn = jasmine.createSpy('original');
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||||
|
|
||||||
spyStrategy.returnValue(17);
|
spyStrategy.returnValue(17);
|
||||||
const returnValue = spyStrategy.exec();
|
const returnValue = spyStrategy.exec();
|
||||||
@@ -44,8 +44,8 @@ describe('SpyStrategy', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can return specified values in order specified when executed', function() {
|
it('can return specified values in order specified when executed', function() {
|
||||||
const originalFn = jasmine.createSpy('original'),
|
const originalFn = jasmine.createSpy('original');
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||||
|
|
||||||
spyStrategy.returnValues('value1', 'value2', 'value3');
|
spyStrategy.returnValues('value1', 'value2', 'value3');
|
||||||
|
|
||||||
@@ -57,8 +57,8 @@ describe('SpyStrategy', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows an exception to be thrown when executed', function() {
|
it('allows an exception to be thrown when executed', function() {
|
||||||
const originalFn = jasmine.createSpy('original'),
|
const originalFn = jasmine.createSpy('original');
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||||
|
|
||||||
spyStrategy.throwError(new TypeError('bar'));
|
spyStrategy.throwError(new TypeError('bar'));
|
||||||
|
|
||||||
@@ -69,8 +69,8 @@ describe('SpyStrategy', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows a string to be thrown, wrapping it into an exception when executed', function() {
|
it('allows a string to be thrown, wrapping it into an exception when executed', function() {
|
||||||
const originalFn = jasmine.createSpy('original'),
|
const originalFn = jasmine.createSpy('original');
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||||
|
|
||||||
spyStrategy.throwError('bar');
|
spyStrategy.throwError('bar');
|
||||||
|
|
||||||
@@ -81,8 +81,8 @@ describe('SpyStrategy', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows a non-Error to be thrown when executed', function() {
|
it('allows a non-Error to be thrown when executed', function() {
|
||||||
const originalFn = jasmine.createSpy('original'),
|
const originalFn = jasmine.createSpy('original');
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||||
|
|
||||||
spyStrategy.throwError({ code: 'ESRCH' });
|
spyStrategy.throwError({ code: 'ESRCH' });
|
||||||
|
|
||||||
@@ -93,9 +93,9 @@ describe('SpyStrategy', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows a fake function to be called instead', function() {
|
it('allows a fake function to be called instead', function() {
|
||||||
const originalFn = jasmine.createSpy('original'),
|
const originalFn = jasmine.createSpy('original');
|
||||||
fakeFn = jasmine.createSpy('fake').and.returnValue(67),
|
const fakeFn = jasmine.createSpy('fake').and.returnValue(67);
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||||
|
|
||||||
spyStrategy.callFake(fakeFn);
|
spyStrategy.callFake(fakeFn);
|
||||||
const returnValue = spyStrategy.exec();
|
const returnValue = spyStrategy.exec();
|
||||||
@@ -105,11 +105,11 @@ describe('SpyStrategy', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows a fake async function to be called instead', function(done) {
|
it('allows a fake async function to be called instead', function(done) {
|
||||||
const originalFn = jasmine.createSpy('original'),
|
const originalFn = jasmine.createSpy('original');
|
||||||
fakeFn = jasmine.createSpy('fake').and.callFake(async () => {
|
const fakeFn = jasmine.createSpy('fake').and.callFake(async () => {
|
||||||
return 67;
|
return 67;
|
||||||
}),
|
});
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||||
|
|
||||||
spyStrategy.callFake(fakeFn);
|
spyStrategy.callFake(fakeFn);
|
||||||
spyStrategy
|
spyStrategy
|
||||||
@@ -127,10 +127,10 @@ describe('SpyStrategy', function() {
|
|||||||
|
|
||||||
describe('#resolveTo', function() {
|
describe('#resolveTo', function() {
|
||||||
it('allows a resolved promise to be returned', function(done) {
|
it('allows a resolved promise to be returned', function(done) {
|
||||||
const originalFn = jasmine.createSpy('original'),
|
const originalFn = jasmine.createSpy('original');
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
const spyStrategy = new privateUnderTest.SpyStrategy({
|
||||||
fn: originalFn
|
fn: originalFn
|
||||||
});
|
});
|
||||||
|
|
||||||
spyStrategy.resolveTo(37);
|
spyStrategy.resolveTo(37);
|
||||||
spyStrategy
|
spyStrategy
|
||||||
@@ -143,10 +143,10 @@ describe('SpyStrategy', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows an empty resolved promise to be returned', function(done) {
|
it('allows an empty resolved promise to be returned', function(done) {
|
||||||
const originalFn = jasmine.createSpy('original'),
|
const originalFn = jasmine.createSpy('original');
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
const spyStrategy = new privateUnderTest.SpyStrategy({
|
||||||
fn: originalFn
|
fn: originalFn
|
||||||
});
|
});
|
||||||
|
|
||||||
spyStrategy.resolveTo();
|
spyStrategy.resolveTo();
|
||||||
spyStrategy
|
spyStrategy
|
||||||
@@ -161,10 +161,10 @@ describe('SpyStrategy', function() {
|
|||||||
|
|
||||||
describe('#rejectWith', function() {
|
describe('#rejectWith', function() {
|
||||||
it('allows a rejected promise to be returned', function(done) {
|
it('allows a rejected promise to be returned', function(done) {
|
||||||
const originalFn = jasmine.createSpy('original'),
|
const originalFn = jasmine.createSpy('original');
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
const spyStrategy = new privateUnderTest.SpyStrategy({
|
||||||
fn: originalFn
|
fn: originalFn
|
||||||
});
|
});
|
||||||
|
|
||||||
spyStrategy.rejectWith(new Error('oops'));
|
spyStrategy.rejectWith(new Error('oops'));
|
||||||
spyStrategy
|
spyStrategy
|
||||||
@@ -178,10 +178,10 @@ describe('SpyStrategy', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows an empty rejected promise to be returned', function(done) {
|
it('allows an empty rejected promise to be returned', function(done) {
|
||||||
const originalFn = jasmine.createSpy('original'),
|
const originalFn = jasmine.createSpy('original');
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
const spyStrategy = new privateUnderTest.SpyStrategy({
|
||||||
fn: originalFn
|
fn: originalFn
|
||||||
});
|
});
|
||||||
|
|
||||||
spyStrategy.rejectWith();
|
spyStrategy.rejectWith();
|
||||||
spyStrategy
|
spyStrategy
|
||||||
@@ -195,10 +195,10 @@ describe('SpyStrategy', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows a non-Error to be rejected', function(done) {
|
it('allows a non-Error to be rejected', function(done) {
|
||||||
const originalFn = jasmine.createSpy('original'),
|
const originalFn = jasmine.createSpy('original');
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
const spyStrategy = new privateUnderTest.SpyStrategy({
|
||||||
fn: originalFn
|
fn: originalFn
|
||||||
});
|
});
|
||||||
|
|
||||||
spyStrategy.rejectWith('oops');
|
spyStrategy.rejectWith('oops');
|
||||||
spyStrategy
|
spyStrategy
|
||||||
@@ -214,18 +214,18 @@ describe('SpyStrategy', function() {
|
|||||||
|
|
||||||
it('allows a custom strategy to be used', function() {
|
it('allows a custom strategy to be used', function() {
|
||||||
const plan = jasmine
|
const plan = jasmine
|
||||||
.createSpy('custom strategy')
|
.createSpy('custom strategy')
|
||||||
.and.returnValue('custom strategy result'),
|
.and.returnValue('custom strategy result');
|
||||||
customStrategy = jasmine
|
const customStrategy = jasmine
|
||||||
.createSpy('custom strategy')
|
.createSpy('custom strategy')
|
||||||
.and.returnValue(plan),
|
.and.returnValue(plan);
|
||||||
originalFn = jasmine.createSpy('original'),
|
const originalFn = jasmine.createSpy('original');
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
const spyStrategy = new privateUnderTest.SpyStrategy({
|
||||||
fn: originalFn,
|
fn: originalFn,
|
||||||
customStrategies: {
|
customStrategies: {
|
||||||
doSomething: customStrategy
|
doSomething: customStrategy
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
spyStrategy.doSomething(1, 2, 3);
|
spyStrategy.doSomething(1, 2, 3);
|
||||||
expect(customStrategy).toHaveBeenCalledWith(1, 2, 3);
|
expect(customStrategy).toHaveBeenCalledWith(1, 2, 3);
|
||||||
@@ -236,15 +236,15 @@ describe('SpyStrategy', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("throws an error if a custom strategy doesn't return a function", function() {
|
it("throws an error if a custom strategy doesn't return a function", function() {
|
||||||
const originalFn = jasmine.createSpy('original'),
|
const originalFn = jasmine.createSpy('original');
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
const spyStrategy = new privateUnderTest.SpyStrategy({
|
||||||
fn: originalFn,
|
fn: originalFn,
|
||||||
customStrategies: {
|
customStrategies: {
|
||||||
doSomething: function() {
|
doSomething: function() {
|
||||||
return 'not a function';
|
return 'not a function';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
spyStrategy.doSomething(1, 2, 3);
|
spyStrategy.doSomething(1, 2, 3);
|
||||||
@@ -263,8 +263,8 @@ describe('SpyStrategy', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('throws an error when a non-function is passed to callFake strategy', function() {
|
it('throws an error when a non-function is passed to callFake strategy', function() {
|
||||||
const originalFn = jasmine.createSpy('original'),
|
const originalFn = jasmine.createSpy('original');
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
spyStrategy.callFake('not a function');
|
spyStrategy.callFake('not a function');
|
||||||
@@ -275,9 +275,9 @@ describe('SpyStrategy', function() {
|
|||||||
|
|
||||||
it('allows generator functions to be passed to callFake strategy', function() {
|
it('allows generator functions to be passed to callFake strategy', function() {
|
||||||
const generator = function*() {
|
const generator = function*() {
|
||||||
yield 'ok';
|
yield 'ok';
|
||||||
},
|
};
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: function() {} });
|
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: function() {} });
|
||||||
|
|
||||||
spyStrategy.callFake(generator);
|
spyStrategy.callFake(generator);
|
||||||
|
|
||||||
@@ -285,9 +285,9 @@ describe('SpyStrategy', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows a return to plan stubbing after another strategy', function() {
|
it('allows a return to plan stubbing after another strategy', function() {
|
||||||
const originalFn = jasmine.createSpy('original'),
|
const originalFn = jasmine.createSpy('original');
|
||||||
fakeFn = jasmine.createSpy('fake').and.returnValue(67),
|
const fakeFn = jasmine.createSpy('fake').and.returnValue(67);
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||||
|
|
||||||
spyStrategy.callFake(fakeFn);
|
spyStrategy.callFake(fakeFn);
|
||||||
let returnValue = spyStrategy.exec();
|
let returnValue = spyStrategy.exec();
|
||||||
@@ -302,9 +302,9 @@ describe('SpyStrategy', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns the spy after changing the strategy', function() {
|
it('returns the spy after changing the strategy', function() {
|
||||||
const spy = {},
|
const spy = {};
|
||||||
spyFn = jasmine.createSpy('spyFn').and.returnValue(spy),
|
const spyFn = jasmine.createSpy('spyFn').and.returnValue(spy);
|
||||||
spyStrategy = new privateUnderTest.SpyStrategy({ getSpy: spyFn });
|
const spyStrategy = new privateUnderTest.SpyStrategy({ getSpy: spyFn });
|
||||||
|
|
||||||
expect(spyStrategy.callThrough()).toBe(spy);
|
expect(spyStrategy.callThrough()).toBe(spy);
|
||||||
expect(spyStrategy.returnValue()).toBe(spy);
|
expect(spyStrategy.returnValue()).toBe(spy);
|
||||||
|
|||||||
@@ -30,26 +30,26 @@ describe('Suite', function() {
|
|||||||
|
|
||||||
it('returns its full name when it has parent suites', function() {
|
it('returns its full name when it has parent suites', function() {
|
||||||
const parentSuite = new privateUnderTest.Suite({
|
const parentSuite = new privateUnderTest.Suite({
|
||||||
env: env,
|
env: env,
|
||||||
description: 'I am a parent suite',
|
description: 'I am a parent suite',
|
||||||
parentSuite: jasmine.createSpy('pretend top level suite')
|
parentSuite: jasmine.createSpy('pretend top level suite')
|
||||||
}),
|
});
|
||||||
suite = new privateUnderTest.Suite({
|
const suite = new privateUnderTest.Suite({
|
||||||
env: env,
|
env: env,
|
||||||
description: 'I am a suite',
|
description: 'I am a suite',
|
||||||
parentSuite: parentSuite
|
parentSuite: parentSuite
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(suite.getFullName()).toEqual('I am a parent suite I am a suite');
|
expect(suite.getFullName()).toEqual('I am a parent suite I am a suite');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds beforeEach functions in order of needed execution', function() {
|
it('adds beforeEach functions in order of needed execution', function() {
|
||||||
const suite = new privateUnderTest.Suite({
|
const suite = new privateUnderTest.Suite({
|
||||||
env: env,
|
env: env,
|
||||||
description: 'I am a suite'
|
description: 'I am a suite'
|
||||||
}),
|
});
|
||||||
outerBefore = { fn: 'outerBeforeEach' },
|
const outerBefore = { fn: 'outerBeforeEach' };
|
||||||
innerBefore = { fn: 'insideBeforeEach' };
|
const innerBefore = { fn: 'insideBeforeEach' };
|
||||||
|
|
||||||
suite.beforeEach(outerBefore);
|
suite.beforeEach(outerBefore);
|
||||||
suite.beforeEach(innerBefore);
|
suite.beforeEach(innerBefore);
|
||||||
@@ -62,11 +62,11 @@ describe('Suite', function() {
|
|||||||
|
|
||||||
it('adds beforeAll functions in order of needed execution', function() {
|
it('adds beforeAll functions in order of needed execution', function() {
|
||||||
const suite = new privateUnderTest.Suite({
|
const suite = new privateUnderTest.Suite({
|
||||||
env: env,
|
env: env,
|
||||||
description: 'I am a suite'
|
description: 'I am a suite'
|
||||||
}),
|
});
|
||||||
outerBefore = { fn: 'outerBeforeAll' },
|
const outerBefore = { fn: 'outerBeforeAll' };
|
||||||
innerBefore = { fn: 'insideBeforeAll' };
|
const innerBefore = { fn: 'insideBeforeAll' };
|
||||||
|
|
||||||
suite.beforeAll(outerBefore);
|
suite.beforeAll(outerBefore);
|
||||||
suite.beforeAll(innerBefore);
|
suite.beforeAll(innerBefore);
|
||||||
@@ -79,11 +79,11 @@ describe('Suite', function() {
|
|||||||
|
|
||||||
it('adds afterEach functions in order of needed execution', function() {
|
it('adds afterEach functions in order of needed execution', function() {
|
||||||
const suite = new privateUnderTest.Suite({
|
const suite = new privateUnderTest.Suite({
|
||||||
env: env,
|
env: env,
|
||||||
description: 'I am a suite'
|
description: 'I am a suite'
|
||||||
}),
|
});
|
||||||
outerAfter = { fn: 'outerAfterEach' },
|
const outerAfter = { fn: 'outerAfterEach' };
|
||||||
innerAfter = { fn: 'insideAfterEach' };
|
const innerAfter = { fn: 'insideAfterEach' };
|
||||||
|
|
||||||
suite.afterEach(outerAfter);
|
suite.afterEach(outerAfter);
|
||||||
suite.afterEach(innerAfter);
|
suite.afterEach(innerAfter);
|
||||||
@@ -96,11 +96,11 @@ describe('Suite', function() {
|
|||||||
|
|
||||||
it('adds afterAll functions in order of needed execution', function() {
|
it('adds afterAll functions in order of needed execution', function() {
|
||||||
const suite = new privateUnderTest.Suite({
|
const suite = new privateUnderTest.Suite({
|
||||||
env: env,
|
env: env,
|
||||||
description: 'I am a suite'
|
description: 'I am a suite'
|
||||||
}),
|
});
|
||||||
outerAfter = { fn: 'outerAfterAll' },
|
const outerAfter = { fn: 'outerAfterAll' };
|
||||||
innerAfter = { fn: 'insideAfterAl' };
|
const innerAfter = { fn: 'insideAfterAl' };
|
||||||
|
|
||||||
suite.afterAll(outerAfter);
|
suite.afterAll(outerAfter);
|
||||||
suite.afterAll(innerAfter);
|
suite.afterAll(innerAfter);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
describe('Timer', function() {
|
describe('Timer', function() {
|
||||||
it('reports the time elapsed', function() {
|
it('reports the time elapsed', function() {
|
||||||
const fakeNow = jasmine.createSpy('fake Date.now'),
|
const fakeNow = jasmine.createSpy('fake Date.now');
|
||||||
timer = new jasmineUnderTest.Timer({ now: fakeNow });
|
const timer = new jasmineUnderTest.Timer({ now: fakeNow });
|
||||||
|
|
||||||
fakeNow.and.returnValue(100);
|
fakeNow.and.returnValue(100);
|
||||||
timer.start();
|
timer.start();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe('TreeProcessor', function() {
|
describe('TreeProcessor', function() {
|
||||||
let nodeNumber = 0,
|
let nodeNumber = 0;
|
||||||
leafNumber = 0;
|
let leafNumber = 0;
|
||||||
|
|
||||||
function Node(attrs) {
|
function Node(attrs) {
|
||||||
attrs = attrs || {};
|
attrs = attrs || {};
|
||||||
@@ -24,11 +24,11 @@ describe('TreeProcessor', function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('processes a single leaf', function() {
|
it('processes a single leaf', function() {
|
||||||
const leaf = new Leaf(),
|
const leaf = new Leaf();
|
||||||
processor = new privateUnderTest.TreeProcessor({
|
const processor = new privateUnderTest.TreeProcessor({
|
||||||
tree: leaf,
|
tree: leaf,
|
||||||
runnableIds: [leaf.id]
|
runnableIds: [leaf.id]
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = processor.processTree();
|
const result = processor.processTree();
|
||||||
|
|
||||||
@@ -36,11 +36,11 @@ describe('TreeProcessor', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('processes a single pending leaf', function() {
|
it('processes a single pending leaf', function() {
|
||||||
const leaf = new Leaf({ markedPending: true }),
|
const leaf = new Leaf({ markedPending: true });
|
||||||
processor = new privateUnderTest.TreeProcessor({
|
const processor = new privateUnderTest.TreeProcessor({
|
||||||
tree: leaf,
|
tree: leaf,
|
||||||
runnableIds: [leaf.id]
|
runnableIds: [leaf.id]
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = processor.processTree();
|
const result = processor.processTree();
|
||||||
|
|
||||||
@@ -48,11 +48,11 @@ describe('TreeProcessor', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('processes a single non-specified leaf', function() {
|
it('processes a single non-specified leaf', function() {
|
||||||
const leaf = new Leaf(),
|
const leaf = new Leaf();
|
||||||
processor = new privateUnderTest.TreeProcessor({
|
const processor = new privateUnderTest.TreeProcessor({
|
||||||
tree: leaf,
|
tree: leaf,
|
||||||
runnableIds: []
|
runnableIds: []
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = processor.processTree();
|
const result = processor.processTree();
|
||||||
|
|
||||||
@@ -60,14 +60,14 @@ describe('TreeProcessor', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('processes a single excluded leaf', function() {
|
it('processes a single excluded leaf', function() {
|
||||||
const leaf = new Leaf(),
|
const leaf = new Leaf();
|
||||||
processor = new privateUnderTest.TreeProcessor({
|
const processor = new privateUnderTest.TreeProcessor({
|
||||||
tree: leaf,
|
tree: leaf,
|
||||||
runnableIds: [leaf.id],
|
runnableIds: [leaf.id],
|
||||||
excludeNode: function() {
|
excludeNode: function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = processor.processTree();
|
const result = processor.processTree();
|
||||||
|
|
||||||
@@ -75,12 +75,12 @@ describe('TreeProcessor', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('processes a tree with a single leaf with the root specified', function() {
|
it('processes a tree with a single leaf with the root specified', function() {
|
||||||
const leaf = new Leaf(),
|
const leaf = new Leaf();
|
||||||
parent = new Node({ children: [leaf] }),
|
const parent = new Node({ children: [leaf] });
|
||||||
processor = new privateUnderTest.TreeProcessor({
|
const processor = new privateUnderTest.TreeProcessor({
|
||||||
tree: parent,
|
tree: parent,
|
||||||
runnableIds: [parent.id]
|
runnableIds: [parent.id]
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = processor.processTree();
|
const result = processor.processTree();
|
||||||
|
|
||||||
@@ -90,12 +90,12 @@ describe('TreeProcessor', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('processes a tree with a single pending leaf, with the root specified', function() {
|
it('processes a tree with a single pending leaf, with the root specified', function() {
|
||||||
const leaf = new Leaf({ markedPending: true }),
|
const leaf = new Leaf({ markedPending: true });
|
||||||
parent = new Node({ children: [leaf] }),
|
const parent = new Node({ children: [leaf] });
|
||||||
processor = new privateUnderTest.TreeProcessor({
|
const processor = new privateUnderTest.TreeProcessor({
|
||||||
tree: parent,
|
tree: parent,
|
||||||
runnableIds: [parent.id]
|
runnableIds: [parent.id]
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = processor.processTree();
|
const result = processor.processTree();
|
||||||
|
|
||||||
@@ -139,24 +139,24 @@ describe('TreeProcessor', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('processes a complicated tree with the root specified', function() {
|
it('processes a complicated tree with the root specified', function() {
|
||||||
const pendingLeaf = new Leaf({ markedPending: true }),
|
const pendingLeaf = new Leaf({ markedPending: true });
|
||||||
executableLeaf = new Leaf({ markedPending: false }),
|
const executableLeaf = new Leaf({ markedPending: false });
|
||||||
parent = new Node({ children: [pendingLeaf, executableLeaf] }),
|
const parent = new Node({ children: [pendingLeaf, executableLeaf] });
|
||||||
childless = new Node(),
|
const childless = new Node();
|
||||||
childOfPending = new Leaf({ markedPending: true }),
|
const childOfPending = new Leaf({ markedPending: true });
|
||||||
pendingNode = new Node({
|
const pendingNode = new Node({
|
||||||
markedPending: true,
|
markedPending: true,
|
||||||
children: [childOfPending]
|
children: [childOfPending]
|
||||||
}),
|
});
|
||||||
parentOfPendings = new Node({
|
const parentOfPendings = new Node({
|
||||||
markedPending: false,
|
markedPending: false,
|
||||||
children: [childless, pendingNode]
|
children: [childless, pendingNode]
|
||||||
}),
|
});
|
||||||
root = new Node({ children: [parent, parentOfPendings] }),
|
const root = new Node({ children: [parent, parentOfPendings] });
|
||||||
processor = new privateUnderTest.TreeProcessor({
|
const processor = new privateUnderTest.TreeProcessor({
|
||||||
tree: root,
|
tree: root,
|
||||||
runnableIds: [root.id]
|
runnableIds: [root.id]
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = processor.processTree();
|
const result = processor.processTree();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
describe('UserContext', function() {
|
describe('UserContext', function() {
|
||||||
it('Behaves just like an plain object', function() {
|
it('Behaves just like an plain object', function() {
|
||||||
const context = new privateUnderTest.UserContext(),
|
const context = new privateUnderTest.UserContext();
|
||||||
properties = [];
|
const properties = [];
|
||||||
|
|
||||||
for (const prop in context) {
|
for (const prop in context) {
|
||||||
if (obj.hasOwnProperty(prop)) {
|
if (obj.hasOwnProperty(prop)) {
|
||||||
|
|||||||
@@ -142,17 +142,17 @@ describe('util', function() {
|
|||||||
|
|
||||||
describe('getPropertyDescriptor', function() {
|
describe('getPropertyDescriptor', function() {
|
||||||
it('get property descriptor from object', function() {
|
it('get property descriptor from object', function() {
|
||||||
const obj = { prop: 1 },
|
const obj = { prop: 1 };
|
||||||
actual = privateUnderTest.util.getPropertyDescriptor(obj, 'prop'),
|
const actual = privateUnderTest.util.getPropertyDescriptor(obj, 'prop');
|
||||||
expected = Object.getOwnPropertyDescriptor(obj, 'prop');
|
const expected = Object.getOwnPropertyDescriptor(obj, 'prop');
|
||||||
|
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('get property descriptor from object property', function() {
|
it('get property descriptor from object property', function() {
|
||||||
const proto = { prop: 1 },
|
const proto = { prop: 1 };
|
||||||
actual = privateUnderTest.util.getPropertyDescriptor(proto, 'prop'),
|
const actual = privateUnderTest.util.getPropertyDescriptor(proto, 'prop');
|
||||||
expected = Object.getOwnPropertyDescriptor(proto, 'prop');
|
const expected = Object.getOwnPropertyDescriptor(proto, 'prop');
|
||||||
|
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ describe('Any', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('matches another constructed object', function() {
|
it('matches another constructed object', function() {
|
||||||
const Thing = function() {},
|
const Thing = function() {};
|
||||||
any = new privateUnderTest.Any(Thing);
|
const any = new privateUnderTest.Any(Thing);
|
||||||
|
|
||||||
expect(any.asymmetricMatch(new Thing())).toBe(true);
|
expect(any.asymmetricMatch(new Thing())).toBe(true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ describe('ArrayContaining', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('jasmineToStrings itself', function() {
|
it('jasmineToStrings itself', function() {
|
||||||
const sample = [],
|
const sample = [];
|
||||||
matcher = new privateUnderTest.ArrayContaining(sample),
|
const matcher = new privateUnderTest.ArrayContaining(sample);
|
||||||
pp = jasmine.createSpy('pp').and.returnValue('sample');
|
const pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||||
|
|
||||||
expect(matcher.jasmineToString(pp)).toEqual(
|
expect(matcher.jasmineToString(pp)).toEqual(
|
||||||
'<jasmine.arrayContaining(sample)>'
|
'<jasmine.arrayContaining(sample)>'
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ describe('ArrayWithExactContents', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('jasmineToStrings itself', function() {
|
it('jasmineToStrings itself', function() {
|
||||||
const sample = [],
|
const sample = [];
|
||||||
matcher = new privateUnderTest.ArrayWithExactContents(sample),
|
const matcher = new privateUnderTest.ArrayWithExactContents(sample);
|
||||||
pp = jasmine.createSpy('pp').and.returnValue('sample');
|
const pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||||
|
|
||||||
expect(matcher.jasmineToString(pp)).toEqual(
|
expect(matcher.jasmineToString(pp)).toEqual(
|
||||||
'<jasmine.arrayWithExactContents(sample)>'
|
'<jasmine.arrayWithExactContents(sample)>'
|
||||||
|
|||||||
@@ -151,9 +151,9 @@ describe('MapContaining', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('defines a `jasmineToString` method', function() {
|
it('defines a `jasmineToString` method', function() {
|
||||||
const sample = new Map(),
|
const sample = new Map();
|
||||||
containing = new privateUnderTest.MapContaining(sample),
|
const containing = new privateUnderTest.MapContaining(sample);
|
||||||
pp = jasmine.createSpy('pp').and.returnValue('sample');
|
const pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||||
|
|
||||||
expect(containing.jasmineToString(pp)).toEqual(
|
expect(containing.jasmineToString(pp)).toEqual(
|
||||||
'<jasmine.mapContaining(sample)>'
|
'<jasmine.mapContaining(sample)>'
|
||||||
|
|||||||
@@ -53,9 +53,9 @@ describe('ObjectContaining', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("jasmineToString's itself", function() {
|
it("jasmineToString's itself", function() {
|
||||||
const sample = {},
|
const sample = {};
|
||||||
matcher = new privateUnderTest.ObjectContaining(sample),
|
const matcher = new privateUnderTest.ObjectContaining(sample);
|
||||||
pp = jasmine.createSpy('pp').and.returnValue('sample');
|
const pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||||
|
|
||||||
expect(matcher.jasmineToString(pp)).toEqual(
|
expect(matcher.jasmineToString(pp)).toEqual(
|
||||||
'<jasmine.objectContaining(sample)>'
|
'<jasmine.objectContaining(sample)>'
|
||||||
@@ -144,9 +144,9 @@ describe('ObjectContaining', function() {
|
|||||||
describe('valuesForDiff_', function() {
|
describe('valuesForDiff_', function() {
|
||||||
describe('when other is not an object', function() {
|
describe('when other is not an object', function() {
|
||||||
it('sets self to jasmineToString()', function() {
|
it('sets self to jasmineToString()', function() {
|
||||||
const containing = new privateUnderTest.ObjectContaining({}),
|
const containing = new privateUnderTest.ObjectContaining({});
|
||||||
pp = privateUnderTest.makePrettyPrinter(),
|
const pp = privateUnderTest.makePrettyPrinter();
|
||||||
result = containing.valuesForDiff_('a', pp);
|
const result = containing.valuesForDiff_('a', pp);
|
||||||
|
|
||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
self: '<jasmine.objectContaining(Object({ }))>',
|
self: '<jasmine.objectContaining(Object({ }))>',
|
||||||
@@ -157,10 +157,10 @@ describe('ObjectContaining', function() {
|
|||||||
|
|
||||||
describe('when other is an object', function() {
|
describe('when other is an object', function() {
|
||||||
it('includes keys that are present in both other and sample', function() {
|
it('includes keys that are present in both other and sample', function() {
|
||||||
const sample = { a: 1, b: 2 },
|
const sample = { a: 1, b: 2 };
|
||||||
other = { a: 3, b: 4 },
|
const other = { a: 3, b: 4 };
|
||||||
containing = new privateUnderTest.ObjectContaining(sample),
|
const containing = new privateUnderTest.ObjectContaining(sample);
|
||||||
result = containing.valuesForDiff_(other);
|
const result = containing.valuesForDiff_(other);
|
||||||
|
|
||||||
expect(result.self).not.toBeInstanceOf(
|
expect(result.self).not.toBeInstanceOf(
|
||||||
privateUnderTest.ObjectContaining
|
privateUnderTest.ObjectContaining
|
||||||
@@ -172,10 +172,10 @@ describe('ObjectContaining', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('includes keys that are present only in sample', function() {
|
it('includes keys that are present only in sample', function() {
|
||||||
const sample = { a: 1, b: 2 },
|
const sample = { a: 1, b: 2 };
|
||||||
other = { a: 3 },
|
const other = { a: 3 };
|
||||||
containing = new privateUnderTest.ObjectContaining(sample),
|
const containing = new privateUnderTest.ObjectContaining(sample);
|
||||||
result = containing.valuesForDiff_(other);
|
const result = containing.valuesForDiff_(other);
|
||||||
|
|
||||||
expect(result.self).not.toBeInstanceOf(
|
expect(result.self).not.toBeInstanceOf(
|
||||||
privateUnderTest.ObjectContaining
|
privateUnderTest.ObjectContaining
|
||||||
@@ -190,10 +190,10 @@ describe('ObjectContaining', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('omits keys that are present only in other', function() {
|
it('omits keys that are present only in other', function() {
|
||||||
const sample = { a: 1, b: 2 },
|
const sample = { a: 1, b: 2 };
|
||||||
other = { a: 3, b: 4, c: 5 },
|
const other = { a: 3, b: 4, c: 5 };
|
||||||
containing = new privateUnderTest.ObjectContaining(sample),
|
const containing = new privateUnderTest.ObjectContaining(sample);
|
||||||
result = containing.valuesForDiff_(other);
|
const result = containing.valuesForDiff_(other);
|
||||||
|
|
||||||
expect(result.self).not.toBeInstanceOf(
|
expect(result.self).not.toBeInstanceOf(
|
||||||
privateUnderTest.ObjectContaining
|
privateUnderTest.ObjectContaining
|
||||||
|
|||||||
@@ -103,9 +103,9 @@ describe('SetContaining', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('defines a `jasmineToString` method', function() {
|
it('defines a `jasmineToString` method', function() {
|
||||||
const sample = new Set(),
|
const sample = new Set();
|
||||||
containing = new privateUnderTest.SetContaining(sample),
|
const containing = new privateUnderTest.SetContaining(sample);
|
||||||
pp = jasmine.createSpy('pp').and.returnValue('sample');
|
const pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||||
|
|
||||||
expect(containing.jasmineToString(pp)).toEqual(
|
expect(containing.jasmineToString(pp)).toEqual(
|
||||||
'<jasmine.setContaining(sample)>'
|
'<jasmine.setContaining(sample)>'
|
||||||
|
|||||||
@@ -145,8 +145,8 @@ describe('base helpers', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('is consistent with setTimeout in this environment', function(done) {
|
it('is consistent with setTimeout in this environment', function(done) {
|
||||||
const f1 = jasmine.createSpy('setTimeout callback for ' + max),
|
const f1 = jasmine.createSpy('setTimeout callback for ' + max);
|
||||||
f2 = jasmine.createSpy('setTimeout callback for ' + (max + 1));
|
const f2 = jasmine.createSpy('setTimeout callback for ' + (max + 1));
|
||||||
|
|
||||||
// Suppress printing of TimeoutOverflowWarning in node
|
// Suppress printing of TimeoutOverflowWarning in node
|
||||||
if (typeof process !== 'undefined' && process.emitWarning) {
|
if (typeof process !== 'undefined' && process.emitWarning) {
|
||||||
|
|||||||
@@ -86,16 +86,16 @@ describe('Custom Async Matchers (Integration)', function() {
|
|||||||
|
|
||||||
it('passes the jasmine utility to the matcher factory', async function() {
|
it('passes the jasmine utility to the matcher factory', async function() {
|
||||||
const matcherFactory = function() {
|
const matcherFactory = function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return Promise.resolve({ pass: true });
|
return Promise.resolve({ pass: true });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
};
|
||||||
matcherFactorySpy = jasmine.createSpy(
|
const matcherFactorySpy = jasmine.createSpy(
|
||||||
'matcherFactorySpy',
|
'matcherFactorySpy',
|
||||||
matcherFactory
|
matcherFactory
|
||||||
);
|
);
|
||||||
|
|
||||||
env.it('spec with expectation', function() {
|
env.it('spec with expectation', function() {
|
||||||
env.addAsyncMatchers({
|
env.addAsyncMatchers({
|
||||||
@@ -117,19 +117,19 @@ describe('Custom Async Matchers (Integration)', function() {
|
|||||||
|
|
||||||
it('provides custom equality testers to the matcher factory via matchersUtil', async function() {
|
it('provides custom equality testers to the matcher factory via matchersUtil', async function() {
|
||||||
const matcherFactory = function(matchersUtil) {
|
const matcherFactory = function(matchersUtil) {
|
||||||
return {
|
return {
|
||||||
compare: function(actual, expected) {
|
compare: function(actual, expected) {
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
pass: matchersUtil.equals(actual[0], expected)
|
pass: matchersUtil.equals(actual[0], expected)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
};
|
||||||
customEqualityFn = jasmine
|
const customEqualityFn = jasmine
|
||||||
.createSpy('customEqualityFn')
|
.createSpy('customEqualityFn')
|
||||||
.and.callFake(function(a, b) {
|
.and.callFake(function(a, b) {
|
||||||
return a.toString() === b;
|
return a.toString() === b;
|
||||||
});
|
});
|
||||||
|
|
||||||
env.it('spec with expectation', function() {
|
env.it('spec with expectation', function() {
|
||||||
env.addCustomEqualityTester(customEqualityFn);
|
env.addCustomEqualityTester(customEqualityFn);
|
||||||
|
|||||||
@@ -210,15 +210,15 @@ describe('Custom Matchers (Integration)', function() {
|
|||||||
|
|
||||||
it('passes the jasmine utility to the matcher factory', async function() {
|
it('passes the jasmine utility to the matcher factory', async function() {
|
||||||
const matcherFactory = function() {
|
const matcherFactory = function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
return { pass: true };
|
return { pass: true };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
};
|
||||||
matcherFactorySpy = jasmine
|
const matcherFactorySpy = jasmine
|
||||||
.createSpy('matcherFactorySpy')
|
.createSpy('matcherFactorySpy')
|
||||||
.and.callFake(matcherFactory);
|
.and.callFake(matcherFactory);
|
||||||
|
|
||||||
env.it('spec with expectation', function() {
|
env.it('spec with expectation', function() {
|
||||||
env.addMatchers({
|
env.addMatchers({
|
||||||
@@ -236,17 +236,17 @@ describe('Custom Matchers (Integration)', function() {
|
|||||||
|
|
||||||
it('provides custom equality testers to the matcher factory via matchersUtil', async function() {
|
it('provides custom equality testers to the matcher factory via matchersUtil', async function() {
|
||||||
const matcherFactory = function(matchersUtil) {
|
const matcherFactory = function(matchersUtil) {
|
||||||
return {
|
return {
|
||||||
compare: function(actual, expected) {
|
compare: function(actual, expected) {
|
||||||
return { pass: matchersUtil.equals(actual[0], expected) };
|
return { pass: matchersUtil.equals(actual[0], expected) };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
};
|
||||||
customEqualityFn = jasmine
|
const customEqualityFn = jasmine
|
||||||
.createSpy('customEqualityFn')
|
.createSpy('customEqualityFn')
|
||||||
.and.callFake(function(a, b) {
|
.and.callFake(function(a, b) {
|
||||||
return a.toString() === b;
|
return a.toString() === b;
|
||||||
});
|
});
|
||||||
|
|
||||||
env.it('spec with expectation', function() {
|
env.it('spec with expectation', function() {
|
||||||
env.addCustomEqualityTester(customEqualityFn);
|
env.addCustomEqualityTester(customEqualityFn);
|
||||||
|
|||||||
@@ -82,11 +82,11 @@ describe('Custom Spy Strategies (Integration)', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows multiple custom strategies to be used', async function() {
|
it('allows multiple custom strategies to be used', async function() {
|
||||||
const plan1 = jasmine.createSpy('plan 1').and.returnValue(42),
|
const plan1 = jasmine.createSpy('plan 1').and.returnValue(42);
|
||||||
strategy1 = jasmine.createSpy('strat 1').and.returnValue(plan1),
|
const strategy1 = jasmine.createSpy('strat 1').and.returnValue(plan1);
|
||||||
plan2 = jasmine.createSpy('plan 2').and.returnValue(24),
|
const plan2 = jasmine.createSpy('plan 2').and.returnValue(24);
|
||||||
strategy2 = jasmine.createSpy('strat 2').and.returnValue(plan2),
|
const strategy2 = jasmine.createSpy('strat 2').and.returnValue(plan2);
|
||||||
specDone = jasmine.createSpy('specDone');
|
const specDone = jasmine.createSpy('specDone');
|
||||||
|
|
||||||
env.beforeEach(function() {
|
env.beforeEach(function() {
|
||||||
env.addSpyStrategy('frobnicate', strategy1);
|
env.addSpyStrategy('frobnicate', strategy1);
|
||||||
|
|||||||
@@ -246,8 +246,8 @@ describe('Env integration', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('calls associated beforeAlls/afterAlls only once per suite', async function() {
|
it('calls associated beforeAlls/afterAlls only once per suite', async function() {
|
||||||
const before = jasmine.createSpy('beforeAll'),
|
const before = jasmine.createSpy('beforeAll');
|
||||||
after = jasmine.createSpy('afterAll');
|
const after = jasmine.createSpy('afterAll');
|
||||||
|
|
||||||
env.describe('with beforeAll and afterAll', function() {
|
env.describe('with beforeAll and afterAll', function() {
|
||||||
env.it('spec', function() {
|
env.it('spec', function() {
|
||||||
@@ -272,8 +272,8 @@ describe('Env integration', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('calls associated beforeAlls/afterAlls only once per suite for async', async function() {
|
it('calls associated beforeAlls/afterAlls only once per suite for async', async function() {
|
||||||
const before = jasmine.createSpy('beforeAll'),
|
const before = jasmine.createSpy('beforeAll');
|
||||||
after = jasmine.createSpy('afterAll');
|
const after = jasmine.createSpy('afterAll');
|
||||||
|
|
||||||
env.describe('with beforeAll and afterAll', function() {
|
env.describe('with beforeAll and afterAll', function() {
|
||||||
env.it('spec', function() {
|
env.it('spec', function() {
|
||||||
@@ -675,8 +675,8 @@ describe('Env integration', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('reports when afterAll throws an exception', async function() {
|
it('reports when afterAll throws an exception', async function() {
|
||||||
const error = new Error('After All Exception'),
|
const error = new Error('After All Exception');
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']);
|
const reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']);
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
|
|
||||||
@@ -719,8 +719,8 @@ describe('Env integration', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('reports when an async afterAll throws an exception', async function() {
|
it('reports when an async afterAll throws an exception', async function() {
|
||||||
const error = new Error('After All Exception'),
|
const error = new Error('After All Exception');
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']);
|
const reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']);
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
|
|
||||||
@@ -838,8 +838,8 @@ describe('Env integration', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Allows specifying which specs and suites to run', async function() {
|
it('Allows specifying which specs and suites to run', async function() {
|
||||||
const calls = [],
|
const calls = [];
|
||||||
suiteCallback = jasmine.createSpy('suite callback');
|
const suiteCallback = jasmine.createSpy('suite callback');
|
||||||
let firstSpec;
|
let firstSpec;
|
||||||
let secondSuite;
|
let secondSuite;
|
||||||
|
|
||||||
@@ -892,8 +892,8 @@ describe('Env integration', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Allows filtering out specs and suites to run programmatically', async function() {
|
it('Allows filtering out specs and suites to run programmatically', async function() {
|
||||||
const calls = [],
|
const calls = [];
|
||||||
suiteCallback = jasmine.createSpy('suite callback');
|
const suiteCallback = jasmine.createSpy('suite callback');
|
||||||
|
|
||||||
env.addReporter({ suiteDone: suiteCallback });
|
env.addReporter({ suiteDone: suiteCallback });
|
||||||
|
|
||||||
@@ -1026,16 +1026,16 @@ describe('Env integration', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('removes all spies added in a spec after the spec is complete', async function() {
|
it('removes all spies added in a spec after the spec is complete', async function() {
|
||||||
const originalFoo = function() {},
|
const originalFoo = function() {};
|
||||||
testObj = {
|
const testObj = {
|
||||||
foo: originalFoo
|
foo: originalFoo
|
||||||
},
|
};
|
||||||
firstSpec = jasmine.createSpy('firstSpec').and.callFake(function() {
|
const firstSpec = jasmine.createSpy('firstSpec').and.callFake(function() {
|
||||||
env.spyOn(testObj, 'foo');
|
env.spyOn(testObj, 'foo');
|
||||||
}),
|
});
|
||||||
secondSpec = jasmine.createSpy('secondSpec').and.callFake(function() {
|
const secondSpec = jasmine.createSpy('secondSpec').and.callFake(function() {
|
||||||
expect(testObj.foo).toBe(originalFoo);
|
expect(testObj.foo).toBe(originalFoo);
|
||||||
});
|
});
|
||||||
env.describe('test suite', function() {
|
env.describe('test suite', function() {
|
||||||
env.it('spec 0', firstSpec);
|
env.it('spec 0', firstSpec);
|
||||||
env.it('spec 1', secondSpec);
|
env.it('spec 1', secondSpec);
|
||||||
@@ -1049,10 +1049,10 @@ describe('Env integration', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('removes all spies added in a suite after the suite is complete', async function() {
|
it('removes all spies added in a suite after the suite is complete', async function() {
|
||||||
const originalFoo = function() {},
|
const originalFoo = function() {};
|
||||||
testObj = {
|
const testObj = {
|
||||||
foo: originalFoo
|
foo: originalFoo
|
||||||
};
|
};
|
||||||
|
|
||||||
env.describe('test suite', function() {
|
env.describe('test suite', function() {
|
||||||
env.beforeAll(function() {
|
env.beforeAll(function() {
|
||||||
@@ -1078,10 +1078,10 @@ describe('Env integration', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('removes a spy from the top suite after the run is complete', async function() {
|
it('removes a spy from the top suite after the run is complete', async function() {
|
||||||
const originalFoo = function() {},
|
const originalFoo = function() {};
|
||||||
testObj = {
|
const testObj = {
|
||||||
foo: originalFoo
|
foo: originalFoo
|
||||||
};
|
};
|
||||||
|
|
||||||
env.beforeAll(function() {
|
env.beforeAll(function() {
|
||||||
env.spyOn(testObj, 'foo');
|
env.spyOn(testObj, 'foo');
|
||||||
@@ -1098,16 +1098,16 @@ describe('Env integration', function() {
|
|||||||
|
|
||||||
it('Mock clock can be installed and used in tests', async function() {
|
it('Mock clock can be installed and used in tests', async function() {
|
||||||
const globalSetTimeout = jasmine
|
const globalSetTimeout = jasmine
|
||||||
.createSpy('globalSetTimeout')
|
.createSpy('globalSetTimeout')
|
||||||
.and.callFake(function(cb, t) {
|
.and.callFake(function(cb, t) {
|
||||||
return setTimeout(cb, t);
|
return setTimeout(cb, t);
|
||||||
}),
|
});
|
||||||
delayedFunctionForGlobalClock = jasmine.createSpy(
|
const delayedFunctionForGlobalClock = jasmine.createSpy(
|
||||||
'delayedFunctionForGlobalClock'
|
'delayedFunctionForGlobalClock'
|
||||||
),
|
);
|
||||||
delayedFunctionForMockClock = jasmine.createSpy(
|
const delayedFunctionForMockClock = jasmine.createSpy(
|
||||||
'delayedFunctionForMockClock'
|
'delayedFunctionForMockClock'
|
||||||
);
|
);
|
||||||
|
|
||||||
env.cleanup_();
|
env.cleanup_();
|
||||||
env = new privateUnderTest.Env({
|
env = new privateUnderTest.Env({
|
||||||
@@ -1255,8 +1255,8 @@ describe('Env integration', function() {
|
|||||||
|
|
||||||
it('should not use the mock clock for asynchronous timeouts', async function() {
|
it('should not use the mock clock for asynchronous timeouts', async function() {
|
||||||
createMockedEnv();
|
createMockedEnv();
|
||||||
const reporter = jasmine.createSpyObj('fakeReporter', ['specDone']),
|
const reporter = jasmine.createSpyObj('fakeReporter', ['specDone']);
|
||||||
clock = env.clock;
|
const clock = env.clock;
|
||||||
|
|
||||||
reporter.specDone.and.callFake(function() {
|
reporter.specDone.and.callFake(function() {
|
||||||
realSetTimeout(function() {
|
realSetTimeout(function() {
|
||||||
@@ -2121,8 +2121,8 @@ describe('Env integration', function() {
|
|||||||
|
|
||||||
await env.execute();
|
await env.execute();
|
||||||
|
|
||||||
const firstSpecResult = reporter.specDone.calls.first().args[0],
|
const firstSpecResult = reporter.specDone.calls.first().args[0];
|
||||||
secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
const secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
||||||
|
|
||||||
expect(firstSpecResult.status).toEqual('passed');
|
expect(firstSpecResult.status).toEqual('passed');
|
||||||
expect(secondSpecResult.status).toEqual('failed');
|
expect(secondSpecResult.status).toEqual('failed');
|
||||||
@@ -2158,9 +2158,9 @@ describe('Env integration', function() {
|
|||||||
|
|
||||||
await env.execute();
|
await env.execute();
|
||||||
|
|
||||||
const firstSpecResult = reporter.specDone.calls.first().args[0],
|
const firstSpecResult = reporter.specDone.calls.first().args[0];
|
||||||
secondSpecResult = reporter.specDone.calls.argsFor(0)[0],
|
const secondSpecResult = reporter.specDone.calls.argsFor(0)[0];
|
||||||
thirdSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
const thirdSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
||||||
|
|
||||||
expect(firstSpecResult.status).toEqual('passed');
|
expect(firstSpecResult.status).toEqual('passed');
|
||||||
expect(secondSpecResult.status).toEqual('passed');
|
expect(secondSpecResult.status).toEqual('passed');
|
||||||
@@ -2188,8 +2188,8 @@ describe('Env integration', function() {
|
|||||||
|
|
||||||
await env.execute();
|
await env.execute();
|
||||||
|
|
||||||
const firstSpecResult = reporter.specDone.calls.first().args[0],
|
const firstSpecResult = reporter.specDone.calls.first().args[0];
|
||||||
secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
const secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
||||||
|
|
||||||
expect(firstSpecResult.status).toEqual('passed');
|
expect(firstSpecResult.status).toEqual('passed');
|
||||||
expect(secondSpecResult.status).toEqual('failed');
|
expect(secondSpecResult.status).toEqual('failed');
|
||||||
@@ -2240,9 +2240,9 @@ describe('Env integration', function() {
|
|||||||
|
|
||||||
await env.execute();
|
await env.execute();
|
||||||
|
|
||||||
const firstSpecResult = reporter.specDone.calls.first().args[0],
|
const firstSpecResult = reporter.specDone.calls.first().args[0];
|
||||||
secondSpecResult = reporter.specDone.calls.argsFor(1)[0],
|
const secondSpecResult = reporter.specDone.calls.argsFor(1)[0];
|
||||||
thirdSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
const thirdSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
||||||
|
|
||||||
expect(firstSpecResult.status).toEqual('passed');
|
expect(firstSpecResult.status).toEqual('passed');
|
||||||
expect(secondSpecResult.status).toEqual('passed');
|
expect(secondSpecResult.status).toEqual('passed');
|
||||||
@@ -2410,8 +2410,11 @@ describe('Env integration', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('reports test properties on specs', async function() {
|
it('reports test properties on specs', async function() {
|
||||||
const env = new privateUnderTest.Env(),
|
const env = new privateUnderTest.Env();
|
||||||
reporter = jasmine.createSpyObj('reporter', ['suiteDone', 'specDone']);
|
const reporter = jasmine.createSpyObj('reporter', [
|
||||||
|
'suiteDone',
|
||||||
|
'specDone'
|
||||||
|
]);
|
||||||
|
|
||||||
reporter.specDone.and.callFake(function(e) {
|
reporter.specDone.and.callFake(function(e) {
|
||||||
expect(e.properties).toEqual({
|
expect(e.properties).toEqual({
|
||||||
@@ -2464,12 +2467,12 @@ describe('Env integration', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('reports test properties on suites', async function() {
|
it('reports test properties on suites', async function() {
|
||||||
const env = new privateUnderTest.Env(),
|
const env = new privateUnderTest.Env();
|
||||||
reporter = jasmine.createSpyObj('reporter', [
|
const reporter = jasmine.createSpyObj('reporter', [
|
||||||
'jasmineDone',
|
'jasmineDone',
|
||||||
'suiteDone',
|
'suiteDone',
|
||||||
'specDone'
|
'specDone'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
reporter.suiteDone.and.callFake(function(e) {
|
reporter.suiteDone.and.callFake(function(e) {
|
||||||
expect(e.properties).toEqual({ b: 'Sweet' });
|
expect(e.properties).toEqual({ b: 'Sweet' });
|
||||||
@@ -2937,15 +2940,15 @@ describe('Env integration', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should report deprecation stack with an error object', async function() {
|
it('should report deprecation stack with an error object', async function() {
|
||||||
const exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
const exceptionFormatter = new privateUnderTest.ExceptionFormatter();
|
||||||
reporter = jasmine.createSpyObj('reporter', [
|
const reporter = jasmine.createSpyObj('reporter', [
|
||||||
'jasmineDone',
|
'jasmineDone',
|
||||||
'suiteDone',
|
'suiteDone',
|
||||||
'specDone'
|
'specDone'
|
||||||
]),
|
]);
|
||||||
topLevelError = new Error('top level deprecation'),
|
const topLevelError = new Error('top level deprecation');
|
||||||
suiteLevelError = new Error('suite level deprecation'),
|
const suiteLevelError = new Error('suite level deprecation');
|
||||||
specLevelError = new Error('spec level deprecation');
|
const specLevelError = new Error('spec level deprecation');
|
||||||
|
|
||||||
// prevent deprecation from being displayed
|
// prevent deprecation from being displayed
|
||||||
spyOn(console, 'error');
|
spyOn(console, 'error');
|
||||||
@@ -3004,9 +3007,9 @@ describe('Env integration', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('supports async matchers', async function() {
|
it('supports async matchers', async function() {
|
||||||
const specDone = jasmine.createSpy('specDone'),
|
const specDone = jasmine.createSpy('specDone');
|
||||||
suiteDone = jasmine.createSpy('suiteDone'),
|
const suiteDone = jasmine.createSpy('suiteDone');
|
||||||
jasmineDone = jasmine.createSpy('jasmineDone');
|
const jasmineDone = jasmine.createSpy('jasmineDone');
|
||||||
|
|
||||||
env.addReporter({
|
env.addReporter({
|
||||||
specDone: specDone,
|
specDone: specDone,
|
||||||
|
|||||||
@@ -560,16 +560,16 @@ describe('Matchers (Integration)', function() {
|
|||||||
|
|
||||||
describe('toHaveBeenCalledBefore', function() {
|
describe('toHaveBeenCalledBefore', function() {
|
||||||
verifyPasses(function(env) {
|
verifyPasses(function(env) {
|
||||||
const a = env.createSpy('a'),
|
const a = env.createSpy('a');
|
||||||
b = env.createSpy('b');
|
const b = env.createSpy('b');
|
||||||
a();
|
a();
|
||||||
b();
|
b();
|
||||||
env.expect(a).toHaveBeenCalledBefore(b);
|
env.expect(a).toHaveBeenCalledBefore(b);
|
||||||
});
|
});
|
||||||
|
|
||||||
verifyFails(function(env) {
|
verifyFails(function(env) {
|
||||||
const a = env.createSpy('a'),
|
const a = env.createSpy('a');
|
||||||
b = env.createSpy('b');
|
const b = env.createSpy('b');
|
||||||
b();
|
b();
|
||||||
a();
|
a();
|
||||||
env.expect(a).toHaveBeenCalledBefore(b);
|
env.expect(a).toHaveBeenCalledBefore(b);
|
||||||
|
|||||||
@@ -517,8 +517,8 @@ describe('spec running', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should allow top level suites to be disabled', async function() {
|
it('should allow top level suites to be disabled', async function() {
|
||||||
const specInADisabledSuite = jasmine.createSpy('specInADisabledSuite'),
|
const specInADisabledSuite = jasmine.createSpy('specInADisabledSuite');
|
||||||
otherSpec = jasmine.createSpy('otherSpec');
|
const otherSpec = jasmine.createSpy('otherSpec');
|
||||||
|
|
||||||
env.xdescribe('A disabled suite', function() {
|
env.xdescribe('A disabled suite', function() {
|
||||||
env.it('spec inside a disabled suite', specInADisabledSuite);
|
env.it('spec inside a disabled suite', specInADisabledSuite);
|
||||||
@@ -551,8 +551,8 @@ describe('spec running', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should recover gracefully when there are errors in describe functions', async function() {
|
it('should recover gracefully when there are errors in describe functions', async function() {
|
||||||
const specs = [],
|
const specs = [];
|
||||||
reporter = jasmine.createSpyObj(['specDone', 'suiteDone']);
|
const reporter = jasmine.createSpyObj(['specDone', 'suiteDone']);
|
||||||
|
|
||||||
reporter.specDone.and.callFake(function(result) {
|
reporter.specDone.and.callFake(function(result) {
|
||||||
specs.push(result.fullName);
|
specs.push(result.fullName);
|
||||||
|
|||||||
@@ -66,11 +66,11 @@ describe('DiffBuilder', function() {
|
|||||||
|
|
||||||
it('uses the injected pretty-printer', function() {
|
it('uses the injected pretty-printer', function() {
|
||||||
const prettyPrinter = function(val) {
|
const prettyPrinter = function(val) {
|
||||||
return '|' + val + '|';
|
return '|' + val + '|';
|
||||||
},
|
};
|
||||||
diffBuilder = new privateUnderTest.DiffBuilder({
|
const diffBuilder = new privateUnderTest.DiffBuilder({
|
||||||
prettyPrinter: prettyPrinter
|
prettyPrinter: prettyPrinter
|
||||||
});
|
});
|
||||||
prettyPrinter.customFormat_ = function() {};
|
prettyPrinter.customFormat_ = function() {};
|
||||||
|
|
||||||
diffBuilder.setRoots({ foo: 'actual' }, { foo: 'expected' });
|
diffBuilder.setRoots({ foo: 'actual' }, { foo: 'expected' });
|
||||||
@@ -84,11 +84,11 @@ describe('DiffBuilder', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('passes the injected pretty-printer to the diff formatter', function() {
|
it('passes the injected pretty-printer to the diff formatter', function() {
|
||||||
const diffFormatter = jasmine.createSpy('diffFormatter'),
|
const diffFormatter = jasmine.createSpy('diffFormatter');
|
||||||
prettyPrinter = function() {},
|
const prettyPrinter = function() {};
|
||||||
diffBuilder = new privateUnderTest.DiffBuilder({
|
const diffBuilder = new privateUnderTest.DiffBuilder({
|
||||||
prettyPrinter: prettyPrinter
|
prettyPrinter: prettyPrinter
|
||||||
});
|
});
|
||||||
prettyPrinter.customFormat_ = function() {};
|
prettyPrinter.customFormat_ = function() {};
|
||||||
|
|
||||||
diffBuilder.setRoots({ x: 'bar' }, { x: 'foo' });
|
diffBuilder.setRoots({ x: 'bar' }, { x: 'foo' });
|
||||||
@@ -219,13 +219,13 @@ describe('DiffBuilder', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ at the root', function() {
|
it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ at the root', function() {
|
||||||
const prettyPrinter = privateUnderTest.makePrettyPrinter([]),
|
const prettyPrinter = privateUnderTest.makePrettyPrinter([]);
|
||||||
diffBuilder = new privateUnderTest.DiffBuilder({
|
const diffBuilder = new privateUnderTest.DiffBuilder({
|
||||||
prettyPrinter: prettyPrinter
|
prettyPrinter: prettyPrinter
|
||||||
}),
|
});
|
||||||
expectedMsg =
|
const expectedMsg =
|
||||||
'Expected $.foo = 1 to equal 2.\n' +
|
'Expected $.foo = 1 to equal 2.\n' +
|
||||||
'Expected $.baz = undefined to equal 3.';
|
'Expected $.baz = undefined to equal 3.';
|
||||||
|
|
||||||
diffBuilder.setRoots(
|
diffBuilder.setRoots(
|
||||||
{ foo: 1, bar: 2 },
|
{ foo: 1, bar: 2 },
|
||||||
@@ -243,13 +243,13 @@ describe('DiffBuilder', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ below the root', function() {
|
it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ below the root', function() {
|
||||||
const prettyPrinter = privateUnderTest.makePrettyPrinter([]),
|
const prettyPrinter = privateUnderTest.makePrettyPrinter([]);
|
||||||
diffBuilder = new privateUnderTest.DiffBuilder({
|
const diffBuilder = new privateUnderTest.DiffBuilder({
|
||||||
prettyPrinter: prettyPrinter
|
prettyPrinter: prettyPrinter
|
||||||
}),
|
});
|
||||||
expectedMsg =
|
const expectedMsg =
|
||||||
'Expected $.x.foo = 1 to equal 2.\n' +
|
'Expected $.x.foo = 1 to equal 2.\n' +
|
||||||
'Expected $.x.baz = undefined to equal 3.';
|
'Expected $.x.baz = undefined to equal 3.';
|
||||||
|
|
||||||
diffBuilder.setRoots(
|
diffBuilder.setRoots(
|
||||||
{ x: { foo: 1, bar: 2 } },
|
{ x: { foo: 1, bar: 2 } },
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
describe('toBePending', function() {
|
describe('toBePending', function() {
|
||||||
it('passes if the actual promise is pending', function() {
|
it('passes if the actual promise is pending', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil);
|
||||||
actual = new Promise(function() {});
|
const actual = new Promise(function() {});
|
||||||
|
|
||||||
return matcher.compare(actual).then(function(result) {
|
return matcher.compare(actual).then(function(result) {
|
||||||
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
||||||
@@ -10,9 +10,9 @@ describe('toBePending', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails if the actual promise is resolved', function() {
|
it('fails if the actual promise is resolved', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil);
|
||||||
actual = Promise.resolve();
|
const actual = Promise.resolve();
|
||||||
|
|
||||||
return matcher.compare(actual).then(function(result) {
|
return matcher.compare(actual).then(function(result) {
|
||||||
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
|
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
|
||||||
@@ -20,9 +20,9 @@ describe('toBePending', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails if the actual promise is rejected', function() {
|
it('fails if the actual promise is rejected', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil);
|
||||||
actual = Promise.reject(new Error('promise was rejected'));
|
const actual = Promise.reject(new Error('promise was rejected'));
|
||||||
|
|
||||||
return matcher.compare(actual).then(function(result) {
|
return matcher.compare(actual).then(function(result) {
|
||||||
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
|
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
|
||||||
@@ -30,9 +30,9 @@ describe('toBePending', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails if actual is not a promise', function() {
|
it('fails if actual is not a promise', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil);
|
||||||
actual = 'not a promise';
|
const actual = 'not a promise';
|
||||||
|
|
||||||
function f() {
|
function f() {
|
||||||
return matcher.compare(actual);
|
return matcher.compare(actual);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
describe('toBeRejected', function() {
|
describe('toBeRejected', function() {
|
||||||
it('passes if the actual is rejected', function() {
|
it('passes if the actual is rejected', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil);
|
||||||
actual = Promise.reject('AsyncExpectationSpec rejection');
|
const actual = Promise.reject('AsyncExpectationSpec rejection');
|
||||||
|
|
||||||
return matcher.compare(actual).then(function(result) {
|
return matcher.compare(actual).then(function(result) {
|
||||||
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
||||||
@@ -10,9 +10,9 @@ describe('toBeRejected', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails if the actual is resolved', function() {
|
it('fails if the actual is resolved', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil);
|
||||||
actual = Promise.resolve();
|
const actual = Promise.resolve();
|
||||||
|
|
||||||
return matcher.compare(actual).then(function(result) {
|
return matcher.compare(actual).then(function(result) {
|
||||||
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
|
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
|
||||||
@@ -20,9 +20,9 @@ describe('toBeRejected', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails if actual is not a promise', function() {
|
it('fails if actual is not a promise', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil);
|
||||||
actual = 'not a promise';
|
const actual = 'not a promise';
|
||||||
|
|
||||||
function f() {
|
function f() {
|
||||||
return matcher.compare(actual);
|
return matcher.compare(actual);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
describe('#toBeRejectedWithError', function() {
|
describe('#toBeRejectedWithError', function() {
|
||||||
it('passes when Error type matches', function() {
|
it('passes when Error type matches', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||||
matchersUtil
|
matchersUtil
|
||||||
),
|
);
|
||||||
actual = Promise.reject(new TypeError('foo'));
|
const actual = Promise.reject(new TypeError('foo'));
|
||||||
|
|
||||||
return matcher.compare(actual, TypeError).then(function(result) {
|
return matcher.compare(actual, TypeError).then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -21,12 +21,12 @@ describe('#toBeRejectedWithError', function() {
|
|||||||
|
|
||||||
it('passes when Error type and message matches', function() {
|
it('passes when Error type and message matches', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||||
matchersUtil
|
matchersUtil
|
||||||
),
|
);
|
||||||
actual = Promise.reject(new TypeError('foo'));
|
const actual = Promise.reject(new TypeError('foo'));
|
||||||
|
|
||||||
return matcher.compare(actual, TypeError, 'foo').then(function(result) {
|
return matcher.compare(actual, TypeError, 'foo').then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -41,12 +41,12 @@ describe('#toBeRejectedWithError', function() {
|
|||||||
|
|
||||||
it('passes when Error matches and is exactly Error', function() {
|
it('passes when Error matches and is exactly Error', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||||
matchersUtil
|
matchersUtil
|
||||||
),
|
);
|
||||||
actual = Promise.reject(new Error());
|
const actual = Promise.reject(new Error());
|
||||||
|
|
||||||
return matcher.compare(actual, Error).then(function(result) {
|
return matcher.compare(actual, Error).then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -61,12 +61,12 @@ describe('#toBeRejectedWithError', function() {
|
|||||||
|
|
||||||
it('passes when Error message matches a string', function() {
|
it('passes when Error message matches a string', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||||
matchersUtil
|
matchersUtil
|
||||||
),
|
);
|
||||||
actual = Promise.reject(new Error('foo'));
|
const actual = Promise.reject(new Error('foo'));
|
||||||
|
|
||||||
return matcher.compare(actual, 'foo').then(function(result) {
|
return matcher.compare(actual, 'foo').then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -81,12 +81,12 @@ describe('#toBeRejectedWithError', function() {
|
|||||||
|
|
||||||
it('passes when Error message matches a RegExp', function() {
|
it('passes when Error message matches a RegExp', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||||
matchersUtil
|
matchersUtil
|
||||||
),
|
);
|
||||||
actual = Promise.reject(new Error('foo'));
|
const actual = Promise.reject(new Error('foo'));
|
||||||
|
|
||||||
return matcher.compare(actual, /foo/).then(function(result) {
|
return matcher.compare(actual, /foo/).then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -101,12 +101,12 @@ describe('#toBeRejectedWithError', function() {
|
|||||||
|
|
||||||
it('passes when Error message is empty', function() {
|
it('passes when Error message is empty', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||||
matchersUtil
|
matchersUtil
|
||||||
),
|
);
|
||||||
actual = Promise.reject(new Error());
|
const actual = Promise.reject(new Error());
|
||||||
|
|
||||||
return matcher.compare(actual, '').then(function(result) {
|
return matcher.compare(actual, '').then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -121,12 +121,12 @@ describe('#toBeRejectedWithError', function() {
|
|||||||
|
|
||||||
it('passes when no arguments', function() {
|
it('passes when no arguments', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||||
matchersUtil
|
matchersUtil
|
||||||
),
|
);
|
||||||
actual = Promise.reject(new Error());
|
const actual = Promise.reject(new Error());
|
||||||
|
|
||||||
return matcher.compare(actual, void 0).then(function(result) {
|
return matcher.compare(actual, void 0).then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -141,12 +141,12 @@ describe('#toBeRejectedWithError', function() {
|
|||||||
|
|
||||||
it('fails when resolved', function() {
|
it('fails when resolved', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||||
matchersUtil
|
matchersUtil
|
||||||
),
|
);
|
||||||
actual = Promise.resolve(new Error('foo'));
|
const actual = Promise.resolve(new Error('foo'));
|
||||||
|
|
||||||
return matcher.compare(actual, 'foo').then(function(result) {
|
return matcher.compare(actual, 'foo').then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -160,12 +160,12 @@ describe('#toBeRejectedWithError', function() {
|
|||||||
|
|
||||||
it('fails when rejected with non Error type', function() {
|
it('fails when rejected with non Error type', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||||
matchersUtil
|
matchersUtil
|
||||||
),
|
);
|
||||||
actual = Promise.reject('foo');
|
const actual = Promise.reject('foo');
|
||||||
|
|
||||||
return matcher.compare(actual, 'foo').then(function(result) {
|
return matcher.compare(actual, 'foo').then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -180,12 +180,12 @@ describe('#toBeRejectedWithError', function() {
|
|||||||
|
|
||||||
it('fails when Error type mismatches', function() {
|
it('fails when Error type mismatches', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||||
matchersUtil
|
matchersUtil
|
||||||
),
|
);
|
||||||
actual = Promise.reject(new Error('foo'));
|
const actual = Promise.reject(new Error('foo'));
|
||||||
|
|
||||||
return matcher.compare(actual, TypeError, 'foo').then(function(result) {
|
return matcher.compare(actual, TypeError, 'foo').then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -200,12 +200,12 @@ describe('#toBeRejectedWithError', function() {
|
|||||||
|
|
||||||
it('fails when Error message mismatches', function() {
|
it('fails when Error message mismatches', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||||
matchersUtil
|
matchersUtil
|
||||||
),
|
);
|
||||||
actual = Promise.reject(new Error('foo'));
|
const actual = Promise.reject(new Error('foo'));
|
||||||
|
|
||||||
return matcher.compare(actual, 'bar').then(function(result) {
|
return matcher.compare(actual, 'bar').then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -220,12 +220,12 @@ describe('#toBeRejectedWithError', function() {
|
|||||||
|
|
||||||
it('fails if actual is not a promise', function() {
|
it('fails if actual is not a promise', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||||
matchersUtil
|
matchersUtil
|
||||||
),
|
);
|
||||||
actual = 'not a promise';
|
const actual = 'not a promise';
|
||||||
|
|
||||||
function f() {
|
function f() {
|
||||||
return matcher.compare(actual);
|
return matcher.compare(actual);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
describe('#toBeRejectedWithMatching', function() {
|
describe('#toBeRejectedWithMatching', function() {
|
||||||
it('passes if the promise is rejected with something matching the predicate', function() {
|
it('passes if the promise is rejected with something matching the predicate', function() {
|
||||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching();
|
||||||
actual = Promise.reject(new Error('nope')),
|
const actual = Promise.reject(new Error('nope'));
|
||||||
predicate = value => value.message === 'nope';
|
const predicate = value => value.message === 'nope';
|
||||||
|
|
||||||
return matcher.compare(actual, predicate).then(function(result) {
|
return matcher.compare(actual, predicate).then(function(result) {
|
||||||
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
||||||
@@ -10,9 +10,9 @@ describe('#toBeRejectedWithMatching', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails if the promise resolves', function() {
|
it('fails if the promise resolves', function() {
|
||||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching();
|
||||||
actual = Promise.resolve(),
|
const actual = Promise.resolve();
|
||||||
predicate = () => true;
|
const predicate = () => true;
|
||||||
|
|
||||||
return matcher.compare(actual, predicate).then(function(result) {
|
return matcher.compare(actual, predicate).then(function(result) {
|
||||||
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
|
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
|
||||||
@@ -20,9 +20,9 @@ describe('#toBeRejectedWithMatching', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails if the promise is rejected with something not matching the predicate', function() {
|
it('fails if the promise is rejected with something not matching the predicate', function() {
|
||||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching();
|
||||||
actual = Promise.reject('A Bad Apple'),
|
const actual = Promise.reject('A Bad Apple');
|
||||||
predicate = value => value === 'A Good Orange';
|
const predicate = value => value === 'A Good Orange';
|
||||||
|
|
||||||
return matcher.compare(actual, predicate).then(function(result) {
|
return matcher.compare(actual, predicate).then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -36,9 +36,9 @@ describe('#toBeRejectedWithMatching', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should build its error correctly when negated', function() {
|
it('should build its error correctly when negated', function() {
|
||||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching();
|
||||||
actual = Promise.reject(true),
|
const actual = Promise.reject(true);
|
||||||
predicate = () => true;
|
const predicate = () => true;
|
||||||
|
|
||||||
return matcher.compare(actual, predicate).then(function(result) {
|
return matcher.compare(actual, predicate).then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -52,8 +52,8 @@ describe('#toBeRejectedWithMatching', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails if actual is not a promise', function() {
|
it('fails if actual is not a promise', function() {
|
||||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching();
|
||||||
actual = 'not a promise';
|
const actual = 'not a promise';
|
||||||
|
|
||||||
function f() {
|
function f() {
|
||||||
return matcher.compare(actual);
|
return matcher.compare(actual);
|
||||||
@@ -65,9 +65,9 @@ describe('#toBeRejectedWithMatching', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails if predicate is not a function', function() {
|
it('fails if predicate is not a function', function() {
|
||||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching();
|
||||||
actual = Promise.resolve(),
|
const actual = Promise.resolve();
|
||||||
predicate = 'not a function';
|
const predicate = 'not a function';
|
||||||
|
|
||||||
function f() {
|
function f() {
|
||||||
return matcher.compare(actual, predicate);
|
return matcher.compare(actual, predicate);
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
describe('#toBeRejectedWith', function() {
|
describe('#toBeRejectedWith', function() {
|
||||||
it('should return true if the promise is rejected with the expected value', function() {
|
it('should return true if the promise is rejected with the expected value', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(
|
||||||
actual = Promise.reject({ error: 'PEBCAK' });
|
matchersUtil
|
||||||
|
);
|
||||||
|
const actual = Promise.reject({ error: 'PEBCAK' });
|
||||||
|
|
||||||
return matcher.compare(actual, { error: 'PEBCAK' }).then(function(result) {
|
return matcher.compare(actual, { error: 'PEBCAK' }).then(function(result) {
|
||||||
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
||||||
@@ -10,9 +12,11 @@ describe('#toBeRejectedWith', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should fail if the promise resolves', function() {
|
it('should fail if the promise resolves', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(
|
||||||
actual = Promise.resolve();
|
matchersUtil
|
||||||
|
);
|
||||||
|
const actual = Promise.resolve();
|
||||||
|
|
||||||
return matcher.compare(actual, '').then(function(result) {
|
return matcher.compare(actual, '').then(function(result) {
|
||||||
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
|
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
|
||||||
@@ -21,10 +25,12 @@ describe('#toBeRejectedWith', function() {
|
|||||||
|
|
||||||
it('should fail if the promise is rejected with a different value', function() {
|
it('should fail if the promise is rejected with a different value', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(
|
||||||
actual = Promise.reject('A Bad Apple');
|
matchersUtil
|
||||||
|
);
|
||||||
|
const actual = Promise.reject('A Bad Apple');
|
||||||
|
|
||||||
return matcher.compare(actual, 'Some Cool Thing').then(function(result) {
|
return matcher.compare(actual, 'Some Cool Thing').then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -39,10 +45,12 @@ describe('#toBeRejectedWith', function() {
|
|||||||
|
|
||||||
it('should build its error correctly when negated', function() {
|
it('should build its error correctly when negated', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(
|
||||||
actual = Promise.reject(true);
|
matchersUtil
|
||||||
|
);
|
||||||
|
const actual = Promise.reject(true);
|
||||||
|
|
||||||
return matcher.compare(actual, true).then(function(result) {
|
return matcher.compare(actual, true).then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -56,15 +64,17 @@ describe('#toBeRejectedWith', function() {
|
|||||||
|
|
||||||
it('should support custom equality testers', function() {
|
it('should support custom equality testers', function() {
|
||||||
const customEqualityTesters = [
|
const customEqualityTesters = [
|
||||||
function() {
|
function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
],
|
];
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
customTesters: customEqualityTesters
|
customTesters: customEqualityTesters
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(
|
||||||
actual = Promise.reject('actual');
|
matchersUtil
|
||||||
|
);
|
||||||
|
const actual = Promise.reject('actual');
|
||||||
|
|
||||||
return matcher.compare(actual, 'expected').then(function(result) {
|
return matcher.compare(actual, 'expected').then(function(result) {
|
||||||
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
||||||
@@ -73,10 +83,12 @@ describe('#toBeRejectedWith', function() {
|
|||||||
|
|
||||||
it('fails if actual is not a promise', function() {
|
it('fails if actual is not a promise', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(
|
||||||
actual = 'not a promise';
|
matchersUtil
|
||||||
|
);
|
||||||
|
const actual = 'not a promise';
|
||||||
|
|
||||||
function f() {
|
function f() {
|
||||||
return matcher.compare(actual);
|
return matcher.compare(actual);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
describe('toBeResolved', function() {
|
describe('toBeResolved', function() {
|
||||||
it('passes if the actual is resolved', function() {
|
it('passes if the actual is resolved', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil);
|
||||||
actual = Promise.resolve();
|
const actual = Promise.resolve();
|
||||||
|
|
||||||
return matcher.compare(actual).then(function(result) {
|
return matcher.compare(actual).then(function(result) {
|
||||||
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
||||||
@@ -11,10 +11,10 @@ describe('toBeResolved', function() {
|
|||||||
|
|
||||||
it('fails if the actual is rejected', function() {
|
it('fails if the actual is rejected', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter([])
|
pp: privateUnderTest.makePrettyPrinter([])
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil);
|
||||||
actual = Promise.reject(new Error('AsyncExpectationSpec rejection'));
|
const actual = Promise.reject(new Error('AsyncExpectationSpec rejection'));
|
||||||
|
|
||||||
return matcher.compare(actual).then(function(result) {
|
return matcher.compare(actual).then(function(result) {
|
||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
@@ -27,9 +27,9 @@ describe('toBeResolved', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails if actual is not a promise', function() {
|
it('fails if actual is not a promise', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil);
|
||||||
actual = 'not a promise';
|
const actual = 'not a promise';
|
||||||
|
|
||||||
function f() {
|
function f() {
|
||||||
return matcher.compare(actual);
|
return matcher.compare(actual);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
describe('#toBeResolvedTo', function() {
|
describe('#toBeResolvedTo', function() {
|
||||||
it('passes if the promise is resolved to the expected value', function() {
|
it('passes if the promise is resolved to the expected value', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil);
|
||||||
actual = Promise.resolve({ foo: 42 });
|
const actual = Promise.resolve({ foo: 42 });
|
||||||
|
|
||||||
return matcher.compare(actual, { foo: 42 }).then(function(result) {
|
return matcher.compare(actual, { foo: 42 }).then(function(result) {
|
||||||
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
||||||
@@ -11,10 +11,10 @@ describe('#toBeResolvedTo', function() {
|
|||||||
|
|
||||||
it('fails if the promise is rejected', function() {
|
it('fails if the promise is rejected', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil);
|
||||||
actual = Promise.reject(new Error('AsyncExpectationSpec error'));
|
const actual = Promise.reject(new Error('AsyncExpectationSpec error'));
|
||||||
|
|
||||||
return matcher.compare(actual, '').then(function(result) {
|
return matcher.compare(actual, '').then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -30,10 +30,10 @@ describe('#toBeResolvedTo', function() {
|
|||||||
|
|
||||||
it('fails if the promise is resolved to a different value', function() {
|
it('fails if the promise is resolved to a different value', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil);
|
||||||
actual = Promise.resolve({ foo: 17 });
|
const actual = Promise.resolve({ foo: 17 });
|
||||||
|
|
||||||
return matcher.compare(actual, { foo: 42 }).then(function(result) {
|
return matcher.compare(actual, { foo: 42 }).then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -48,10 +48,10 @@ describe('#toBeResolvedTo', function() {
|
|||||||
|
|
||||||
it('builds its message correctly when negated', function() {
|
it('builds its message correctly when negated', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil);
|
||||||
actual = Promise.resolve(true);
|
const actual = Promise.resolve(true);
|
||||||
|
|
||||||
return matcher.compare(actual, true).then(function(result) {
|
return matcher.compare(actual, true).then(function(result) {
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
@@ -65,16 +65,16 @@ describe('#toBeResolvedTo', function() {
|
|||||||
|
|
||||||
it('supports custom equality testers', function() {
|
it('supports custom equality testers', function() {
|
||||||
const customEqualityTesters = [
|
const customEqualityTesters = [
|
||||||
function() {
|
function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
],
|
];
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
customTesters: customEqualityTesters,
|
customTesters: customEqualityTesters,
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil);
|
||||||
actual = Promise.resolve('actual');
|
const actual = Promise.resolve('actual');
|
||||||
|
|
||||||
return matcher.compare(actual, 'expected').then(function(result) {
|
return matcher.compare(actual, 'expected').then(function(result) {
|
||||||
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
||||||
@@ -83,10 +83,10 @@ describe('#toBeResolvedTo', function() {
|
|||||||
|
|
||||||
it('fails if actual is not a promise', function() {
|
it('fails if actual is not a promise', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
|
const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil);
|
||||||
actual = 'not a promise';
|
const actual = 'not a promise';
|
||||||
|
|
||||||
function f() {
|
function f() {
|
||||||
return matcher.compare(actual);
|
return matcher.compare(actual);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
describe('matchersUtil', function() {
|
describe('matchersUtil', function() {
|
||||||
it('exposes the injected pretty-printer as .pp', function() {
|
it('exposes the injected pretty-printer as .pp', function() {
|
||||||
const pp = function() {},
|
const pp = function() {};
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
|
const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||||
|
|
||||||
expect(matchersUtil.pp).toBe(pp);
|
expect(matchersUtil.pp).toBe(pp);
|
||||||
});
|
});
|
||||||
@@ -86,8 +86,8 @@ describe('matchersUtil', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('passes for Arrays that are equivalent, with elements added by changing length', function() {
|
it('passes for Arrays that are equivalent, with elements added by changing length', function() {
|
||||||
const foo = [],
|
const foo = [];
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
foo.length = 1;
|
foo.length = 1;
|
||||||
|
|
||||||
expect(matchersUtil.equals(foo, [undefined])).toBe(true);
|
expect(matchersUtil.equals(foo, [undefined])).toBe(true);
|
||||||
@@ -104,9 +104,9 @@ describe('matchersUtil', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails for Arrays whose contents are equivalent, but have differing properties', function() {
|
it('fails for Arrays whose contents are equivalent, but have differing properties', function() {
|
||||||
const one = [1, 2, 3],
|
const one = [1, 2, 3];
|
||||||
two = [1, 2, 3],
|
const two = [1, 2, 3];
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
one.foo = 'bar';
|
one.foo = 'bar';
|
||||||
two.foo = 'baz';
|
two.foo = 'baz';
|
||||||
@@ -115,9 +115,9 @@ describe('matchersUtil', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('passes for Arrays with equivalent contents and properties', function() {
|
it('passes for Arrays with equivalent contents and properties', function() {
|
||||||
const one = [1, 2, 3],
|
const one = [1, 2, 3];
|
||||||
two = [1, 2, 3],
|
const two = [1, 2, 3];
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
one.foo = 'bar';
|
one.foo = 'bar';
|
||||||
two.foo = 'bar';
|
two.foo = 'bar';
|
||||||
@@ -126,9 +126,9 @@ describe('matchersUtil', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('handles symbol keys in Arrays', function() {
|
it('handles symbol keys in Arrays', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
sym = Symbol('foo'),
|
const sym = Symbol('foo');
|
||||||
arr1 = [];
|
const arr1 = [];
|
||||||
let arr2 = [];
|
let arr2 = [];
|
||||||
|
|
||||||
arr1[sym] = 'bar';
|
arr1[sym] = 'bar';
|
||||||
@@ -200,9 +200,9 @@ describe('matchersUtil', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('passes for Objects that are equivalent (with cycles)', function() {
|
it('passes for Objects that are equivalent (with cycles)', function() {
|
||||||
const actual = { a: 'foo' },
|
const actual = { a: 'foo' };
|
||||||
expected = { a: 'foo' },
|
const expected = { a: 'foo' };
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
actual.b = actual;
|
actual.b = actual;
|
||||||
expected.b = actual;
|
expected.b = actual;
|
||||||
@@ -211,9 +211,9 @@ describe('matchersUtil', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails for Objects that are not equivalent (with cycles)', function() {
|
it('fails for Objects that are not equivalent (with cycles)', function() {
|
||||||
const actual = { a: 'foo' },
|
const actual = { a: 'foo' };
|
||||||
expected = { a: 'bar' },
|
const expected = { a: 'bar' };
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
actual.b = actual;
|
actual.b = actual;
|
||||||
expected.b = actual;
|
expected.b = actual;
|
||||||
@@ -222,26 +222,26 @@ describe('matchersUtil', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails for Objects that have the same number of keys, but different keys/values', function() {
|
it('fails for Objects that have the same number of keys, but different keys/values', function() {
|
||||||
const expected = { a: undefined },
|
const expected = { a: undefined };
|
||||||
actual = { b: 1 },
|
const actual = { b: 1 };
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
expect(matchersUtil.equals(actual, expected)).toBe(false);
|
expect(matchersUtil.equals(actual, expected)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fails when comparing an empty object to an empty array (issue #114)', function() {
|
it('fails when comparing an empty object to an empty array (issue #114)', function() {
|
||||||
const emptyObject = {},
|
const emptyObject = {};
|
||||||
emptyArray = [],
|
const emptyArray = [];
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
expect(matchersUtil.equals(emptyObject, emptyArray)).toBe(false);
|
expect(matchersUtil.equals(emptyObject, emptyArray)).toBe(false);
|
||||||
expect(matchersUtil.equals(emptyArray, emptyObject)).toBe(false);
|
expect(matchersUtil.equals(emptyArray, emptyObject)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('passes for equivalent frozen objects (GitHub issue #266)', function() {
|
it('passes for equivalent frozen objects (GitHub issue #266)', function() {
|
||||||
const a = { foo: 1 },
|
const a = { foo: 1 };
|
||||||
b = { foo: 1 },
|
const b = { foo: 1 };
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
Object.freeze(a);
|
Object.freeze(a);
|
||||||
Object.freeze(b);
|
Object.freeze(b);
|
||||||
@@ -250,9 +250,9 @@ describe('matchersUtil', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('passes for equivalent Promises (GitHub issue #1314)', function() {
|
it('passes for equivalent Promises (GitHub issue #1314)', function() {
|
||||||
const p1 = new Promise(function() {}),
|
const p1 = new Promise(function() {});
|
||||||
p2 = new Promise(function() {}),
|
const p2 = new Promise(function() {});
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
expect(matchersUtil.equals(p1, p1)).toBe(true);
|
expect(matchersUtil.equals(p1, p1)).toBe(true);
|
||||||
expect(matchersUtil.equals(p1, p2)).toBe(false);
|
expect(matchersUtil.equals(p1, p2)).toBe(false);
|
||||||
@@ -344,18 +344,18 @@ describe('matchersUtil', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('passes when Any is used', function() {
|
it('passes when Any is used', function() {
|
||||||
const number = 3,
|
const number = 3;
|
||||||
anyNumber = new privateUnderTest.Any(Number),
|
const anyNumber = new privateUnderTest.Any(Number);
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
expect(matchersUtil.equals(number, anyNumber)).toBe(true);
|
expect(matchersUtil.equals(number, anyNumber)).toBe(true);
|
||||||
expect(matchersUtil.equals(anyNumber, number)).toBe(true);
|
expect(matchersUtil.equals(anyNumber, number)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fails when Any is compared to something unexpected', function() {
|
it('fails when Any is compared to something unexpected', function() {
|
||||||
const number = 3,
|
const number = 3;
|
||||||
anyString = new privateUnderTest.Any(String),
|
const anyString = new privateUnderTest.Any(String);
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
expect(matchersUtil.equals(number, anyString)).toBe(false);
|
expect(matchersUtil.equals(number, anyString)).toBe(false);
|
||||||
expect(matchersUtil.equals(anyString, number)).toBe(false);
|
expect(matchersUtil.equals(anyString, number)).toBe(false);
|
||||||
@@ -363,11 +363,11 @@ describe('matchersUtil', function() {
|
|||||||
|
|
||||||
it('passes when ObjectContaining is used', function() {
|
it('passes when ObjectContaining is used', function() {
|
||||||
const obj = {
|
const obj = {
|
||||||
foo: 3,
|
foo: 3,
|
||||||
bar: 7
|
bar: 7
|
||||||
},
|
};
|
||||||
containing = new privateUnderTest.ObjectContaining({ foo: 3 }),
|
const containing = new privateUnderTest.ObjectContaining({ foo: 3 });
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
expect(matchersUtil.equals(obj, containing)).toBe(true);
|
expect(matchersUtil.equals(obj, containing)).toBe(true);
|
||||||
expect(matchersUtil.equals(containing, obj)).toBe(true);
|
expect(matchersUtil.equals(containing, obj)).toBe(true);
|
||||||
@@ -399,11 +399,11 @@ describe('matchersUtil', function() {
|
|||||||
|
|
||||||
it('passes when an asymmetric equality tester returns true', function() {
|
it('passes when an asymmetric equality tester returns true', function() {
|
||||||
const tester = {
|
const tester = {
|
||||||
asymmetricMatch: function() {
|
asymmetricMatch: function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
expect(matchersUtil.equals(false, tester)).toBe(true);
|
expect(matchersUtil.equals(false, tester)).toBe(true);
|
||||||
expect(matchersUtil.equals(tester, false)).toBe(true);
|
expect(matchersUtil.equals(tester, false)).toBe(true);
|
||||||
@@ -411,19 +411,19 @@ describe('matchersUtil', function() {
|
|||||||
|
|
||||||
it('fails when an asymmetric equality tester returns false', function() {
|
it('fails when an asymmetric equality tester returns false', function() {
|
||||||
const tester = {
|
const tester = {
|
||||||
asymmetricMatch: function() {
|
asymmetricMatch: function() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
expect(matchersUtil.equals(true, tester)).toBe(false);
|
expect(matchersUtil.equals(true, tester)).toBe(false);
|
||||||
expect(matchersUtil.equals(tester, true)).toBe(false);
|
expect(matchersUtil.equals(tester, true)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('passes when ArrayContaining is used', function() {
|
it('passes when ArrayContaining is used', function() {
|
||||||
const arr = ['foo', 'bar'],
|
const arr = ['foo', 'bar'];
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
matchersUtil.equals(arr, new privateUnderTest.ArrayContaining(['bar']))
|
matchersUtil.equals(arr, new privateUnderTest.ArrayContaining(['bar']))
|
||||||
@@ -432,12 +432,12 @@ describe('matchersUtil', function() {
|
|||||||
|
|
||||||
it('passes when a custom equality matcher returns true', function() {
|
it('passes when a custom equality matcher returns true', function() {
|
||||||
const tester = function() {
|
const tester = function() {
|
||||||
return true;
|
return true;
|
||||||
},
|
};
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
customTesters: [tester],
|
customTesters: [tester],
|
||||||
pp: function() {}
|
pp: function() {}
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(matchersUtil.equals(1, 2)).toBe(true);
|
expect(matchersUtil.equals(1, 2)).toBe(true);
|
||||||
});
|
});
|
||||||
@@ -463,46 +463,46 @@ describe('matchersUtil', function() {
|
|||||||
|
|
||||||
it('fails for equivalents when a custom equality matcher returns false', function() {
|
it('fails for equivalents when a custom equality matcher returns false', function() {
|
||||||
const tester = function() {
|
const tester = function() {
|
||||||
return false;
|
return false;
|
||||||
},
|
};
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
customTesters: [tester],
|
customTesters: [tester],
|
||||||
pp: function() {}
|
pp: function() {}
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(matchersUtil.equals(1, 1)).toBe(false);
|
expect(matchersUtil.equals(1, 1)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('passes for an asymmetric equality tester that returns true when a custom equality tester return false', function() {
|
it('passes for an asymmetric equality tester that returns true when a custom equality tester return false', function() {
|
||||||
const asymmetricTester = {
|
const asymmetricTester = {
|
||||||
asymmetricMatch: function() {
|
asymmetricMatch: function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
symmetricTester = function() {
|
const symmetricTester = function() {
|
||||||
return false;
|
return false;
|
||||||
},
|
};
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
customTesters: [symmetricTester()],
|
customTesters: [symmetricTester()],
|
||||||
pp: function() {}
|
pp: function() {}
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(matchersUtil.equals(asymmetricTester, true)).toBe(true);
|
expect(matchersUtil.equals(asymmetricTester, true)).toBe(true);
|
||||||
expect(matchersUtil.equals(true, asymmetricTester)).toBe(true);
|
expect(matchersUtil.equals(true, asymmetricTester)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('passes when an Any is compared to an Any that checks for the same type', function() {
|
it('passes when an Any is compared to an Any that checks for the same type', function() {
|
||||||
const any1 = new privateUnderTest.Any(Function),
|
const any1 = new privateUnderTest.Any(Function);
|
||||||
any2 = new privateUnderTest.Any(Function),
|
const any2 = new privateUnderTest.Any(Function);
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
expect(matchersUtil.equals(any1, any2)).toBe(true);
|
expect(matchersUtil.equals(any1, any2)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('passes for null prototype objects with same properties', function() {
|
it('passes for null prototype objects with same properties', function() {
|
||||||
const objA = Object.create(null),
|
const objA = Object.create(null);
|
||||||
objB = Object.create(null),
|
const objB = Object.create(null);
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
objA.name = 'test';
|
objA.name = 'test';
|
||||||
objB.name = 'test';
|
objB.name = 'test';
|
||||||
@@ -511,9 +511,9 @@ describe('matchersUtil', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails for null prototype objects with different properties', function() {
|
it('fails for null prototype objects with different properties', function() {
|
||||||
const objA = Object.create(null),
|
const objA = Object.create(null);
|
||||||
objB = Object.create(null),
|
const objB = Object.create(null);
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
objA.name = 'test';
|
objA.name = 'test';
|
||||||
objB.test = 'name';
|
objB.test = 'name';
|
||||||
@@ -673,8 +673,8 @@ describe('matchersUtil', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails when comparing two different URLs', function() {
|
it('fails when comparing two different URLs', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
url1 = new URL('http://localhost/1');
|
const url1 = new URL('http://localhost/1');
|
||||||
|
|
||||||
expect(matchersUtil.equals(url1, new URL('http://localhost/2'))).toBe(
|
expect(matchersUtil.equals(url1, new URL('http://localhost/2'))).toBe(
|
||||||
false
|
false
|
||||||
@@ -914,24 +914,24 @@ describe('matchersUtil', function() {
|
|||||||
describe('Building diffs for asymmetric equality testers', function() {
|
describe('Building diffs for asymmetric equality testers', function() {
|
||||||
it('diffs the values returned by valuesForDiff_', function() {
|
it('diffs the values returned by valuesForDiff_', function() {
|
||||||
const tester = {
|
const tester = {
|
||||||
asymmetricMatch: function() {
|
asymmetricMatch: function() {
|
||||||
return false;
|
return false;
|
||||||
},
|
|
||||||
valuesForDiff_: function() {
|
|
||||||
return {
|
|
||||||
self: 'asymmetric tester value',
|
|
||||||
other: 'other value'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
actual = { x: 42 },
|
valuesForDiff_: function() {
|
||||||
expected = { x: tester },
|
return {
|
||||||
diffBuilder = jasmine.createSpyObj('diffBuilder', [
|
self: 'asymmetric tester value',
|
||||||
'recordMismatch',
|
other: 'other value'
|
||||||
'withPath',
|
};
|
||||||
'setRoots'
|
}
|
||||||
]),
|
};
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const actual = { x: 42 };
|
||||||
|
const expected = { x: tester };
|
||||||
|
const diffBuilder = jasmine.createSpyObj('diffBuilder', [
|
||||||
|
'recordMismatch',
|
||||||
|
'withPath',
|
||||||
|
'setRoots'
|
||||||
|
]);
|
||||||
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
diffBuilder.withPath.and.callFake(function(p, block) {
|
diffBuilder.withPath.and.callFake(function(p, block) {
|
||||||
block();
|
block();
|
||||||
@@ -948,18 +948,18 @@ describe('matchersUtil', function() {
|
|||||||
|
|
||||||
it('records both objects when the tester does not implement valuesForDiff', function() {
|
it('records both objects when the tester does not implement valuesForDiff', function() {
|
||||||
const tester = {
|
const tester = {
|
||||||
asymmetricMatch: function() {
|
asymmetricMatch: function() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
actual = { x: 42 },
|
const actual = { x: 42 };
|
||||||
expected = { x: tester },
|
const expected = { x: tester };
|
||||||
diffBuilder = jasmine.createSpyObj('diffBuilder', [
|
const diffBuilder = jasmine.createSpyObj('diffBuilder', [
|
||||||
'recordMismatch',
|
'recordMismatch',
|
||||||
'withPath',
|
'withPath',
|
||||||
'setRoots'
|
'setRoots'
|
||||||
]),
|
]);
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
diffBuilder.withPath.and.callFake(function(p, block) {
|
diffBuilder.withPath.and.callFake(function(p, block) {
|
||||||
block();
|
block();
|
||||||
@@ -976,8 +976,8 @@ describe('matchersUtil', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('uses a diffBuilder if one is provided as the third argument', function() {
|
it('uses a diffBuilder if one is provided as the third argument', function() {
|
||||||
const diffBuilder = new privateUnderTest.DiffBuilder(),
|
const diffBuilder = new privateUnderTest.DiffBuilder();
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
|
|
||||||
spyOn(diffBuilder, 'recordMismatch');
|
spyOn(diffBuilder, 'recordMismatch');
|
||||||
spyOn(diffBuilder, 'withPath').and.callThrough();
|
spyOn(diffBuilder, 'withPath').and.callThrough();
|
||||||
@@ -1026,12 +1026,12 @@ describe('matchersUtil', function() {
|
|||||||
|
|
||||||
it('uses custom equality testers if actual is an Array', function() {
|
it('uses custom equality testers if actual is an Array', function() {
|
||||||
const customTester = function() {
|
const customTester = function() {
|
||||||
return true;
|
return true;
|
||||||
},
|
};
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
customTesters: [customTester],
|
customTesters: [customTester],
|
||||||
pp: function() {}
|
pp: function() {}
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(matchersUtil.contains([1, 2], 3)).toBe(true);
|
expect(matchersUtil.contains([1, 2], 3)).toBe(true);
|
||||||
});
|
});
|
||||||
@@ -1091,59 +1091,59 @@ describe('matchersUtil', function() {
|
|||||||
|
|
||||||
describe('buildFailureMessage', function() {
|
describe('buildFailureMessage', function() {
|
||||||
it('builds an English sentence for a failure case', function() {
|
it('builds an English sentence for a failure case', function() {
|
||||||
const actual = 'foo',
|
const actual = 'foo';
|
||||||
name = 'toBar',
|
const name = 'toBar';
|
||||||
pp = privateUnderTest.makePrettyPrinter(),
|
const pp = privateUnderTest.makePrettyPrinter();
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }),
|
const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||||
message = matchersUtil.buildFailureMessage(name, false, actual);
|
const message = matchersUtil.buildFailureMessage(name, false, actual);
|
||||||
|
|
||||||
expect(message).toEqual("Expected 'foo' to bar.");
|
expect(message).toEqual("Expected 'foo' to bar.");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("builds an English sentence for a 'not' failure case", function() {
|
it("builds an English sentence for a 'not' failure case", function() {
|
||||||
const actual = 'foo',
|
const actual = 'foo';
|
||||||
name = 'toBar',
|
const name = 'toBar';
|
||||||
isNot = true,
|
const isNot = true;
|
||||||
pp = privateUnderTest.makePrettyPrinter(),
|
const pp = privateUnderTest.makePrettyPrinter();
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }),
|
const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||||
message = matchersUtil.buildFailureMessage(name, isNot, actual);
|
const message = matchersUtil.buildFailureMessage(name, isNot, actual);
|
||||||
|
|
||||||
expect(message).toEqual("Expected 'foo' not to bar.");
|
expect(message).toEqual("Expected 'foo' not to bar.");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('builds an English sentence for an arbitrary array of expected arguments', function() {
|
it('builds an English sentence for an arbitrary array of expected arguments', function() {
|
||||||
const actual = 'foo',
|
const actual = 'foo';
|
||||||
name = 'toBar',
|
const name = 'toBar';
|
||||||
pp = privateUnderTest.makePrettyPrinter(),
|
const pp = privateUnderTest.makePrettyPrinter();
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }),
|
const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||||
message = matchersUtil.buildFailureMessage(
|
const message = matchersUtil.buildFailureMessage(
|
||||||
name,
|
name,
|
||||||
false,
|
false,
|
||||||
actual,
|
actual,
|
||||||
'quux',
|
'quux',
|
||||||
'corge'
|
'corge'
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(message).toEqual("Expected 'foo' to bar 'quux', 'corge'.");
|
expect(message).toEqual("Expected 'foo' to bar 'quux', 'corge'.");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('uses the injected pretty-printer to format the expecteds and actual', function() {
|
it('uses the injected pretty-printer to format the expecteds and actual', function() {
|
||||||
const actual = 'foo',
|
const actual = 'foo';
|
||||||
expected1 = 'qux',
|
const expected1 = 'qux';
|
||||||
expected2 = 'grault',
|
const expected2 = 'grault';
|
||||||
name = 'toBar',
|
const name = 'toBar';
|
||||||
isNot = false,
|
const isNot = false;
|
||||||
pp = function(value) {
|
const pp = function(value) {
|
||||||
return '<' + value + '>';
|
return '<' + value + '>';
|
||||||
},
|
};
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }),
|
const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||||
message = matchersUtil.buildFailureMessage(
|
const message = matchersUtil.buildFailureMessage(
|
||||||
name,
|
name,
|
||||||
isNot,
|
isNot,
|
||||||
actual,
|
actual,
|
||||||
expected1,
|
expected1,
|
||||||
expected2
|
expected2
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(message).toEqual('Expected <foo> to bar <qux>, <grault>.');
|
expect(message).toEqual('Expected <foo> to bar <qux>, <grault>.');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
describe('nothing', function() {
|
describe('nothing', function() {
|
||||||
it('should pass', function() {
|
it('should pass', function() {
|
||||||
const matcher = privateUnderTest.matchers.nothing(),
|
const matcher = privateUnderTest.matchers.nothing();
|
||||||
result = matcher.compare();
|
const result = matcher.compare();
|
||||||
|
|
||||||
expect(result.pass).toBe(true);
|
expect(result.pass).toBe(true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ describe('toBeNaN', function() {
|
|||||||
|
|
||||||
it('has a custom message on failure', function() {
|
it('has a custom message on failure', function() {
|
||||||
const matcher = privateUnderTest.matchers.toBeNaN({
|
const matcher = privateUnderTest.matchers.toBeNaN({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
result = matcher.compare(0);
|
const result = matcher.compare(0);
|
||||||
|
|
||||||
expect(result.message()).toEqual('Expected 0 to be NaN.');
|
expect(result.message()).toEqual('Expected 0 to be NaN.');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,16 +15,16 @@ describe('toBeNegativeInfinity', function() {
|
|||||||
|
|
||||||
it('has a custom message on failure', function() {
|
it('has a custom message on failure', function() {
|
||||||
const matcher = privateUnderTest.matchers.toBeNegativeInfinity({
|
const matcher = privateUnderTest.matchers.toBeNegativeInfinity({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
result = matcher.compare(0);
|
const result = matcher.compare(0);
|
||||||
|
|
||||||
expect(result.message()).toEqual('Expected 0 to be -Infinity.');
|
expect(result.message()).toEqual('Expected 0 to be -Infinity.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('succeeds for -Infinity', function() {
|
it('succeeds for -Infinity', function() {
|
||||||
const matcher = privateUnderTest.matchers.toBeNegativeInfinity(),
|
const matcher = privateUnderTest.matchers.toBeNegativeInfinity();
|
||||||
result = matcher.compare(Number.NEGATIVE_INFINITY);
|
const result = matcher.compare(Number.NEGATIVE_INFINITY);
|
||||||
|
|
||||||
expect(result.pass).toBe(true);
|
expect(result.pass).toBe(true);
|
||||||
expect(result.message).toEqual('Expected actual not to be -Infinity.');
|
expect(result.message).toEqual('Expected actual not to be -Infinity.');
|
||||||
|
|||||||
@@ -15,16 +15,16 @@ describe('toBePositiveInfinity', function() {
|
|||||||
|
|
||||||
it('has a custom message on failure', function() {
|
it('has a custom message on failure', function() {
|
||||||
const matcher = privateUnderTest.matchers.toBePositiveInfinity({
|
const matcher = privateUnderTest.matchers.toBePositiveInfinity({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
result = matcher.compare(0);
|
const result = matcher.compare(0);
|
||||||
|
|
||||||
expect(result.message()).toEqual('Expected 0 to be Infinity.');
|
expect(result.message()).toEqual('Expected 0 to be Infinity.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('succeeds for Infinity', function() {
|
it('succeeds for Infinity', function() {
|
||||||
const matcher = privateUnderTest.matchers.toBePositiveInfinity(),
|
const matcher = privateUnderTest.matchers.toBePositiveInfinity();
|
||||||
result = matcher.compare(Number.POSITIVE_INFINITY);
|
const result = matcher.compare(Number.POSITIVE_INFINITY);
|
||||||
|
|
||||||
expect(result.pass).toBe(true);
|
expect(result.pass).toBe(true);
|
||||||
expect(result.message).toEqual('Expected actual not to be Infinity.');
|
expect(result.message).toEqual('Expected actual not to be Infinity.');
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
describe('toBe', function() {
|
describe('toBe', function() {
|
||||||
it('passes with no message when actual === expected', function() {
|
it('passes with no message when actual === expected', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
matcher = privateUnderTest.matchers.toBe(matchersUtil),
|
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
|
||||||
result = matcher.compare(1, 1);
|
const result = matcher.compare(1, 1);
|
||||||
expect(result.pass).toBe(true);
|
expect(result.pass).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('passes with a custom message when expected is an array', function() {
|
it('passes with a custom message when expected is an array', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.matchers.toBe(matchersUtil),
|
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
|
||||||
array = [1];
|
const array = [1];
|
||||||
|
|
||||||
const result = matcher.compare(array, array);
|
const result = matcher.compare(array, array);
|
||||||
expect(result.pass).toBe(true);
|
expect(result.pass).toBe(true);
|
||||||
@@ -22,10 +22,10 @@ describe('toBe', function() {
|
|||||||
|
|
||||||
it('passes with a custom message when expected is an object', function() {
|
it('passes with a custom message when expected is an object', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.matchers.toBe(matchersUtil),
|
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
|
||||||
obj = { foo: 'bar' };
|
const obj = { foo: 'bar' };
|
||||||
|
|
||||||
const result = matcher.compare(obj, obj);
|
const result = matcher.compare(obj, obj);
|
||||||
expect(result.pass).toBe(true);
|
expect(result.pass).toBe(true);
|
||||||
@@ -35,19 +35,19 @@ describe('toBe', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails with no message when actual !== expected', function() {
|
it('fails with no message when actual !== expected', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||||
matcher = privateUnderTest.matchers.toBe(matchersUtil),
|
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
|
||||||
result = matcher.compare(1, 2);
|
const result = matcher.compare(1, 2);
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
expect(result.message).toBeUndefined();
|
expect(result.message).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fails with a custom message when expected is an array', function() {
|
it('fails with a custom message when expected is an array', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.matchers.toBe(matchersUtil),
|
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
|
||||||
result = matcher.compare([1], [1]);
|
const result = matcher.compare([1], [1]);
|
||||||
|
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
expect(result.message).toBe(
|
expect(result.message).toBe(
|
||||||
@@ -57,10 +57,10 @@ describe('toBe', function() {
|
|||||||
|
|
||||||
it('fails with a custom message when expected is an object', function() {
|
it('fails with a custom message when expected is an object', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.matchers.toBe(matchersUtil),
|
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
|
||||||
result = matcher.compare({ foo: 'bar' }, { foo: 'bar' });
|
const result = matcher.compare({ foo: 'bar' }, { foo: 'bar' });
|
||||||
|
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
expect(result.message).toBe(
|
expect(result.message).toBe(
|
||||||
@@ -70,12 +70,14 @@ describe('toBe', function() {
|
|||||||
|
|
||||||
it('works with custom object formatters when expected is an object', function() {
|
it('works with custom object formatters when expected is an object', function() {
|
||||||
const formatter = function(x) {
|
const formatter = function(x) {
|
||||||
return '<' + x.foo + '>';
|
return '<' + x.foo + '>';
|
||||||
},
|
};
|
||||||
prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]),
|
const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]);
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil({ pp: prettyPrinter }),
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
matcher = privateUnderTest.matchers.toBe(matchersUtil),
|
pp: prettyPrinter
|
||||||
result = matcher.compare({ foo: 'bar' }, { foo: 'bar' });
|
});
|
||||||
|
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
|
||||||
|
const result = matcher.compare({ foo: 'bar' }, { foo: 'bar' });
|
||||||
|
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
expect(result.message).toBe(
|
expect(result.message).toBe(
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
describe('toContain', function() {
|
describe('toContain', function() {
|
||||||
it('delegates to privateUnderTest.MatchersUtil.contains', function() {
|
it('delegates to privateUnderTest.MatchersUtil.contains', function() {
|
||||||
const matchersUtil = {
|
const matchersUtil = {
|
||||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
||||||
},
|
};
|
||||||
matcher = privateUnderTest.matchers.toContain(matchersUtil);
|
const matcher = privateUnderTest.matchers.toContain(matchersUtil);
|
||||||
|
|
||||||
const result = matcher.compare('ABC', 'B');
|
const result = matcher.compare('ABC', 'B');
|
||||||
expect(matchersUtil.contains).toHaveBeenCalledWith('ABC', 'B');
|
expect(matchersUtil.contains).toHaveBeenCalledWith('ABC', 'B');
|
||||||
@@ -12,12 +12,12 @@ describe('toContain', function() {
|
|||||||
|
|
||||||
it('works with custom equality testers', function() {
|
it('works with custom equality testers', function() {
|
||||||
const tester = function(a, b) {
|
const tester = function(a, b) {
|
||||||
return a.toString() === b.toString();
|
return a.toString() === b.toString();
|
||||||
},
|
};
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
customTesters: [tester]
|
customTesters: [tester]
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.matchers.toContain(matchersUtil);
|
const matcher = privateUnderTest.matchers.toContain(matchersUtil);
|
||||||
|
|
||||||
const result = matcher.compare(['1', '2'], 2);
|
const result = matcher.compare(['1', '2'], 2);
|
||||||
expect(result.pass).toBe(true);
|
expect(result.pass).toBe(true);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,10 @@
|
|||||||
describe('toHaveBeenCalledBefore', function() {
|
describe('toHaveBeenCalledBefore', function() {
|
||||||
it('throws an exception when the actual is not a spy', function() {
|
it('throws an exception when the actual is not a spy', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore({
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
fn = function() {},
|
const fn = function() {};
|
||||||
spy = new privateUnderTest.Env().createSpy('a spy');
|
const spy = new privateUnderTest.Env().createSpy('a spy');
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
matcher.compare(fn, spy);
|
matcher.compare(fn, spy);
|
||||||
@@ -13,10 +13,10 @@ describe('toHaveBeenCalledBefore', function() {
|
|||||||
|
|
||||||
it('throws an exception when the expected is not a spy', function() {
|
it('throws an exception when the expected is not a spy', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore({
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
spy = new privateUnderTest.Env().createSpy('a spy'),
|
const spy = new privateUnderTest.Env().createSpy('a spy');
|
||||||
fn = function() {};
|
const fn = function() {};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
matcher.compare(spy, fn);
|
matcher.compare(spy, fn);
|
||||||
@@ -24,9 +24,9 @@ describe('toHaveBeenCalledBefore', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails when the actual was not called', function() {
|
it('fails when the actual was not called', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore();
|
||||||
firstSpy = new privateUnderTest.Spy('first spy'),
|
const firstSpy = new privateUnderTest.Spy('first spy');
|
||||||
secondSpy = new privateUnderTest.Spy('second spy');
|
const secondSpy = new privateUnderTest.Spy('second spy');
|
||||||
|
|
||||||
secondSpy();
|
secondSpy();
|
||||||
|
|
||||||
@@ -38,9 +38,9 @@ describe('toHaveBeenCalledBefore', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails when the expected was not called', function() {
|
it('fails when the expected was not called', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore();
|
||||||
firstSpy = new privateUnderTest.Spy('first spy'),
|
const firstSpy = new privateUnderTest.Spy('first spy');
|
||||||
secondSpy = new privateUnderTest.Spy('second spy');
|
const secondSpy = new privateUnderTest.Spy('second spy');
|
||||||
|
|
||||||
firstSpy();
|
firstSpy();
|
||||||
|
|
||||||
@@ -52,9 +52,9 @@ describe('toHaveBeenCalledBefore', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails when the actual is called after the expected', function() {
|
it('fails when the actual is called after the expected', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore();
|
||||||
firstSpy = new privateUnderTest.Spy('first spy'),
|
const firstSpy = new privateUnderTest.Spy('first spy');
|
||||||
secondSpy = new privateUnderTest.Spy('second spy');
|
const secondSpy = new privateUnderTest.Spy('second spy');
|
||||||
|
|
||||||
secondSpy();
|
secondSpy();
|
||||||
firstSpy();
|
firstSpy();
|
||||||
@@ -67,9 +67,9 @@ describe('toHaveBeenCalledBefore', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails when the actual is called before and after the expected', function() {
|
it('fails when the actual is called before and after the expected', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore();
|
||||||
firstSpy = new privateUnderTest.Spy('first spy'),
|
const firstSpy = new privateUnderTest.Spy('first spy');
|
||||||
secondSpy = new privateUnderTest.Spy('second spy');
|
const secondSpy = new privateUnderTest.Spy('second spy');
|
||||||
|
|
||||||
firstSpy();
|
firstSpy();
|
||||||
secondSpy();
|
secondSpy();
|
||||||
@@ -83,9 +83,9 @@ describe('toHaveBeenCalledBefore', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails when the expected is called before and after the actual', function() {
|
it('fails when the expected is called before and after the actual', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore();
|
||||||
firstSpy = new privateUnderTest.Spy('first spy'),
|
const firstSpy = new privateUnderTest.Spy('first spy');
|
||||||
secondSpy = new privateUnderTest.Spy('second spy');
|
const secondSpy = new privateUnderTest.Spy('second spy');
|
||||||
|
|
||||||
secondSpy();
|
secondSpy();
|
||||||
firstSpy();
|
firstSpy();
|
||||||
@@ -99,9 +99,9 @@ describe('toHaveBeenCalledBefore', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('passes when the actual is called before the expected', function() {
|
it('passes when the actual is called before the expected', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore();
|
||||||
firstSpy = new privateUnderTest.Spy('first spy'),
|
const firstSpy = new privateUnderTest.Spy('first spy');
|
||||||
secondSpy = new privateUnderTest.Spy('second spy');
|
const secondSpy = new privateUnderTest.Spy('second spy');
|
||||||
|
|
||||||
firstSpy();
|
firstSpy();
|
||||||
secondSpy();
|
secondSpy();
|
||||||
@@ -114,9 +114,9 @@ describe('toHaveBeenCalledBefore', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('set the correct calls as verified when passing', function() {
|
it('set the correct calls as verified when passing', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore();
|
||||||
firstSpy = new privateUnderTest.Spy('first spy'),
|
const firstSpy = new privateUnderTest.Spy('first spy');
|
||||||
secondSpy = new privateUnderTest.Spy('second spy');
|
const secondSpy = new privateUnderTest.Spy('second spy');
|
||||||
|
|
||||||
firstSpy();
|
firstSpy();
|
||||||
secondSpy();
|
secondSpy();
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
describe('toHaveBeenCalledOnceWith', function() {
|
describe('toHaveBeenCalledOnceWith', function() {
|
||||||
it('passes when the actual was called only once and with matching parameters', function() {
|
it('passes when the actual was called only once and with matching parameters', function() {
|
||||||
const pp = privateUnderTest.makePrettyPrinter(),
|
const pp = privateUnderTest.makePrettyPrinter();
|
||||||
util = new privateUnderTest.MatchersUtil({ pp: pp }),
|
const util = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||||
matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util);
|
||||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||||
|
|
||||||
calledSpy('a', 'b');
|
calledSpy('a', 'b');
|
||||||
const result = matcher.compare(calledSpy, 'a', 'b');
|
const result = matcher.compare(calledSpy, 'a', 'b');
|
||||||
@@ -16,17 +16,17 @@ describe('toHaveBeenCalledOnceWith', function() {
|
|||||||
|
|
||||||
it('supports custom equality testers', function() {
|
it('supports custom equality testers', function() {
|
||||||
const customEqualityTesters = [
|
const customEqualityTesters = [
|
||||||
function() {
|
function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
],
|
];
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
customTesters: customEqualityTesters
|
customTesters: customEqualityTesters
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(
|
||||||
matchersUtil
|
matchersUtil
|
||||||
),
|
);
|
||||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||||
|
|
||||||
calledSpy('a', 'b');
|
calledSpy('a', 'b');
|
||||||
const result = matcher.compare(calledSpy, 'a', 'a');
|
const result = matcher.compare(calledSpy, 'a', 'a');
|
||||||
@@ -35,10 +35,10 @@ describe('toHaveBeenCalledOnceWith', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails when the actual was never called', function() {
|
it('fails when the actual was never called', function() {
|
||||||
const pp = privateUnderTest.makePrettyPrinter(),
|
const pp = privateUnderTest.makePrettyPrinter();
|
||||||
util = new privateUnderTest.MatchersUtil({ pp: pp }),
|
const util = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||||
matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util);
|
||||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||||
|
|
||||||
const result = matcher.compare(calledSpy, 'a', 'b');
|
const result = matcher.compare(calledSpy, 'a', 'b');
|
||||||
|
|
||||||
@@ -49,10 +49,10 @@ describe('toHaveBeenCalledOnceWith', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails when the actual was called once with different parameters', function() {
|
it('fails when the actual was called once with different parameters', function() {
|
||||||
const pp = privateUnderTest.makePrettyPrinter(),
|
const pp = privateUnderTest.makePrettyPrinter();
|
||||||
util = new privateUnderTest.MatchersUtil({ pp: pp }),
|
const util = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||||
matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util);
|
||||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||||
|
|
||||||
calledSpy('a', 'c');
|
calledSpy('a', 'c');
|
||||||
const result = matcher.compare(calledSpy, 'a', 'b');
|
const result = matcher.compare(calledSpy, 'a', 'b');
|
||||||
@@ -64,10 +64,10 @@ describe('toHaveBeenCalledOnceWith', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails when the actual was called multiple times with expected parameters', function() {
|
it('fails when the actual was called multiple times with expected parameters', function() {
|
||||||
const pp = privateUnderTest.makePrettyPrinter(),
|
const pp = privateUnderTest.makePrettyPrinter();
|
||||||
util = new privateUnderTest.MatchersUtil({ pp: pp }),
|
const util = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||||
matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util);
|
||||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||||
|
|
||||||
calledSpy('a', 'b');
|
calledSpy('a', 'b');
|
||||||
calledSpy('a', 'b');
|
calledSpy('a', 'b');
|
||||||
@@ -80,10 +80,10 @@ describe('toHaveBeenCalledOnceWith', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails when the actual was called multiple times (one of them - with expected parameters)', function() {
|
it('fails when the actual was called multiple times (one of them - with expected parameters)', function() {
|
||||||
const pp = privateUnderTest.makePrettyPrinter(),
|
const pp = privateUnderTest.makePrettyPrinter();
|
||||||
util = new privateUnderTest.MatchersUtil({ pp: pp }),
|
const util = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||||
matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util);
|
||||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||||
|
|
||||||
calledSpy('a', 'b');
|
calledSpy('a', 'b');
|
||||||
calledSpy('a', 'c');
|
calledSpy('a', 'c');
|
||||||
@@ -96,10 +96,10 @@ describe('toHaveBeenCalledOnceWith', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('throws an exception when the actual is not a spy', function() {
|
it('throws an exception when the actual is not a spy', function() {
|
||||||
const pp = privateUnderTest.makePrettyPrinter(),
|
const pp = privateUnderTest.makePrettyPrinter();
|
||||||
util = new privateUnderTest.MatchersUtil({ pp: pp }),
|
const util = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||||
matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util);
|
||||||
fn = function() {};
|
const fn = function() {};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
matcher.compare(fn);
|
matcher.compare(fn);
|
||||||
@@ -107,10 +107,10 @@ describe('toHaveBeenCalledOnceWith', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('set the correct calls as verified when passing', function() {
|
it('set the correct calls as verified when passing', function() {
|
||||||
const pp = privateUnderTest.makePrettyPrinter(),
|
const pp = privateUnderTest.makePrettyPrinter();
|
||||||
util = new privateUnderTest.MatchersUtil({ pp: pp }),
|
const util = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||||
matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util);
|
||||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||||
|
|
||||||
calledSpy('x');
|
calledSpy('x');
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
describe('toHaveBeenCalled', function() {
|
describe('toHaveBeenCalled', function() {
|
||||||
it('passes when the actual was called, with a custom .not fail message', function() {
|
it('passes when the actual was called, with a custom .not fail message', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalled(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalled();
|
||||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||||
|
|
||||||
calledSpy();
|
calledSpy();
|
||||||
|
|
||||||
@@ -13,8 +13,8 @@ describe('toHaveBeenCalled', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails when the actual was not called', function() {
|
it('fails when the actual was not called', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalled(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalled();
|
||||||
uncalledSpy = new privateUnderTest.Spy('uncalled spy');
|
const uncalledSpy = new privateUnderTest.Spy('uncalled spy');
|
||||||
|
|
||||||
const result = matcher.compare(uncalledSpy);
|
const result = matcher.compare(uncalledSpy);
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
@@ -22,9 +22,9 @@ describe('toHaveBeenCalled', function() {
|
|||||||
|
|
||||||
it('throws an exception when the actual is not a spy', function() {
|
it('throws an exception when the actual is not a spy', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalled({
|
const matcher = privateUnderTest.matchers.toHaveBeenCalled({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
fn = function() {};
|
const fn = function() {};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
matcher.compare(fn);
|
matcher.compare(fn);
|
||||||
@@ -32,8 +32,8 @@ describe('toHaveBeenCalled', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('throws an exception when invoked with any arguments', function() {
|
it('throws an exception when invoked with any arguments', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalled(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalled();
|
||||||
spy = new privateUnderTest.Spy('sample spy');
|
const spy = new privateUnderTest.Spy('sample spy');
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
matcher.compare(spy, 'foo');
|
matcher.compare(spy, 'foo');
|
||||||
@@ -41,8 +41,8 @@ describe('toHaveBeenCalled', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('has a custom message on failure', function() {
|
it('has a custom message on failure', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalled(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalled();
|
||||||
spy = new privateUnderTest.Spy('sample-spy');
|
const spy = new privateUnderTest.Spy('sample-spy');
|
||||||
|
|
||||||
const result = matcher.compare(spy);
|
const result = matcher.compare(spy);
|
||||||
|
|
||||||
@@ -52,8 +52,8 @@ describe('toHaveBeenCalled', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('set the correct calls as verified when passing', function() {
|
it('set the correct calls as verified when passing', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalled(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalled();
|
||||||
spy = new privateUnderTest.Spy('sample-spy');
|
const spy = new privateUnderTest.Spy('sample-spy');
|
||||||
|
|
||||||
spy();
|
spy();
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
describe('toHaveBeenCalledTimes', function() {
|
describe('toHaveBeenCalledTimes', function() {
|
||||||
it('passes when the actual 0 matches the expected 0 ', function() {
|
it('passes when the actual 0 matches the expected 0 ', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes();
|
||||||
calledSpy = new privateUnderTest.Spy('called-spy'),
|
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||||
result = matcher.compare(calledSpy, 0);
|
const result = matcher.compare(calledSpy, 0);
|
||||||
expect(result.pass).toBeTruthy();
|
expect(result.pass).toBeTruthy();
|
||||||
});
|
});
|
||||||
it('passes when the actual matches the expected', function() {
|
it('passes when the actual matches the expected', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes();
|
||||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||||
calledSpy();
|
calledSpy();
|
||||||
|
|
||||||
const result = matcher.compare(calledSpy, 1);
|
const result = matcher.compare(calledSpy, 1);
|
||||||
@@ -15,8 +15,8 @@ describe('toHaveBeenCalledTimes', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails when expected numbers is not supplied', function() {
|
it('fails when expected numbers is not supplied', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes();
|
||||||
spy = new privateUnderTest.Spy('spy');
|
const spy = new privateUnderTest.Spy('spy');
|
||||||
|
|
||||||
spy();
|
spy();
|
||||||
expect(function() {
|
expect(function() {
|
||||||
@@ -27,16 +27,16 @@ describe('toHaveBeenCalledTimes', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails when the actual was called less than the expected', function() {
|
it('fails when the actual was called less than the expected', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes();
|
||||||
uncalledSpy = new privateUnderTest.Spy('uncalled spy');
|
const uncalledSpy = new privateUnderTest.Spy('uncalled spy');
|
||||||
|
|
||||||
const result = matcher.compare(uncalledSpy, 2);
|
const result = matcher.compare(uncalledSpy, 2);
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fails when the actual was called more than expected', function() {
|
it('fails when the actual was called more than expected', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes();
|
||||||
uncalledSpy = new privateUnderTest.Spy('uncalled spy');
|
const uncalledSpy = new privateUnderTest.Spy('uncalled spy');
|
||||||
|
|
||||||
uncalledSpy();
|
uncalledSpy();
|
||||||
uncalledSpy();
|
uncalledSpy();
|
||||||
@@ -47,9 +47,9 @@ describe('toHaveBeenCalledTimes', function() {
|
|||||||
|
|
||||||
it('throws an exception when the actual is not a spy', function() {
|
it('throws an exception when the actual is not a spy', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes({
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
fn = function() {};
|
const fn = function() {};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
matcher.compare(fn);
|
matcher.compare(fn);
|
||||||
@@ -57,8 +57,8 @@ describe('toHaveBeenCalledTimes', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('has a custom message on failure that tells it was called only once', function() {
|
it('has a custom message on failure that tells it was called only once', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes();
|
||||||
spy = new privateUnderTest.Spy('sample-spy');
|
const spy = new privateUnderTest.Spy('sample-spy');
|
||||||
spy();
|
spy();
|
||||||
spy();
|
spy();
|
||||||
spy();
|
spy();
|
||||||
@@ -73,8 +73,8 @@ describe('toHaveBeenCalledTimes', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('has a custom message on failure that tells how many times it was called', function() {
|
it('has a custom message on failure that tells how many times it was called', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes();
|
||||||
spy = new privateUnderTest.Spy('sample-spy');
|
const spy = new privateUnderTest.Spy('sample-spy');
|
||||||
spy();
|
spy();
|
||||||
spy();
|
spy();
|
||||||
spy();
|
spy();
|
||||||
@@ -89,8 +89,8 @@ describe('toHaveBeenCalledTimes', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('set the correct calls as verified when passing', function() {
|
it('set the correct calls as verified when passing', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes();
|
||||||
spy = new privateUnderTest.Spy('sample-spy');
|
const spy = new privateUnderTest.Spy('sample-spy');
|
||||||
|
|
||||||
spy();
|
spy();
|
||||||
spy();
|
spy();
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
describe('toHaveBeenCalledWith', function() {
|
describe('toHaveBeenCalledWith', function() {
|
||||||
it('passes when the actual was called with matching parameters', function() {
|
it('passes when the actual was called with matching parameters', function() {
|
||||||
const matchersUtil = {
|
const matchersUtil = {
|
||||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
|
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
|
||||||
equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
|
equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
},
|
};
|
||||||
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
|
||||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
matchersUtil
|
||||||
|
);
|
||||||
|
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||||
|
|
||||||
calledSpy('a', 'b');
|
calledSpy('a', 'b');
|
||||||
const result = matcher.compare(calledSpy, 'a', 'b');
|
const result = matcher.compare(calledSpy, 'a', 'b');
|
||||||
@@ -19,15 +21,17 @@ describe('toHaveBeenCalledWith', function() {
|
|||||||
|
|
||||||
it('supports custom equality testers', function() {
|
it('supports custom equality testers', function() {
|
||||||
const customEqualityTesters = [
|
const customEqualityTesters = [
|
||||||
function() {
|
function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
],
|
];
|
||||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
customTesters: customEqualityTesters
|
customTesters: customEqualityTesters
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
|
||||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
matchersUtil
|
||||||
|
);
|
||||||
|
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||||
|
|
||||||
calledSpy('a', 'b');
|
calledSpy('a', 'b');
|
||||||
const result = matcher.compare(calledSpy, 'a', 'b');
|
const result = matcher.compare(calledSpy, 'a', 'b');
|
||||||
@@ -36,13 +40,13 @@ describe('toHaveBeenCalledWith', function() {
|
|||||||
|
|
||||||
it('fails when the actual was not called', function() {
|
it('fails when the actual was not called', function() {
|
||||||
const matchersUtil = {
|
const matchersUtil = {
|
||||||
contains: jasmine
|
contains: jasmine.createSpy('delegated-contains').and.returnValue(false),
|
||||||
.createSpy('delegated-contains')
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
.and.returnValue(false),
|
};
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
|
||||||
},
|
matchersUtil
|
||||||
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
|
);
|
||||||
uncalledSpy = new privateUnderTest.Spy('uncalled spy');
|
const uncalledSpy = new privateUnderTest.Spy('uncalled spy');
|
||||||
|
|
||||||
const result = matcher.compare(uncalledSpy);
|
const result = matcher.compare(uncalledSpy);
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
@@ -53,10 +57,12 @@ describe('toHaveBeenCalledWith', function() {
|
|||||||
|
|
||||||
it('fails when the actual was called with different parameters', function() {
|
it('fails when the actual was called with different parameters', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
|
||||||
calledSpy = new privateUnderTest.Spy('called spy');
|
matchersUtil
|
||||||
|
);
|
||||||
|
const calledSpy = new privateUnderTest.Spy('called spy');
|
||||||
|
|
||||||
calledSpy('a');
|
calledSpy('a');
|
||||||
calledSpy('c', 'd');
|
calledSpy('c', 'd');
|
||||||
@@ -85,9 +91,9 @@ describe('toHaveBeenCalledWith', function() {
|
|||||||
|
|
||||||
it('throws an exception when the actual is not a spy', function() {
|
it('throws an exception when the actual is not a spy', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith({
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
fn = function() {};
|
const fn = function() {};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
matcher.compare(fn);
|
matcher.compare(fn);
|
||||||
@@ -96,12 +102,14 @@ describe('toHaveBeenCalledWith', function() {
|
|||||||
|
|
||||||
it('set the correct calls as verified when passing', function() {
|
it('set the correct calls as verified when passing', function() {
|
||||||
const matchersUtil = {
|
const matchersUtil = {
|
||||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
|
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
|
||||||
equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
|
equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
},
|
};
|
||||||
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
|
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
|
||||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
matchersUtil
|
||||||
|
);
|
||||||
|
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||||
|
|
||||||
calledSpy('a', 'b');
|
calledSpy('a', 'b');
|
||||||
matcher.compare(calledSpy, 'a', 'b');
|
matcher.compare(calledSpy, 'a', 'b');
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
describe('toHaveClass', function() {
|
describe('toHaveClass', function() {
|
||||||
it('fails for a DOM element that lacks the expected class', function() {
|
it('fails for a DOM element that lacks the expected class', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveClass(),
|
const matcher = privateUnderTest.matchers.toHaveClass();
|
||||||
result = matcher.compare(
|
const result = matcher.compare(
|
||||||
specHelpers.domHelpers.createElementWithClassName(''),
|
specHelpers.domHelpers.createElementWithClassName(''),
|
||||||
'foo'
|
'foo'
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('passes for a DOM element that has the expected class', function() {
|
it('passes for a DOM element that has the expected class', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveClass(),
|
const matcher = privateUnderTest.matchers.toHaveClass();
|
||||||
el = specHelpers.domHelpers.createElementWithClassName('foo bar baz');
|
const el = specHelpers.domHelpers.createElementWithClassName('foo bar baz');
|
||||||
|
|
||||||
expect(matcher.compare(el, 'foo').pass).toBe(true);
|
expect(matcher.compare(el, 'foo').pass).toBe(true);
|
||||||
expect(matcher.compare(el, 'bar').pass).toBe(true);
|
expect(matcher.compare(el, 'bar').pass).toBe(true);
|
||||||
@@ -19,8 +19,8 @@ describe('toHaveClass', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails for a DOM element that only has other classes', function() {
|
it('fails for a DOM element that only has other classes', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveClass(),
|
const matcher = privateUnderTest.matchers.toHaveClass();
|
||||||
el = specHelpers.domHelpers.createElementWithClassName('foo bar');
|
const el = specHelpers.domHelpers.createElementWithClassName('foo bar');
|
||||||
|
|
||||||
expect(matcher.compare(el, 'fo').pass).toBe(false);
|
expect(matcher.compare(el, 'fo').pass).toBe(false);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
describe('toHaveClasses', function() {
|
describe('toHaveClasses', function() {
|
||||||
it('fails for a DOM element that lacks all the expected classes', function() {
|
it('fails for a DOM element that lacks all the expected classes', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveClasses(),
|
const matcher = privateUnderTest.matchers.toHaveClasses();
|
||||||
result = matcher.compare(
|
const result = matcher.compare(
|
||||||
specHelpers.domHelpers.createElementWithClassName(''),
|
specHelpers.domHelpers.createElementWithClassName(''),
|
||||||
['foo', 'bar']
|
['foo', 'bar']
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('passes for a DOM element that has all the expected classes', function() {
|
it('passes for a DOM element that has all the expected classes', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveClasses(),
|
const matcher = privateUnderTest.matchers.toHaveClasses();
|
||||||
el = specHelpers.domHelpers.createElementWithClassName('foo bar baz');
|
const el = specHelpers.domHelpers.createElementWithClassName('foo bar baz');
|
||||||
|
|
||||||
expect(matcher.compare(el, ['foo', 'bar']).pass).toBe(true);
|
expect(matcher.compare(el, ['foo', 'bar']).pass).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fails for a DOM element that only has some matching classes', function() {
|
it('fails for a DOM element that only has some matching classes', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveClasses(),
|
const matcher = privateUnderTest.matchers.toHaveClasses();
|
||||||
el = specHelpers.domHelpers.createElementWithClassName('foo bar');
|
const el = specHelpers.domHelpers.createElementWithClassName('foo bar');
|
||||||
|
|
||||||
expect(matcher.compare(el, ['foo', 'can']).pass).toBe(false);
|
expect(matcher.compare(el, ['foo', 'can']).pass).toBe(false);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -130,17 +130,17 @@ describe('toHaveNoOtherSpyInteractions', function() {
|
|||||||
|
|
||||||
it('handles multiple interactions with a single spy', function() {
|
it('handles multiple interactions with a single spy', function() {
|
||||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
matcher = privateUnderTest.matchers.toHaveNoOtherSpyInteractions(
|
const matcher = privateUnderTest.matchers.toHaveNoOtherSpyInteractions(
|
||||||
matchersUtil
|
matchersUtil
|
||||||
),
|
);
|
||||||
toHaveBeenCalledWithMatcher = privateUnderTest.matchers.toHaveBeenCalledWith(
|
const toHaveBeenCalledWithMatcher = privateUnderTest.matchers.toHaveBeenCalledWith(
|
||||||
matchersUtil
|
matchersUtil
|
||||||
),
|
);
|
||||||
spyObj = jasmineUnderTest
|
const spyObj = jasmineUnderTest
|
||||||
.getEnv()
|
.getEnv()
|
||||||
.createSpyObj('NewClass', ['spyA', 'spyB']);
|
.createSpyObj('NewClass', ['spyA', 'spyB']);
|
||||||
|
|
||||||
spyObj.spyA('x');
|
spyObj.spyA('x');
|
||||||
spyObj.spyA('y');
|
spyObj.spyA('y');
|
||||||
|
|||||||
@@ -2,24 +2,24 @@ describe('toHaveSize', function() {
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
it('passes for an array whose length matches', function() {
|
it('passes for an array whose length matches', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||||
result = matcher.compare([1, 2], 2);
|
const result = matcher.compare([1, 2], 2);
|
||||||
|
|
||||||
expect(result.pass).toBe(true);
|
expect(result.pass).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fails for an array whose length does not match', function() {
|
it('fails for an array whose length does not match', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||||
result = matcher.compare([1, 2, 3], 2);
|
const result = matcher.compare([1, 2, 3], 2);
|
||||||
|
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('informs about the size of an array whose length does not match', function() {
|
it('informs about the size of an array whose length does not match', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveSize({
|
const matcher = privateUnderTest.matchers.toHaveSize({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
result = matcher.compare([1, 2, 3], 2);
|
const result = matcher.compare([1, 2, 3], 2);
|
||||||
|
|
||||||
expect(result.message()).toEqual(
|
expect(result.message()).toEqual(
|
||||||
'Expected [ 1, 2, 3 ] with size 3 to have size 2.'
|
'Expected [ 1, 2, 3 ] with size 3 to have size 2.'
|
||||||
@@ -27,43 +27,43 @@ describe('toHaveSize', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('passes for an object with the proper number of keys', function() {
|
it('passes for an object with the proper number of keys', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||||
result = matcher.compare({ a: 1, b: 2 }, 2);
|
const result = matcher.compare({ a: 1, b: 2 }, 2);
|
||||||
|
|
||||||
expect(result.pass).toBe(true);
|
expect(result.pass).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fails for an object with a different number of keys', function() {
|
it('fails for an object with a different number of keys', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||||
result = matcher.compare({ a: 1, b: 2 }, 1);
|
const result = matcher.compare({ a: 1, b: 2 }, 1);
|
||||||
|
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('passes for an object with an explicit `length` property that matches', function() {
|
it('passes for an object with an explicit `length` property that matches', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||||
result = matcher.compare({ a: 1, b: 2, length: 5 }, 5);
|
const result = matcher.compare({ a: 1, b: 2, length: 5 }, 5);
|
||||||
|
|
||||||
expect(result.pass).toBe(true);
|
expect(result.pass).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fails for an object with an explicit `length` property that does not match', function() {
|
it('fails for an object with an explicit `length` property that does not match', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||||
result = matcher.compare({ a: 1, b: 2, length: 5 }, 1);
|
const result = matcher.compare({ a: 1, b: 2, length: 5 }, 1);
|
||||||
|
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('passes for a string whose length matches', function() {
|
it('passes for a string whose length matches', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||||
result = matcher.compare('ab', 2);
|
const result = matcher.compare('ab', 2);
|
||||||
|
|
||||||
expect(result.pass).toBe(true);
|
expect(result.pass).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fails for a string whose length does not match', function() {
|
it('fails for a string whose length does not match', function() {
|
||||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||||
result = matcher.compare('abc', 2);
|
const result = matcher.compare('abc', 2);
|
||||||
|
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
});
|
});
|
||||||
@@ -73,8 +73,8 @@ describe('toHaveSize', function() {
|
|||||||
map.set('a', 1);
|
map.set('a', 1);
|
||||||
map.set('b', 2);
|
map.set('b', 2);
|
||||||
|
|
||||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||||
result = matcher.compare(map, 2);
|
const result = matcher.compare(map, 2);
|
||||||
|
|
||||||
expect(result.pass).toBe(true);
|
expect(result.pass).toBe(true);
|
||||||
});
|
});
|
||||||
@@ -84,8 +84,8 @@ describe('toHaveSize', function() {
|
|||||||
map.set('a', 1);
|
map.set('a', 1);
|
||||||
map.set('b', 2);
|
map.set('b', 2);
|
||||||
|
|
||||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||||
result = matcher.compare(map, 1);
|
const result = matcher.compare(map, 1);
|
||||||
|
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
});
|
});
|
||||||
@@ -95,8 +95,8 @@ describe('toHaveSize', function() {
|
|||||||
set.add('a');
|
set.add('a');
|
||||||
set.add('b');
|
set.add('b');
|
||||||
|
|
||||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||||
result = matcher.compare(set, 2);
|
const result = matcher.compare(set, 2);
|
||||||
|
|
||||||
expect(result.pass).toBe(true);
|
expect(result.pass).toBe(true);
|
||||||
});
|
});
|
||||||
@@ -106,8 +106,8 @@ describe('toHaveSize', function() {
|
|||||||
set.add('a');
|
set.add('a');
|
||||||
set.add('b');
|
set.add('b');
|
||||||
|
|
||||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||||
result = matcher.compare(set, 1);
|
const result = matcher.compare(set, 1);
|
||||||
|
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ describe('toThrowError', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('throws an error when the expected is not an Error, string, or RegExp', function() {
|
it('throws an error when the expected is not an Error, string, or RegExp', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
const matcher = privateUnderTest.matchers.toThrowError();
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new Error('foo');
|
throw new Error('foo');
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
matcher.compare(fn, 1);
|
matcher.compare(fn, 1);
|
||||||
@@ -19,10 +19,10 @@ describe('toThrowError', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('throws an error when the expected error type is not an Error', function() {
|
it('throws an error when the expected error type is not an Error', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
const matcher = privateUnderTest.matchers.toThrowError();
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new Error('foo');
|
throw new Error('foo');
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
matcher.compare(fn, void 0, 'foo');
|
matcher.compare(fn, void 0, 'foo');
|
||||||
@@ -30,10 +30,10 @@ describe('toThrowError', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('throws an error when the expected error message is not a string or RegExp', function() {
|
it('throws an error when the expected error message is not a string or RegExp', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
const matcher = privateUnderTest.matchers.toThrowError();
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new Error('foo');
|
throw new Error('foo');
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
matcher.compare(fn, Error, 1);
|
matcher.compare(fn, Error, 1);
|
||||||
@@ -41,10 +41,10 @@ describe('toThrowError', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails if actual does not throw at all', function() {
|
it('fails if actual does not throw at all', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
const matcher = privateUnderTest.matchers.toThrowError();
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn);
|
const result = matcher.compare(fn);
|
||||||
|
|
||||||
@@ -54,11 +54,11 @@ describe('toThrowError', function() {
|
|||||||
|
|
||||||
it('fails if thrown is not an instanceof Error', function() {
|
it('fails if thrown is not an instanceof Error', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowError({
|
const matcher = privateUnderTest.matchers.toThrowError({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw 4;
|
throw 4;
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn);
|
const result = matcher.compare(fn);
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
@@ -104,11 +104,11 @@ describe('toThrowError', function() {
|
|||||||
|
|
||||||
it('fails with the correct message if thrown is a falsy value', function() {
|
it('fails with the correct message if thrown is a falsy value', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowError({
|
const matcher = privateUnderTest.matchers.toThrowError({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw undefined;
|
throw undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn);
|
const result = matcher.compare(fn);
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
@@ -118,10 +118,10 @@ describe('toThrowError', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('passes if thrown is a type of Error, but there is no expected error', function() {
|
it('passes if thrown is a type of Error, but there is no expected error', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
const matcher = privateUnderTest.matchers.toThrowError();
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new TypeError();
|
throw new TypeError();
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn);
|
const result = matcher.compare(fn);
|
||||||
|
|
||||||
@@ -133,11 +133,11 @@ describe('toThrowError', function() {
|
|||||||
|
|
||||||
it('passes if thrown is an Error and the expected is the same message', function() {
|
it('passes if thrown is an Error and the expected is the same message', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowError({
|
const matcher = privateUnderTest.matchers.toThrowError({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new Error('foo');
|
throw new Error('foo');
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn, 'foo');
|
const result = matcher.compare(fn, 'foo');
|
||||||
|
|
||||||
@@ -149,11 +149,11 @@ describe('toThrowError', function() {
|
|||||||
|
|
||||||
it('fails if thrown is an Error and the expected is not the same message', function() {
|
it('fails if thrown is an Error and the expected is not the same message', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowError({
|
const matcher = privateUnderTest.matchers.toThrowError({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new Error('foo');
|
throw new Error('foo');
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn, 'bar');
|
const result = matcher.compare(fn, 'bar');
|
||||||
|
|
||||||
@@ -165,11 +165,11 @@ describe('toThrowError', function() {
|
|||||||
|
|
||||||
it('passes if thrown is an Error and the expected is a RegExp that matches the message', function() {
|
it('passes if thrown is an Error and the expected is a RegExp that matches the message', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowError({
|
const matcher = privateUnderTest.matchers.toThrowError({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new Error('a long message');
|
throw new Error('a long message');
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn, /long/);
|
const result = matcher.compare(fn, /long/);
|
||||||
|
|
||||||
@@ -181,11 +181,11 @@ describe('toThrowError', function() {
|
|||||||
|
|
||||||
it('fails if thrown is an Error and the expected is a RegExp that does not match the message', function() {
|
it('fails if thrown is an Error and the expected is a RegExp that does not match the message', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowError({
|
const matcher = privateUnderTest.matchers.toThrowError({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new Error('a long message');
|
throw new Error('a long message');
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn, /foo/);
|
const result = matcher.compare(fn, /foo/);
|
||||||
|
|
||||||
@@ -196,10 +196,10 @@ describe('toThrowError', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('passes if thrown is an Error and the expected the same Error', function() {
|
it('passes if thrown is an Error and the expected the same Error', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
const matcher = privateUnderTest.matchers.toThrowError();
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new Error();
|
throw new Error();
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn, Error);
|
const result = matcher.compare(fn, Error);
|
||||||
|
|
||||||
@@ -208,13 +208,13 @@ describe('toThrowError', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('passes if thrown is a custom error that takes arguments and the expected is the same error', function() {
|
it('passes if thrown is a custom error that takes arguments and the expected is the same error', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
const matcher = privateUnderTest.matchers.toThrowError();
|
||||||
CustomError = function CustomError(arg) {
|
const CustomError = function CustomError(arg) {
|
||||||
arg.x;
|
arg.x;
|
||||||
},
|
};
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new CustomError({ x: 1 });
|
throw new CustomError({ x: 1 });
|
||||||
};
|
};
|
||||||
|
|
||||||
CustomError.prototype = new Error();
|
CustomError.prototype = new Error();
|
||||||
|
|
||||||
@@ -227,10 +227,10 @@ describe('toThrowError', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails if thrown is an Error and the expected is a different Error', function() {
|
it('fails if thrown is an Error and the expected is a different Error', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
const matcher = privateUnderTest.matchers.toThrowError();
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new Error();
|
throw new Error();
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn, TypeError);
|
const result = matcher.compare(fn, TypeError);
|
||||||
|
|
||||||
@@ -242,13 +242,13 @@ describe('toThrowError', function() {
|
|||||||
|
|
||||||
it('passes if thrown is a type of Error and it is equal to the expected Error and message', function() {
|
it('passes if thrown is a type of Error and it is equal to the expected Error and message', function() {
|
||||||
const matchersUtil = {
|
const matchersUtil = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
},
|
};
|
||||||
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
|
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new TypeError('foo');
|
throw new TypeError('foo');
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn, TypeError, 'foo');
|
const result = matcher.compare(fn, TypeError, 'foo');
|
||||||
|
|
||||||
@@ -260,16 +260,16 @@ describe('toThrowError', function() {
|
|||||||
|
|
||||||
it('passes if thrown is a custom error that takes arguments and it is equal to the expected custom error and message', function() {
|
it('passes if thrown is a custom error that takes arguments and it is equal to the expected custom error and message', function() {
|
||||||
const matchersUtil = {
|
const matchersUtil = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
},
|
};
|
||||||
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
|
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
|
||||||
CustomError = function CustomError(arg) {
|
const CustomError = function CustomError(arg) {
|
||||||
this.message = arg.message;
|
this.message = arg.message;
|
||||||
},
|
};
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new CustomError({ message: 'foo' });
|
throw new CustomError({ message: 'foo' });
|
||||||
};
|
};
|
||||||
|
|
||||||
CustomError.prototype = new Error();
|
CustomError.prototype = new Error();
|
||||||
|
|
||||||
@@ -284,13 +284,13 @@ describe('toThrowError', function() {
|
|||||||
describe('with a string', function() {
|
describe('with a string', function() {
|
||||||
it('fails if thrown is a type of Error and the expected is a different Error', function() {
|
it('fails if thrown is a type of Error and the expected is a different Error', function() {
|
||||||
const matchersUtil = {
|
const matchersUtil = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
},
|
};
|
||||||
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
|
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new TypeError('foo');
|
throw new TypeError('foo');
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn, TypeError, 'bar');
|
const result = matcher.compare(fn, TypeError, 'bar');
|
||||||
|
|
||||||
@@ -304,13 +304,13 @@ describe('toThrowError', function() {
|
|||||||
describe('with a regex', function() {
|
describe('with a regex', function() {
|
||||||
it('fails if thrown is a type of Error and the expected is a different Error', function() {
|
it('fails if thrown is a type of Error and the expected is a different Error', function() {
|
||||||
const matchersUtil = {
|
const matchersUtil = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
},
|
};
|
||||||
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
|
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new TypeError('foo');
|
throw new TypeError('foo');
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn, TypeError, /bar/);
|
const result = matcher.compare(fn, TypeError, /bar/);
|
||||||
|
|
||||||
@@ -323,13 +323,13 @@ describe('toThrowError', function() {
|
|||||||
|
|
||||||
it('passes if thrown is a type of Error and has the same type as the expected Error and the message matches the expected message', function() {
|
it('passes if thrown is a type of Error and has the same type as the expected Error and the message matches the expected message', function() {
|
||||||
const matchersUtil = {
|
const matchersUtil = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
},
|
};
|
||||||
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
|
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new TypeError('foo');
|
throw new TypeError('foo');
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn, TypeError, /foo/);
|
const result = matcher.compare(fn, TypeError, /foo/);
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ describe('toThrowMatching', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('throws an error when the expected is not a function', function() {
|
it('throws an error when the expected is not a function', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowMatching(),
|
const matcher = privateUnderTest.matchers.toThrowMatching();
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new Error('foo');
|
throw new Error('foo');
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
matcher.compare(fn, 1);
|
matcher.compare(fn, 1);
|
||||||
@@ -21,10 +21,10 @@ describe('toThrowMatching', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails if actual does not throw at all', function() {
|
it('fails if actual does not throw at all', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowMatching(),
|
const matcher = privateUnderTest.matchers.toThrowMatching();
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn, function() {
|
const result = matcher.compare(fn, function() {
|
||||||
return true;
|
return true;
|
||||||
@@ -36,11 +36,11 @@ describe('toThrowMatching', function() {
|
|||||||
|
|
||||||
it('fails with the correct message if thrown is a falsy value', function() {
|
it('fails with the correct message if thrown is a falsy value', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowMatching({
|
const matcher = privateUnderTest.matchers.toThrowMatching({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw undefined;
|
throw undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn, function() {
|
const result = matcher.compare(fn, function() {
|
||||||
return false;
|
return false;
|
||||||
@@ -52,13 +52,13 @@ describe('toThrowMatching', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('passes if the argument is a function that returns true when called with the error', function() {
|
it('passes if the argument is a function that returns true when called with the error', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowMatching(),
|
const matcher = privateUnderTest.matchers.toThrowMatching();
|
||||||
predicate = function(e) {
|
const predicate = function(e) {
|
||||||
return e.message === 'nope';
|
return e.message === 'nope';
|
||||||
},
|
};
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new TypeError('nope');
|
throw new TypeError('nope');
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn, predicate);
|
const result = matcher.compare(fn, predicate);
|
||||||
|
|
||||||
@@ -70,14 +70,14 @@ describe('toThrowMatching', function() {
|
|||||||
|
|
||||||
it('fails if the argument is a function that returns false when called with the error', function() {
|
it('fails if the argument is a function that returns false when called with the error', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrowMatching({
|
const matcher = privateUnderTest.matchers.toThrowMatching({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
predicate = function(e) {
|
const predicate = function(e) {
|
||||||
return e.message === 'oh no';
|
return e.message === 'oh no';
|
||||||
},
|
};
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw new TypeError('nope');
|
throw new TypeError('nope');
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn, predicate);
|
const result = matcher.compare(fn, predicate);
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ describe('toThrow', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fails if actual does not throw', function() {
|
it('fails if actual does not throw', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrow(),
|
const matcher = privateUnderTest.matchers.toThrow();
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn);
|
const result = matcher.compare(fn);
|
||||||
|
|
||||||
@@ -22,13 +22,13 @@ describe('toThrow', function() {
|
|||||||
|
|
||||||
it('passes if it throws but there is no expected', function() {
|
it('passes if it throws but there is no expected', function() {
|
||||||
const matchersUtil = {
|
const matchersUtil = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
},
|
};
|
||||||
matcher = privateUnderTest.matchers.toThrow(matchersUtil),
|
const matcher = privateUnderTest.matchers.toThrow(matchersUtil);
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw 5;
|
throw 5;
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn);
|
const result = matcher.compare(fn);
|
||||||
|
|
||||||
@@ -40,11 +40,11 @@ describe('toThrow', function() {
|
|||||||
|
|
||||||
it('passes even if what is thrown is falsy', function() {
|
it('passes even if what is thrown is falsy', function() {
|
||||||
const matcher = privateUnderTest.matchers.toThrow({
|
const matcher = privateUnderTest.matchers.toThrow({
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
}),
|
});
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw undefined;
|
throw undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn);
|
const result = matcher.compare(fn);
|
||||||
expect(result.pass).toBe(true);
|
expect(result.pass).toBe(true);
|
||||||
@@ -55,13 +55,13 @@ describe('toThrow', function() {
|
|||||||
|
|
||||||
it('passes if what is thrown is equivalent to what is expected', function() {
|
it('passes if what is thrown is equivalent to what is expected', function() {
|
||||||
const matchersUtil = {
|
const matchersUtil = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
},
|
};
|
||||||
matcher = privateUnderTest.matchers.toThrow(matchersUtil),
|
const matcher = privateUnderTest.matchers.toThrow(matchersUtil);
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw 5;
|
throw 5;
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn, 5);
|
const result = matcher.compare(fn, 5);
|
||||||
|
|
||||||
@@ -71,13 +71,13 @@ describe('toThrow', function() {
|
|||||||
|
|
||||||
it('fails if what is thrown is not equivalent to what is expected', function() {
|
it('fails if what is thrown is not equivalent to what is expected', function() {
|
||||||
const matchersUtil = {
|
const matchersUtil = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
},
|
};
|
||||||
matcher = privateUnderTest.matchers.toThrow(matchersUtil),
|
const matcher = privateUnderTest.matchers.toThrow(matchersUtil);
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw 5;
|
throw 5;
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn, 'foo');
|
const result = matcher.compare(fn, 'foo');
|
||||||
|
|
||||||
@@ -89,13 +89,13 @@ describe('toThrow', function() {
|
|||||||
|
|
||||||
it('fails if what is thrown is not equivalent to undefined', function() {
|
it('fails if what is thrown is not equivalent to undefined', function() {
|
||||||
const matchersUtil = {
|
const matchersUtil = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||||
pp: privateUnderTest.makePrettyPrinter()
|
pp: privateUnderTest.makePrettyPrinter()
|
||||||
},
|
};
|
||||||
matcher = privateUnderTest.matchers.toThrow(matchersUtil),
|
const matcher = privateUnderTest.matchers.toThrow(matchersUtil);
|
||||||
fn = function() {
|
const fn = function() {
|
||||||
throw 5;
|
throw 5;
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = matcher.compare(fn, void 0);
|
const result = matcher.compare(fn, void 0);
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,10 @@
|
|||||||
toHaveFailedExpectationsForRunnable: function() {
|
toHaveFailedExpectationsForRunnable: function() {
|
||||||
return {
|
return {
|
||||||
compare: function(actual, fullName, expectedFailures) {
|
compare: function(actual, fullName, expectedFailures) {
|
||||||
let foundRunnable = false,
|
let foundRunnable = false;
|
||||||
expectations = true,
|
let expectations = true;
|
||||||
foundFailures = [];
|
let foundFailures = [];
|
||||||
|
|
||||||
for (let i = 0; i < actual.calls.count(); i++) {
|
for (let i = 0; i < actual.calls.count(); i++) {
|
||||||
const args = actual.calls.argsFor(i)[0];
|
const args = actual.calls.argsFor(i)[0];
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
(function() {
|
(function() {
|
||||||
const path = require('path'),
|
const path = require('path');
|
||||||
glob = require('glob');
|
const glob = require('glob');
|
||||||
|
|
||||||
const jasmineUnderTestRequire = require(path.join(
|
const jasmineUnderTestRequire = require(path.join(
|
||||||
__dirname,
|
__dirname,
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('emits a deprecation warning', function() {
|
it('emits a deprecation warning', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
expect(deprecator.addDeprecationWarning).toHaveBeenCalledWith(
|
expect(deprecator.addDeprecationWarning).toHaveBeenCalledWith(
|
||||||
@@ -32,14 +32,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('builds the initial DOM elements, including the title banner', function() {
|
it('builds the initial DOM elements, including the title banner', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
// Main top-level elements
|
// Main top-level elements
|
||||||
@@ -62,14 +62,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('builds a single reporter even if initialized multiple times', function() {
|
it('builds a single reporter even if initialized multiple times', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
@@ -130,14 +130,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('reports the status symbol of a excluded spec', function() {
|
it('reports the status symbol of a excluded spec', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.specDone({
|
reporter.specDone({
|
||||||
id: 789,
|
id: 789,
|
||||||
@@ -156,14 +156,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('reports the status symbol of a pending spec', function() {
|
it('reports the status symbol of a pending spec', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
reporter.specDone({
|
reporter.specDone({
|
||||||
@@ -179,14 +179,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('reports the status symbol of a passing spec', function() {
|
it('reports the status symbol of a passing spec', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
reporter.specDone({
|
reporter.specDone({
|
||||||
@@ -203,14 +203,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('reports the status symbol of a failing spec', function() {
|
it('reports the status symbol of a failing spec', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
@@ -229,14 +229,14 @@ describe('HtmlReporter', function() {
|
|||||||
|
|
||||||
describe('when there are deprecation warnings', function() {
|
describe('when there are deprecation warnings', function() {
|
||||||
it('displays the messages in their own alert bars', function() {
|
it('displays the messages in their own alert bars', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
@@ -278,14 +278,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('displays expandable stack traces', function() {
|
it('displays expandable stack traces', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
@@ -322,14 +322,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('omits the expander when there is no stack trace', function() {
|
it('omits the expander when there is no stack trace', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
@@ -349,14 +349,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('nicely formats the verboseDeprecations note', function() {
|
it('nicely formats the verboseDeprecations note', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
@@ -384,14 +384,14 @@ describe('HtmlReporter', function() {
|
|||||||
if (!window.console) {
|
if (!window.console) {
|
||||||
window.console = { error: function() {} };
|
window.console = { error: function() {} };
|
||||||
}
|
}
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(console, 'error');
|
spyOn(console, 'error');
|
||||||
|
|
||||||
@@ -422,14 +422,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('reports the run time', function() {
|
it('reports the run time', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
@@ -444,17 +444,17 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('reports the suite names with status, and spec names with status and duration', function() {
|
it('reports the suite names with status, and spec names with status and duration', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
addToExistingQueryString: function(key, value) {
|
addToExistingQueryString: function(key, value) {
|
||||||
return '?foo=bar&' + key + '=' + value;
|
return '?foo=bar&' + key + '=' + value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
reporter.jasmineStarted({});
|
reporter.jasmineStarted({});
|
||||||
@@ -561,24 +561,24 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('has an options menu', function() {
|
it('has an options menu', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
const trigger = container.querySelector(
|
const trigger = container.querySelector(
|
||||||
'.jasmine-run-options .jasmine-trigger'
|
'.jasmine-run-options .jasmine-trigger'
|
||||||
),
|
);
|
||||||
payload = container.querySelector(
|
const payload = container.querySelector(
|
||||||
'.jasmine-run-options .jasmine-payload'
|
'.jasmine-run-options .jasmine-payload'
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(payload).not.toHaveClass('jasmine-open');
|
expect(payload).not.toHaveClass('jasmine-open');
|
||||||
|
|
||||||
@@ -593,14 +593,14 @@ describe('HtmlReporter', function() {
|
|||||||
|
|
||||||
describe('when there are global errors', function() {
|
describe('when there are global errors', function() {
|
||||||
it('displays the exceptions in their own alert bars', function() {
|
it('displays the exceptions in their own alert bars', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
@@ -671,14 +671,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('displays file and line information if available', function() {
|
it('displays file and line information if available', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
@@ -707,14 +707,14 @@ describe('HtmlReporter', function() {
|
|||||||
|
|
||||||
describe('UI for stop on spec failure', function() {
|
describe('UI for stop on spec failure', function() {
|
||||||
it('should be unchecked for full execution', function() {
|
it('should be unchecked for full execution', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
@@ -724,14 +724,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be checked if stopping short', function() {
|
it('should be checked if stopping short', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
env.configure({ stopOnSpecFailure: true });
|
env.configure({ stopOnSpecFailure: true });
|
||||||
|
|
||||||
@@ -743,16 +743,16 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should navigate and turn the setting on', function() {
|
it('should navigate and turn the setting on', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
navigationHandler = jasmine.createSpy('navigate'),
|
const navigationHandler = jasmine.createSpy('navigate');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
navigateWithNewParam: navigationHandler,
|
navigateWithNewParam: navigationHandler,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
@@ -767,16 +767,16 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should navigate and turn the setting off', function() {
|
it('should navigate and turn the setting off', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
navigationHandler = jasmine.createSpy('navigate'),
|
const navigationHandler = jasmine.createSpy('navigate');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
navigateWithNewParam: navigationHandler,
|
navigateWithNewParam: navigationHandler,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
env.configure({ stopOnSpecFailure: true });
|
env.configure({ stopOnSpecFailure: true });
|
||||||
|
|
||||||
@@ -795,14 +795,14 @@ describe('HtmlReporter', function() {
|
|||||||
|
|
||||||
describe('UI for throwing errors on expectation failures', function() {
|
describe('UI for throwing errors on expectation failures', function() {
|
||||||
it('should be unchecked if not throwing', function() {
|
it('should be unchecked if not throwing', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
@@ -814,14 +814,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be checked if throwing', function() {
|
it('should be checked if throwing', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
env.configure({ stopSpecOnExpectationFailure: true });
|
env.configure({ stopSpecOnExpectationFailure: true });
|
||||||
|
|
||||||
@@ -835,16 +835,16 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should navigate and change the setting to on', function() {
|
it('should navigate and change the setting to on', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
navigateHandler = jasmine.createSpy('navigate'),
|
const navigateHandler = jasmine.createSpy('navigate');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
navigateWithNewParam: navigateHandler
|
navigateWithNewParam: navigateHandler
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
@@ -861,16 +861,16 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should navigate and change the setting to off', function() {
|
it('should navigate and change the setting to off', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
navigateHandler = jasmine.createSpy('navigate'),
|
const navigateHandler = jasmine.createSpy('navigate');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
navigateWithNewParam: navigateHandler
|
navigateWithNewParam: navigateHandler
|
||||||
});
|
});
|
||||||
|
|
||||||
env.configure({ stopSpecOnExpectationFailure: true });
|
env.configure({ stopSpecOnExpectationFailure: true });
|
||||||
|
|
||||||
@@ -937,14 +937,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not display specs that have been disabled', function() {
|
it('should not display specs that have been disabled', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
env.configure({ hideDisabled: true });
|
env.configure({ hideDisabled: true });
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
@@ -965,14 +965,14 @@ describe('HtmlReporter', function() {
|
|||||||
|
|
||||||
describe('UI for running tests in random order', function() {
|
describe('UI for running tests in random order', function() {
|
||||||
it('should be unchecked if not randomizing', function() {
|
it('should be unchecked if not randomizing', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
env.configure({ random: false });
|
env.configure({ random: false });
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
@@ -983,14 +983,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be checked if randomizing', function() {
|
it('should be checked if randomizing', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
env.configure({ random: true });
|
env.configure({ random: true });
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
@@ -1001,16 +1001,16 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should navigate and change the setting to on', function() {
|
it('should navigate and change the setting to on', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
navigateHandler = jasmine.createSpy('navigate'),
|
const navigateHandler = jasmine.createSpy('navigate');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
navigateWithNewParam: navigateHandler
|
navigateWithNewParam: navigateHandler
|
||||||
});
|
});
|
||||||
|
|
||||||
env.configure({ random: false });
|
env.configure({ random: false });
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
@@ -1023,16 +1023,16 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should navigate and change the setting to off', function() {
|
it('should navigate and change the setting to off', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
navigateHandler = jasmine.createSpy('navigate'),
|
const navigateHandler = jasmine.createSpy('navigate');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
navigateWithNewParam: navigateHandler
|
navigateWithNewParam: navigateHandler
|
||||||
});
|
});
|
||||||
|
|
||||||
env.configure({ random: true });
|
env.configure({ random: true });
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
@@ -1045,14 +1045,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should show the seed bar if randomizing', function() {
|
it('should show the seed bar if randomizing', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({
|
reporter.jasmineDone({
|
||||||
@@ -1069,14 +1069,14 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not show the current seed bar if not randomizing', function() {
|
it('should not show the current seed bar if not randomizing', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
@@ -1114,16 +1114,16 @@ describe('HtmlReporter', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should include non-spec query params in the jasmine-skipped link when present', function() {
|
it('should include non-spec query params in the jasmine-skipped link when present', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: function() {
|
getContainer: function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
},
|
||||||
addToExistingQueryString: function(key, value) {
|
addToExistingQueryString: function(key, value) {
|
||||||
return '?foo=bar&' + key + '=' + value;
|
return '?foo=bar&' + key + '=' + value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
||||||
@@ -1140,12 +1140,12 @@ describe('HtmlReporter', function() {
|
|||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
container = document.createElement('div');
|
container = document.createElement('div');
|
||||||
const getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
reporter.jasmineStarted({ totalSpecsDefined: 2 });
|
reporter.jasmineStarted({ totalSpecsDefined: 2 });
|
||||||
@@ -1464,9 +1464,9 @@ describe('HtmlReporter', function() {
|
|||||||
|
|
||||||
it('reports traces when present', function() {
|
it('reports traces when present', function() {
|
||||||
const specFailure = container.querySelectorAll(
|
const specFailure = container.querySelectorAll(
|
||||||
'.jasmine-spec-detail.jasmine-failed'
|
'.jasmine-spec-detail.jasmine-failed'
|
||||||
)[2],
|
)[2];
|
||||||
debugLogs = specFailure.querySelector('.jasmine-debug-log table');
|
const debugLogs = specFailure.querySelector('.jasmine-debug-log table');
|
||||||
|
|
||||||
expect(debugLogs).toBeTruthy();
|
expect(debugLogs).toBeTruthy();
|
||||||
const rows = debugLogs.querySelectorAll('tbody tr');
|
const rows = debugLogs.querySelectorAll('tbody tr');
|
||||||
@@ -1570,14 +1570,14 @@ describe('HtmlReporter', function() {
|
|||||||
describe('The overall result bar', function() {
|
describe('The overall result bar', function() {
|
||||||
describe("When the jasmineDone event's overallStatus is 'passed'", function() {
|
describe("When the jasmineDone event's overallStatus is 'passed'", function() {
|
||||||
it('has class jasmine-passed', function() {
|
it('has class jasmine-passed', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
@@ -1594,14 +1594,14 @@ describe('HtmlReporter', function() {
|
|||||||
|
|
||||||
describe("When the jasmineDone event's overallStatus is 'failed'", function() {
|
describe("When the jasmineDone event's overallStatus is 'failed'", function() {
|
||||||
it('has class jasmine-failed', function() {
|
it('has class jasmine-failed', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
@@ -1618,14 +1618,14 @@ describe('HtmlReporter', function() {
|
|||||||
|
|
||||||
describe("When the jasmineDone event's overallStatus is 'incomplete'", function() {
|
describe("When the jasmineDone event's overallStatus is 'incomplete'", function() {
|
||||||
it('has class jasmine-incomplete', function() {
|
it('has class jasmine-incomplete', function() {
|
||||||
const container = document.createElement('div'),
|
const container = document.createElement('div');
|
||||||
getContainer = function() {
|
const getContainer = function() {
|
||||||
return container;
|
return container;
|
||||||
},
|
};
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer
|
getContainer: getContainer
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
|
|||||||
@@ -606,11 +606,11 @@ describe('HtmlReporterV2', function() {
|
|||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
const trigger = container.querySelector(
|
const trigger = container.querySelector(
|
||||||
'.jasmine-run-options .jasmine-trigger'
|
'.jasmine-run-options .jasmine-trigger'
|
||||||
),
|
);
|
||||||
payload = container.querySelector(
|
const payload = container.querySelector(
|
||||||
'.jasmine-run-options .jasmine-payload'
|
'.jasmine-run-options .jasmine-payload'
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(payload).not.toHaveClass('jasmine-open');
|
expect(payload).not.toHaveClass('jasmine-open');
|
||||||
|
|
||||||
@@ -1202,9 +1202,9 @@ describe('HtmlReporterV2', function() {
|
|||||||
|
|
||||||
it('reports traces when present', function() {
|
it('reports traces when present', function() {
|
||||||
const specFailure = container.querySelectorAll(
|
const specFailure = container.querySelectorAll(
|
||||||
'.jasmine-spec-detail.jasmine-failed'
|
'.jasmine-spec-detail.jasmine-failed'
|
||||||
)[2],
|
)[2];
|
||||||
debugLogs = specFailure.querySelector('.jasmine-debug-log table');
|
const debugLogs = specFailure.querySelector('.jasmine-debug-log table');
|
||||||
|
|
||||||
expect(debugLogs).toBeTruthy();
|
expect(debugLogs).toBeTruthy();
|
||||||
const rows = debugLogs.querySelectorAll('tbody tr');
|
const rows = debugLogs.querySelectorAll('tbody tr');
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ describe('QueryString', function() {
|
|||||||
describe('#navigateWithNewParam', function() {
|
describe('#navigateWithNewParam', function() {
|
||||||
it('sets the query string to include the given key/value pair', function() {
|
it('sets the query string to include the given key/value pair', function() {
|
||||||
const windowLocation = {
|
const windowLocation = {
|
||||||
search: ''
|
search: ''
|
||||||
},
|
};
|
||||||
queryString = new jasmineUnderTest.QueryString({
|
const queryString = new jasmineUnderTest.QueryString({
|
||||||
getWindowLocation: function() {
|
getWindowLocation: function() {
|
||||||
return windowLocation;
|
return windowLocation;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
queryString.navigateWithNewParam('foo', 'bar baz');
|
queryString.navigateWithNewParam('foo', 'bar baz');
|
||||||
|
|
||||||
@@ -17,13 +17,13 @@ describe('QueryString', function() {
|
|||||||
|
|
||||||
it('leaves existing params alone', function() {
|
it('leaves existing params alone', function() {
|
||||||
const windowLocation = {
|
const windowLocation = {
|
||||||
search: '?foo=bar'
|
search: '?foo=bar'
|
||||||
},
|
};
|
||||||
queryString = new jasmineUnderTest.QueryString({
|
const queryString = new jasmineUnderTest.QueryString({
|
||||||
getWindowLocation: function() {
|
getWindowLocation: function() {
|
||||||
return windowLocation;
|
return windowLocation;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
queryString.navigateWithNewParam('baz', 'quux');
|
queryString.navigateWithNewParam('baz', 'quux');
|
||||||
|
|
||||||
@@ -35,13 +35,13 @@ describe('QueryString', function() {
|
|||||||
describe('#fullStringWithNewParam', function() {
|
describe('#fullStringWithNewParam', function() {
|
||||||
it('gets the query string including the given key/value pair', function() {
|
it('gets the query string including the given key/value pair', function() {
|
||||||
const windowLocation = {
|
const windowLocation = {
|
||||||
search: '?foo=bar'
|
search: '?foo=bar'
|
||||||
},
|
};
|
||||||
queryString = new jasmineUnderTest.QueryString({
|
const queryString = new jasmineUnderTest.QueryString({
|
||||||
getWindowLocation: function() {
|
getWindowLocation: function() {
|
||||||
return windowLocation;
|
return windowLocation;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = queryString.fullStringWithNewParam('baz', 'quux');
|
const result = queryString.fullStringWithNewParam('baz', 'quux');
|
||||||
|
|
||||||
@@ -53,26 +53,26 @@ describe('QueryString', function() {
|
|||||||
describe('#getParam', function() {
|
describe('#getParam', function() {
|
||||||
it('returns the value of the requested key', function() {
|
it('returns the value of the requested key', function() {
|
||||||
const windowLocation = {
|
const windowLocation = {
|
||||||
search: '?baz=quux%20corge'
|
search: '?baz=quux%20corge'
|
||||||
},
|
};
|
||||||
queryString = new jasmineUnderTest.QueryString({
|
const queryString = new jasmineUnderTest.QueryString({
|
||||||
getWindowLocation: function() {
|
getWindowLocation: function() {
|
||||||
return windowLocation;
|
return windowLocation;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(queryString.getParam('baz')).toEqual('quux corge');
|
expect(queryString.getParam('baz')).toEqual('quux corge');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns null if the key is not present', function() {
|
it('returns null if the key is not present', function() {
|
||||||
const windowLocation = {
|
const windowLocation = {
|
||||||
search: ''
|
search: ''
|
||||||
},
|
};
|
||||||
queryString = new jasmineUnderTest.QueryString({
|
const queryString = new jasmineUnderTest.QueryString({
|
||||||
getWindowLocation: function() {
|
getWindowLocation: function() {
|
||||||
return windowLocation;
|
return windowLocation;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(queryString.getParam('baz')).toBeFalsy();
|
expect(queryString.getParam('baz')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
describe('ResultsNode', function() {
|
describe('ResultsNode', function() {
|
||||||
it('wraps a result', function() {
|
it('wraps a result', function() {
|
||||||
const fakeResult = {
|
const fakeResult = {
|
||||||
id: 123,
|
id: 123,
|
||||||
message: 'foo'
|
message: 'foo'
|
||||||
},
|
};
|
||||||
node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
|
const node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
|
||||||
|
|
||||||
expect(node.result).toBe(fakeResult);
|
expect(node.result).toBe(fakeResult);
|
||||||
expect(node.type).toEqual('suite');
|
expect(node.type).toEqual('suite');
|
||||||
@@ -12,14 +12,14 @@ describe('ResultsNode', function() {
|
|||||||
|
|
||||||
it('can add children with a type', function() {
|
it('can add children with a type', function() {
|
||||||
const fakeResult = {
|
const fakeResult = {
|
||||||
id: 123,
|
id: 123,
|
||||||
message: 'foo'
|
message: 'foo'
|
||||||
},
|
};
|
||||||
fakeChildResult = {
|
const fakeChildResult = {
|
||||||
id: 456,
|
id: 456,
|
||||||
message: 'bar'
|
message: 'bar'
|
||||||
},
|
};
|
||||||
node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
|
const node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
|
||||||
|
|
||||||
node.addChild(fakeChildResult, 'spec');
|
node.addChild(fakeChildResult, 'spec');
|
||||||
|
|
||||||
@@ -30,14 +30,14 @@ describe('ResultsNode', function() {
|
|||||||
|
|
||||||
it('has a pointer back to its parent ResultNode', function() {
|
it('has a pointer back to its parent ResultNode', function() {
|
||||||
const fakeResult = {
|
const fakeResult = {
|
||||||
id: 123,
|
id: 123,
|
||||||
message: 'foo'
|
message: 'foo'
|
||||||
},
|
};
|
||||||
fakeChildResult = {
|
const fakeChildResult = {
|
||||||
id: 456,
|
id: 456,
|
||||||
message: 'bar'
|
message: 'bar'
|
||||||
},
|
};
|
||||||
node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
|
const node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
|
||||||
|
|
||||||
node.addChild(fakeChildResult, 'spec');
|
node.addChild(fakeChildResult, 'spec');
|
||||||
|
|
||||||
@@ -46,14 +46,14 @@ describe('ResultsNode', function() {
|
|||||||
|
|
||||||
it('can provide the most recent child', function() {
|
it('can provide the most recent child', function() {
|
||||||
const fakeResult = {
|
const fakeResult = {
|
||||||
id: 123,
|
id: 123,
|
||||||
message: 'foo'
|
message: 'foo'
|
||||||
},
|
};
|
||||||
fakeChildResult = {
|
const fakeChildResult = {
|
||||||
id: 456,
|
id: 456,
|
||||||
message: 'bar'
|
message: 'bar'
|
||||||
},
|
};
|
||||||
node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
|
const node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
|
||||||
|
|
||||||
node.addChild(fakeChildResult, 'spec');
|
node.addChild(fakeChildResult, 'spec');
|
||||||
|
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ describe('Spy Registry browser-specific behavior', function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('can spy on and unspy window.onerror', function() {
|
it('can spy on and unspy window.onerror', function() {
|
||||||
const spies = [],
|
const spies = [];
|
||||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||||
currentSpies: function() {
|
currentSpies: function() {
|
||||||
return spies;
|
return spies;
|
||||||
},
|
},
|
||||||
createSpy: createSpy,
|
createSpy: createSpy,
|
||||||
global: window
|
global: window
|
||||||
}),
|
});
|
||||||
originalHandler = window.onerror;
|
const originalHandler = window.onerror;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
spyRegistry.spyOn(window, 'onerror');
|
spyRegistry.spyOn(window, 'onerror');
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const path = require('path'),
|
const path = require('path');
|
||||||
jasmineBrowser = require('jasmine-browser-runner'),
|
const jasmineBrowser = require('jasmine-browser-runner');
|
||||||
jasmineCore = require('../../lib/jasmine-core');
|
const jasmineCore = require('../../lib/jasmine-core');
|
||||||
|
|
||||||
const config = require(path.resolve('spec/support/jasmine-browser.js'));
|
const config = require(path.resolve('spec/support/jasmine-browser.js'));
|
||||||
config.clearReporters = true;
|
config.clearReporters = true;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const path = require('path'),
|
const path = require('path');
|
||||||
jasmineBrowser = require('jasmine-browser-runner'),
|
const jasmineBrowser = require('jasmine-browser-runner');
|
||||||
jasmineCore = require('../../lib/jasmine-core.js');
|
const jasmineCore = require('../../lib/jasmine-core.js');
|
||||||
|
|
||||||
const configFile = process.argv[2] || 'jasmine-browser.js';
|
const configFile = process.argv[2] || 'jasmine-browser.js';
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
*
|
*
|
||||||
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
|
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
|
||||||
*/
|
*/
|
||||||
const jasmine = jasmineRequire.core(jasmineRequire),
|
const jasmine = jasmineRequire.core(jasmineRequire);
|
||||||
global = jasmine.getGlobal();
|
const global = jasmine.getGlobal();
|
||||||
global.jasmine = jasmine;
|
global.jasmine = jasmine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -55,15 +55,15 @@ module.exports.noGlobals = function() {
|
|||||||
return jasmineInterface;
|
return jasmineInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
const path = require('path'),
|
const path = require('path');
|
||||||
fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const rootPath = path.join(__dirname, 'jasmine-core'),
|
const rootPath = path.join(__dirname, 'jasmine-core');
|
||||||
bootFiles = ['boot0.js', 'boot1.js'],
|
const bootFiles = ['boot0.js', 'boot1.js'];
|
||||||
legacyBootFiles = ['boot.js'],
|
const legacyBootFiles = ['boot.js'];
|
||||||
cssFiles = [],
|
const cssFiles = [];
|
||||||
jsFiles = [],
|
const jsFiles = [];
|
||||||
jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles);
|
const jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles);
|
||||||
|
|
||||||
fs.readdirSync(rootPath).forEach(function(file) {
|
fs.readdirSync(rootPath).forEach(function(file) {
|
||||||
if (fs.statSync(path.join(rootPath, file)).isFile()) {
|
if (fs.statSync(path.join(rootPath, file)).isFile()) {
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ getJasmineRequireObj().JsApiReporter = function(j$) {
|
|||||||
return status;
|
return status;
|
||||||
};
|
};
|
||||||
|
|
||||||
const suites = [],
|
const suites = [];
|
||||||
suites_hash = {};
|
const suites_hash = {};
|
||||||
|
|
||||||
this.suiteStarted = function(result) {
|
this.suiteStarted = function(result) {
|
||||||
suites_hash[result.id] = result;
|
suites_hash[result.id] = result;
|
||||||
|
|||||||
@@ -364,10 +364,12 @@ getJasmineRequireObj().Spec = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const extractCustomPendingMessage = function(e) {
|
const extractCustomPendingMessage = function(e) {
|
||||||
const fullMessage = e.toString(),
|
const fullMessage = e.toString();
|
||||||
boilerplateStart = fullMessage.indexOf(Spec.pendingSpecExceptionMessage),
|
const boilerplateStart = fullMessage.indexOf(
|
||||||
boilerplateEnd =
|
Spec.pendingSpecExceptionMessage
|
||||||
boilerplateStart + Spec.pendingSpecExceptionMessage.length;
|
);
|
||||||
|
const boilerplateEnd =
|
||||||
|
boilerplateStart + Spec.pendingSpecExceptionMessage.length;
|
||||||
|
|
||||||
return fullMessage.slice(boilerplateEnd);
|
return fullMessage.slice(boilerplateEnd);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -40,22 +40,22 @@ getJasmineRequireObj().Spy = function(j$) {
|
|||||||
};
|
};
|
||||||
const { originalFn, customStrategies, defaultStrategyFn } = optionals || {};
|
const { originalFn, customStrategies, defaultStrategyFn } = optionals || {};
|
||||||
|
|
||||||
const numArgs = typeof originalFn === 'function' ? originalFn.length : 0,
|
const numArgs = typeof originalFn === 'function' ? originalFn.length : 0;
|
||||||
wrapper = makeFunc(numArgs, function(context, args, invokeNew) {
|
const wrapper = makeFunc(numArgs, function(context, args, invokeNew) {
|
||||||
return spy(context, args, invokeNew);
|
return spy(context, args, invokeNew);
|
||||||
}),
|
});
|
||||||
strategyDispatcher = new SpyStrategyDispatcher(
|
const strategyDispatcher = new SpyStrategyDispatcher(
|
||||||
{
|
{
|
||||||
name: name,
|
name: name,
|
||||||
fn: originalFn,
|
fn: originalFn,
|
||||||
getSpy: function() {
|
getSpy: function() {
|
||||||
return wrapper;
|
return wrapper;
|
||||||
},
|
|
||||||
customStrategies: customStrategies
|
|
||||||
},
|
},
|
||||||
matchersUtil
|
customStrategies: customStrategies
|
||||||
),
|
},
|
||||||
callTracker = new j$.private.CallTracker();
|
matchersUtil
|
||||||
|
);
|
||||||
|
const callTracker = new j$.private.CallTracker();
|
||||||
|
|
||||||
function makeFunc(length, fn) {
|
function makeFunc(length, fn) {
|
||||||
switch (length) {
|
switch (length) {
|
||||||
|
|||||||
@@ -200,10 +200,10 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let pointer = obj,
|
let pointer = obj;
|
||||||
propsToSpyOn = [],
|
let propsToSpyOn = [];
|
||||||
properties,
|
let properties;
|
||||||
propertiesToSkip = [];
|
let propertiesToSkip = [];
|
||||||
|
|
||||||
while (
|
while (
|
||||||
pointer &&
|
pointer &&
|
||||||
|
|||||||
@@ -323,9 +323,9 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
|||||||
|
|
||||||
function beforeAndAfterFns(targetSuite) {
|
function beforeAndAfterFns(targetSuite) {
|
||||||
return function() {
|
return function() {
|
||||||
let befores = [],
|
let befores = [];
|
||||||
afters = [],
|
let afters = [];
|
||||||
suite = targetSuite;
|
let suite = targetSuite;
|
||||||
|
|
||||||
while (suite) {
|
while (suite) {
|
||||||
befores = befores.concat(suite.beforeFns);
|
befores = befores.concat(suite.beforeFns);
|
||||||
|
|||||||
@@ -144,15 +144,15 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
|
|||||||
|
|
||||||
function segmentChildren(node, orderedChildren, stats, executableIndex) {
|
function segmentChildren(node, orderedChildren, stats, executableIndex) {
|
||||||
let currentSegment = {
|
let currentSegment = {
|
||||||
index: 0,
|
index: 0,
|
||||||
owner: node,
|
owner: node,
|
||||||
nodes: [],
|
nodes: [],
|
||||||
min: startingMin(executableIndex),
|
min: startingMin(executableIndex),
|
||||||
max: startingMax(executableIndex)
|
max: startingMax(executableIndex)
|
||||||
},
|
};
|
||||||
result = [currentSegment],
|
let result = [currentSegment];
|
||||||
lastMax = defaultMax,
|
let lastMax = defaultMax;
|
||||||
orderedChildSegments = orderChildSegments(orderedChildren, stats);
|
let orderedChildSegments = orderChildSegments(orderedChildren, stats);
|
||||||
|
|
||||||
function isSegmentBoundary(minIndex) {
|
function isSegmentBoundary(minIndex) {
|
||||||
return (
|
return (
|
||||||
@@ -163,9 +163,9 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < orderedChildSegments.length; i++) {
|
for (let i = 0; i < orderedChildSegments.length; i++) {
|
||||||
const childSegment = orderedChildSegments[i],
|
const childSegment = orderedChildSegments[i];
|
||||||
maxIndex = childSegment.max,
|
const maxIndex = childSegment.max;
|
||||||
minIndex = childSegment.min;
|
const minIndex = childSegment.min;
|
||||||
|
|
||||||
if (isSegmentBoundary(minIndex)) {
|
if (isSegmentBoundary(minIndex)) {
|
||||||
currentSegment = {
|
currentSegment = {
|
||||||
@@ -188,12 +188,12 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function orderChildSegments(children, stats) {
|
function orderChildSegments(children, stats) {
|
||||||
const specifiedOrder = [],
|
const specifiedOrder = [];
|
||||||
unspecifiedOrder = [];
|
const unspecifiedOrder = [];
|
||||||
|
|
||||||
for (let i = 0; i < children.length; i++) {
|
for (let i = 0; i < children.length; i++) {
|
||||||
const child = children[i],
|
const child = children[i];
|
||||||
segments = stats[child.id].segments;
|
const segments = stats[child.id].segments;
|
||||||
|
|
||||||
for (let j = 0; j < segments.length; j++) {
|
for (let j = 0; j < segments.length; j++) {
|
||||||
const seg = segments[j];
|
const seg = segments[j];
|
||||||
|
|||||||
@@ -76,14 +76,14 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
MatchersUtil.prototype.buildFailureMessage = function() {
|
MatchersUtil.prototype.buildFailureMessage = function() {
|
||||||
const args = Array.prototype.slice.call(arguments, 0),
|
const args = Array.prototype.slice.call(arguments, 0);
|
||||||
matcherName = args[0],
|
const matcherName = args[0];
|
||||||
isNot = args[1],
|
const isNot = args[1];
|
||||||
actual = args[2],
|
const actual = args[2];
|
||||||
expected = args.slice(3),
|
const expected = args.slice(3);
|
||||||
englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) {
|
const englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) {
|
||||||
return ' ' + s.toLowerCase();
|
return ' ' + s.toLowerCase();
|
||||||
});
|
});
|
||||||
|
|
||||||
let message =
|
let message =
|
||||||
'Expected ' +
|
'Expected ' +
|
||||||
@@ -465,8 +465,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|||||||
} else {
|
} else {
|
||||||
// Objects with different constructors are not equivalent, but `Object`s
|
// Objects with different constructors are not equivalent, but `Object`s
|
||||||
// or `Array`s from different frames are.
|
// or `Array`s from different frames are.
|
||||||
const aCtor = a.constructor,
|
const aCtor = a.constructor;
|
||||||
bCtor = b.constructor;
|
const bCtor = b.constructor;
|
||||||
if (
|
if (
|
||||||
aCtor !== bCtor &&
|
aCtor !== bCtor &&
|
||||||
isFunction(aCtor) &&
|
isFunction(aCtor) &&
|
||||||
@@ -572,11 +572,11 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function objectKeysAreDifferentFormatter(pp, actual, expected, path) {
|
function objectKeysAreDifferentFormatter(pp, actual, expected, path) {
|
||||||
const missingProperties = extraKeysAndValues(expected, actual),
|
const missingProperties = extraKeysAndValues(expected, actual);
|
||||||
extraProperties = extraKeysAndValues(actual, expected),
|
const extraProperties = extraKeysAndValues(actual, expected);
|
||||||
missingPropertiesMessage = formatKeyValuePairs(pp, missingProperties),
|
const missingPropertiesMessage = formatKeyValuePairs(pp, missingProperties);
|
||||||
extraPropertiesMessage = formatKeyValuePairs(pp, extraProperties),
|
const extraPropertiesMessage = formatKeyValuePairs(pp, extraProperties);
|
||||||
messages = [];
|
const messages = [];
|
||||||
|
|
||||||
if (!path.depth()) {
|
if (!path.depth()) {
|
||||||
path = 'object';
|
path = 'object';
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$) {
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const availableMatchers = [
|
const availableMatchers = [
|
||||||
'toBePending',
|
'toBePending',
|
||||||
'toBeResolved',
|
'toBeResolved',
|
||||||
'toBeRejected',
|
'toBeRejected',
|
||||||
'toBeResolvedTo',
|
'toBeResolvedTo',
|
||||||
'toBeRejectedWith',
|
'toBeRejectedWith',
|
||||||
'toBeRejectedWithError',
|
'toBeRejectedWithError',
|
||||||
'toBeRejectedWithMatching'
|
'toBeRejectedWithMatching'
|
||||||
],
|
];
|
||||||
matchers = {};
|
const matchers = {};
|
||||||
|
|
||||||
for (const name of availableMatchers) {
|
for (const name of availableMatchers) {
|
||||||
matchers[name] = jRequire[name](j$);
|
matchers[name] = jRequire[name](j$);
|
||||||
|
|||||||
@@ -2,43 +2,43 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const availableMatchers = [
|
const availableMatchers = [
|
||||||
'nothing',
|
'nothing',
|
||||||
'toBe',
|
'toBe',
|
||||||
'toBeCloseTo',
|
'toBeCloseTo',
|
||||||
'toBeDefined',
|
'toBeDefined',
|
||||||
'toBeInstanceOf',
|
'toBeInstanceOf',
|
||||||
'toBeFalse',
|
'toBeFalse',
|
||||||
'toBeFalsy',
|
'toBeFalsy',
|
||||||
'toBeGreaterThan',
|
'toBeGreaterThan',
|
||||||
'toBeGreaterThanOrEqual',
|
'toBeGreaterThanOrEqual',
|
||||||
'toBeLessThan',
|
'toBeLessThan',
|
||||||
'toBeLessThanOrEqual',
|
'toBeLessThanOrEqual',
|
||||||
'toBeNaN',
|
'toBeNaN',
|
||||||
'toBeNegativeInfinity',
|
'toBeNegativeInfinity',
|
||||||
'toBeNull',
|
'toBeNull',
|
||||||
'toBePositiveInfinity',
|
'toBePositiveInfinity',
|
||||||
'toBeTrue',
|
'toBeTrue',
|
||||||
'toBeTruthy',
|
'toBeTruthy',
|
||||||
'toBeUndefined',
|
'toBeUndefined',
|
||||||
'toBeNullish',
|
'toBeNullish',
|
||||||
'toContain',
|
'toContain',
|
||||||
'toEqual',
|
'toEqual',
|
||||||
'toHaveSize',
|
'toHaveSize',
|
||||||
'toHaveBeenCalled',
|
'toHaveBeenCalled',
|
||||||
'toHaveBeenCalledBefore',
|
'toHaveBeenCalledBefore',
|
||||||
'toHaveBeenCalledOnceWith',
|
'toHaveBeenCalledOnceWith',
|
||||||
'toHaveBeenCalledTimes',
|
'toHaveBeenCalledTimes',
|
||||||
'toHaveBeenCalledWith',
|
'toHaveBeenCalledWith',
|
||||||
'toHaveClass',
|
'toHaveClass',
|
||||||
'toHaveClasses',
|
'toHaveClasses',
|
||||||
'toHaveSpyInteractions',
|
'toHaveSpyInteractions',
|
||||||
'toHaveNoOtherSpyInteractions',
|
'toHaveNoOtherSpyInteractions',
|
||||||
'toMatch',
|
'toMatch',
|
||||||
'toThrow',
|
'toThrow',
|
||||||
'toThrowError',
|
'toThrowError',
|
||||||
'toThrowMatching'
|
'toThrowMatching'
|
||||||
],
|
];
|
||||||
matchers = {};
|
const matchers = {};
|
||||||
|
|
||||||
for (const name of availableMatchers) {
|
for (const name of availableMatchers) {
|
||||||
matchers[name] = jRequire[name](j$);
|
matchers[name] = jRequire[name](j$);
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ getJasmineRequireObj().toEqual = function(j$) {
|
|||||||
return {
|
return {
|
||||||
compare: function(actual, expected) {
|
compare: function(actual, expected) {
|
||||||
const result = {
|
const result = {
|
||||||
pass: false
|
pass: false
|
||||||
},
|
};
|
||||||
diffBuilder = new j$.private.DiffBuilder({
|
const diffBuilder = new j$.private.DiffBuilder({
|
||||||
prettyPrinter: matchersUtil.pp
|
prettyPrinter: matchersUtil.pp
|
||||||
});
|
});
|
||||||
|
|
||||||
result.pass = matchersUtil.equals(actual, expected, diffBuilder);
|
result.pass = matchersUtil.equals(actual, expected, diffBuilder);
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) {
|
|||||||
function toHaveBeenCalledOnceWith(matchersUtil) {
|
function toHaveBeenCalledOnceWith(matchersUtil) {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
const args = Array.prototype.slice.call(arguments, 0),
|
const args = Array.prototype.slice.call(arguments, 0);
|
||||||
actual = args[0],
|
const actual = args[0];
|
||||||
expectedArgs = args.slice(1);
|
const expectedArgs = args.slice(1);
|
||||||
|
|
||||||
if (!j$.isSpy(actual)) {
|
if (!j$.isSpy(actual)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const args = Array.prototype.slice.call(arguments, 0),
|
const args = Array.prototype.slice.call(arguments, 0);
|
||||||
result = { pass: false };
|
const result = { pass: false };
|
||||||
|
|
||||||
if (!j$.private.isNumber(expected)) {
|
if (!j$.private.isNumber(expected)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
|||||||
function toHaveBeenCalledWith(matchersUtil) {
|
function toHaveBeenCalledWith(matchersUtil) {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
const args = Array.prototype.slice.call(arguments, 0),
|
const args = Array.prototype.slice.call(arguments, 0);
|
||||||
actual = args[0],
|
const actual = args[0];
|
||||||
expectedArgs = args.slice(1),
|
const expectedArgs = args.slice(1);
|
||||||
result = { pass: false };
|
const result = { pass: false };
|
||||||
|
|
||||||
if (!j$.isSpy(actual)) {
|
if (!j$.isSpy(actual)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ getJasmineRequireObj().util = function(j$) {
|
|||||||
|
|
||||||
util.cloneArgs = function(args) {
|
util.cloneArgs = function(args) {
|
||||||
return Array.from(args).map(function(arg) {
|
return Array.from(args).map(function(arg) {
|
||||||
const str = Object.prototype.toString.apply(arg),
|
const str = Object.prototype.toString.apply(arg);
|
||||||
primitives = /^\[object (Boolean|String|RegExp|Number)/;
|
const primitives = /^\[object (Boolean|String|RegExp|Number)/;
|
||||||
|
|
||||||
// All falsey values are either primitives, `null`, or `undefined.
|
// All falsey values are either primitives, `null`, or `undefined.
|
||||||
if (!arg || str.match(primitives)) {
|
if (!arg || str.match(primitives)) {
|
||||||
@@ -35,8 +35,8 @@ getJasmineRequireObj().util = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
util.getPropertyDescriptor = function(obj, methodName) {
|
util.getPropertyDescriptor = function(obj, methodName) {
|
||||||
let descriptor,
|
let descriptor;
|
||||||
proto = obj;
|
let proto = obj;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
descriptor = Object.getOwnPropertyDescriptor(proto, methodName);
|
descriptor = Object.getOwnPropertyDescriptor(proto, methodName);
|
||||||
|
|||||||
@@ -138,9 +138,9 @@ jasmineRequire.Banner = function(j$) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger'),
|
const optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger');
|
||||||
optionsPayload = optionsMenuDom.querySelector('.jasmine-payload'),
|
const optionsPayload = optionsMenuDom.querySelector('.jasmine-payload');
|
||||||
isOpen = /\bjasmine-open\b/;
|
const isOpen = /\bjasmine-open\b/;
|
||||||
|
|
||||||
optionsTrigger.onclick = function() {
|
optionsTrigger.onclick = function() {
|
||||||
if (isOpen.test(optionsPayload.className)) {
|
if (isOpen.test(optionsPayload.className)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user