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:
Steve Gravrock
2026-03-10 20:02:42 -07:00
parent 03ebebf6fb
commit 434575f49d
88 changed files with 3650 additions and 3604 deletions

View File

@@ -7,10 +7,10 @@ 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
@@ -28,9 +28,9 @@ 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() {}
}), }),
@@ -53,9 +53,9 @@ 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
}); });
@@ -78,9 +78,9 @@ describe('AsyncExpectation', function() {
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
@@ -106,9 +106,9 @@ describe('AsyncExpectation', function() {
return 'failure message'; return 'failure message';
}, },
pp: privateUnderTest.makePrettyPrinter() pp: privateUnderTest.makePrettyPrinter()
}, };
addExpectationResult = jasmine.createSpy('addExpectationResult'), const addExpectationResult = jasmine.createSpy('addExpectationResult');
expectation = privateUnderTest.Expectation.asyncFactory({ const expectation = privateUnderTest.Expectation.asyncFactory({
actual: Promise.reject('b'), actual: Promise.reject('b'),
addExpectationResult: addExpectationResult, addExpectationResult: addExpectationResult,
matchersUtil: matchersUtil matchersUtil: matchersUtil
@@ -159,10 +159,10 @@ 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 })
@@ -183,9 +183,9 @@ 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({
@@ -213,8 +213,8 @@ describe('AsyncExpectation', 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
}); });
@@ -225,18 +225,18 @@ 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',
@@ -251,19 +251,19 @@ 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',
@@ -317,8 +317,8 @@ describe('AsyncExpectation', function() {
} }
}; };
} }
}, };
matchersUtil = { const matchersUtil = {
buildFailureMessage: function() { buildFailureMessage: function() {
return ''; return '';
} }
@@ -447,8 +447,8 @@ describe('AsyncExpectation', function() {
} }
}; };
} }
}, };
matchersUtil = { const matchersUtil = {
buildFailureMessage: function() { buildFailureMessage: function() {
return 'default message'; return 'default message';
} }

View File

@@ -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 });

View File

@@ -5,19 +5,19 @@ describe('Clock', function() {
typeof process.versions.node === 'string'; typeof process.versions.node === 'string';
it('does not replace setTimeout until it is installed', function() { it('does not replace setTimeout until it is installed', function() {
const fakeSetTimeout = jasmine.createSpy('global setTimeout'), const fakeSetTimeout = jasmine.createSpy('global setTimeout');
fakeGlobal = { setTimeout: fakeSetTimeout }, const fakeGlobal = { setTimeout: fakeSetTimeout };
delayedFunctionScheduler = jasmine.createSpyObj( const delayedFunctionScheduler = jasmine.createSpyObj(
'delayedFunctionScheduler', 'delayedFunctionScheduler',
['scheduleFunction'] ['scheduleFunction']
), );
delayedFn = jasmine.createSpy('delayedFn'), const delayedFn = jasmine.createSpy('delayedFn');
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
fakeGlobal, fakeGlobal,
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -40,18 +40,18 @@ describe('Clock', function() {
}); });
it('does not replace clearTimeout until it is installed', function() { it('does not replace clearTimeout until it is installed', function() {
const fakeClearTimeout = jasmine.createSpy('global cleartimeout'), const fakeClearTimeout = jasmine.createSpy('global cleartimeout');
fakeGlobal = { clearTimeout: fakeClearTimeout }, const fakeGlobal = { clearTimeout: fakeClearTimeout };
delayedFunctionScheduler = jasmine.createSpyObj( const delayedFunctionScheduler = jasmine.createSpyObj(
'delayedFunctionScheduler', 'delayedFunctionScheduler',
['removeFunctionWithId'] ['removeFunctionWithId']
), );
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
fakeGlobal, fakeGlobal,
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -76,19 +76,19 @@ describe('Clock', function() {
}); });
it('does not replace setInterval until it is installed', function() { it('does not replace setInterval until it is installed', function() {
const fakeSetInterval = jasmine.createSpy('global setInterval'), const fakeSetInterval = jasmine.createSpy('global setInterval');
fakeGlobal = { setInterval: fakeSetInterval }, const fakeGlobal = { setInterval: fakeSetInterval };
delayedFunctionScheduler = jasmine.createSpyObj( const delayedFunctionScheduler = jasmine.createSpyObj(
'delayedFunctionScheduler', 'delayedFunctionScheduler',
['scheduleFunction'] ['scheduleFunction']
), );
delayedFn = jasmine.createSpy('delayedFn'), const delayedFn = jasmine.createSpy('delayedFn');
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
fakeGlobal, fakeGlobal,
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -111,18 +111,18 @@ describe('Clock', function() {
}); });
it('does not replace clearInterval until it is installed', function() { it('does not replace clearInterval until it is installed', function() {
const fakeClearInterval = jasmine.createSpy('global clearinterval'), const fakeClearInterval = jasmine.createSpy('global clearinterval');
fakeGlobal = { clearInterval: fakeClearInterval }, const fakeGlobal = { clearInterval: fakeClearInterval };
delayedFunctionScheduler = jasmine.createSpyObj( const delayedFunctionScheduler = jasmine.createSpyObj(
'delayedFunctionScheduler', 'delayedFunctionScheduler',
['removeFunctionWithId'] ['removeFunctionWithId']
), );
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
fakeGlobal, fakeGlobal,
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -147,14 +147,14 @@ describe('Clock', function() {
}); });
it('does not install if the current setTimeout is not the original function on the global', function() { it('does not install if the current setTimeout is not the original function on the global', function() {
const originalFakeSetTimeout = function() {}, const originalFakeSetTimeout = function() {};
replacedSetTimeout = function() {}, const replacedSetTimeout = function() {};
fakeGlobal = { setTimeout: originalFakeSetTimeout }, const fakeGlobal = { setTimeout: originalFakeSetTimeout };
delayedFunctionSchedulerFactory = jasmine.createSpy( const delayedFunctionSchedulerFactory = jasmine.createSpy(
'delayedFunctionSchedulerFactory' 'delayedFunctionSchedulerFactory'
), );
mockDate = {}, const mockDate = {};
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
fakeGlobal, fakeGlobal,
delayedFunctionSchedulerFactory, delayedFunctionSchedulerFactory,
mockDate mockDate
@@ -171,14 +171,14 @@ describe('Clock', function() {
}); });
it('does not install if the current clearTimeout is not the original function on the global', function() { it('does not install if the current clearTimeout is not the original function on the global', function() {
const originalFakeClearTimeout = function() {}, const originalFakeClearTimeout = function() {};
replacedClearTimeout = function() {}, const replacedClearTimeout = function() {};
fakeGlobal = { clearTimeout: originalFakeClearTimeout }, const fakeGlobal = { clearTimeout: originalFakeClearTimeout };
delayedFunctionSchedulerFactory = jasmine.createSpy( const delayedFunctionSchedulerFactory = jasmine.createSpy(
'delayedFunctionSchedulerFactory' 'delayedFunctionSchedulerFactory'
), );
mockDate = {}, const mockDate = {};
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
fakeGlobal, fakeGlobal,
delayedFunctionSchedulerFactory, delayedFunctionSchedulerFactory,
mockDate mockDate
@@ -195,14 +195,14 @@ describe('Clock', function() {
}); });
it('does not install if the current setInterval is not the original function on the global', function() { it('does not install if the current setInterval is not the original function on the global', function() {
const originalFakeSetInterval = function() {}, const originalFakeSetInterval = function() {};
replacedSetInterval = function() {}, const replacedSetInterval = function() {};
fakeGlobal = { setInterval: originalFakeSetInterval }, const fakeGlobal = { setInterval: originalFakeSetInterval };
delayedFunctionSchedulerFactory = jasmine.createSpy( const delayedFunctionSchedulerFactory = jasmine.createSpy(
'delayedFunctionSchedulerFactory' 'delayedFunctionSchedulerFactory'
), );
mockDate = {}, const mockDate = {};
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
fakeGlobal, fakeGlobal,
delayedFunctionSchedulerFactory, delayedFunctionSchedulerFactory,
mockDate mockDate
@@ -219,14 +219,14 @@ describe('Clock', function() {
}); });
it('does not install if the current clearInterval is not the original function on the global', function() { it('does not install if the current clearInterval is not the original function on the global', function() {
const originalFakeClearInterval = function() {}, const originalFakeClearInterval = function() {};
replacedClearInterval = function() {}, const replacedClearInterval = function() {};
fakeGlobal = { clearInterval: originalFakeClearInterval }, const fakeGlobal = { clearInterval: originalFakeClearInterval };
delayedFunctionSchedulerFactory = jasmine.createSpy( const delayedFunctionSchedulerFactory = jasmine.createSpy(
'delayedFunctionSchedulerFactory' 'delayedFunctionSchedulerFactory'
), );
mockDate = {}, const mockDate = {};
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
fakeGlobal, fakeGlobal,
delayedFunctionSchedulerFactory, delayedFunctionSchedulerFactory,
mockDate mockDate
@@ -243,27 +243,27 @@ describe('Clock', function() {
}); });
it('restores the global timer functions on uninstall', function() { it('restores the global timer functions on uninstall', function() {
const fakeSetTimeout = jasmine.createSpy('global setTimeout'), const fakeSetTimeout = jasmine.createSpy('global setTimeout');
fakeClearTimeout = jasmine.createSpy('global clearTimeout'), const fakeClearTimeout = jasmine.createSpy('global clearTimeout');
fakeSetInterval = jasmine.createSpy('global setInterval'), const fakeSetInterval = jasmine.createSpy('global setInterval');
fakeClearInterval = jasmine.createSpy('global clearInterval'), const fakeClearInterval = jasmine.createSpy('global clearInterval');
fakeGlobal = { const fakeGlobal = {
setTimeout: fakeSetTimeout, setTimeout: fakeSetTimeout,
clearTimeout: fakeClearTimeout, clearTimeout: fakeClearTimeout,
setInterval: fakeSetInterval, setInterval: fakeSetInterval,
clearInterval: fakeClearInterval clearInterval: fakeClearInterval
}, };
delayedFunctionScheduler = jasmine.createSpyObj( const delayedFunctionScheduler = jasmine.createSpyObj(
'delayedFunctionScheduler', 'delayedFunctionScheduler',
['scheduleFunction', 'reset'] ['scheduleFunction', 'reset']
), );
delayedFn = jasmine.createSpy('delayedFn'), const delayedFn = jasmine.createSpy('delayedFn');
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
fakeGlobal, fakeGlobal,
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -286,27 +286,27 @@ describe('Clock', function() {
}); });
it('can be installed for the duration of a passed in function and uninstalled when done', function() { it('can be installed for the duration of a passed in function and uninstalled when done', function() {
const fakeSetTimeout = jasmine.createSpy('global setTimeout'), const fakeSetTimeout = jasmine.createSpy('global setTimeout');
fakeClearTimeout = jasmine.createSpy('global clearTimeout'), const fakeClearTimeout = jasmine.createSpy('global clearTimeout');
fakeSetInterval = jasmine.createSpy('global setInterval'), const fakeSetInterval = jasmine.createSpy('global setInterval');
fakeClearInterval = jasmine.createSpy('global clearInterval'), const fakeClearInterval = jasmine.createSpy('global clearInterval');
fakeGlobal = { const fakeGlobal = {
setTimeout: fakeSetTimeout, setTimeout: fakeSetTimeout,
clearTimeout: fakeClearTimeout, clearTimeout: fakeClearTimeout,
setInterval: fakeSetInterval, setInterval: fakeSetInterval,
clearInterval: fakeClearInterval clearInterval: fakeClearInterval
}, };
delayedFunctionScheduler = jasmine.createSpyObj( const delayedFunctionScheduler = jasmine.createSpyObj(
'delayedFunctionScheduler', 'delayedFunctionScheduler',
['scheduleFunction', 'reset', 'removeFunctionWithId'] ['scheduleFunction', 'reset', 'removeFunctionWithId']
), );
delayedFn = jasmine.createSpy('delayedFn'), const delayedFn = jasmine.createSpy('delayedFn');
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
fakeGlobal, fakeGlobal,
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -346,27 +346,27 @@ describe('Clock', function() {
}); });
it('can be installed for the duration of a passed in function and uninstalled if an error is thrown', function() { it('can be installed for the duration of a passed in function and uninstalled if an error is thrown', function() {
const fakeSetTimeout = jasmine.createSpy('global setTimeout'), const fakeSetTimeout = jasmine.createSpy('global setTimeout');
fakeClearTimeout = jasmine.createSpy('global clearTimeout'), const fakeClearTimeout = jasmine.createSpy('global clearTimeout');
fakeSetInterval = jasmine.createSpy('global setInterval'), const fakeSetInterval = jasmine.createSpy('global setInterval');
fakeClearInterval = jasmine.createSpy('global clearInterval'), const fakeClearInterval = jasmine.createSpy('global clearInterval');
fakeGlobal = { const fakeGlobal = {
setTimeout: fakeSetTimeout, setTimeout: fakeSetTimeout,
clearTimeout: fakeClearTimeout, clearTimeout: fakeClearTimeout,
setInterval: fakeSetInterval, setInterval: fakeSetInterval,
clearInterval: fakeClearInterval clearInterval: fakeClearInterval
}, };
delayedFunctionScheduler = jasmine.createSpyObj( const delayedFunctionScheduler = jasmine.createSpyObj(
'delayedFunctionScheduler', 'delayedFunctionScheduler',
['scheduleFunction', 'reset', 'removeFunctionWithId'] ['scheduleFunction', 'reset', 'removeFunctionWithId']
), );
delayedFn = jasmine.createSpy('delayedFn'), const delayedFn = jasmine.createSpy('delayedFn');
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
fakeGlobal, fakeGlobal,
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -445,24 +445,24 @@ describe('Clock', function() {
describe('setTimeout', function() { describe('setTimeout', function() {
it('schedules the delayed function with the fake timer', function() { it('schedules the delayed function with the fake timer', function() {
const fakeSetTimeout = jasmine.createSpy('setTimeout'), const fakeSetTimeout = jasmine.createSpy('setTimeout');
scheduleFunction = jasmine.createSpy('scheduleFunction'), const scheduleFunction = jasmine.createSpy('scheduleFunction');
delayedFunctionScheduler = { scheduleFunction: scheduleFunction }, const delayedFunctionScheduler = { scheduleFunction: scheduleFunction };
fakeGlobal = { setTimeout: fakeSetTimeout }, const fakeGlobal = { setTimeout: fakeSetTimeout };
delayedFn = jasmine.createSpy('delayedFn'), const delayedFn = jasmine.createSpy('delayedFn');
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
fakeGlobal, fakeGlobal,
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
}, },
mockDate mockDate
), );
timeout = new clock.FakeTimeout(); const timeout = new clock.FakeTimeout();
clock.install(); clock.install();
clock.setTimeout(delayedFn, 0, 'a', 'b'); clock.setTimeout(delayedFn, 0, 'a', 'b');
@@ -487,20 +487,20 @@ describe('Clock', function() {
}); });
it('returns an id for the delayed function', function() { it('returns an id for the delayed function', function() {
const fakeSetTimeout = jasmine.createSpy('setTimeout'), const fakeSetTimeout = jasmine.createSpy('setTimeout');
scheduleId = 123, const scheduleId = 123;
scheduleFunction = jasmine const scheduleFunction = jasmine
.createSpy('scheduleFunction') .createSpy('scheduleFunction')
.and.returnValue(scheduleId), .and.returnValue(scheduleId);
delayedFunctionScheduler = { scheduleFunction: scheduleFunction }, const delayedFunctionScheduler = { scheduleFunction: scheduleFunction };
fakeGlobal = { setTimeout: fakeSetTimeout }, const fakeGlobal = { setTimeout: fakeSetTimeout };
delayedFn = jasmine.createSpy('delayedFn'), const delayedFn = jasmine.createSpy('delayedFn');
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
fakeGlobal, fakeGlobal,
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -521,18 +521,18 @@ describe('Clock', function() {
describe('clearTimeout', function() { describe('clearTimeout', function() {
it('clears the scheduled function with the scheduler', function() { it('clears the scheduled function with the scheduler', function() {
const fakeClearTimeout = jasmine.createSpy('clearTimeout'), const fakeClearTimeout = jasmine.createSpy('clearTimeout');
delayedFunctionScheduler = jasmine.createSpyObj( const delayedFunctionScheduler = jasmine.createSpyObj(
'delayedFunctionScheduler', 'delayedFunctionScheduler',
['removeFunctionWithId'] ['removeFunctionWithId']
), );
fakeGlobal = { setTimeout: fakeClearTimeout }, const fakeGlobal = { setTimeout: fakeClearTimeout };
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
fakeGlobal, fakeGlobal,
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -552,24 +552,24 @@ describe('Clock', function() {
describe('setInterval', function() { describe('setInterval', function() {
it('schedules the delayed function with the fake timer', function() { it('schedules the delayed function with the fake timer', function() {
const fakeSetInterval = jasmine.createSpy('setInterval'), const fakeSetInterval = jasmine.createSpy('setInterval');
scheduleFunction = jasmine.createSpy('scheduleFunction'), const scheduleFunction = jasmine.createSpy('scheduleFunction');
delayedFunctionScheduler = { scheduleFunction: scheduleFunction }, const delayedFunctionScheduler = { scheduleFunction: scheduleFunction };
fakeGlobal = { setInterval: fakeSetInterval }, const fakeGlobal = { setInterval: fakeSetInterval };
delayedFn = jasmine.createSpy('delayedFn'), const delayedFn = jasmine.createSpy('delayedFn');
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
fakeGlobal, fakeGlobal,
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
}, },
mockDate mockDate
), );
timeout = new clock.FakeTimeout(); const timeout = new clock.FakeTimeout();
clock.install(); clock.install();
clock.setInterval(delayedFn, 0, 'a', 'b'); clock.setInterval(delayedFn, 0, 'a', 'b');
@@ -595,20 +595,20 @@ describe('Clock', function() {
}); });
it('returns an id for the delayed function', function() { it('returns an id for the delayed function', function() {
const fakeSetInterval = jasmine.createSpy('setInterval'), const fakeSetInterval = jasmine.createSpy('setInterval');
scheduleId = 123, const scheduleId = 123;
scheduleFunction = jasmine const scheduleFunction = jasmine
.createSpy('scheduleFunction') .createSpy('scheduleFunction')
.and.returnValue(scheduleId), .and.returnValue(scheduleId);
delayedFunctionScheduler = { scheduleFunction: scheduleFunction }, const delayedFunctionScheduler = { scheduleFunction: scheduleFunction };
fakeGlobal = { setInterval: fakeSetInterval }, const fakeGlobal = { setInterval: fakeSetInterval };
delayedFn = jasmine.createSpy('delayedFn'), const delayedFn = jasmine.createSpy('delayedFn');
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
fakeGlobal, fakeGlobal,
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -629,18 +629,18 @@ describe('Clock', function() {
describe('clearInterval', function() { describe('clearInterval', function() {
it('clears the scheduled function with the scheduler', function() { it('clears the scheduled function with the scheduler', function() {
const clearInterval = jasmine.createSpy('clearInterval'), const clearInterval = jasmine.createSpy('clearInterval');
delayedFunctionScheduler = jasmine.createSpyObj( const delayedFunctionScheduler = jasmine.createSpyObj(
'delayedFunctionScheduler', 'delayedFunctionScheduler',
['removeFunctionWithId'] ['removeFunctionWithId']
), );
fakeGlobal = { setInterval: clearInterval }, const fakeGlobal = { setInterval: clearInterval };
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
fakeGlobal, fakeGlobal,
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -671,17 +671,17 @@ describe('Clock', function() {
describe('Clock (acceptance)', function() { describe('Clock (acceptance)', function() {
it('can run setTimeouts/setIntervals synchronously', function() { it('can run setTimeouts/setIntervals synchronously', function() {
const delayedFn1 = jasmine.createSpy('delayedFn1'), const delayedFn1 = jasmine.createSpy('delayedFn1');
delayedFn2 = jasmine.createSpy('delayedFn2'), const delayedFn2 = jasmine.createSpy('delayedFn2');
delayedFn3 = jasmine.createSpy('delayedFn3'), const delayedFn3 = jasmine.createSpy('delayedFn3');
recurring1 = jasmine.createSpy('recurring1'), const recurring1 = jasmine.createSpy('recurring1');
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
{ setTimeout: setTimeout }, { setTimeout: setTimeout },
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -776,10 +776,10 @@ describe('Clock (acceptance)', function() {
}); });
it('can run setTimeouts/setIntervals asynchronously', function() { it('can run setTimeouts/setIntervals asynchronously', function() {
const recurring = jasmine.createSpy('recurring'), const recurring = jasmine.createSpy('recurring');
fn1 = jasmine.createSpy('fn1'), const fn1 = jasmine.createSpy('fn1');
fn2 = jasmine.createSpy('fn2'), const fn2 = jasmine.createSpy('fn2');
fn3 = jasmine.createSpy('fn3'); const fn3 = jasmine.createSpy('fn3');
const intervalId = clock.setInterval(recurring, 50); const intervalId = clock.setInterval(recurring, 50);
// In a microtask, add some timeouts. // In a microtask, add some timeouts.
@@ -884,14 +884,14 @@ describe('Clock (acceptance)', function() {
}); });
it('can clear a previously set timeout', function() { it('can clear a previously set timeout', function() {
const clearedFn = jasmine.createSpy('clearedFn'), const clearedFn = jasmine.createSpy('clearedFn');
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
{ setTimeout: function() {} }, { setTimeout: function() {} },
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -911,14 +911,14 @@ describe('Clock (acceptance)', function() {
}); });
it("can clear a previously set interval using that interval's handler", function() { it("can clear a previously set interval using that interval's handler", function() {
const spy = jasmine.createSpy('spy'), const spy = jasmine.createSpy('spy');
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
{ setInterval: function() {} }, { setInterval: function() {} },
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -938,14 +938,14 @@ describe('Clock (acceptance)', function() {
}); });
it('correctly schedules functions after the Clock has advanced', function() { it('correctly schedules functions after the Clock has advanced', function() {
const delayedFn1 = jasmine.createSpy('delayedFn1'), const delayedFn1 = jasmine.createSpy('delayedFn1');
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
{ setTimeout: function() {} }, { setTimeout: function() {} },
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -964,15 +964,15 @@ describe('Clock (acceptance)', function() {
}); });
it('correctly schedules functions while the Clock is advancing', function() { it('correctly schedules functions while the Clock is advancing', function() {
const delayedFn1 = jasmine.createSpy('delayedFn1'), const delayedFn1 = jasmine.createSpy('delayedFn1');
delayedFn2 = jasmine.createSpy('delayedFn2'), const delayedFn2 = jasmine.createSpy('delayedFn2');
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
{ setTimeout: function() {} }, { setTimeout: function() {} },
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -995,15 +995,15 @@ describe('Clock (acceptance)', function() {
}); });
it('correctly calls functions scheduled while the Clock is advancing', function() { it('correctly calls functions scheduled while the Clock is advancing', function() {
const delayedFn1 = jasmine.createSpy('delayedFn1'), const delayedFn1 = jasmine.createSpy('delayedFn1');
delayedFn2 = jasmine.createSpy('delayedFn2'), const delayedFn2 = jasmine.createSpy('delayedFn2');
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
{ setTimeout: function() {} }, { setTimeout: function() {} },
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -1023,15 +1023,15 @@ describe('Clock (acceptance)', function() {
}); });
it('correctly schedules functions scheduled while the Clock is advancing but after the Clock is uninstalled', function() { it('correctly schedules functions scheduled while the Clock is advancing but after the Clock is uninstalled', function() {
const delayedFn1 = jasmine.createSpy('delayedFn1'), const delayedFn1 = jasmine.createSpy('delayedFn1');
delayedFn2 = jasmine.createSpy('delayedFn2'), const delayedFn2 = jasmine.createSpy('delayedFn2');
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
mockDate = { const mockDate = {
install: function() {}, install: function() {},
tick: function() {}, tick: function() {},
uninstall: function() {} uninstall: function() {}
}, };
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
{ setTimeout: function() {} }, { setTimeout: function() {} },
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -1057,10 +1057,10 @@ describe('Clock (acceptance)', function() {
}); });
it('does not mock the Date object by default', function() { it('does not mock the Date object by default', function() {
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
global = { Date: Date }, const global = { Date: Date };
mockDate = new privateUnderTest.MockDate(global), const mockDate = new privateUnderTest.MockDate(global);
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
{ setTimeout: setTimeout }, { setTimeout: setTimeout },
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -1080,10 +1080,10 @@ describe('Clock (acceptance)', function() {
}); });
it('mocks the Date object and sets it to current time', function() { it('mocks the Date object and sets it to current time', function() {
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
global = { Date: Date }, const global = { Date: Date };
mockDate = new privateUnderTest.MockDate(global), const mockDate = new privateUnderTest.MockDate(global);
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
{ setTimeout: setTimeout }, { setTimeout: setTimeout },
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -1110,17 +1110,17 @@ describe('Clock (acceptance)', function() {
}); });
it('mocks the Date object and sets it to a given time', function() { it('mocks the Date object and sets it to a given time', function() {
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
global = { Date: Date }, const global = { Date: Date };
mockDate = new privateUnderTest.MockDate(global), const mockDate = new privateUnderTest.MockDate(global);
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
{ setTimeout: setTimeout }, { setTimeout: setTimeout },
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
}, },
mockDate mockDate
), );
baseTime = new Date(2013, 9, 23); const baseTime = new Date(2013, 9, 23);
clock.install().mockDate(baseTime); clock.install().mockDate(baseTime);
@@ -1143,10 +1143,10 @@ describe('Clock (acceptance)', function() {
}); });
it('throws mockDate is called with a non-Date', function() { it('throws mockDate is called with a non-Date', function() {
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
global = { Date: Date }, const global = { Date: Date };
mockDate = new privateUnderTest.MockDate(global), const mockDate = new privateUnderTest.MockDate(global);
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
{ setTimeout: setTimeout }, { setTimeout: setTimeout },
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -1161,17 +1161,17 @@ describe('Clock (acceptance)', function() {
}); });
it('mocks the Date object and updates the date per delayed function', function() { it('mocks the Date object and updates the date per delayed function', function() {
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
global = { Date: Date }, const global = { Date: Date };
mockDate = new privateUnderTest.MockDate(global), const mockDate = new privateUnderTest.MockDate(global);
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
{ setTimeout: setTimeout }, { setTimeout: setTimeout },
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
}, },
mockDate mockDate
), );
baseTime = new Date(); const baseTime = new Date();
clock.install().mockDate(baseTime); clock.install().mockDate(baseTime);
@@ -1200,10 +1200,10 @@ describe('Clock (acceptance)', function() {
}); });
it('correctly clears a scheduled timeout while the Clock is advancing', function() { it('correctly clears a scheduled timeout while the Clock is advancing', function() {
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
global = { Date: Date, setTimeout: undefined }, const global = { Date: Date, setTimeout: undefined };
mockDate = new privateUnderTest.MockDate(global), const mockDate = new privateUnderTest.MockDate(global);
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
global, global,
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;
@@ -1225,10 +1225,10 @@ describe('Clock (acceptance)', function() {
}); });
it('correctly clears a scheduled interval while the Clock is advancing', function() { it('correctly clears a scheduled interval while the Clock is advancing', function() {
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
global = { Date: Date, setTimeout: undefined }, const global = { Date: Date, setTimeout: undefined };
mockDate = new privateUnderTest.MockDate(global), const mockDate = new privateUnderTest.MockDate(global);
clock = new privateUnderTest.Clock( const clock = new privateUnderTest.Clock(
global, global,
function() { function() {
return delayedFunctionScheduler; return delayedFunctionScheduler;

View File

@@ -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,8 +199,8 @@ 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();
}; };
@@ -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);

View File

@@ -6,9 +6,9 @@ describe('ExceptionFormatter', function() {
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)'
@@ -21,9 +21,9 @@ describe('ExceptionFormatter', function() {
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)'
@@ -34,9 +34,9 @@ describe('ExceptionFormatter', 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');
}); });

View File

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

View File

@@ -3,8 +3,8 @@ describe('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
}); });
@@ -27,17 +27,17 @@ 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,
@@ -54,18 +54,18 @@ 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,
@@ -88,11 +88,11 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
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,
@@ -121,13 +121,13 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
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,
@@ -159,8 +159,8 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
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',
@@ -193,8 +193,8 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
addExpectationResult = jasmine.createSpy('addExpectationResult'); const addExpectationResult = jasmine.createSpy('addExpectationResult');
const expectation = privateUnderTest.Expectation.factory({ const expectation = privateUnderTest.Expectation.factory({
customMatchers: matchers, customMatchers: matchers,
@@ -222,8 +222,8 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
addExpectationResult = jasmine.createSpy('addExpectationResult'); const addExpectationResult = jasmine.createSpy('addExpectationResult');
const expectation = privateUnderTest.Expectation.factory({ const expectation = privateUnderTest.Expectation.factory({
customMatchers: matchers, customMatchers: matchers,
@@ -251,13 +251,13 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
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,
@@ -289,8 +289,8 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
addExpectationResult = jasmine.createSpy('addExpectationResult'); const addExpectationResult = jasmine.createSpy('addExpectationResult');
const expectation = privateUnderTest.Expectation.factory({ const expectation = privateUnderTest.Expectation.factory({
customMatchers: matchers, customMatchers: matchers,
@@ -321,8 +321,8 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
addExpectationResult = jasmine.createSpy('addExpectationResult'); const addExpectationResult = jasmine.createSpy('addExpectationResult');
const expectation = privateUnderTest.Expectation.factory({ const expectation = privateUnderTest.Expectation.factory({
customMatchers: matchers, customMatchers: matchers,
@@ -356,8 +356,8 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
addExpectationResult = jasmine.createSpy('addExpectationResult'); const addExpectationResult = jasmine.createSpy('addExpectationResult');
const expectation = privateUnderTest.Expectation.factory({ const expectation = privateUnderTest.Expectation.factory({
customMatchers: matchers, customMatchers: matchers,
@@ -390,8 +390,8 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
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',
@@ -424,8 +424,8 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
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',
@@ -460,8 +460,8 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
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',
@@ -490,14 +490,14 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
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',
@@ -523,9 +523,9 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
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
@@ -550,9 +550,9 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
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
@@ -580,9 +580,9 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
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
@@ -607,10 +607,10 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
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',
@@ -643,9 +643,9 @@ describe('Expectation', function() {
} }
}; };
} }
}, };
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

View File

@@ -137,8 +137,8 @@ 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
}); });
@@ -147,8 +147,8 @@ describe('JsApiReporter', function() {
}); });
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
}); });
@@ -159,8 +159,8 @@ 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
}); });

View File

@@ -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();
@@ -17,9 +17,9 @@ describe('FakeDate', 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();
@@ -34,9 +34,9 @@ describe('FakeDate', 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();
@@ -53,9 +53,9 @@ describe('FakeDate', 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));
@@ -93,8 +93,8 @@ describe('FakeDate', 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);
@@ -113,8 +113,8 @@ describe('FakeDate', 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);
@@ -139,8 +139,8 @@ describe('FakeDate', 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();

View File

@@ -230,23 +230,23 @@ describe('PrettyPrinter', function() {
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]);
@@ -389,9 +389,9 @@ 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() {
@@ -544,9 +544,9 @@ describe('PrettyPrinter', function() {
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');
}); });
@@ -556,9 +556,9 @@ describe('PrettyPrinter', function() {
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' })");
}); });
@@ -576,9 +576,9 @@ describe('PrettyPrinter', function() {
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');
}); });
@@ -588,9 +588,9 @@ describe('PrettyPrinter', function() {
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();
}); });

View File

@@ -16,10 +16,10 @@ 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() {
@@ -43,8 +43,8 @@ describe('QueueRunner', function() {
asyncContext = this; asyncContext = this;
done(); done();
} }
}, };
queueRunner = new privateUnderTest.QueueRunner({ const queueRunner = new privateUnderTest.QueueRunner({
queueableFns: [queueableFn1, queueableFn2, queueableFn3] queueableFns: [queueableFn1, queueableFn2, queueableFn3]
}); });
@@ -69,29 +69,29 @@ 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
}); });
@@ -126,10 +126,10 @@ describe('QueueRunner', 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
}); });
@@ -147,17 +147,17 @@ 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
}); });
@@ -181,15 +181,15 @@ 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() {
@@ -209,9 +209,9 @@ describe('QueueRunner', function() {
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() {
@@ -227,17 +227,17 @@ 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
}); });
@@ -254,12 +254,16 @@ 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({ };
const queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' };
const onComplete = jasmine.createSpy('onComplete');
const onException = jasmine.createSpy('onException');
const queueRunner = new privateUnderTest.QueueRunner({
queueableFns: [beforeFn, queueableFn], queueableFns: [beforeFn, queueableFn],
onComplete: onComplete, onComplete: onComplete,
onException: onException onException: onException
@@ -302,11 +306,11 @@ 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
@@ -327,10 +331,10 @@ describe('QueueRunner', function() {
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
@@ -350,10 +354,10 @@ describe('QueueRunner', function() {
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
@@ -374,10 +378,10 @@ describe('QueueRunner', function() {
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
}); });
@@ -394,9 +398,9 @@ describe('QueueRunner', function() {
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();
@@ -426,22 +430,20 @@ describe('QueueRunner', function() {
throwAsync(); throwAsync();
}, },
timeout: 1 timeout: 1
}, };
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') }, const nextQueueableFn = { fn: jasmine.createSpy('nextFunction') };
onException = jasmine.createSpy('onException'), const onException = jasmine.createSpy('onException');
globalErrors = { const globalErrors = {
pushListener: jasmine.createSpy('pushListener'), pushListener: jasmine.createSpy('pushListener'),
popListener: jasmine.createSpy('popListener') popListener: jasmine.createSpy('popListener')
}, };
queueRunner = new privateUnderTest.QueueRunner({ const queueRunner = new privateUnderTest.QueueRunner({
queueableFns: [queueableFn, nextQueueableFn], queueableFns: [queueableFn, nextQueueableFn],
onException: onException, onException: onException,
globalErrors: globalErrors globalErrors: globalErrors
}), });
throwAsync = function() { const throwAsync = function() {
globalErrors.pushListener.calls globalErrors.pushListener.calls.mostRecent().args[0](new Error('foo'));
.mostRecent()
.args[0](new Error('foo'));
jasmine.clock().tick(2); jasmine.clock().tick(2);
}; };
@@ -476,25 +478,25 @@ describe('QueueRunner', function() {
fn: function(done) { fn: function(done) {
done(); done();
} }
}, };
errorListeners = [], const errorListeners = [];
globalErrors = { const globalErrors = {
pushListener: function(f) { pushListener: function(f) {
errorListeners.push(f); errorListeners.push(f);
}, },
popListener: function() { popListener: function() {
errorListeners.pop(); errorListeners.pop();
} }
}, };
clearStack = jasmine.createSpyObj('clearStack', ['clearStack']), const clearStack = jasmine.createSpyObj('clearStack', ['clearStack']);
onException = jasmine.createSpy('onException'), const onException = jasmine.createSpy('onException');
queueRunner = new privateUnderTest.QueueRunner({ const queueRunner = new privateUnderTest.QueueRunner({
queueableFns: [queueableFn], queueableFns: [queueableFn],
globalErrors: globalErrors, globalErrors: globalErrors,
clearStack: clearStack, clearStack: clearStack,
onException: onException onException: onException
}), });
error = new Error('nope'); const error = new Error('nope');
queueRunner.execute(); queueRunner.execute();
jasmine.clock().tick(); jasmine.clock().tick();
@@ -523,19 +525,19 @@ 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() {
@@ -543,8 +545,8 @@ describe('QueueRunner', function() {
}, 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
}); });
@@ -564,18 +566,18 @@ 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
}); });
@@ -596,9 +598,9 @@ describe('QueueRunner', function() {
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
}); });
@@ -618,8 +620,8 @@ 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
}); });
@@ -638,9 +640,9 @@ 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
}); });
@@ -656,9 +658,9 @@ describe('QueueRunner', function() {
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
}); });
@@ -673,9 +675,9 @@ describe('QueueRunner', function() {
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]
}); });
@@ -750,14 +752,14 @@ describe('QueueRunner', function() {
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
@@ -772,18 +774,18 @@ 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' type: 'afterEach'
}, };
cleanupFn2 = { const cleanupFn2 = {
fn: jasmine.createSpy('cleanupFn2'), fn: jasmine.createSpy('cleanupFn2'),
type: 'afterEach' type: 'afterEach'
}, };
queueRunner = new privateUnderTest.QueueRunner({ const queueRunner = new privateUnderTest.QueueRunner({
queueableFns: [queueableFn, cleanupFn1, cleanupFn2], queueableFns: [queueableFn, cleanupFn1, cleanupFn2],
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
}); });
@@ -840,10 +842,13 @@ describe('QueueRunner', function() {
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'),
type: 'specCleanup'
};
const queueRunner = new privateUnderTest.QueueRunner({
queueableFns: [queueableFn, nextQueueableFn, cleanupFn], queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
}); });
@@ -859,13 +864,13 @@ describe('QueueRunner', function() {
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
}); });
@@ -879,9 +884,9 @@ 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
}); });
@@ -905,11 +910,11 @@ describe('QueueRunner', function() {
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

View File

@@ -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' });

View File

@@ -181,9 +181,9 @@ 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
@@ -389,8 +389,8 @@ 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

View File

@@ -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() {
@@ -217,9 +217,9 @@ 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() {
@@ -241,9 +241,9 @@ 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() {
@@ -265,8 +265,8 @@ describe('SpyRegistry', 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() {
@@ -285,8 +285,8 @@ 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,9 +655,9 @@ 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;
}, },
@@ -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() {

View File

@@ -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);
} }

View File

@@ -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,8 +127,8 @@ 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
}); });
@@ -143,8 +143,8 @@ 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
}); });
@@ -161,8 +161,8 @@ 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
}); });
@@ -178,8 +178,8 @@ 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
}); });
@@ -195,8 +195,8 @@ 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
}); });
@@ -215,12 +215,12 @@ 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
@@ -236,8 +236,8 @@ 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() {
@@ -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');
@@ -276,8 +276,8 @@ 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);

View File

@@ -33,8 +33,8 @@ describe('Suite', function() {
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
@@ -47,9 +47,9 @@ describe('Suite', 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);
@@ -64,9 +64,9 @@ describe('Suite', 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);
@@ -81,9 +81,9 @@ describe('Suite', 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);
@@ -98,9 +98,9 @@ describe('Suite', 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);

View File

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

View File

@@ -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,8 +24,8 @@ 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]
}); });
@@ -36,8 +36,8 @@ 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]
}); });
@@ -48,8 +48,8 @@ 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: []
}); });
@@ -60,8 +60,8 @@ 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() {
@@ -75,9 +75,9 @@ 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]
}); });
@@ -90,9 +90,9 @@ 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]
}); });
@@ -139,21 +139,21 @@ 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]
}); });

View File

@@ -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)) {

View File

@@ -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);
}); });

View File

@@ -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);
}); });

View File

@@ -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)>'

View File

@@ -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)>'

View File

@@ -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)>'

View File

@@ -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

View File

@@ -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)>'

View File

@@ -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) {

View File

@@ -91,8 +91,8 @@ describe('Custom Async Matchers (Integration)', function() {
return Promise.resolve({ pass: true }); return Promise.resolve({ pass: true });
} }
}; };
}, };
matcherFactorySpy = jasmine.createSpy( const matcherFactorySpy = jasmine.createSpy(
'matcherFactorySpy', 'matcherFactorySpy',
matcherFactory matcherFactory
); );
@@ -124,8 +124,8 @@ describe('Custom Async Matchers (Integration)', function() {
}); });
} }
}; };
}, };
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;

View File

@@ -215,8 +215,8 @@ describe('Custom Matchers (Integration)', function() {
return { pass: true }; return { pass: true };
} }
}; };
}, };
matcherFactorySpy = jasmine const matcherFactorySpy = jasmine
.createSpy('matcherFactorySpy') .createSpy('matcherFactorySpy')
.and.callFake(matcherFactory); .and.callFake(matcherFactory);
@@ -241,8 +241,8 @@ describe('Custom Matchers (Integration)', function() {
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;

View File

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

View File

@@ -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,14 +1026,14 @@ 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() {
@@ -1049,8 +1049,8 @@ 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
}; };
@@ -1078,8 +1078,8 @@ 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
}; };
@@ -1101,11 +1101,11 @@ describe('Env integration', function() {
.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'
); );
@@ -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,8 +2467,8 @@ 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'
@@ -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,

View File

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

View File

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

View File

@@ -67,8 +67,8 @@ 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() {};
@@ -84,9 +84,9 @@ 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() {};
@@ -219,11 +219,11 @@ 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.';
@@ -243,11 +243,11 @@ 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.';

View File

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

View File

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

View File

@@ -2,11 +2,11 @@ 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(
@@ -22,11 +22,11 @@ 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(
@@ -42,11 +42,11 @@ 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(
@@ -62,11 +62,11 @@ 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(
@@ -82,11 +82,11 @@ 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(
@@ -102,11 +102,11 @@ 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(
@@ -122,11 +122,11 @@ 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(
@@ -142,11 +142,11 @@ 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(
@@ -161,11 +161,11 @@ 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(
@@ -181,11 +181,11 @@ 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(
@@ -201,11 +201,11 @@ 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(
@@ -221,11 +221,11 @@ 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);

View File

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

View File

@@ -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 }));
@@ -22,9 +26,11 @@ 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(
@@ -40,9 +46,11 @@ 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(
@@ -59,12 +67,14 @@ describe('#toBeRejectedWith', function() {
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 }));
@@ -74,9 +84,11 @@ 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);

View File

@@ -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 }));
@@ -12,9 +12,9 @@ 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);

View File

@@ -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 }));
@@ -12,9 +12,9 @@ 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(
@@ -31,9 +31,9 @@ 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(
@@ -49,9 +49,9 @@ 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(
@@ -68,13 +68,13 @@ describe('#toBeResolvedTo', function() {
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 }));
@@ -84,9 +84,9 @@ 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);

View File

@@ -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);
@@ -365,9 +365,9 @@ describe('matchersUtil', 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);
@@ -402,8 +402,8 @@ describe('matchersUtil', function() {
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);
@@ -414,16 +414,16 @@ describe('matchersUtil', function() {
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']))
@@ -433,8 +433,8 @@ 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() {}
}); });
@@ -464,8 +464,8 @@ 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() {}
}); });
@@ -478,11 +478,11 @@ describe('matchersUtil', function() {
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() {}
}); });
@@ -492,17 +492,17 @@ describe('matchersUtil', function() {
}); });
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
@@ -923,15 +923,15 @@ describe('matchersUtil', function() {
other: 'other value' other: 'other value'
}; };
} }
}, };
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();
@@ -951,15 +951,15 @@ describe('matchersUtil', function() {
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();
@@ -1027,8 +1027,8 @@ 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() {}
}); });
@@ -1091,32 +1091,32 @@ 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,
@@ -1128,16 +1128,16 @@ describe('matchersUtil', function() {
}); });
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,

View File

@@ -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);
}); });

View File

@@ -29,8 +29,8 @@ 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.');
}); });

View File

@@ -16,15 +16,15 @@ 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.');

View File

@@ -16,15 +16,15 @@ 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.');

View File

@@ -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);
@@ -23,9 +23,9 @@ 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,9 +35,9 @@ 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();
}); });
@@ -45,9 +45,9 @@ describe('toBe', function() {
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(
@@ -58,9 +58,9 @@ 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(
@@ -71,11 +71,13 @@ 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(

View File

@@ -2,8 +2,8 @@ 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');
@@ -13,11 +13,11 @@ 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);

View File

@@ -4,8 +4,8 @@ describe('toEqual', function() {
function compareEquals(actual, expected) { function compareEquals(actual, expected) {
const matchersUtil = new privateUnderTest.MatchersUtil({ const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter() pp: privateUnderTest.makePrettyPrinter()
}), });
matcher = privateUnderTest.matchers.toEqual(matchersUtil); const matcher = privateUnderTest.matchers.toEqual(matchersUtil);
const result = matcher.compare(actual, expected); const result = matcher.compare(actual, expected);
@@ -19,8 +19,8 @@ describe('toEqual', function() {
return 'does not matter'; return 'does not matter';
}, },
DiffBuilder: new privateUnderTest.DiffBuilder() DiffBuilder: new privateUnderTest.DiffBuilder()
}, };
matcher = privateUnderTest.matchers.toEqual(matchersUtil); const matcher = privateUnderTest.matchers.toEqual(matchersUtil);
const result = matcher.compare(1, 1); const result = matcher.compare(1, 1);
@@ -31,11 +31,11 @@ describe('toEqual', 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.toEqual(matchersUtil); const matcher = privateUnderTest.matchers.toEqual(matchersUtil);
const result = matcher.compare(1, '1'); const result = matcher.compare(1, '1');
@@ -43,18 +43,18 @@ describe('toEqual', function() {
}); });
it('reports the difference between objects that are not equal', function() { it('reports the difference between objects that are not equal', function() {
const actual = { x: 1, y: 3 }, const actual = { x: 1, y: 3 };
expected = { x: 2, y: 3 }, const expected = { x: 2, y: 3 };
message = 'Expected $.x = 1 to equal 2.'; const message = 'Expected $.x = 1 to equal 2.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports differences between enumerable symbol properties', function() { it('reports differences between enumerable symbol properties', function() {
const x = Symbol('x'), const x = Symbol('x');
actual = { [x]: 1, y: 3 }, const actual = { [x]: 1, y: 3 };
expected = { [x]: 2, y: 3 }, const expected = { [x]: 2, y: 3 };
message = 'Expected $[Symbol(x)] = 1 to equal 2.'; const message = 'Expected $[Symbol(x)] = 1 to equal 2.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
@@ -72,33 +72,33 @@ describe('toEqual', function() {
}); });
it('reports the difference between nested objects that are not equal', function() { it('reports the difference between nested objects that are not equal', function() {
const actual = { x: { y: 1 } }, const actual = { x: { y: 1 } };
expected = { x: { y: 2 } }, const expected = { x: { y: 2 } };
message = 'Expected $.x.y = 1 to equal 2.'; const message = 'Expected $.x.y = 1 to equal 2.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it("formats property access so that it's valid JavaScript", function() { it("formats property access so that it's valid JavaScript", function() {
const actual = { 'my prop': 1 }, const actual = { 'my prop': 1 };
expected = { 'my prop': 2 }, const expected = { 'my prop': 2 };
message = "Expected $['my prop'] = 1 to equal 2."; const message = "Expected $['my prop'] = 1 to equal 2.";
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports missing properties', function() { it('reports missing properties', function() {
const actual = { x: {} }, const actual = { x: {} };
expected = { x: { y: 1 } }, const expected = { x: { y: 1 } };
message = 'Expected $.x to have properties\n' + ' y: 1'; const message = 'Expected $.x to have properties\n' + ' y: 1';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports mismatches as well as missing or extra properties', function() { it('reports mismatches as well as missing or extra properties', function() {
const actual = { x: { z: 2 } }, const actual = { x: { z: 2 } };
expected = { x: { y: 1, z: 3 } }, const expected = { x: { y: 1, z: 3 } };
message = const message =
'Expected $.x to have properties\n' + 'Expected $.x to have properties\n' +
' y: 1\n' + ' y: 1\n' +
'Expected $.x.z = 2 to equal 3.'; 'Expected $.x.z = 2 to equal 3.';
@@ -107,34 +107,36 @@ describe('toEqual', function() {
}); });
it('reports missing symbol properties', function() { it('reports missing symbol properties', function() {
const actual = { x: {} }, const actual = { x: {} };
expected = { x: { [Symbol('y')]: 1 } }, const expected = { x: { [Symbol('y')]: 1 } };
message = 'Expected $.x to have properties\n' + ' Symbol(y): 1'; const message = 'Expected $.x to have properties\n' + ' Symbol(y): 1';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports extra symbol properties', function() { it('reports extra symbol properties', function() {
const actual = { x: { [Symbol('y')]: 1 } }, const actual = { x: { [Symbol('y')]: 1 } };
expected = { x: {} }, const expected = { x: {} };
message = 'Expected $.x not to have properties\n' + ' Symbol(y): 1'; const message =
'Expected $.x not to have properties\n' + ' Symbol(y): 1';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports extra properties', function() { it('reports extra properties', function() {
const actual = { x: { y: 1, z: 2 } }, const actual = { x: { y: 1, z: 2 } };
expected = { x: {} }, const expected = { x: {} };
message = const message =
'Expected $.x not to have properties\n' + ' y: 1\n' + ' z: 2'; 'Expected $.x not to have properties\n' + ' y: 1\n' + ' z: 2';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('pretty-prints properties', function() { it('pretty-prints properties', function() {
const actual = { x: { y: 'foo bar' } }, const actual = { x: { y: 'foo bar' } };
expected = { x: {} }, const expected = { x: {} };
message = 'Expected $.x not to have properties\n' + " y: 'foo bar'"; const message =
'Expected $.x not to have properties\n' + " y: 'foo bar'";
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
@@ -146,12 +148,12 @@ describe('toEqual', function() {
} }
} }
const actual = { x: { y: 1, z: 2, f: 4 } }, const actual = { x: { y: 1, z: 2, f: 4 } };
expected = { x: { y: 1, z: 2, g: 3 } }, const expected = { x: { y: 1, z: 2, g: 3 } };
pp = privateUnderTest.makePrettyPrinter([formatter]), const pp = privateUnderTest.makePrettyPrinter([formatter]);
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }), const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
matcher = privateUnderTest.matchers.toEqual(matchersUtil), const matcher = privateUnderTest.matchers.toEqual(matchersUtil);
message = const message =
'Expected $.x to have properties\n' + 'Expected $.x to have properties\n' +
' g: |3|\n' + ' g: |3|\n' +
'Expected $.x not to have properties\n' + 'Expected $.x not to have properties\n' +
@@ -167,12 +169,14 @@ describe('toEqual', function() {
} }
} }
const actual = [{ foo: 4 }], const actual = [{ foo: 4 }];
expected = [{ foo: 5 }], const expected = [{ foo: 5 }];
prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]), const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]);
matchersUtil = new privateUnderTest.MatchersUtil({ pp: prettyPrinter }), const matchersUtil = new privateUnderTest.MatchersUtil({
matcher = privateUnderTest.matchers.toEqual(matchersUtil), pp: prettyPrinter
message = 'Expected $[0].foo = |4| to equal |5|.'; });
const matcher = privateUnderTest.matchers.toEqual(matchersUtil);
const message = 'Expected $[0].foo = |4| to equal |5|.';
expect(matcher.compare(actual, expected).message).toEqual(message); expect(matcher.compare(actual, expected).message).toEqual(message);
}); });
@@ -189,17 +193,19 @@ describe('toEqual', function() {
foo: { a: 1, b: 2 }, foo: { a: 1, b: 2 },
bar: 'should not be pretty printed' bar: 'should not be pretty printed'
} }
], ];
expected = [ const expected = [
{ {
foo: { a: 5, b: 2 }, foo: { a: 5, b: 2 },
bar: "shouldn't be pretty printed" bar: "shouldn't be pretty printed"
} }
], ];
prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]), const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]);
matchersUtil = new privateUnderTest.MatchersUtil({ pp: prettyPrinter }), const matchersUtil = new privateUnderTest.MatchersUtil({
matcher = privateUnderTest.matchers.toEqual(matchersUtil), pp: prettyPrinter
message = });
const matcher = privateUnderTest.matchers.toEqual(matchersUtil);
const message =
'Expected $[0].foo = [thing with a=1, b=2] to equal [thing with a=5, b=2].\n' + 'Expected $[0].foo = [thing with a=1, b=2] to equal [thing with a=5, b=2].\n' +
"Expected $[0].bar = 'should not be pretty printed' to equal 'shouldn't be pretty printed'."; "Expected $[0].bar = 'should not be pretty printed' to equal 'shouldn't be pretty printed'.";
@@ -207,9 +213,9 @@ describe('toEqual', function() {
}); });
it('reports extra and missing properties of the root-level object', function() { it('reports extra and missing properties of the root-level object', function() {
const actual = { x: 1 }, const actual = { x: 1 };
expected = { a: 1 }, const expected = { a: 1 };
message = const message =
'Expected object to have properties\n' + 'Expected object to have properties\n' +
' a: 1\n' + ' a: 1\n' +
'Expected object not to have properties\n' + 'Expected object not to have properties\n' +
@@ -219,42 +225,42 @@ describe('toEqual', function() {
}); });
it('reports multiple incorrect values', function() { it('reports multiple incorrect values', function() {
const actual = { x: 1, y: 2 }, const actual = { x: 1, y: 2 };
expected = { x: 3, y: 4 }, const expected = { x: 3, y: 4 };
message = const message =
'Expected $.x = 1 to equal 3.\n' + 'Expected $.y = 2 to equal 4.'; 'Expected $.x = 1 to equal 3.\n' + 'Expected $.y = 2 to equal 4.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports mismatch between actual child object and expected child number', function() { it('reports mismatch between actual child object and expected child number', function() {
const actual = { x: { y: 2 } }, const actual = { x: { y: 2 } };
expected = { x: 1 }, const expected = { x: 1 };
message = 'Expected $.x = Object({ y: 2 }) to equal 1.'; const message = 'Expected $.x = Object({ y: 2 }) to equal 1.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('uses the default failure message if actual is not an object', function() { it('uses the default failure message if actual is not an object', function() {
const actual = 1, const actual = 1;
expected = { x: {} }, const expected = { x: {} };
message = 'Expected 1 to equal Object({ x: Object({ }) }).'; const message = 'Expected 1 to equal Object({ x: Object({ }) }).';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('uses the default failure message if expected is not an object', function() { it('uses the default failure message if expected is not an object', function() {
const actual = { x: {} }, const actual = { x: {} };
expected = 1, const expected = 1;
message = 'Expected Object({ x: Object({ }) }) to equal 1.'; const message = 'Expected Object({ x: Object({ }) }) to equal 1.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('uses the default failure message given arrays with different lengths', function() { it('uses the default failure message given arrays with different lengths', function() {
const actual = [1, 2], const actual = [1, 2];
expected = [1, 2, 3], const expected = [1, 2, 3];
message = const message =
'Expected $.length = 2 to equal 3.\n' + 'Expected $.length = 2 to equal 3.\n' +
'Expected $[2] = undefined to equal 3.'; 'Expected $[2] = undefined to equal 3.';
@@ -262,107 +268,107 @@ describe('toEqual', function() {
}); });
it('reports a mismatch between elements of equal-length arrays', function() { it('reports a mismatch between elements of equal-length arrays', function() {
const actual = [1, 2, 5], const actual = [1, 2, 5];
expected = [1, 2, 3], const expected = [1, 2, 3];
message = 'Expected $[2] = 5 to equal 3.'; const message = 'Expected $[2] = 5 to equal 3.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports a mismatch between multiple array elements', function() { it('reports a mismatch between multiple array elements', function() {
const actual = [2, 2, 5], const actual = [2, 2, 5];
expected = [1, 2, 3], const expected = [1, 2, 3];
message = const message =
'Expected $[0] = 2 to equal 1.\n' + 'Expected $[2] = 5 to equal 3.'; 'Expected $[0] = 2 to equal 1.\n' + 'Expected $[2] = 5 to equal 3.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports a mismatch between properties of objects in arrays', function() { it('reports a mismatch between properties of objects in arrays', function() {
const actual = [{ x: 1 }], const actual = [{ x: 1 }];
expected = [{ x: 2 }], const expected = [{ x: 2 }];
message = 'Expected $[0].x = 1 to equal 2.'; const message = 'Expected $[0].x = 1 to equal 2.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports a mismatch between arrays in objects', function() { it('reports a mismatch between arrays in objects', function() {
const actual = { x: [1] }, const actual = { x: [1] };
expected = { x: [2] }, const expected = { x: [2] };
message = 'Expected $.x[0] = 1 to equal 2.'; const message = 'Expected $.x[0] = 1 to equal 2.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports mismatches between nested arrays', function() { it('reports mismatches between nested arrays', function() {
const actual = [[1]], const actual = [[1]];
expected = [[2]], const expected = [[2]];
message = 'Expected $[0][0] = 1 to equal 2.'; const message = 'Expected $[0][0] = 1 to equal 2.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports mismatches between arrays of different types', function() { it('reports mismatches between arrays of different types', function() {
const actual = new Uint32Array([1, 2, 3]), const actual = new Uint32Array([1, 2, 3]);
expected = new Uint16Array([1, 2, 3]), const expected = new Uint16Array([1, 2, 3]);
message = const message =
'Expected Uint32Array [ 1, 2, 3 ] to equal Uint16Array [ 1, 2, 3 ].'; 'Expected Uint32Array [ 1, 2, 3 ] to equal Uint16Array [ 1, 2, 3 ].';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports mismatches involving NaN', function() { it('reports mismatches involving NaN', function() {
const actual = { x: 0 }, const actual = { x: 0 };
expected = { x: 0 / 0 }, const expected = { x: 0 / 0 };
message = 'Expected $.x = 0 to equal NaN.'; const message = 'Expected $.x = 0 to equal NaN.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports mismatches involving regular expressions', function() { it('reports mismatches involving regular expressions', function() {
const actual = { x: '1' }, const actual = { x: '1' };
expected = { x: /1/ }, const expected = { x: /1/ };
message = "Expected $.x = '1' to equal /1/."; const message = "Expected $.x = '1' to equal /1/.";
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports mismatches involving infinities', function() { it('reports mismatches involving infinities', function() {
const actual = { x: 0 }, const actual = { x: 0 };
expected = { x: 1 / 0 }, const expected = { x: 1 / 0 };
message = 'Expected $.x = 0 to equal Infinity.'; const message = 'Expected $.x = 0 to equal Infinity.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports mismatches involving booleans', function() { it('reports mismatches involving booleans', function() {
const actual = { x: false }, const actual = { x: false };
expected = { x: true }, const expected = { x: true };
message = 'Expected $.x = false to equal true.'; const message = 'Expected $.x = false to equal true.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports mismatches involving strings', function() { it('reports mismatches involving strings', function() {
const actual = { x: 'foo' }, const actual = { x: 'foo' };
expected = { x: 'bar' }, const expected = { x: 'bar' };
message = "Expected $.x = 'foo' to equal 'bar'."; const message = "Expected $.x = 'foo' to equal 'bar'.";
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports mismatches involving undefined', function() { it('reports mismatches involving undefined', function() {
const actual = { x: void 0 }, const actual = { x: void 0 };
expected = { x: 0 }, const expected = { x: 0 };
message = 'Expected $.x = undefined to equal 0.'; const message = 'Expected $.x = undefined to equal 0.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports mismatches involving null', function() { it('reports mismatches involving null', function() {
const actual = { x: null }, const actual = { x: null };
expected = { x: 0 }, const expected = { x: 0 };
message = 'Expected $.x = null to equal 0.'; const message = 'Expected $.x = null to equal 0.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
@@ -371,9 +377,9 @@ describe('toEqual', function() {
function Foo() {} function Foo() {}
function Bar() {} function Bar() {}
const actual = { x: new Foo() }, const actual = { x: new Foo() };
expected = { x: new Bar() }, const expected = { x: new Bar() };
message = 'Expected $.x to be a kind of Bar, but was Foo({ }).'; const message = 'Expected $.x to be a kind of Bar, but was Foo({ }).';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
@@ -387,12 +393,13 @@ describe('toEqual', function() {
} }
} }
const actual = { x: new Foo() }, const actual = { x: new Foo() };
expected = { x: new Bar() }, const expected = { x: new Bar() };
message = 'Expected $.x to be a kind of Bar, but was |[object Object]|.', const message =
pp = privateUnderTest.makePrettyPrinter([formatter]), 'Expected $.x to be a kind of Bar, but was |[object Object]|.';
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }), const pp = privateUnderTest.makePrettyPrinter([formatter]);
matcher = privateUnderTest.matchers.toEqual(matchersUtil); const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
const matcher = privateUnderTest.matchers.toEqual(matchersUtil);
expect(matcher.compare(actual, expected).message).toEqual(message); expect(matcher.compare(actual, expected).message).toEqual(message);
}); });
@@ -401,9 +408,9 @@ describe('toEqual', function() {
function Foo() {} function Foo() {}
function Bar() {} function Bar() {}
const actual = new Foo(), const actual = new Foo();
expected = new Bar(), const expected = new Bar();
message = 'Expected object to be a kind of Bar, but was Foo({ }).'; const message = 'Expected object to be a kind of Bar, but was Foo({ }).';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
@@ -413,17 +420,17 @@ describe('toEqual', function() {
}); });
it('reports mismatches between objects with their own constructor property', function() { it('reports mismatches between objects with their own constructor property', function() {
const actual = { x: { constructor: 'blerf' } }, const actual = { x: { constructor: 'blerf' } };
expected = { x: { constructor: 'ftarrh' } }, const expected = { x: { constructor: 'ftarrh' } };
message = "Expected $.x.constructor = 'blerf' to equal 'ftarrh'."; const message = "Expected $.x.constructor = 'blerf' to equal 'ftarrh'.";
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports mismatches between an object with a real constructor and one with its own constructor property', function() { it('reports mismatches between an object with a real constructor and one with its own constructor property', function() {
const actual = { x: {} }, const actual = { x: {} };
expected = { x: { constructor: 'ftarrh' } }, const expected = { x: { constructor: 'ftarrh' } };
message = const message =
'Expected $.x to have properties\n' + " constructor: 'ftarrh'"; 'Expected $.x to have properties\n' + " constructor: 'ftarrh'";
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
@@ -433,25 +440,25 @@ describe('toEqual', function() {
}); });
it('reports mismatches between 0 and -0', function() { it('reports mismatches between 0 and -0', function() {
const actual = { x: 0 }, const actual = { x: 0 };
expected = { x: -0 }, const expected = { x: -0 };
message = 'Expected $.x = 0 to equal -0.'; const message = 'Expected $.x = 0 to equal -0.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports mismatches between 0 and Number.MIN_VALUE', function() { it('reports mismatches between 0 and Number.MIN_VALUE', function() {
const actual = { x: 0 }, const actual = { x: 0 };
expected = { x: Number.MIN_VALUE }, const expected = { x: Number.MIN_VALUE };
message = 'Expected $.x = 0 to equal 5e-324.'; const message = 'Expected $.x = 0 to equal 5e-324.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports mismatches between Errors', function() { it('reports mismatches between Errors', function() {
const actual = { x: new Error('the error you got') }, const actual = { x: new Error('the error you got') };
expected = { x: new Error('the error you want') }, const expected = { x: new Error('the error you want') };
message = const message =
'Expected $.x = Error: the error you got to equal Error: the error you want.'; 'Expected $.x = Error: the error you got to equal Error: the error you want.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
@@ -713,24 +720,24 @@ describe('toEqual', function() {
}); });
it('reports mismatches between DOM nodes with different tags', function() { it('reports mismatches between DOM nodes with different tags', function() {
const actual = { a: this.doc.createElement('div') }, const actual = { a: this.doc.createElement('div') };
expected = { a: this.doc.createElement('p') }, const expected = { a: this.doc.createElement('p') };
message = 'Expected $.a = <div> to equal <p>.'; const message = 'Expected $.a = <div> to equal <p>.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports mismatches between DOM nodes with different content', function() { it('reports mismatches between DOM nodes with different content', function() {
const nodeA = this.doc.createElement('div'), const nodeA = this.doc.createElement('div');
nodeB = this.doc.createElement('div'); const nodeB = this.doc.createElement('div');
nodeA.setAttribute('thing', 'foo'); nodeA.setAttribute('thing', 'foo');
nodeB.setAttribute('thing', 'bar'); nodeB.setAttribute('thing', 'bar');
expect(nodeA.isEqualNode(nodeB)).toBe(false); expect(nodeA.isEqualNode(nodeB)).toBe(false);
const actual = { a: nodeA }, const actual = { a: nodeA };
expected = { a: nodeB }, const expected = { a: nodeB };
message = const message =
'Expected $.a = <div thing="foo"> to equal <div thing="bar">.'; 'Expected $.a = <div thing="foo"> to equal <div thing="bar">.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
@@ -740,8 +747,11 @@ describe('toEqual', function() {
const nodeA = this.doc.createElementNS( const nodeA = this.doc.createElementNS(
'http://www.w3.org/2000/svg', 'http://www.w3.org/2000/svg',
'svg' 'svg'
), );
nodeB = this.doc.createElementNS('http://www.w3.org/2000/svg', 'svg'); const nodeB = this.doc.createElementNS(
'http://www.w3.org/2000/svg',
'svg'
);
nodeA.setAttribute('height', '50'); nodeA.setAttribute('height', '50');
nodeB.setAttribute('height', '30'); nodeB.setAttribute('height', '30');
@@ -754,33 +764,33 @@ describe('toEqual', function() {
nodeA.appendChild(rect); nodeA.appendChild(rect);
expect(nodeA.isEqualNode(nodeB)).toBe(false); expect(nodeA.isEqualNode(nodeB)).toBe(false);
const actual = { a: nodeA }, const actual = { a: nodeA };
expected = { a: nodeB }, const expected = { a: nodeB };
message = const message =
'Expected $.a = <svg height="50">...</svg> to equal <svg height="30">.'; 'Expected $.a = <svg height="50">...</svg> to equal <svg height="30">.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports whole DOM node when attribute contains > character', function() { it('reports whole DOM node when attribute contains > character', function() {
const nodeA = this.doc.createElement('div'), const nodeA = this.doc.createElement('div');
nodeB = this.doc.createElement('div'); const nodeB = this.doc.createElement('div');
nodeA.setAttribute('thing', '>>>'); nodeA.setAttribute('thing', '>>>');
nodeB.setAttribute('thing', 'bar'); nodeB.setAttribute('thing', 'bar');
expect(nodeA.isEqualNode(nodeB)).toBe(false); expect(nodeA.isEqualNode(nodeB)).toBe(false);
const actual = { a: nodeA }, const actual = { a: nodeA };
expected = { a: nodeB }, const expected = { a: nodeB };
message = const message =
'Expected $.a = <div thing=">>>"> to equal <div thing="bar">.'; 'Expected $.a = <div thing=">>>"> to equal <div thing="bar">.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports no content when DOM node has multiple empty text nodes', function() { it('reports no content when DOM node has multiple empty text nodes', function() {
const nodeA = this.doc.createElement('div'), const nodeA = this.doc.createElement('div');
nodeB = this.doc.createElement('div'); const nodeB = this.doc.createElement('div');
nodeA.appendChild(this.doc.createTextNode('')); nodeA.appendChild(this.doc.createTextNode(''));
nodeA.appendChild(this.doc.createTextNode('')); nodeA.appendChild(this.doc.createTextNode(''));
@@ -788,85 +798,86 @@ describe('toEqual', function() {
nodeA.appendChild(this.doc.createTextNode('')); nodeA.appendChild(this.doc.createTextNode(''));
expect(nodeA.isEqualNode(nodeB)).toBe(false); expect(nodeA.isEqualNode(nodeB)).toBe(false);
const actual = { a: nodeA }, const actual = { a: nodeA };
expected = { a: nodeB }, const expected = { a: nodeB };
message = 'Expected $.a = <div> to equal <div>.'; const message = 'Expected $.a = <div> to equal <div>.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports content when DOM node has non empty text node', function() { it('reports content when DOM node has non empty text node', function() {
const nodeA = this.doc.createElement('div'), const nodeA = this.doc.createElement('div');
nodeB = this.doc.createElement('div'); const nodeB = this.doc.createElement('div');
nodeA.appendChild(this.doc.createTextNode('Hello Jasmine!')); nodeA.appendChild(this.doc.createTextNode('Hello Jasmine!'));
expect(nodeA.isEqualNode(nodeB)).toBe(false); expect(nodeA.isEqualNode(nodeB)).toBe(false);
const actual = { a: nodeA }, const actual = { a: nodeA };
expected = { a: nodeB }, const expected = { a: nodeB };
message = 'Expected $.a = <div>...</div> to equal <div>.'; const message = 'Expected $.a = <div>...</div> to equal <div>.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports empty DOM attributes', function() { it('reports empty DOM attributes', function() {
const nodeA = this.doc.createElement('div'), const nodeA = this.doc.createElement('div');
nodeB = this.doc.createElement('div'); const nodeB = this.doc.createElement('div');
nodeA.setAttribute('contenteditable', ''); nodeA.setAttribute('contenteditable', '');
expect(nodeA.isEqualNode(nodeB)).toBe(false); expect(nodeA.isEqualNode(nodeB)).toBe(false);
const actual = { a: nodeA }, const actual = { a: nodeA };
expected = { a: nodeB }, const expected = { a: nodeB };
message = 'Expected $.a = <div contenteditable> to equal <div>.'; const message = 'Expected $.a = <div contenteditable> to equal <div>.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports 0 attr value as non empty DOM attribute', function() { it('reports 0 attr value as non empty DOM attribute', function() {
const nodeA = this.doc.createElement('div'), const nodeA = this.doc.createElement('div');
nodeB = this.doc.createElement('div'); const nodeB = this.doc.createElement('div');
nodeA.setAttribute('contenteditable', 0); nodeA.setAttribute('contenteditable', 0);
expect(nodeA.isEqualNode(nodeB)).toBe(false); expect(nodeA.isEqualNode(nodeB)).toBe(false);
const actual = { a: nodeA }, const actual = { a: nodeA };
expected = { a: nodeB }, const expected = { a: nodeB };
message = 'Expected $.a = <div contenteditable="0"> to equal <div>.'; const message =
'Expected $.a = <div contenteditable="0"> to equal <div>.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('reports mismatches between a DOM node and a bare Object', function() { it('reports mismatches between a DOM node and a bare Object', function() {
const actual = { a: this.doc.createElement('div') }, const actual = { a: this.doc.createElement('div') };
expected = { a: {} }, const expected = { a: {} };
message = 'Expected $.a = <div> to equal Object({ }).'; const message = 'Expected $.a = <div> to equal Object({ }).';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
}); });
it('reports asymmetric mismatches', function() { it('reports asymmetric mismatches', function() {
const actual = { a: 1 }, const actual = { a: 1 };
expected = { a: jasmineUnderTest.any(String) }, const expected = { a: jasmineUnderTest.any(String) };
message = 'Expected $.a = 1 to equal <jasmine.any(String)>.'; const message = 'Expected $.a = 1 to equal <jasmine.any(String)>.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
expect(compareEquals(actual, expected).pass).toBe(false); expect(compareEquals(actual, expected).pass).toBe(false);
}); });
it('reports asymmetric mismatches when the asymmetric comparand is the actual value', function() { it('reports asymmetric mismatches when the asymmetric comparand is the actual value', function() {
const actual = { a: jasmineUnderTest.any(String) }, const actual = { a: jasmineUnderTest.any(String) };
expected = { a: 1 }, const expected = { a: 1 };
message = 'Expected $.a = <jasmine.any(String)> to equal 1.'; const message = 'Expected $.a = <jasmine.any(String)> to equal 1.';
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
expect(compareEquals(actual, expected).pass).toBe(false); expect(compareEquals(actual, expected).pass).toBe(false);
}); });
it('does not report a mismatch when asymmetric matchers are satisfied', function() { it('does not report a mismatch when asymmetric matchers are satisfied', function() {
const actual = { a: 'a' }, const actual = { a: 'a' };
expected = { a: jasmineUnderTest.any(String) }; const expected = { a: jasmineUnderTest.any(String) };
expect(compareEquals(actual, expected).message).toEqual(''); expect(compareEquals(actual, expected).message).toEqual('');
expect(compareEquals(actual, expected).pass).toBe(true); expect(compareEquals(actual, expected).pass).toBe(true);
@@ -920,11 +931,10 @@ describe('toEqual', function() {
describe('different length arrays', function() { describe('different length arrays', function() {
it('actual array is longer', function() { it('actual array is longer', function() {
const actual = [1, 1, 2, 3, 5], const actual = [1, 1, 2, 3, 5];
expected = [1, 1, 2, 3], const expected = [1, 1, 2, 3];
message = const message =
'Expected $.length = 5 to equal 4.\n' + 'Expected $.length = 5 to equal 4.\n' + 'Unexpected $[4] = 5 in array.';
'Unexpected $[4] = 5 in array.';
expect(compareEquals(actual, expected).pass).toBe(false); expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
@@ -937,12 +947,12 @@ describe('toEqual', function() {
} }
} }
const actual = [1, 1, 2, 3, 5], const actual = [1, 1, 2, 3, 5];
expected = [1, 1, 2, 3], const expected = [1, 1, 2, 3];
pp = privateUnderTest.makePrettyPrinter([formatter]), const pp = privateUnderTest.makePrettyPrinter([formatter]);
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }), const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
matcher = privateUnderTest.matchers.toEqual(matchersUtil), const matcher = privateUnderTest.matchers.toEqual(matchersUtil);
message = const message =
'Expected $.length = |5| to equal |4|.\n' + 'Expected $.length = |5| to equal |4|.\n' +
'Unexpected $[4] = |5| in array.'; 'Unexpected $[4] = |5| in array.';
@@ -950,9 +960,9 @@ describe('toEqual', function() {
}); });
it('expected array is longer', function() { it('expected array is longer', function() {
const actual = [1, 1, 2, 3], const actual = [1, 1, 2, 3];
expected = [1, 1, 2, 3, 5], const expected = [1, 1, 2, 3, 5];
message = const message =
'Expected $.length = 4 to equal 5.\n' + 'Expected $.length = 4 to equal 5.\n' +
'Expected $[4] = undefined to equal 5.'; 'Expected $[4] = undefined to equal 5.';
@@ -961,27 +971,27 @@ describe('toEqual', function() {
}); });
it('undefined in middle of actual array', function() { it('undefined in middle of actual array', function() {
const actual = [1, void 0, 3], const actual = [1, void 0, 3];
expected = [1, 2, 3], const expected = [1, 2, 3];
message = 'Expected $[1] = undefined to equal 2.'; const message = 'Expected $[1] = undefined to equal 2.';
expect(compareEquals(actual, expected).pass).toBe(false); expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('undefined in middle of expected array', function() { it('undefined in middle of expected array', function() {
const actual = [1, 2, 3], const actual = [1, 2, 3];
expected = [1, void 0, 3], const expected = [1, void 0, 3];
message = 'Expected $[1] = 2 to equal undefined.'; const message = 'Expected $[1] = 2 to equal undefined.';
expect(compareEquals(actual, expected).pass).toBe(false); expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);
}); });
it('actual array is longer by 4 elements', function() { it('actual array is longer by 4 elements', function() {
const actual = [1, 1, 2, 3, 5, 8, 13], const actual = [1, 1, 2, 3, 5, 8, 13];
expected = [1, 1, 2], const expected = [1, 1, 2];
message = const message =
'Expected $.length = 7 to equal 3.\n' + 'Expected $.length = 7 to equal 3.\n' +
'Unexpected $[3] = 3 in array.\n' + 'Unexpected $[3] = 3 in array.\n' +
'Unexpected $[4] = 5 in array.\n' + 'Unexpected $[4] = 5 in array.\n' +
@@ -993,9 +1003,9 @@ describe('toEqual', function() {
}); });
it('expected array is longer by 4 elements', function() { it('expected array is longer by 4 elements', function() {
const actual = [1, 1, 2], const actual = [1, 1, 2];
expected = [1, 1, 2, 3, 5, 8, 13], const expected = [1, 1, 2, 3, 5, 8, 13];
message = const message =
'Expected $.length = 3 to equal 7.\n' + 'Expected $.length = 3 to equal 7.\n' +
'Expected $[3] = undefined to equal 3.\n' + 'Expected $[3] = undefined to equal 3.\n' +
'Expected $[4] = undefined to equal 5.\n' + 'Expected $[4] = undefined to equal 5.\n' +
@@ -1007,9 +1017,9 @@ describe('toEqual', function() {
}); });
it('different length and different elements', function() { it('different length and different elements', function() {
const actual = [1], const actual = [1];
expected = [2, 3], const expected = [2, 3];
message = const message =
'Expected $.length = 1 to equal 2.\n' + 'Expected $.length = 1 to equal 2.\n' +
'Expected $[0] = 1 to equal 2.\n' + 'Expected $[0] = 1 to equal 2.\n' +
'Expected $[1] = undefined to equal 3.'; 'Expected $[1] = undefined to equal 3.';
@@ -1019,9 +1029,9 @@ describe('toEqual', function() {
}); });
it('object with nested array (actual longer than expected)', function() { it('object with nested array (actual longer than expected)', function() {
const actual = { values: [1, 1, 2, 3] }, const actual = { values: [1, 1, 2, 3] };
expected = { values: [1, 1, 2] }, const expected = { values: [1, 1, 2] };
message = const message =
'Expected $.values.length = 4 to equal 3.\n' + 'Expected $.values.length = 4 to equal 3.\n' +
'Unexpected $.values[3] = 3 in array.'; 'Unexpected $.values[3] = 3 in array.';
@@ -1030,9 +1040,9 @@ describe('toEqual', function() {
}); });
it('object with nested array (expected longer than actual)', function() { it('object with nested array (expected longer than actual)', function() {
const actual = { values: [1, 1, 2] }, const actual = { values: [1, 1, 2] };
expected = { values: [1, 1, 2, 3] }, const expected = { values: [1, 1, 2, 3] };
message = const message =
'Expected $.values.length = 3 to equal 4.\n' + 'Expected $.values.length = 3 to equal 4.\n' +
'Expected $.values[3] = undefined to equal 3.'; 'Expected $.values[3] = undefined to equal 3.';
@@ -1041,9 +1051,9 @@ describe('toEqual', function() {
}); });
it('array with unexpected nested object', function() { it('array with unexpected nested object', function() {
const actual = [1, 1, 2, { value: 3 }], const actual = [1, 1, 2, { value: 3 }];
expected = [1, 1, 2], const expected = [1, 1, 2];
message = const message =
'Expected $.length = 4 to equal 3.\n' + 'Expected $.length = 4 to equal 3.\n' +
'Unexpected $[3] = Object({ value: 3 }) in array.'; 'Unexpected $[3] = Object({ value: 3 }) in array.';
@@ -1052,9 +1062,9 @@ describe('toEqual', function() {
}); });
it('array with missing nested object', function() { it('array with missing nested object', function() {
const actual = [1, 1, 2], const actual = [1, 1, 2];
expected = [1, 1, 2, { value: 3 }], const expected = [1, 1, 2, { value: 3 }];
message = const message =
'Expected $.length = 3 to equal 4.\n' + 'Expected $.length = 3 to equal 4.\n' +
'Expected $[3] = undefined to equal Object({ value: 3 }).'; 'Expected $[3] = undefined to equal Object({ value: 3 }).';
@@ -1063,9 +1073,9 @@ describe('toEqual', function() {
}); });
it('array with nested different length array', function() { it('array with nested different length array', function() {
const actual = [[1], [1, 2]], const actual = [[1], [1, 2]];
expected = [[1, 1], [2]], const expected = [[1, 1], [2]];
message = const message =
'Expected $[0].length = 1 to equal 2.\n' + 'Expected $[0].length = 1 to equal 2.\n' +
'Expected $[0][1] = undefined to equal 1.\n' + 'Expected $[0][1] = undefined to equal 1.\n' +
'Expected $[1].length = 2 to equal 1.\n' + 'Expected $[1].length = 2 to equal 1.\n' +
@@ -1077,9 +1087,9 @@ describe('toEqual', function() {
}); });
it('last element of longer array is undefined', function() { it('last element of longer array is undefined', function() {
const actual = [1, 2], const actual = [1, 2];
expected = [1, 2, void 0], const expected = [1, 2, void 0];
message = 'Expected $.length = 2 to equal 3.'; const message = 'Expected $.length = 2 to equal 3.';
expect(compareEquals(actual, expected).pass).toBe(false); expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).message).toEqual(message);

View File

@@ -2,9 +2,9 @@ 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);
@@ -14,9 +14,9 @@ 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();

View File

@@ -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');
@@ -19,14 +19,14 @@ describe('toHaveBeenCalledOnceWith', function() {
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');

View File

@@ -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);
@@ -23,8 +23,8 @@ 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();

View File

@@ -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();
@@ -48,8 +48,8 @@ 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();

View File

@@ -4,9 +4,11 @@ describe('toHaveBeenCalledWith', function() {
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');
@@ -22,12 +24,14 @@ describe('toHaveBeenCalledWith', function() {
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')
.and.returnValue(false),
pp: privateUnderTest.makePrettyPrinter() pp: privateUnderTest.makePrettyPrinter()
}, };
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
uncalledSpy = new privateUnderTest.Spy('uncalled spy'); matchersUtil
);
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);
@@ -54,9 +58,11 @@ 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');
@@ -86,8 +92,8 @@ 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);
@@ -99,9 +105,11 @@ describe('toHaveBeenCalledWith', function() {
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');

View File

@@ -1,7 +1,7 @@
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'
); );
@@ -10,8 +10,8 @@ describe('toHaveClass', function() {
}); });
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);
}); });

View File

@@ -1,7 +1,7 @@
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']
); );
@@ -10,15 +10,15 @@ describe('toHaveClasses', function() {
}); });
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);
}); });

View File

@@ -131,14 +131,14 @@ 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']);

View File

@@ -2,15 +2,15 @@ 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);
}); });
@@ -18,8 +18,8 @@ describe('toHaveSize', function() {
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);
}); });

View File

@@ -8,8 +8,8 @@ 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');
}; };
@@ -19,8 +19,8 @@ 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');
}; };
@@ -30,8 +30,8 @@ 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');
}; };
@@ -41,8 +41,8 @@ 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;
}; };
@@ -55,8 +55,8 @@ 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;
}; };
@@ -105,8 +105,8 @@ 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;
}; };
@@ -118,8 +118,8 @@ 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();
}; };
@@ -134,8 +134,8 @@ 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');
}; };
@@ -150,8 +150,8 @@ 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');
}; };
@@ -166,8 +166,8 @@ 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');
}; };
@@ -182,8 +182,8 @@ 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');
}; };
@@ -196,8 +196,8 @@ 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();
}; };
@@ -208,11 +208,11 @@ 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 });
}; };
@@ -227,8 +227,8 @@ 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();
}; };
@@ -244,9 +244,9 @@ describe('toThrowError', 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');
}; };
@@ -262,12 +262,12 @@ describe('toThrowError', 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' });
}; };
@@ -286,9 +286,9 @@ describe('toThrowError', 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');
}; };
@@ -306,9 +306,9 @@ describe('toThrowError', 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');
}; };
@@ -325,9 +325,9 @@ describe('toThrowError', 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');
}; };

View File

@@ -10,8 +10,8 @@ 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');
}; };
@@ -21,8 +21,8 @@ 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;
}; };
@@ -37,8 +37,8 @@ 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;
}; };
@@ -52,11 +52,11 @@ 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');
}; };
@@ -71,11 +71,11 @@ 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');
}; };

View File

@@ -9,8 +9,8 @@ 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;
}; };
@@ -24,9 +24,9 @@ describe('toThrow', 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;
}; };
@@ -41,8 +41,8 @@ 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;
}; };
@@ -57,9 +57,9 @@ describe('toThrow', 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;
}; };
@@ -73,9 +73,9 @@ describe('toThrow', 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;
}; };
@@ -91,9 +91,9 @@ describe('toThrow', 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;
}; };

View File

@@ -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];

View File

@@ -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,

View File

@@ -14,11 +14,11 @@ 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
}); });
@@ -32,11 +32,11 @@ 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
}); });
@@ -62,11 +62,11 @@ 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
}); });
@@ -130,11 +130,11 @@ 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
}); });
@@ -156,11 +156,11 @@ 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
}); });
@@ -179,11 +179,11 @@ 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
}); });
@@ -203,11 +203,11 @@ 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
}); });
@@ -229,11 +229,11 @@ 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
}); });
@@ -278,11 +278,11 @@ 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
}); });
@@ -322,11 +322,11 @@ 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
}); });
@@ -349,11 +349,11 @@ 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
}); });
@@ -384,11 +384,11 @@ 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
}); });
@@ -422,11 +422,11 @@ 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
}); });
@@ -444,11 +444,11 @@ 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) {
@@ -561,11 +561,11 @@ 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
}); });
@@ -575,8 +575,8 @@ describe('HtmlReporter', function() {
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'
); );
@@ -593,11 +593,11 @@ 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
}); });
@@ -671,11 +671,11 @@ 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
}); });
@@ -707,11 +707,11 @@ 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
}); });
@@ -724,11 +724,11 @@ 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
}); });
@@ -743,12 +743,12 @@ 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
@@ -767,12 +767,12 @@ 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
@@ -795,11 +795,11 @@ 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
}); });
@@ -814,11 +814,11 @@ 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
}); });
@@ -835,12 +835,12 @@ 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
@@ -861,12 +861,12 @@ 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
@@ -937,11 +937,11 @@ 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
}); });
@@ -965,11 +965,11 @@ 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
}); });
@@ -983,11 +983,11 @@ 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
}); });
@@ -1001,12 +1001,12 @@ 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
@@ -1023,12 +1023,12 @@ 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
@@ -1045,11 +1045,11 @@ 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
}); });
@@ -1069,11 +1069,11 @@ 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
}); });
@@ -1114,8 +1114,8 @@ 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;
@@ -1141,8 +1141,8 @@ describe('HtmlReporter', 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
}); });
@@ -1465,8 +1465,8 @@ 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,11 +1570,11 @@ 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
}); });
@@ -1594,11 +1594,11 @@ 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
}); });
@@ -1618,11 +1618,11 @@ 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
}); });

View File

@@ -607,8 +607,8 @@ describe('HtmlReporterV2', function() {
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'
); );
@@ -1203,8 +1203,8 @@ 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');

View File

@@ -3,8 +3,8 @@ describe('QueryString', 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;
} }
@@ -18,8 +18,8 @@ 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;
} }
@@ -36,8 +36,8 @@ describe('QueryString', 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;
} }
@@ -54,8 +54,8 @@ describe('QueryString', 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;
} }
@@ -67,8 +67,8 @@ describe('QueryString', function() {
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;
} }

View File

@@ -3,8 +3,8 @@ describe('ResultsNode', 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');
@@ -14,12 +14,12 @@ describe('ResultsNode', 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');
@@ -32,12 +32,12 @@ describe('ResultsNode', 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');
@@ -48,12 +48,12 @@ describe('ResultsNode', 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');

View File

@@ -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');

View File

@@ -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;

View File

@@ -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';

View File

@@ -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;
/** /**

View File

@@ -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()) {

View File

@@ -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;

View File

@@ -364,9 +364,11 @@ 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
);
const boilerplateEnd =
boilerplateStart + Spec.pendingSpecExceptionMessage.length; boilerplateStart + Spec.pendingSpecExceptionMessage.length;
return fullMessage.slice(boilerplateEnd); return fullMessage.slice(boilerplateEnd);

View File

@@ -40,11 +40,11 @@ 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,
@@ -54,8 +54,8 @@ getJasmineRequireObj().Spy = function(j$) {
customStrategies: customStrategies customStrategies: customStrategies
}, },
matchersUtil matchersUtil
), );
callTracker = new j$.private.CallTracker(); const callTracker = new j$.private.CallTracker();
function makeFunc(length, fn) { function makeFunc(length, fn) {
switch (length) { switch (length) {

View File

@@ -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 &&

View File

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

View File

@@ -149,10 +149,10 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
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];

View File

@@ -76,12 +76,12 @@ 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();
}); });
@@ -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';

View File

@@ -9,8 +9,8 @@ getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$) {
'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$);

View File

@@ -37,8 +37,8 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
'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$);

View File

@@ -15,8 +15,8 @@ getJasmineRequireObj().toEqual = function(j$) {
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
}); });

View File

@@ -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(

View File

@@ -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(

View File

@@ -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(

View File

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

View File

@@ -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)) {