Use one declaration per statement
The old style of merging all of a function's variable declarations into a single statement made some sense back in the days of var, but there's no reason to keep doing it now that we use const and let.
This commit is contained in:
@@ -7,10 +7,10 @@ describe('AsyncExpectation', function() {
|
||||
|
||||
describe('#not', function() {
|
||||
it('converts a pass to a fail', function() {
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
actual = Promise.resolve(),
|
||||
pp = privateUnderTest.makePrettyPrinter(),
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const actual = Promise.resolve();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
actual: actual,
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -28,9 +28,9 @@ describe('AsyncExpectation', function() {
|
||||
});
|
||||
|
||||
it('converts a fail to a pass', function() {
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
actual = Promise.reject(new Error('nope')),
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const actual = Promise.reject(new Error('nope'));
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
matchersUtil: new privateUnderTest.MatchersUtil({
|
||||
pp: function() {}
|
||||
}),
|
||||
@@ -53,9 +53,9 @@ describe('AsyncExpectation', function() {
|
||||
it('propagates rejections from the comparison function', function() {
|
||||
const error = new Error('ExpectationSpec failure');
|
||||
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
actual = dummyPromise(),
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const actual = dummyPromise();
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
actual: actual,
|
||||
addExpectationResult: addExpectationResult
|
||||
});
|
||||
@@ -78,9 +78,9 @@ describe('AsyncExpectation', function() {
|
||||
pp: function(val) {
|
||||
return val.toString();
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
actual: Promise.reject('rejected'),
|
||||
addExpectationResult: addExpectationResult,
|
||||
matchersUtil: matchersUtil
|
||||
@@ -106,9 +106,9 @@ describe('AsyncExpectation', function() {
|
||||
return 'failure message';
|
||||
},
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
actual: Promise.reject('b'),
|
||||
addExpectationResult: addExpectationResult,
|
||||
matchersUtil: matchersUtil
|
||||
@@ -159,10 +159,10 @@ describe('AsyncExpectation', function() {
|
||||
});
|
||||
|
||||
it('works with #not', function() {
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
actual = Promise.resolve(),
|
||||
pp = privateUnderTest.makePrettyPrinter(),
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const actual = Promise.resolve();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
actual: actual,
|
||||
addExpectationResult: addExpectationResult,
|
||||
matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp })
|
||||
@@ -183,9 +183,9 @@ describe('AsyncExpectation', function() {
|
||||
});
|
||||
|
||||
it('works with #not and a custom message', function() {
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
actual = Promise.resolve('a'),
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const actual = Promise.resolve('a');
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
actual: actual,
|
||||
addExpectationResult: addExpectationResult,
|
||||
matchersUtil: new privateUnderTest.MatchersUtil({
|
||||
@@ -213,8 +213,8 @@ describe('AsyncExpectation', function() {
|
||||
const asyncMatchers = {
|
||||
toFoo: function() {},
|
||||
toBar: function() {}
|
||||
},
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
};
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
customAsyncMatchers: asyncMatchers
|
||||
});
|
||||
|
||||
@@ -225,18 +225,18 @@ describe('AsyncExpectation', function() {
|
||||
it("wraps matchers's compare functions, passing in matcher dependencies", function() {
|
||||
const fakeCompare = function() {
|
||||
return Promise.resolve({ pass: true });
|
||||
},
|
||||
matcherFactory = jasmine
|
||||
};
|
||||
const matcherFactory = jasmine
|
||||
.createSpy('matcher')
|
||||
.and.returnValue({ compare: fakeCompare }),
|
||||
matchers = {
|
||||
.and.returnValue({ compare: fakeCompare });
|
||||
const matchers = {
|
||||
toFoo: matcherFactory
|
||||
},
|
||||
matchersUtil = {
|
||||
};
|
||||
const matchersUtil = {
|
||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
matchersUtil: matchersUtil,
|
||||
customAsyncMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
@@ -251,19 +251,19 @@ describe('AsyncExpectation', function() {
|
||||
it("wraps matchers's compare functions, passing the actual and expected", function() {
|
||||
const fakeCompare = jasmine
|
||||
.createSpy('fake-compare')
|
||||
.and.returnValue(Promise.resolve({ pass: true })),
|
||||
matchers = {
|
||||
.and.returnValue(Promise.resolve({ pass: true }));
|
||||
const matchers = {
|
||||
toFoo: function() {
|
||||
return {
|
||||
compare: fakeCompare
|
||||
};
|
||||
}
|
||||
},
|
||||
matchersUtil = {
|
||||
};
|
||||
const matchersUtil = {
|
||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const expectation = privateUnderTest.Expectation.asyncFactory({
|
||||
matchersUtil: matchersUtil,
|
||||
customAsyncMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
@@ -317,8 +317,8 @@ describe('AsyncExpectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
matchersUtil = {
|
||||
};
|
||||
const matchersUtil = {
|
||||
buildFailureMessage: function() {
|
||||
return '';
|
||||
}
|
||||
@@ -447,8 +447,8 @@ describe('AsyncExpectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
matchersUtil = {
|
||||
};
|
||||
const matchersUtil = {
|
||||
buildFailureMessage: function() {
|
||||
return 'default message';
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ describe('CallTracker', function() {
|
||||
it("tracks the 'this' object from each execution", function() {
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
|
||||
const this0 = {},
|
||||
this1 = {};
|
||||
const this0 = {};
|
||||
const this1 = {};
|
||||
callTracker.track({ object: this0, args: [] });
|
||||
callTracker.track({ object: this1, args: [] });
|
||||
callTracker.track({ args: [] });
|
||||
@@ -120,8 +120,8 @@ describe('CallTracker', function() {
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
callTracker.saveArgumentsByValue();
|
||||
|
||||
const objectArg = { foo: 'bar' },
|
||||
arrayArg = ['foo', 'bar'];
|
||||
const objectArg = { foo: 'bar' };
|
||||
const arrayArg = ['foo', 'bar'];
|
||||
|
||||
callTracker.track({
|
||||
object: {},
|
||||
@@ -138,8 +138,8 @@ describe('CallTracker', function() {
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
callTracker.saveArgumentsByValue(args => JSON.parse(JSON.stringify(args)));
|
||||
|
||||
const objectArg = { foo: { bar: { baz: ['qux'] } } },
|
||||
arrayArg = ['foo', 'bar'];
|
||||
const objectArg = { foo: { bar: { baz: ['qux'] } } };
|
||||
const arrayArg = ['foo', 'bar'];
|
||||
|
||||
callTracker.track({
|
||||
object: {},
|
||||
@@ -161,9 +161,9 @@ describe('CallTracker', function() {
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
callTracker.saveArgumentsByValue(JSON.stringify);
|
||||
|
||||
const objectArg = { foo: { bar: { baz: ['qux'] } } },
|
||||
arrayArg = ['foo', 'bar'],
|
||||
args = [objectArg, arrayArg, false, undefined, null, NaN, '', 0, 1.0];
|
||||
const objectArg = { foo: { bar: { baz: ['qux'] } } };
|
||||
const arrayArg = ['foo', 'bar'];
|
||||
const args = [objectArg, arrayArg, false, undefined, null, NaN, '', 0, 1.0];
|
||||
|
||||
callTracker.track({ object: {}, args });
|
||||
|
||||
@@ -171,8 +171,8 @@ describe('CallTracker', function() {
|
||||
});
|
||||
|
||||
it('saves primitive arguments by value', function() {
|
||||
const callTracker = new privateUnderTest.CallTracker(),
|
||||
args = [undefined, null, false, '', /\s/, 0, 1.2, NaN];
|
||||
const callTracker = new privateUnderTest.CallTracker();
|
||||
const args = [undefined, null, false, '', /\s/, 0, 1.2, NaN];
|
||||
|
||||
callTracker.saveArgumentsByValue();
|
||||
callTracker.track({ object: {}, args: args });
|
||||
|
||||
@@ -5,19 +5,19 @@ describe('Clock', function() {
|
||||
typeof process.versions.node === 'string';
|
||||
|
||||
it('does not replace setTimeout until it is installed', function() {
|
||||
const fakeSetTimeout = jasmine.createSpy('global setTimeout'),
|
||||
fakeGlobal = { setTimeout: fakeSetTimeout },
|
||||
delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
const fakeSetTimeout = jasmine.createSpy('global setTimeout');
|
||||
const fakeGlobal = { setTimeout: fakeSetTimeout };
|
||||
const delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
'delayedFunctionScheduler',
|
||||
['scheduleFunction']
|
||||
),
|
||||
delayedFn = jasmine.createSpy('delayedFn'),
|
||||
mockDate = {
|
||||
);
|
||||
const delayedFn = jasmine.createSpy('delayedFn');
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -40,18 +40,18 @@ describe('Clock', function() {
|
||||
});
|
||||
|
||||
it('does not replace clearTimeout until it is installed', function() {
|
||||
const fakeClearTimeout = jasmine.createSpy('global cleartimeout'),
|
||||
fakeGlobal = { clearTimeout: fakeClearTimeout },
|
||||
delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
const fakeClearTimeout = jasmine.createSpy('global cleartimeout');
|
||||
const fakeGlobal = { clearTimeout: fakeClearTimeout };
|
||||
const delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
'delayedFunctionScheduler',
|
||||
['removeFunctionWithId']
|
||||
),
|
||||
mockDate = {
|
||||
);
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -76,19 +76,19 @@ describe('Clock', function() {
|
||||
});
|
||||
|
||||
it('does not replace setInterval until it is installed', function() {
|
||||
const fakeSetInterval = jasmine.createSpy('global setInterval'),
|
||||
fakeGlobal = { setInterval: fakeSetInterval },
|
||||
delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
const fakeSetInterval = jasmine.createSpy('global setInterval');
|
||||
const fakeGlobal = { setInterval: fakeSetInterval };
|
||||
const delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
'delayedFunctionScheduler',
|
||||
['scheduleFunction']
|
||||
),
|
||||
delayedFn = jasmine.createSpy('delayedFn'),
|
||||
mockDate = {
|
||||
);
|
||||
const delayedFn = jasmine.createSpy('delayedFn');
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -111,18 +111,18 @@ describe('Clock', function() {
|
||||
});
|
||||
|
||||
it('does not replace clearInterval until it is installed', function() {
|
||||
const fakeClearInterval = jasmine.createSpy('global clearinterval'),
|
||||
fakeGlobal = { clearInterval: fakeClearInterval },
|
||||
delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
const fakeClearInterval = jasmine.createSpy('global clearinterval');
|
||||
const fakeGlobal = { clearInterval: fakeClearInterval };
|
||||
const delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
'delayedFunctionScheduler',
|
||||
['removeFunctionWithId']
|
||||
),
|
||||
mockDate = {
|
||||
);
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
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() {
|
||||
const originalFakeSetTimeout = function() {},
|
||||
replacedSetTimeout = function() {},
|
||||
fakeGlobal = { setTimeout: originalFakeSetTimeout },
|
||||
delayedFunctionSchedulerFactory = jasmine.createSpy(
|
||||
const originalFakeSetTimeout = function() {};
|
||||
const replacedSetTimeout = function() {};
|
||||
const fakeGlobal = { setTimeout: originalFakeSetTimeout };
|
||||
const delayedFunctionSchedulerFactory = jasmine.createSpy(
|
||||
'delayedFunctionSchedulerFactory'
|
||||
),
|
||||
mockDate = {},
|
||||
clock = new privateUnderTest.Clock(
|
||||
);
|
||||
const mockDate = {};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
delayedFunctionSchedulerFactory,
|
||||
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() {
|
||||
const originalFakeClearTimeout = function() {},
|
||||
replacedClearTimeout = function() {},
|
||||
fakeGlobal = { clearTimeout: originalFakeClearTimeout },
|
||||
delayedFunctionSchedulerFactory = jasmine.createSpy(
|
||||
const originalFakeClearTimeout = function() {};
|
||||
const replacedClearTimeout = function() {};
|
||||
const fakeGlobal = { clearTimeout: originalFakeClearTimeout };
|
||||
const delayedFunctionSchedulerFactory = jasmine.createSpy(
|
||||
'delayedFunctionSchedulerFactory'
|
||||
),
|
||||
mockDate = {},
|
||||
clock = new privateUnderTest.Clock(
|
||||
);
|
||||
const mockDate = {};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
delayedFunctionSchedulerFactory,
|
||||
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() {
|
||||
const originalFakeSetInterval = function() {},
|
||||
replacedSetInterval = function() {},
|
||||
fakeGlobal = { setInterval: originalFakeSetInterval },
|
||||
delayedFunctionSchedulerFactory = jasmine.createSpy(
|
||||
const originalFakeSetInterval = function() {};
|
||||
const replacedSetInterval = function() {};
|
||||
const fakeGlobal = { setInterval: originalFakeSetInterval };
|
||||
const delayedFunctionSchedulerFactory = jasmine.createSpy(
|
||||
'delayedFunctionSchedulerFactory'
|
||||
),
|
||||
mockDate = {},
|
||||
clock = new privateUnderTest.Clock(
|
||||
);
|
||||
const mockDate = {};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
delayedFunctionSchedulerFactory,
|
||||
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() {
|
||||
const originalFakeClearInterval = function() {},
|
||||
replacedClearInterval = function() {},
|
||||
fakeGlobal = { clearInterval: originalFakeClearInterval },
|
||||
delayedFunctionSchedulerFactory = jasmine.createSpy(
|
||||
const originalFakeClearInterval = function() {};
|
||||
const replacedClearInterval = function() {};
|
||||
const fakeGlobal = { clearInterval: originalFakeClearInterval };
|
||||
const delayedFunctionSchedulerFactory = jasmine.createSpy(
|
||||
'delayedFunctionSchedulerFactory'
|
||||
),
|
||||
mockDate = {},
|
||||
clock = new privateUnderTest.Clock(
|
||||
);
|
||||
const mockDate = {};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
delayedFunctionSchedulerFactory,
|
||||
mockDate
|
||||
@@ -243,27 +243,27 @@ describe('Clock', function() {
|
||||
});
|
||||
|
||||
it('restores the global timer functions on uninstall', function() {
|
||||
const fakeSetTimeout = jasmine.createSpy('global setTimeout'),
|
||||
fakeClearTimeout = jasmine.createSpy('global clearTimeout'),
|
||||
fakeSetInterval = jasmine.createSpy('global setInterval'),
|
||||
fakeClearInterval = jasmine.createSpy('global clearInterval'),
|
||||
fakeGlobal = {
|
||||
const fakeSetTimeout = jasmine.createSpy('global setTimeout');
|
||||
const fakeClearTimeout = jasmine.createSpy('global clearTimeout');
|
||||
const fakeSetInterval = jasmine.createSpy('global setInterval');
|
||||
const fakeClearInterval = jasmine.createSpy('global clearInterval');
|
||||
const fakeGlobal = {
|
||||
setTimeout: fakeSetTimeout,
|
||||
clearTimeout: fakeClearTimeout,
|
||||
setInterval: fakeSetInterval,
|
||||
clearInterval: fakeClearInterval
|
||||
},
|
||||
delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
};
|
||||
const delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
'delayedFunctionScheduler',
|
||||
['scheduleFunction', 'reset']
|
||||
),
|
||||
delayedFn = jasmine.createSpy('delayedFn'),
|
||||
mockDate = {
|
||||
);
|
||||
const delayedFn = jasmine.createSpy('delayedFn');
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
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() {
|
||||
const fakeSetTimeout = jasmine.createSpy('global setTimeout'),
|
||||
fakeClearTimeout = jasmine.createSpy('global clearTimeout'),
|
||||
fakeSetInterval = jasmine.createSpy('global setInterval'),
|
||||
fakeClearInterval = jasmine.createSpy('global clearInterval'),
|
||||
fakeGlobal = {
|
||||
const fakeSetTimeout = jasmine.createSpy('global setTimeout');
|
||||
const fakeClearTimeout = jasmine.createSpy('global clearTimeout');
|
||||
const fakeSetInterval = jasmine.createSpy('global setInterval');
|
||||
const fakeClearInterval = jasmine.createSpy('global clearInterval');
|
||||
const fakeGlobal = {
|
||||
setTimeout: fakeSetTimeout,
|
||||
clearTimeout: fakeClearTimeout,
|
||||
setInterval: fakeSetInterval,
|
||||
clearInterval: fakeClearInterval
|
||||
},
|
||||
delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
};
|
||||
const delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
'delayedFunctionScheduler',
|
||||
['scheduleFunction', 'reset', 'removeFunctionWithId']
|
||||
),
|
||||
delayedFn = jasmine.createSpy('delayedFn'),
|
||||
mockDate = {
|
||||
);
|
||||
const delayedFn = jasmine.createSpy('delayedFn');
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
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() {
|
||||
const fakeSetTimeout = jasmine.createSpy('global setTimeout'),
|
||||
fakeClearTimeout = jasmine.createSpy('global clearTimeout'),
|
||||
fakeSetInterval = jasmine.createSpy('global setInterval'),
|
||||
fakeClearInterval = jasmine.createSpy('global clearInterval'),
|
||||
fakeGlobal = {
|
||||
const fakeSetTimeout = jasmine.createSpy('global setTimeout');
|
||||
const fakeClearTimeout = jasmine.createSpy('global clearTimeout');
|
||||
const fakeSetInterval = jasmine.createSpy('global setInterval');
|
||||
const fakeClearInterval = jasmine.createSpy('global clearInterval');
|
||||
const fakeGlobal = {
|
||||
setTimeout: fakeSetTimeout,
|
||||
clearTimeout: fakeClearTimeout,
|
||||
setInterval: fakeSetInterval,
|
||||
clearInterval: fakeClearInterval
|
||||
},
|
||||
delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
};
|
||||
const delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
'delayedFunctionScheduler',
|
||||
['scheduleFunction', 'reset', 'removeFunctionWithId']
|
||||
),
|
||||
delayedFn = jasmine.createSpy('delayedFn'),
|
||||
mockDate = {
|
||||
);
|
||||
const delayedFn = jasmine.createSpy('delayedFn');
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -445,24 +445,24 @@ describe('Clock', function() {
|
||||
|
||||
describe('setTimeout', function() {
|
||||
it('schedules the delayed function with the fake timer', function() {
|
||||
const fakeSetTimeout = jasmine.createSpy('setTimeout'),
|
||||
scheduleFunction = jasmine.createSpy('scheduleFunction'),
|
||||
delayedFunctionScheduler = { scheduleFunction: scheduleFunction },
|
||||
fakeGlobal = { setTimeout: fakeSetTimeout },
|
||||
delayedFn = jasmine.createSpy('delayedFn'),
|
||||
mockDate = {
|
||||
const fakeSetTimeout = jasmine.createSpy('setTimeout');
|
||||
const scheduleFunction = jasmine.createSpy('scheduleFunction');
|
||||
const delayedFunctionScheduler = { scheduleFunction: scheduleFunction };
|
||||
const fakeGlobal = { setTimeout: fakeSetTimeout };
|
||||
const delayedFn = jasmine.createSpy('delayedFn');
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
},
|
||||
mockDate
|
||||
),
|
||||
timeout = new clock.FakeTimeout();
|
||||
);
|
||||
const timeout = new clock.FakeTimeout();
|
||||
|
||||
clock.install();
|
||||
clock.setTimeout(delayedFn, 0, 'a', 'b');
|
||||
@@ -487,20 +487,20 @@ describe('Clock', function() {
|
||||
});
|
||||
|
||||
it('returns an id for the delayed function', function() {
|
||||
const fakeSetTimeout = jasmine.createSpy('setTimeout'),
|
||||
scheduleId = 123,
|
||||
scheduleFunction = jasmine
|
||||
const fakeSetTimeout = jasmine.createSpy('setTimeout');
|
||||
const scheduleId = 123;
|
||||
const scheduleFunction = jasmine
|
||||
.createSpy('scheduleFunction')
|
||||
.and.returnValue(scheduleId),
|
||||
delayedFunctionScheduler = { scheduleFunction: scheduleFunction },
|
||||
fakeGlobal = { setTimeout: fakeSetTimeout },
|
||||
delayedFn = jasmine.createSpy('delayedFn'),
|
||||
mockDate = {
|
||||
.and.returnValue(scheduleId);
|
||||
const delayedFunctionScheduler = { scheduleFunction: scheduleFunction };
|
||||
const fakeGlobal = { setTimeout: fakeSetTimeout };
|
||||
const delayedFn = jasmine.createSpy('delayedFn');
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -521,18 +521,18 @@ describe('Clock', function() {
|
||||
|
||||
describe('clearTimeout', function() {
|
||||
it('clears the scheduled function with the scheduler', function() {
|
||||
const fakeClearTimeout = jasmine.createSpy('clearTimeout'),
|
||||
delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
const fakeClearTimeout = jasmine.createSpy('clearTimeout');
|
||||
const delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
'delayedFunctionScheduler',
|
||||
['removeFunctionWithId']
|
||||
),
|
||||
fakeGlobal = { setTimeout: fakeClearTimeout },
|
||||
mockDate = {
|
||||
);
|
||||
const fakeGlobal = { setTimeout: fakeClearTimeout };
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -552,24 +552,24 @@ describe('Clock', function() {
|
||||
|
||||
describe('setInterval', function() {
|
||||
it('schedules the delayed function with the fake timer', function() {
|
||||
const fakeSetInterval = jasmine.createSpy('setInterval'),
|
||||
scheduleFunction = jasmine.createSpy('scheduleFunction'),
|
||||
delayedFunctionScheduler = { scheduleFunction: scheduleFunction },
|
||||
fakeGlobal = { setInterval: fakeSetInterval },
|
||||
delayedFn = jasmine.createSpy('delayedFn'),
|
||||
mockDate = {
|
||||
const fakeSetInterval = jasmine.createSpy('setInterval');
|
||||
const scheduleFunction = jasmine.createSpy('scheduleFunction');
|
||||
const delayedFunctionScheduler = { scheduleFunction: scheduleFunction };
|
||||
const fakeGlobal = { setInterval: fakeSetInterval };
|
||||
const delayedFn = jasmine.createSpy('delayedFn');
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
},
|
||||
mockDate
|
||||
),
|
||||
timeout = new clock.FakeTimeout();
|
||||
);
|
||||
const timeout = new clock.FakeTimeout();
|
||||
|
||||
clock.install();
|
||||
clock.setInterval(delayedFn, 0, 'a', 'b');
|
||||
@@ -595,20 +595,20 @@ describe('Clock', function() {
|
||||
});
|
||||
|
||||
it('returns an id for the delayed function', function() {
|
||||
const fakeSetInterval = jasmine.createSpy('setInterval'),
|
||||
scheduleId = 123,
|
||||
scheduleFunction = jasmine
|
||||
const fakeSetInterval = jasmine.createSpy('setInterval');
|
||||
const scheduleId = 123;
|
||||
const scheduleFunction = jasmine
|
||||
.createSpy('scheduleFunction')
|
||||
.and.returnValue(scheduleId),
|
||||
delayedFunctionScheduler = { scheduleFunction: scheduleFunction },
|
||||
fakeGlobal = { setInterval: fakeSetInterval },
|
||||
delayedFn = jasmine.createSpy('delayedFn'),
|
||||
mockDate = {
|
||||
.and.returnValue(scheduleId);
|
||||
const delayedFunctionScheduler = { scheduleFunction: scheduleFunction };
|
||||
const fakeGlobal = { setInterval: fakeSetInterval };
|
||||
const delayedFn = jasmine.createSpy('delayedFn');
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -629,18 +629,18 @@ describe('Clock', function() {
|
||||
|
||||
describe('clearInterval', function() {
|
||||
it('clears the scheduled function with the scheduler', function() {
|
||||
const clearInterval = jasmine.createSpy('clearInterval'),
|
||||
delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
const clearInterval = jasmine.createSpy('clearInterval');
|
||||
const delayedFunctionScheduler = jasmine.createSpyObj(
|
||||
'delayedFunctionScheduler',
|
||||
['removeFunctionWithId']
|
||||
),
|
||||
fakeGlobal = { setInterval: clearInterval },
|
||||
mockDate = {
|
||||
);
|
||||
const fakeGlobal = { setInterval: clearInterval };
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
fakeGlobal,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -671,17 +671,17 @@ describe('Clock', function() {
|
||||
|
||||
describe('Clock (acceptance)', function() {
|
||||
it('can run setTimeouts/setIntervals synchronously', function() {
|
||||
const delayedFn1 = jasmine.createSpy('delayedFn1'),
|
||||
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
||||
delayedFn3 = jasmine.createSpy('delayedFn3'),
|
||||
recurring1 = jasmine.createSpy('recurring1'),
|
||||
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
mockDate = {
|
||||
const delayedFn1 = jasmine.createSpy('delayedFn1');
|
||||
const delayedFn2 = jasmine.createSpy('delayedFn2');
|
||||
const delayedFn3 = jasmine.createSpy('delayedFn3');
|
||||
const recurring1 = jasmine.createSpy('recurring1');
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: setTimeout },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -776,10 +776,10 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('can run setTimeouts/setIntervals asynchronously', function() {
|
||||
const recurring = jasmine.createSpy('recurring'),
|
||||
fn1 = jasmine.createSpy('fn1'),
|
||||
fn2 = jasmine.createSpy('fn2'),
|
||||
fn3 = jasmine.createSpy('fn3');
|
||||
const recurring = jasmine.createSpy('recurring');
|
||||
const fn1 = jasmine.createSpy('fn1');
|
||||
const fn2 = jasmine.createSpy('fn2');
|
||||
const fn3 = jasmine.createSpy('fn3');
|
||||
|
||||
const intervalId = clock.setInterval(recurring, 50);
|
||||
// In a microtask, add some timeouts.
|
||||
@@ -884,14 +884,14 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('can clear a previously set timeout', function() {
|
||||
const clearedFn = jasmine.createSpy('clearedFn'),
|
||||
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
mockDate = {
|
||||
const clearedFn = jasmine.createSpy('clearedFn');
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: function() {} },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -911,14 +911,14 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it("can clear a previously set interval using that interval's handler", function() {
|
||||
const spy = jasmine.createSpy('spy'),
|
||||
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
mockDate = {
|
||||
const spy = jasmine.createSpy('spy');
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
{ setInterval: function() {} },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -938,14 +938,14 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('correctly schedules functions after the Clock has advanced', function() {
|
||||
const delayedFn1 = jasmine.createSpy('delayedFn1'),
|
||||
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
mockDate = {
|
||||
const delayedFn1 = jasmine.createSpy('delayedFn1');
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: function() {} },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -964,15 +964,15 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('correctly schedules functions while the Clock is advancing', function() {
|
||||
const delayedFn1 = jasmine.createSpy('delayedFn1'),
|
||||
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
||||
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
mockDate = {
|
||||
const delayedFn1 = jasmine.createSpy('delayedFn1');
|
||||
const delayedFn2 = jasmine.createSpy('delayedFn2');
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: function() {} },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -995,15 +995,15 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('correctly calls functions scheduled while the Clock is advancing', function() {
|
||||
const delayedFn1 = jasmine.createSpy('delayedFn1'),
|
||||
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
||||
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
mockDate = {
|
||||
const delayedFn1 = jasmine.createSpy('delayedFn1');
|
||||
const delayedFn2 = jasmine.createSpy('delayedFn2');
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: function() {} },
|
||||
function() {
|
||||
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() {
|
||||
const delayedFn1 = jasmine.createSpy('delayedFn1'),
|
||||
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
||||
delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
mockDate = {
|
||||
const delayedFn1 = jasmine.createSpy('delayedFn1');
|
||||
const delayedFn2 = jasmine.createSpy('delayedFn2');
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const mockDate = {
|
||||
install: function() {},
|
||||
tick: function() {},
|
||||
uninstall: function() {}
|
||||
},
|
||||
clock = new privateUnderTest.Clock(
|
||||
};
|
||||
const clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: function() {} },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -1057,10 +1057,10 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('does not mock the Date object by default', function() {
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
global = { Date: Date },
|
||||
mockDate = new privateUnderTest.MockDate(global),
|
||||
clock = new privateUnderTest.Clock(
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const global = { Date: Date };
|
||||
const mockDate = new privateUnderTest.MockDate(global);
|
||||
const clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: setTimeout },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -1080,10 +1080,10 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('mocks the Date object and sets it to current time', function() {
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
global = { Date: Date },
|
||||
mockDate = new privateUnderTest.MockDate(global),
|
||||
clock = new privateUnderTest.Clock(
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const global = { Date: Date };
|
||||
const mockDate = new privateUnderTest.MockDate(global);
|
||||
const clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: setTimeout },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -1110,17 +1110,17 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('mocks the Date object and sets it to a given time', function() {
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
global = { Date: Date },
|
||||
mockDate = new privateUnderTest.MockDate(global),
|
||||
clock = new privateUnderTest.Clock(
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const global = { Date: Date };
|
||||
const mockDate = new privateUnderTest.MockDate(global);
|
||||
const clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: setTimeout },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
},
|
||||
mockDate
|
||||
),
|
||||
baseTime = new Date(2013, 9, 23);
|
||||
);
|
||||
const baseTime = new Date(2013, 9, 23);
|
||||
|
||||
clock.install().mockDate(baseTime);
|
||||
|
||||
@@ -1143,10 +1143,10 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('throws mockDate is called with a non-Date', function() {
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
global = { Date: Date },
|
||||
mockDate = new privateUnderTest.MockDate(global),
|
||||
clock = new privateUnderTest.Clock(
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const global = { Date: Date };
|
||||
const mockDate = new privateUnderTest.MockDate(global);
|
||||
const clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: setTimeout },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -1161,17 +1161,17 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('mocks the Date object and updates the date per delayed function', function() {
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
global = { Date: Date },
|
||||
mockDate = new privateUnderTest.MockDate(global),
|
||||
clock = new privateUnderTest.Clock(
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const global = { Date: Date };
|
||||
const mockDate = new privateUnderTest.MockDate(global);
|
||||
const clock = new privateUnderTest.Clock(
|
||||
{ setTimeout: setTimeout },
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
},
|
||||
mockDate
|
||||
),
|
||||
baseTime = new Date();
|
||||
);
|
||||
const baseTime = new Date();
|
||||
|
||||
clock.install().mockDate(baseTime);
|
||||
|
||||
@@ -1200,10 +1200,10 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('correctly clears a scheduled timeout while the Clock is advancing', function() {
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
global = { Date: Date, setTimeout: undefined },
|
||||
mockDate = new privateUnderTest.MockDate(global),
|
||||
clock = new privateUnderTest.Clock(
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const global = { Date: Date, setTimeout: undefined };
|
||||
const mockDate = new privateUnderTest.MockDate(global);
|
||||
const clock = new privateUnderTest.Clock(
|
||||
global,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
@@ -1225,10 +1225,10 @@ describe('Clock (acceptance)', function() {
|
||||
});
|
||||
|
||||
it('correctly clears a scheduled interval while the Clock is advancing', function() {
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
global = { Date: Date, setTimeout: undefined },
|
||||
mockDate = new privateUnderTest.MockDate(global),
|
||||
clock = new privateUnderTest.Clock(
|
||||
const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const global = { Date: Date, setTimeout: undefined };
|
||||
const mockDate = new privateUnderTest.MockDate(global);
|
||||
const clock = new privateUnderTest.Clock(
|
||||
global,
|
||||
function() {
|
||||
return delayedFunctionScheduler;
|
||||
|
||||
@@ -2,8 +2,8 @@ describe('DelayedFunctionScheduler', function() {
|
||||
'use strict';
|
||||
|
||||
it('schedules a function for later execution', function() {
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn');
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const fn = jasmine.createSpy('fn');
|
||||
|
||||
scheduler.scheduleFunction(fn, 0);
|
||||
|
||||
@@ -25,8 +25,8 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('#tick defaults to 0', function() {
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn');
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const fn = jasmine.createSpy('fn');
|
||||
|
||||
scheduler.scheduleFunction(fn, 0);
|
||||
|
||||
@@ -38,8 +38,8 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('defaults delay to 0', function() {
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn');
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const fn = jasmine.createSpy('fn');
|
||||
|
||||
scheduler.scheduleFunction(fn);
|
||||
|
||||
@@ -51,8 +51,8 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('optionally passes params to scheduled functions', function() {
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn');
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const fn = jasmine.createSpy('fn');
|
||||
|
||||
scheduler.scheduleFunction(fn, 0, ['foo', 'bar']);
|
||||
|
||||
@@ -64,8 +64,8 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('scheduled fns can optionally reoccur', function() {
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn');
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const fn = jasmine.createSpy('fn');
|
||||
|
||||
scheduler.scheduleFunction(fn, 20, [], true);
|
||||
|
||||
@@ -97,9 +97,9 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('#removeFunctionWithId removes a previously scheduled function with a given id', function() {
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn'),
|
||||
timeoutKey = scheduler.scheduleFunction(fn, 0);
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const fn = jasmine.createSpy('fn');
|
||||
const timeoutKey = scheduler.scheduleFunction(fn, 0);
|
||||
|
||||
expect(fn).not.toHaveBeenCalled();
|
||||
|
||||
@@ -132,9 +132,9 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('schedules a function for later execution during a tick', function() {
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn'),
|
||||
fnDelay = 10;
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const fn = jasmine.createSpy('fn');
|
||||
const fnDelay = 10;
|
||||
|
||||
scheduler.scheduleFunction(function() {
|
||||
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() {
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn'),
|
||||
fnDelay = 10;
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const fn = jasmine.createSpy('fn');
|
||||
const fnDelay = 10;
|
||||
let timeoutKey;
|
||||
|
||||
scheduler.scheduleFunction(function() {
|
||||
@@ -199,8 +199,8 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('executes recurring functions after rescheduling them', function() {
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
recurring = function() {
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const recurring = function() {
|
||||
expect(scheduler.scheduleFunction).toHaveBeenCalled();
|
||||
};
|
||||
|
||||
@@ -212,10 +212,10 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('removes functions during a tick that runs the function', function() {
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
spy = jasmine.createSpy('fn'),
|
||||
spyAndRemove = jasmine.createSpy('fn'),
|
||||
fnDelay = 10;
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const spy = jasmine.createSpy('fn');
|
||||
const spyAndRemove = jasmine.createSpy('fn');
|
||||
const fnDelay = 10;
|
||||
let timeoutKey;
|
||||
|
||||
spyAndRemove.and.callFake(function() {
|
||||
@@ -233,9 +233,9 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('removes functions during the first tick that runs the function', function() {
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn'),
|
||||
fnDelay = 10;
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const fn = jasmine.createSpy('fn');
|
||||
const fnDelay = 10;
|
||||
let timeoutKey;
|
||||
|
||||
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() {
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn'),
|
||||
fnDelay = 10;
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const fn = jasmine.createSpy('fn');
|
||||
const fnDelay = 10;
|
||||
|
||||
scheduler.removeFunctionWithId('foo');
|
||||
scheduler.scheduleFunction(fn, fnDelay, [], false, 'foo');
|
||||
@@ -303,8 +303,8 @@ describe('DelayedFunctionScheduler', function() {
|
||||
});
|
||||
|
||||
it('updates the mockDate per scheduled time', function() {
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler(),
|
||||
tickDate = jasmine.createSpy('tickDate');
|
||||
const scheduler = new privateUnderTest.DelayedFunctionScheduler();
|
||||
const tickDate = jasmine.createSpy('tickDate');
|
||||
|
||||
scheduler.scheduleFunction(function() {});
|
||||
scheduler.scheduleFunction(function() {}, 1);
|
||||
|
||||
@@ -6,9 +6,9 @@ describe('ExceptionFormatter', function() {
|
||||
lineNumber: '1978',
|
||||
message: 'you got your foo in my bar',
|
||||
name: 'A Classic Mistake'
|
||||
},
|
||||
exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
||||
message = exceptionFormatter.message(sampleFirefoxException);
|
||||
};
|
||||
const exceptionFormatter = new privateUnderTest.ExceptionFormatter();
|
||||
const message = exceptionFormatter.message(sampleFirefoxException);
|
||||
|
||||
expect(message).toEqual(
|
||||
'A Classic Mistake: you got your foo in my bar in foo.js (line 1978)'
|
||||
@@ -21,9 +21,9 @@ describe('ExceptionFormatter', function() {
|
||||
line: '1978',
|
||||
message: 'you got your foo in my bar',
|
||||
name: 'A Classic Mistake'
|
||||
},
|
||||
exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
||||
message = exceptionFormatter.message(sampleWebkitException);
|
||||
};
|
||||
const exceptionFormatter = new privateUnderTest.ExceptionFormatter();
|
||||
const message = exceptionFormatter.message(sampleWebkitException);
|
||||
|
||||
expect(message).toEqual(
|
||||
'A Classic Mistake: you got your foo in my bar in foo.js (line 1978)'
|
||||
@@ -34,9 +34,9 @@ describe('ExceptionFormatter', function() {
|
||||
const sampleV8 = {
|
||||
message: 'you got your foo in my bar',
|
||||
name: 'A Classic Mistake'
|
||||
},
|
||||
exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
||||
message = exceptionFormatter.message(sampleV8);
|
||||
};
|
||||
const exceptionFormatter = new privateUnderTest.ExceptionFormatter();
|
||||
const message = exceptionFormatter.message(sampleV8);
|
||||
|
||||
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() {
|
||||
const unnamedError = { message: 'This is an unnamed error message.' };
|
||||
|
||||
const exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
||||
message = exceptionFormatter.message(unnamedError);
|
||||
const exceptionFormatter = new privateUnderTest.ExceptionFormatter();
|
||||
const message = exceptionFormatter.message(unnamedError);
|
||||
|
||||
expect(message).toEqual('This is an unnamed error message.');
|
||||
});
|
||||
@@ -57,16 +57,16 @@ describe('ExceptionFormatter', function() {
|
||||
};
|
||||
const emptyError = new EmptyError();
|
||||
|
||||
const exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
||||
message = exceptionFormatter.message(emptyError);
|
||||
const exceptionFormatter = new privateUnderTest.ExceptionFormatter();
|
||||
const message = exceptionFormatter.message(emptyError);
|
||||
|
||||
expect(message).toEqual('[EmptyError] thrown');
|
||||
});
|
||||
|
||||
it("formats thrown exceptions that aren't errors", function() {
|
||||
const thrown = 'crazy error',
|
||||
exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
||||
message = exceptionFormatter.message(thrown);
|
||||
const thrown = 'crazy error';
|
||||
const exceptionFormatter = new privateUnderTest.ExceptionFormatter();
|
||||
const message = exceptionFormatter.message(thrown);
|
||||
|
||||
expect(message).toEqual('crazy error thrown');
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
describe('ExpectationFilterChain', function() {
|
||||
describe('#addFilter', function() {
|
||||
it('returns a new filter chain with the added filter', function() {
|
||||
const first = jasmine.createSpy('first'),
|
||||
second = jasmine.createSpy('second'),
|
||||
orig = new privateUnderTest.ExpectationFilterChain({
|
||||
const first = jasmine.createSpy('first');
|
||||
const second = jasmine.createSpy('second');
|
||||
const orig = new privateUnderTest.ExpectationFilterChain({
|
||||
modifyFailureMessage: first
|
||||
}),
|
||||
added = orig.addFilter({ selectComparisonFunc: second });
|
||||
});
|
||||
const added = orig.addFilter({ selectComparisonFunc: second });
|
||||
|
||||
added.modifyFailureMessage();
|
||||
expect(first).toHaveBeenCalled();
|
||||
@@ -15,8 +15,8 @@ describe('ExpectationFilterChain', function() {
|
||||
});
|
||||
|
||||
it('does not modify the original filter chain', function() {
|
||||
const orig = new privateUnderTest.ExpectationFilterChain({}),
|
||||
f = jasmine.createSpy('f');
|
||||
const orig = new privateUnderTest.ExpectationFilterChain({});
|
||||
const f = jasmine.createSpy('f');
|
||||
|
||||
orig.addFilter({ selectComparisonFunc: f });
|
||||
|
||||
@@ -36,13 +36,13 @@ describe('ExpectationFilterChain', function() {
|
||||
|
||||
describe('When some filters have #selectComparisonFunc', function() {
|
||||
it('calls the first filter that has #selectComparisonFunc', function() {
|
||||
const first = jasmine.createSpy('first').and.returnValue('first'),
|
||||
second = jasmine.createSpy('second').and.returnValue('second'),
|
||||
chain = new privateUnderTest.ExpectationFilterChain()
|
||||
const first = jasmine.createSpy('first').and.returnValue('first');
|
||||
const second = jasmine.createSpy('second').and.returnValue('second');
|
||||
const chain = new privateUnderTest.ExpectationFilterChain()
|
||||
.addFilter({ selectComparisonFunc: first })
|
||||
.addFilter({ selectComparisonFunc: second }),
|
||||
matcher = {},
|
||||
result = chain.selectComparisonFunc(matcher);
|
||||
.addFilter({ selectComparisonFunc: second });
|
||||
const matcher = {};
|
||||
const result = chain.selectComparisonFunc(matcher);
|
||||
|
||||
expect(first).toHaveBeenCalledWith(matcher);
|
||||
expect(second).not.toHaveBeenCalled();
|
||||
@@ -62,15 +62,15 @@ describe('ExpectationFilterChain', function() {
|
||||
|
||||
describe('When some filters have #buildFailureMessage', function() {
|
||||
it('calls the first filter that has #buildFailureMessage', function() {
|
||||
const first = jasmine.createSpy('first').and.returnValue('first'),
|
||||
second = jasmine.createSpy('second').and.returnValue('second'),
|
||||
chain = new privateUnderTest.ExpectationFilterChain()
|
||||
const first = jasmine.createSpy('first').and.returnValue('first');
|
||||
const second = jasmine.createSpy('second').and.returnValue('second');
|
||||
const chain = new privateUnderTest.ExpectationFilterChain()
|
||||
.addFilter({ buildFailureMessage: first })
|
||||
.addFilter({ buildFailureMessage: second }),
|
||||
matcherResult = { pass: false },
|
||||
matcherName = 'foo',
|
||||
args = [],
|
||||
matchersUtil = {};
|
||||
.addFilter({ buildFailureMessage: second });
|
||||
const matcherResult = { pass: false };
|
||||
const matcherName = 'foo';
|
||||
const args = [];
|
||||
const matchersUtil = {};
|
||||
|
||||
const result = chain.buildFailureMessage(
|
||||
matcherResult,
|
||||
@@ -102,12 +102,12 @@ describe('ExpectationFilterChain', function() {
|
||||
|
||||
describe('When some filters have #modifyFailureMessage', function() {
|
||||
it('calls the first filter that has #modifyFailureMessage', function() {
|
||||
const first = jasmine.createSpy('first').and.returnValue('first'),
|
||||
second = jasmine.createSpy('second').and.returnValue('second'),
|
||||
chain = new privateUnderTest.ExpectationFilterChain()
|
||||
const first = jasmine.createSpy('first').and.returnValue('first');
|
||||
const second = jasmine.createSpy('second').and.returnValue('second');
|
||||
const chain = new privateUnderTest.ExpectationFilterChain()
|
||||
.addFilter({ modifyFailureMessage: first })
|
||||
.addFilter({ modifyFailureMessage: second }),
|
||||
result = chain.modifyFailureMessage('original');
|
||||
.addFilter({ modifyFailureMessage: second });
|
||||
const result = chain.modifyFailureMessage('original');
|
||||
|
||||
expect(first).toHaveBeenCalledWith('original');
|
||||
expect(second).not.toHaveBeenCalled();
|
||||
|
||||
@@ -3,8 +3,8 @@ describe('Expectation', function() {
|
||||
const matchers = {
|
||||
toFoo: function() {},
|
||||
toBar: function() {}
|
||||
},
|
||||
expectation = privateUnderTest.Expectation.factory({
|
||||
};
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers
|
||||
});
|
||||
|
||||
@@ -27,17 +27,17 @@ describe('Expectation', function() {
|
||||
it("wraps matchers's compare functions, passing in matcher dependencies", function() {
|
||||
const fakeCompare = function() {
|
||||
return { pass: true };
|
||||
},
|
||||
matcherFactory = jasmine
|
||||
};
|
||||
const matcherFactory = jasmine
|
||||
.createSpy('matcher')
|
||||
.and.returnValue({ compare: fakeCompare }),
|
||||
matchers = {
|
||||
.and.returnValue({ compare: fakeCompare });
|
||||
const matchers = {
|
||||
toFoo: matcherFactory
|
||||
},
|
||||
matchersUtil = {
|
||||
};
|
||||
const matchersUtil = {
|
||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
matchersUtil: matchersUtil,
|
||||
@@ -54,18 +54,18 @@ describe('Expectation', function() {
|
||||
it("wraps matchers's compare functions, passing the actual and expected", function() {
|
||||
const fakeCompare = jasmine
|
||||
.createSpy('fake-compare')
|
||||
.and.returnValue({ pass: true }),
|
||||
matchers = {
|
||||
.and.returnValue({ pass: true });
|
||||
const matchers = {
|
||||
toFoo: function() {
|
||||
return {
|
||||
compare: fakeCompare
|
||||
};
|
||||
}
|
||||
},
|
||||
matchersUtil = {
|
||||
};
|
||||
const matchersUtil = {
|
||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
matchersUtil: matchersUtil,
|
||||
@@ -88,11 +88,11 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
matchersUtil = {
|
||||
};
|
||||
const matchersUtil = {
|
||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
@@ -121,13 +121,13 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
matchersUtil = {
|
||||
};
|
||||
const matchersUtil = {
|
||||
buildFailureMessage: function() {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
@@ -159,8 +159,8 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
actual: 'an actual',
|
||||
@@ -193,8 +193,8 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
@@ -222,8 +222,8 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
@@ -251,13 +251,13 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
matchersUtil = {
|
||||
};
|
||||
const matchersUtil = {
|
||||
buildFailureMessage: function() {
|
||||
return 'default message';
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
@@ -289,8 +289,8 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
@@ -321,8 +321,8 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
@@ -356,8 +356,8 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
@@ -390,8 +390,8 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
actual: 'an actual',
|
||||
@@ -424,8 +424,8 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
actual: 'an actual',
|
||||
@@ -460,8 +460,8 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
actual: 'an actual',
|
||||
@@ -490,14 +490,14 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
matchersUtil = {
|
||||
};
|
||||
const matchersUtil = {
|
||||
buildFailureMessage: function() {
|
||||
return 'failure message';
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = privateUnderTest.Expectation.factory({
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
matchersUtil: matchersUtil,
|
||||
actual: 'an actual',
|
||||
@@ -523,9 +523,9 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = privateUnderTest.Expectation.factory({
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -550,9 +550,9 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = privateUnderTest.Expectation.factory({
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -580,9 +580,9 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = privateUnderTest.Expectation.factory({
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -607,10 +607,10 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
pp = privateUnderTest.makePrettyPrinter(),
|
||||
expectation = privateUnderTest.Expectation.factory({
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
actual: 'an actual',
|
||||
@@ -643,9 +643,9 @@ describe('Expectation', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = privateUnderTest.Expectation.factory({
|
||||
};
|
||||
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||
const expectation = privateUnderTest.Expectation.factory({
|
||||
actual: 'an actual',
|
||||
customMatchers: matchers,
|
||||
addExpectationResult: addExpectationResult
|
||||
|
||||
@@ -137,8 +137,8 @@ describe('JsApiReporter', function() {
|
||||
|
||||
describe('#executionTime', function() {
|
||||
it('should start the timer when jasmine starts', function() {
|
||||
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
||||
reporter = new privateUnderTest.JsApiReporter({
|
||||
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']);
|
||||
const reporter = new privateUnderTest.JsApiReporter({
|
||||
timer: timerSpy
|
||||
});
|
||||
|
||||
@@ -147,8 +147,8 @@ describe('JsApiReporter', function() {
|
||||
});
|
||||
|
||||
it('should return the time it took the specs to run, in ms', function() {
|
||||
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
||||
reporter = new privateUnderTest.JsApiReporter({
|
||||
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']);
|
||||
const reporter = new privateUnderTest.JsApiReporter({
|
||||
timer: timerSpy
|
||||
});
|
||||
|
||||
@@ -159,8 +159,8 @@ describe('JsApiReporter', function() {
|
||||
|
||||
describe("when the specs haven't finished being run", function() {
|
||||
it('should return undefined', function() {
|
||||
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
||||
reporter = new privateUnderTest.JsApiReporter({
|
||||
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']);
|
||||
const reporter = new privateUnderTest.JsApiReporter({
|
||||
timer: timerSpy
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('FakeDate', function() {
|
||||
it('does not fail if no global date is found', function() {
|
||||
const fakeGlobal = {},
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
const fakeGlobal = {};
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
expect(function() {
|
||||
mockDate.install();
|
||||
@@ -17,9 +17,9 @@ describe('FakeDate', function() {
|
||||
return {
|
||||
getTime: function() {}
|
||||
};
|
||||
}),
|
||||
fakeGlobal = { Date: globalDate },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
});
|
||||
const fakeGlobal = { Date: globalDate };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
expect(fakeGlobal.Date).toEqual(globalDate);
|
||||
mockDate.install();
|
||||
@@ -34,9 +34,9 @@ describe('FakeDate', function() {
|
||||
return {
|
||||
getTime: function() {}
|
||||
};
|
||||
}),
|
||||
fakeGlobal = { Date: globalDate },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
});
|
||||
const fakeGlobal = { Date: globalDate };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
mockDate.uninstall();
|
||||
@@ -53,9 +53,9 @@ describe('FakeDate', function() {
|
||||
return 1000;
|
||||
}
|
||||
};
|
||||
}),
|
||||
fakeGlobal = { Date: globalDate },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
});
|
||||
const fakeGlobal = { Date: globalDate };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
|
||||
@@ -65,9 +65,9 @@ describe('FakeDate', function() {
|
||||
});
|
||||
|
||||
it('can accept a date as time base when installing', function() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal),
|
||||
baseDate = new Date();
|
||||
const fakeGlobal = { Date: Date };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
const baseDate = new Date();
|
||||
|
||||
spyOn(baseDate, 'getTime').and.returnValue(123);
|
||||
mockDate.install(baseDate);
|
||||
@@ -76,8 +76,8 @@ describe('FakeDate', function() {
|
||||
});
|
||||
|
||||
it('makes real dates', function() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
const fakeGlobal = { Date: Date };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
expect(new fakeGlobal.Date()).toEqual(jasmine.any(Date));
|
||||
@@ -93,8 +93,8 @@ describe('FakeDate', function() {
|
||||
return 1000;
|
||||
}
|
||||
};
|
||||
}),
|
||||
fakeGlobal = { Date: globalDate };
|
||||
});
|
||||
const fakeGlobal = { Date: globalDate };
|
||||
|
||||
globalDate.now = function() {};
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
@@ -113,8 +113,8 @@ describe('FakeDate', function() {
|
||||
return 1000;
|
||||
}
|
||||
};
|
||||
}),
|
||||
fakeGlobal = { Date: globalDate };
|
||||
});
|
||||
const fakeGlobal = { Date: globalDate };
|
||||
|
||||
globalDate.now = function() {};
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
@@ -139,8 +139,8 @@ describe('FakeDate', function() {
|
||||
return 1000;
|
||||
}
|
||||
};
|
||||
}),
|
||||
fakeGlobal = { Date: globalDate };
|
||||
});
|
||||
const fakeGlobal = { Date: globalDate };
|
||||
|
||||
globalDate.now = function() {};
|
||||
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() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
const fakeGlobal = { Date: Date };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
|
||||
@@ -167,8 +167,8 @@ describe('FakeDate', function() {
|
||||
});
|
||||
|
||||
it("allows creation of a Date that isn't fully specified", function() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
const fakeGlobal = { Date: Date };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
|
||||
@@ -177,9 +177,9 @@ describe('FakeDate', function() {
|
||||
});
|
||||
|
||||
it('allows creation of a Date with millis', function() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal),
|
||||
now = new Date(2014, 3, 15).getTime();
|
||||
const fakeGlobal = { Date: Date };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
const now = new Date(2014, 3, 15).getTime();
|
||||
|
||||
mockDate.install();
|
||||
|
||||
@@ -188,8 +188,8 @@ describe('FakeDate', function() {
|
||||
});
|
||||
|
||||
it('copies all Date properties to the mocked date', function() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
const fakeGlobal = { Date: Date };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
|
||||
|
||||
@@ -230,23 +230,23 @@ describe('PrettyPrinter', function() {
|
||||
jasmineToString: function() {
|
||||
return 'object a';
|
||||
}
|
||||
},
|
||||
b = {
|
||||
};
|
||||
const b = {
|
||||
jasmineToString: function() {
|
||||
return 'object b';
|
||||
}
|
||||
},
|
||||
c = {
|
||||
};
|
||||
const c = {
|
||||
jasmineToString: jasmine
|
||||
.createSpy('c jasmineToString')
|
||||
.and.returnValue('')
|
||||
},
|
||||
d = {
|
||||
};
|
||||
const d = {
|
||||
jasmineToString: jasmine
|
||||
.createSpy('d jasmineToString')
|
||||
.and.returnValue('')
|
||||
},
|
||||
pp = privateUnderTest.makePrettyPrinter();
|
||||
};
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
|
||||
withMaxChars(30, function() {
|
||||
pp([{ a: a, b: b, c: c }, d]);
|
||||
@@ -389,9 +389,9 @@ describe('PrettyPrinter', function() {
|
||||
it('should stringify spyOn toString properly', function() {
|
||||
const TestObject = {
|
||||
someFunction: function() {}
|
||||
},
|
||||
env = new privateUnderTest.Env(),
|
||||
pp = privateUnderTest.makePrettyPrinter();
|
||||
};
|
||||
const env = new privateUnderTest.Env();
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
@@ -544,9 +544,9 @@ describe('PrettyPrinter', function() {
|
||||
function(obj) {
|
||||
return '3rd: ' + obj.foo;
|
||||
}
|
||||
],
|
||||
pp = privateUnderTest.makePrettyPrinter(customObjectFormatters),
|
||||
obj = { foo: 'bar' };
|
||||
];
|
||||
const pp = privateUnderTest.makePrettyPrinter(customObjectFormatters);
|
||||
const obj = { foo: 'bar' };
|
||||
|
||||
expect(pp(obj)).toEqual('2nd: bar');
|
||||
});
|
||||
@@ -556,9 +556,9 @@ describe('PrettyPrinter', function() {
|
||||
function() {
|
||||
return undefined;
|
||||
}
|
||||
],
|
||||
pp = privateUnderTest.makePrettyPrinter(customObjectFormatters),
|
||||
obj = { foo: 'bar' };
|
||||
];
|
||||
const pp = privateUnderTest.makePrettyPrinter(customObjectFormatters);
|
||||
const obj = { foo: 'bar' };
|
||||
|
||||
expect(pp(obj)).toEqual("Object({ foo: 'bar' })");
|
||||
});
|
||||
@@ -576,9 +576,9 @@ describe('PrettyPrinter', function() {
|
||||
function(obj) {
|
||||
return '3rd: ' + obj.foo;
|
||||
}
|
||||
],
|
||||
pp = privateUnderTest.makePrettyPrinter(customObjectFormatters),
|
||||
obj = { foo: 'bar' };
|
||||
];
|
||||
const pp = privateUnderTest.makePrettyPrinter(customObjectFormatters);
|
||||
const obj = { foo: 'bar' };
|
||||
|
||||
expect(pp.customFormat_(obj)).toEqual('2nd: bar');
|
||||
});
|
||||
@@ -588,9 +588,9 @@ describe('PrettyPrinter', function() {
|
||||
function() {
|
||||
return undefined;
|
||||
}
|
||||
],
|
||||
pp = privateUnderTest.makePrettyPrinter(customObjectFormatters),
|
||||
obj = { foo: 'bar' };
|
||||
];
|
||||
const pp = privateUnderTest.makePrettyPrinter(customObjectFormatters);
|
||||
const obj = { foo: 'bar' };
|
||||
|
||||
expect(pp.customFormat_(obj)).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -16,10 +16,10 @@ describe('QueueRunner', function() {
|
||||
});
|
||||
|
||||
it("runs all the functions it's passed", function() {
|
||||
const calls = [],
|
||||
queueableFn1 = { fn: jasmine.createSpy('fn1') },
|
||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
const calls = [];
|
||||
const queueableFn1 = { fn: jasmine.createSpy('fn1') };
|
||||
const queueableFn2 = { fn: jasmine.createSpy('fn2') };
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2]
|
||||
});
|
||||
queueableFn1.fn.and.callFake(function() {
|
||||
@@ -43,8 +43,8 @@ describe('QueueRunner', function() {
|
||||
asyncContext = this;
|
||||
done();
|
||||
}
|
||||
},
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
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:
|
||||
//createSpy('asyncfn').and.callFake(function(done) {});
|
||||
|
||||
const onComplete = jasmine.createSpy('onComplete'),
|
||||
beforeCallback = jasmine.createSpy('beforeCallback'),
|
||||
fnCallback = jasmine.createSpy('fnCallback'),
|
||||
afterCallback = jasmine.createSpy('afterCallback'),
|
||||
queueableFn1 = {
|
||||
const onComplete = jasmine.createSpy('onComplete');
|
||||
const beforeCallback = jasmine.createSpy('beforeCallback');
|
||||
const fnCallback = jasmine.createSpy('fnCallback');
|
||||
const afterCallback = jasmine.createSpy('afterCallback');
|
||||
const queueableFn1 = {
|
||||
fn: function(done) {
|
||||
beforeCallback();
|
||||
setTimeout(done, 100);
|
||||
}
|
||||
},
|
||||
queueableFn2 = {
|
||||
};
|
||||
const queueableFn2 = {
|
||||
fn: function(done) {
|
||||
fnCallback();
|
||||
setTimeout(done, 100);
|
||||
}
|
||||
},
|
||||
queueableFn3 = {
|
||||
};
|
||||
const queueableFn3 = {
|
||||
fn: function(done) {
|
||||
afterCallback();
|
||||
setTimeout(done, 100);
|
||||
}
|
||||
},
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2, queueableFn3],
|
||||
onComplete: onComplete
|
||||
});
|
||||
@@ -126,10 +126,10 @@ describe('QueueRunner', function() {
|
||||
done.fail('foo');
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
||||
failFn = jasmine.createSpy('fail'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const queueableFn2 = { fn: jasmine.createSpy('fn2') };
|
||||
const failFn = jasmine.createSpy('fail');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2],
|
||||
fail: failFn
|
||||
});
|
||||
@@ -147,17 +147,17 @@ describe('QueueRunner', function() {
|
||||
|
||||
describe('When next is called with an argument', function() {
|
||||
it('explicitly fails and moves to the next function', function() {
|
||||
const err = 'anything except undefined',
|
||||
queueableFn1 = {
|
||||
const err = 'anything except undefined';
|
||||
const queueableFn1 = {
|
||||
fn: function(done) {
|
||||
setTimeout(function() {
|
||||
done(err);
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
||||
failFn = jasmine.createSpy('fail'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const queueableFn2 = { fn: jasmine.createSpy('fn2') };
|
||||
const failFn = jasmine.createSpy('fail');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2],
|
||||
fail: failFn
|
||||
});
|
||||
@@ -181,15 +181,15 @@ describe('QueueRunner', function() {
|
||||
// except on a major release and with a deprecation warning in
|
||||
// advance.
|
||||
it('explicitly fails and moves to the next function', function(done) {
|
||||
const err = new Error('foo'),
|
||||
queueableFn1 = {
|
||||
const err = new Error('foo');
|
||||
const queueableFn1 = {
|
||||
fn: function() {
|
||||
return Promise.resolve(err);
|
||||
}
|
||||
},
|
||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
||||
failFn = jasmine.createSpy('fail'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const queueableFn2 = { fn: jasmine.createSpy('fn2') };
|
||||
const failFn = jasmine.createSpy('fail');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2],
|
||||
fail: failFn,
|
||||
onComplete: function() {
|
||||
@@ -209,9 +209,9 @@ describe('QueueRunner', function() {
|
||||
fn: function() {
|
||||
return Promise.resolve('not an error');
|
||||
}
|
||||
},
|
||||
failFn = jasmine.createSpy('fail'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const failFn = jasmine.createSpy('fail');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1],
|
||||
fail: failFn,
|
||||
onComplete: function() {
|
||||
@@ -227,17 +227,17 @@ describe('QueueRunner', function() {
|
||||
});
|
||||
|
||||
it('does not cause an explicit fail if execution is being stopped', function() {
|
||||
const err = new privateUnderTest.StopExecutionError('foo'),
|
||||
queueableFn1 = {
|
||||
const err = new privateUnderTest.StopExecutionError('foo');
|
||||
const queueableFn1 = {
|
||||
fn: function(done) {
|
||||
setTimeout(function() {
|
||||
done(err);
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
||||
failFn = jasmine.createSpy('fail'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const queueableFn2 = { fn: jasmine.createSpy('fn2') };
|
||||
const failFn = jasmine.createSpy('fail');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2],
|
||||
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() {
|
||||
const timeout = 3,
|
||||
beforeFn = { fn: function(done) {}, type: 'before', timeout: timeout },
|
||||
queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' },
|
||||
onComplete = jasmine.createSpy('onComplete'),
|
||||
onException = jasmine.createSpy('onException'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
const timeout = 3;
|
||||
const beforeFn = {
|
||||
fn: function(done) {},
|
||||
type: 'before',
|
||||
timeout: timeout
|
||||
};
|
||||
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],
|
||||
onComplete: onComplete,
|
||||
onException: onException
|
||||
@@ -302,11 +306,11 @@ describe('QueueRunner', function() {
|
||||
});
|
||||
|
||||
it('by default does not set a timeout for asynchronous functions', function() {
|
||||
const beforeFn = { fn: function(done) {} },
|
||||
queueableFn = { fn: jasmine.createSpy('fn') },
|
||||
onComplete = jasmine.createSpy('onComplete'),
|
||||
onException = jasmine.createSpy('onException'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
const beforeFn = { fn: function(done) {} };
|
||||
const queueableFn = { fn: jasmine.createSpy('fn') };
|
||||
const onComplete = jasmine.createSpy('onComplete');
|
||||
const onException = jasmine.createSpy('onException');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [beforeFn, queueableFn],
|
||||
onComplete: onComplete,
|
||||
onException: onException
|
||||
@@ -327,10 +331,10 @@ describe('QueueRunner', function() {
|
||||
fn: function(done) {
|
||||
throw new Error('error!');
|
||||
}
|
||||
},
|
||||
onComplete = jasmine.createSpy('onComplete'),
|
||||
onException = jasmine.createSpy('onException'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const onComplete = jasmine.createSpy('onComplete');
|
||||
const onException = jasmine.createSpy('onException');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
onComplete: onComplete,
|
||||
onException: onException
|
||||
@@ -350,10 +354,10 @@ describe('QueueRunner', function() {
|
||||
fn: function(done) {
|
||||
done();
|
||||
}
|
||||
},
|
||||
onComplete = jasmine.createSpy('onComplete'),
|
||||
onException = jasmine.createSpy('onException'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const onComplete = jasmine.createSpy('onComplete');
|
||||
const onException = jasmine.createSpy('onException');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
onComplete: onComplete,
|
||||
onException: onException
|
||||
@@ -374,10 +378,10 @@ describe('QueueRunner', function() {
|
||||
done();
|
||||
done();
|
||||
}
|
||||
},
|
||||
nextQueueableFn = { fn: jasmine.createSpy('nextFn') },
|
||||
onMultipleDone = jasmine.createSpy('onMultipleDone'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const nextQueueableFn = { fn: jasmine.createSpy('nextFn') };
|
||||
const onMultipleDone = jasmine.createSpy('onMultipleDone');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn, nextQueueableFn],
|
||||
onMultipleDone: onMultipleDone
|
||||
});
|
||||
@@ -394,9 +398,9 @@ describe('QueueRunner', function() {
|
||||
setTimeout(done, 1);
|
||||
throw new Error('error!');
|
||||
}
|
||||
},
|
||||
nextQueueableFn = { fn: jasmine.createSpy('nextFn') },
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const nextQueueableFn = { fn: jasmine.createSpy('nextFn') };
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn, nextQueueableFn]
|
||||
});
|
||||
queueRunner.execute();
|
||||
@@ -426,22 +430,20 @@ describe('QueueRunner', function() {
|
||||
throwAsync();
|
||||
},
|
||||
timeout: 1
|
||||
},
|
||||
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
|
||||
onException = jasmine.createSpy('onException'),
|
||||
globalErrors = {
|
||||
};
|
||||
const nextQueueableFn = { fn: jasmine.createSpy('nextFunction') };
|
||||
const onException = jasmine.createSpy('onException');
|
||||
const globalErrors = {
|
||||
pushListener: jasmine.createSpy('pushListener'),
|
||||
popListener: jasmine.createSpy('popListener')
|
||||
},
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn, nextQueueableFn],
|
||||
onException: onException,
|
||||
globalErrors: globalErrors
|
||||
}),
|
||||
throwAsync = function() {
|
||||
globalErrors.pushListener.calls
|
||||
.mostRecent()
|
||||
.args[0](new Error('foo'));
|
||||
});
|
||||
const throwAsync = function() {
|
||||
globalErrors.pushListener.calls.mostRecent().args[0](new Error('foo'));
|
||||
jasmine.clock().tick(2);
|
||||
};
|
||||
|
||||
@@ -476,25 +478,25 @@ describe('QueueRunner', function() {
|
||||
fn: function(done) {
|
||||
done();
|
||||
}
|
||||
},
|
||||
errorListeners = [],
|
||||
globalErrors = {
|
||||
};
|
||||
const errorListeners = [];
|
||||
const globalErrors = {
|
||||
pushListener: function(f) {
|
||||
errorListeners.push(f);
|
||||
},
|
||||
popListener: function() {
|
||||
errorListeners.pop();
|
||||
}
|
||||
},
|
||||
clearStack = jasmine.createSpyObj('clearStack', ['clearStack']),
|
||||
onException = jasmine.createSpy('onException'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const clearStack = jasmine.createSpyObj('clearStack', ['clearStack']);
|
||||
const onException = jasmine.createSpy('onException');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
globalErrors: globalErrors,
|
||||
clearStack: clearStack,
|
||||
onException: onException
|
||||
}),
|
||||
error = new Error('nope');
|
||||
});
|
||||
const error = new Error('nope');
|
||||
|
||||
queueRunner.execute();
|
||||
jasmine.clock().tick();
|
||||
@@ -523,19 +525,19 @@ describe('QueueRunner', function() {
|
||||
});
|
||||
|
||||
it('runs the function asynchronously, advancing once the promise is settled', function() {
|
||||
const onComplete = jasmine.createSpy('onComplete'),
|
||||
fnCallback = jasmine.createSpy('fnCallback'),
|
||||
p1 = new StubPromise(),
|
||||
p2 = new StubPromise(),
|
||||
queueableFn1 = {
|
||||
const onComplete = jasmine.createSpy('onComplete');
|
||||
const fnCallback = jasmine.createSpy('fnCallback');
|
||||
const p1 = new StubPromise();
|
||||
const p2 = new StubPromise();
|
||||
const queueableFn1 = {
|
||||
fn: function() {
|
||||
setTimeout(function() {
|
||||
p1.resolveHandler();
|
||||
}, 100);
|
||||
return p1;
|
||||
}
|
||||
},
|
||||
queueableFn2 = {
|
||||
};
|
||||
const queueableFn2 = {
|
||||
fn: function() {
|
||||
fnCallback();
|
||||
setTimeout(function() {
|
||||
@@ -543,8 +545,8 @@ describe('QueueRunner', function() {
|
||||
}, 100);
|
||||
return p2;
|
||||
}
|
||||
},
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2],
|
||||
onComplete: onComplete
|
||||
});
|
||||
@@ -564,18 +566,18 @@ describe('QueueRunner', function() {
|
||||
});
|
||||
|
||||
it('handles a rejected promise like an unhandled exception', function() {
|
||||
const promise = new StubPromise(),
|
||||
queueableFn1 = {
|
||||
const promise = new StubPromise();
|
||||
const queueableFn1 = {
|
||||
fn: function() {
|
||||
setTimeout(function() {
|
||||
promise.rejectHandler('foo');
|
||||
}, 100);
|
||||
return promise;
|
||||
}
|
||||
},
|
||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
||||
onExceptionCallback = jasmine.createSpy('on exception callback'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const queueableFn2 = { fn: jasmine.createSpy('fn2') };
|
||||
const onExceptionCallback = jasmine.createSpy('on exception callback');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2],
|
||||
onException: onExceptionCallback
|
||||
});
|
||||
@@ -596,9 +598,9 @@ describe('QueueRunner', function() {
|
||||
fn: function(done) {
|
||||
return new StubPromise();
|
||||
}
|
||||
},
|
||||
onException = jasmine.createSpy('onException'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const onException = jasmine.createSpy('onException');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
onException: onException
|
||||
});
|
||||
@@ -618,8 +620,8 @@ describe('QueueRunner', function() {
|
||||
|
||||
it('issues a more specific error if the function is `async`', function() {
|
||||
async function fn(done) {}
|
||||
const onException = jasmine.createSpy('onException'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
const onException = jasmine.createSpy('onException');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [{ fn: fn }],
|
||||
onException: onException
|
||||
});
|
||||
@@ -638,9 +640,9 @@ describe('QueueRunner', function() {
|
||||
});
|
||||
|
||||
it('passes final errors to exception handlers', function() {
|
||||
const error = new Error('fake error'),
|
||||
onExceptionCallback = jasmine.createSpy('on exception callback'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
const error = new Error('fake error');
|
||||
const onExceptionCallback = jasmine.createSpy('on exception callback');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
onException: onExceptionCallback
|
||||
});
|
||||
|
||||
@@ -656,9 +658,9 @@ describe('QueueRunner', function() {
|
||||
fn: function() {
|
||||
throw new Error('fake error');
|
||||
}
|
||||
},
|
||||
onExceptionCallback = jasmine.createSpy('on exception callback'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const onExceptionCallback = jasmine.createSpy('on exception callback');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
onException: onExceptionCallback
|
||||
});
|
||||
@@ -673,9 +675,9 @@ describe('QueueRunner', function() {
|
||||
fn: function(done) {
|
||||
throw new Error('error');
|
||||
}
|
||||
},
|
||||
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const nextQueueableFn = { fn: jasmine.createSpy('nextFunction') };
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn, nextQueueableFn]
|
||||
});
|
||||
|
||||
@@ -750,14 +752,14 @@ describe('QueueRunner', function() {
|
||||
fn: function() {
|
||||
throw new Error('error');
|
||||
}
|
||||
},
|
||||
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
|
||||
cleanupFn = {
|
||||
};
|
||||
const nextQueueableFn = { fn: jasmine.createSpy('nextFunction') };
|
||||
const cleanupFn = {
|
||||
fn: jasmine.createSpy('cleanup'),
|
||||
type: 'specCleanup'
|
||||
},
|
||||
onComplete = jasmine.createSpy('onComplete'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const onComplete = jasmine.createSpy('onComplete');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
|
||||
onComplete: onComplete,
|
||||
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||
@@ -772,18 +774,18 @@ describe('QueueRunner', function() {
|
||||
});
|
||||
|
||||
it('does not skip when a cleanup function throws', function() {
|
||||
const queueableFn = { fn: function() {} },
|
||||
cleanupFn1 = {
|
||||
const queueableFn = { fn: function() {} };
|
||||
const cleanupFn1 = {
|
||||
fn: function() {
|
||||
throw new Error('error');
|
||||
},
|
||||
type: 'afterEach'
|
||||
},
|
||||
cleanupFn2 = {
|
||||
};
|
||||
const cleanupFn2 = {
|
||||
fn: jasmine.createSpy('cleanupFn2'),
|
||||
type: 'afterEach'
|
||||
},
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn, cleanupFn1, cleanupFn2],
|
||||
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||
});
|
||||
@@ -840,10 +842,13 @@ describe('QueueRunner', function() {
|
||||
fn: function(done) {
|
||||
done.fail('nope');
|
||||
}
|
||||
},
|
||||
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
|
||||
cleanupFn = { fn: jasmine.createSpy('cleanup'), type: 'specCleanup' },
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const nextQueueableFn = { fn: jasmine.createSpy('nextFunction') };
|
||||
const cleanupFn = {
|
||||
fn: jasmine.createSpy('cleanup'),
|
||||
type: 'specCleanup'
|
||||
};
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
|
||||
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||
});
|
||||
@@ -859,13 +864,13 @@ describe('QueueRunner', function() {
|
||||
fn: function(done) {
|
||||
done(new Error('nope'));
|
||||
}
|
||||
},
|
||||
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
|
||||
cleanupFn = {
|
||||
};
|
||||
const nextQueueableFn = { fn: jasmine.createSpy('nextFunction') };
|
||||
const cleanupFn = {
|
||||
fn: jasmine.createSpy('cleanup'),
|
||||
type: 'specCleanup'
|
||||
},
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn, nextQueueableFn, cleanupFn],
|
||||
SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy
|
||||
});
|
||||
@@ -879,9 +884,9 @@ describe('QueueRunner', function() {
|
||||
});
|
||||
|
||||
it('calls a provided complete callback when done', function() {
|
||||
const queueableFn = { fn: jasmine.createSpy('fn') },
|
||||
completeCallback = jasmine.createSpy('completeCallback'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
const queueableFn = { fn: jasmine.createSpy('fn') };
|
||||
const completeCallback = jasmine.createSpy('completeCallback');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
onComplete: completeCallback
|
||||
});
|
||||
@@ -905,11 +910,11 @@ describe('QueueRunner', function() {
|
||||
fn: function(done) {
|
||||
done();
|
||||
}
|
||||
},
|
||||
afterFn = { fn: jasmine.createSpy('afterFn') },
|
||||
completeCallback = jasmine.createSpy('completeCallback'),
|
||||
clearStack = jasmine.createSpyObj('clearStack', ['clearStack']),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
};
|
||||
const afterFn = { fn: jasmine.createSpy('afterFn') };
|
||||
const completeCallback = jasmine.createSpy('completeCallback');
|
||||
const clearStack = jasmine.createSpyObj('clearStack', ['clearStack']);
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [asyncFn, afterFn],
|
||||
clearStack: clearStack,
|
||||
onComplete: completeCallback
|
||||
|
||||
@@ -12,13 +12,13 @@ describe('ReportDispatcher', function() {
|
||||
});
|
||||
|
||||
it('dispatches requested methods to added reporters', function() {
|
||||
const runQueue = jasmine.createSpy('runQueue'),
|
||||
dispatcher = new privateUnderTest.ReportDispatcher(
|
||||
const runQueue = jasmine.createSpy('runQueue');
|
||||
const dispatcher = new privateUnderTest.ReportDispatcher(
|
||||
['foo', 'bar'],
|
||||
runQueue
|
||||
),
|
||||
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']),
|
||||
anotherReporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
||||
);
|
||||
const reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
||||
const anotherReporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
||||
|
||||
dispatcher.addReporter(reporter);
|
||||
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() {
|
||||
const runQueue = jasmine.createSpy('runQueue'),
|
||||
dispatcher = new privateUnderTest.ReportDispatcher(['foo'], runQueue),
|
||||
reporter = jasmine.createSpyObj('reporter', ['baz']);
|
||||
const runQueue = jasmine.createSpy('runQueue');
|
||||
const dispatcher = new privateUnderTest.ReportDispatcher(['foo'], runQueue);
|
||||
const reporter = jasmine.createSpyObj('reporter', ['baz']);
|
||||
|
||||
dispatcher.addReporter(reporter);
|
||||
|
||||
@@ -115,12 +115,12 @@ describe('ReportDispatcher', function() {
|
||||
});
|
||||
|
||||
it("allows providing a fallback reporter in case there's no other reporter", function() {
|
||||
const runQueue = jasmine.createSpy('runQueue'),
|
||||
dispatcher = new privateUnderTest.ReportDispatcher(
|
||||
const runQueue = jasmine.createSpy('runQueue');
|
||||
const dispatcher = new privateUnderTest.ReportDispatcher(
|
||||
['foo', 'bar'],
|
||||
runQueue
|
||||
),
|
||||
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
||||
);
|
||||
const reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
||||
|
||||
dispatcher.provideFallbackReporter(reporter);
|
||||
dispatcher.foo({ an: 'event' });
|
||||
@@ -138,13 +138,16 @@ describe('ReportDispatcher', function() {
|
||||
});
|
||||
|
||||
it('does not call fallback reporting methods when another reporter is provided', function() {
|
||||
const runQueue = jasmine.createSpy('runQueue'),
|
||||
dispatcher = new privateUnderTest.ReportDispatcher(
|
||||
const runQueue = jasmine.createSpy('runQueue');
|
||||
const dispatcher = new privateUnderTest.ReportDispatcher(
|
||||
['foo', 'bar'],
|
||||
runQueue
|
||||
),
|
||||
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']),
|
||||
fallbackReporter = jasmine.createSpyObj('otherReporter', ['foo', 'bar']);
|
||||
);
|
||||
const reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
||||
const fallbackReporter = jasmine.createSpyObj('otherReporter', [
|
||||
'foo',
|
||||
'bar'
|
||||
]);
|
||||
|
||||
dispatcher.provideFallbackReporter(fallbackReporter);
|
||||
dispatcher.addReporter(reporter);
|
||||
@@ -164,13 +167,13 @@ describe('ReportDispatcher', function() {
|
||||
});
|
||||
|
||||
it('allows registered reporters to be cleared', function() {
|
||||
const runQueue = jasmine.createSpy('runQueue'),
|
||||
dispatcher = new privateUnderTest.ReportDispatcher(
|
||||
const runQueue = jasmine.createSpy('runQueue');
|
||||
const dispatcher = new privateUnderTest.ReportDispatcher(
|
||||
['foo', 'bar'],
|
||||
runQueue
|
||||
),
|
||||
reporter1 = jasmine.createSpyObj('reporter1', ['foo', 'bar']),
|
||||
reporter2 = jasmine.createSpyObj('reporter2', ['foo', 'bar']);
|
||||
);
|
||||
const reporter1 = jasmine.createSpyObj('reporter1', ['foo', 'bar']);
|
||||
const reporter2 = jasmine.createSpyObj('reporter2', ['foo', 'bar']);
|
||||
|
||||
dispatcher.addReporter(reporter1);
|
||||
dispatcher.foo({ an: 'event' });
|
||||
|
||||
@@ -181,9 +181,9 @@ describe('Spec', function() {
|
||||
});
|
||||
|
||||
it('is "pending" if created without a function body', function() {
|
||||
const startCallback = jasmine.createSpy('startCallback'),
|
||||
resultCallback = jasmine.createSpy('resultCallback'),
|
||||
spec = new privateUnderTest.Spec({
|
||||
const startCallback = jasmine.createSpy('startCallback');
|
||||
const resultCallback = jasmine.createSpy('resultCallback');
|
||||
const spec = new privateUnderTest.Spec({
|
||||
onStart: startCallback,
|
||||
queueableFn: { fn: null },
|
||||
resultCallback: resultCallback
|
||||
@@ -389,8 +389,8 @@ describe('Spec', function() {
|
||||
});
|
||||
|
||||
it('does not throw an ExpectationFailed error when handling an error', function() {
|
||||
const resultCallback = jasmine.createSpy('resultCallback'),
|
||||
spec = new privateUnderTest.Spec({
|
||||
const resultCallback = jasmine.createSpy('resultCallback');
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: function() {} },
|
||||
resultCallback: resultCallback,
|
||||
throwOnExpectationFailure: true
|
||||
|
||||
@@ -14,8 +14,8 @@ describe('SpyRegistry', function() {
|
||||
});
|
||||
|
||||
it('checks that a method name was passed', function() {
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
||||
target = {};
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry();
|
||||
const target = {};
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOn(target);
|
||||
@@ -30,8 +30,8 @@ describe('SpyRegistry', function() {
|
||||
});
|
||||
|
||||
it('checks that the method name is not `null`', function() {
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
||||
target = {};
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry();
|
||||
const target = {};
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOn(target, null);
|
||||
@@ -39,8 +39,8 @@ describe('SpyRegistry', function() {
|
||||
});
|
||||
|
||||
it('checks for the existence of the method', function() {
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
||||
target = {};
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry();
|
||||
const target = {};
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOn(target, 'pants');
|
||||
@@ -48,14 +48,14 @@ describe('SpyRegistry', function() {
|
||||
});
|
||||
|
||||
it('checks if it has already been spied upon', function() {
|
||||
const spies = [],
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
const spies = [];
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
},
|
||||
createSpy: createSpy
|
||||
}),
|
||||
target = { spiedFunc: function() {} };
|
||||
});
|
||||
const target = { spiedFunc: function() {} };
|
||||
|
||||
spyRegistry.spyOn(target, 'spiedFunc');
|
||||
|
||||
@@ -77,13 +77,13 @@ describe('SpyRegistry', function() {
|
||||
}
|
||||
});
|
||||
|
||||
const spies = [],
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
const spies = [];
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
}
|
||||
}),
|
||||
target = { spiedFunc: scope.myFunc };
|
||||
});
|
||||
const target = { spiedFunc: scope.myFunc };
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOn(scope, 'myFunc');
|
||||
@@ -158,8 +158,8 @@ describe('SpyRegistry', function() {
|
||||
});
|
||||
|
||||
it('checks that a property name was passed', function() {
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
||||
target = {};
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry();
|
||||
const target = {};
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOnProperty(target);
|
||||
@@ -167,8 +167,8 @@ describe('SpyRegistry', function() {
|
||||
});
|
||||
|
||||
it('checks for the existence of the method', function() {
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
||||
target = {};
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry();
|
||||
const target = {};
|
||||
|
||||
expect(function() {
|
||||
spyRegistry.spyOnProperty(target, 'pants');
|
||||
@@ -176,8 +176,8 @@ describe('SpyRegistry', function() {
|
||||
});
|
||||
|
||||
it('checks for the existence of access type', function() {
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry(),
|
||||
target = {};
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry();
|
||||
const target = {};
|
||||
|
||||
Object.defineProperty(target, 'pants', {
|
||||
get: function() {
|
||||
@@ -217,9 +217,9 @@ describe('SpyRegistry', function() {
|
||||
it('overrides the property getter on the object and returns the spy', function() {
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: createSpy
|
||||
}),
|
||||
target = {},
|
||||
returnValue = 1;
|
||||
});
|
||||
const target = {};
|
||||
const returnValue = 1;
|
||||
|
||||
Object.defineProperty(target, 'spiedProperty', {
|
||||
get: function() {
|
||||
@@ -241,9 +241,9 @@ describe('SpyRegistry', function() {
|
||||
it('overrides the property setter on the object and returns the spy', function() {
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: createSpy
|
||||
}),
|
||||
target = {},
|
||||
returnValue = 1;
|
||||
});
|
||||
const target = {};
|
||||
const returnValue = 1;
|
||||
|
||||
Object.defineProperty(target, 'spiedProperty', {
|
||||
get: function() {
|
||||
@@ -265,8 +265,8 @@ describe('SpyRegistry', function() {
|
||||
it('throws an error if respy is not allowed', function() {
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: createSpy
|
||||
}),
|
||||
target = {};
|
||||
});
|
||||
const target = {};
|
||||
|
||||
Object.defineProperty(target, 'spiedProp', {
|
||||
get: function() {
|
||||
@@ -285,8 +285,8 @@ describe('SpyRegistry', function() {
|
||||
it('returns the original spy if respy is allowed', function() {
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
createSpy: createSpy
|
||||
}),
|
||||
target = {};
|
||||
});
|
||||
const target = {};
|
||||
|
||||
spyRegistry.allowRespy(true);
|
||||
|
||||
@@ -564,15 +564,15 @@ describe('SpyRegistry', function() {
|
||||
|
||||
describe('#clearSpies', function() {
|
||||
it('restores the original functions on the spied-upon objects', function() {
|
||||
const spies = [],
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
const spies = [];
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
},
|
||||
createSpy: createSpy
|
||||
}),
|
||||
originalFunction = function() {},
|
||||
target = { spiedFunc: originalFunction };
|
||||
});
|
||||
const originalFunction = function() {};
|
||||
const target = { spiedFunc: originalFunction };
|
||||
|
||||
spyRegistry.spyOn(target, 'spiedFunc');
|
||||
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() {
|
||||
const spies = [],
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
const spies = [];
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
},
|
||||
createSpy: createSpy
|
||||
}),
|
||||
originalFunction = function() {},
|
||||
target = { spiedFunc: originalFunction };
|
||||
});
|
||||
const originalFunction = function() {};
|
||||
const target = { spiedFunc: originalFunction };
|
||||
|
||||
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() {
|
||||
const spies = [],
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
const spies = [];
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
},
|
||||
createSpy: createSpy
|
||||
}),
|
||||
originalFunction = function() {},
|
||||
targetParent = { spiedFunc: originalFunction };
|
||||
});
|
||||
const originalFunction = function() {};
|
||||
const targetParent = { spiedFunc: originalFunction };
|
||||
|
||||
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() {
|
||||
const spies = [],
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
const spies = [];
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
},
|
||||
createSpy: createSpy
|
||||
}),
|
||||
originalFunction = function() {},
|
||||
targetParent = { spiedFunc: originalFunction };
|
||||
});
|
||||
const originalFunction = function() {};
|
||||
const targetParent = { spiedFunc: originalFunction };
|
||||
|
||||
const target = Object.create(targetParent);
|
||||
|
||||
@@ -655,9 +655,9 @@ describe('SpyRegistry', function() {
|
||||
function FakeWindow() {}
|
||||
FakeWindow.prototype.onerror = function() {};
|
||||
|
||||
const spies = [],
|
||||
global = new FakeWindow(),
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
const spies = [];
|
||||
const global = new FakeWindow();
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
},
|
||||
@@ -674,15 +674,15 @@ describe('SpyRegistry', function() {
|
||||
|
||||
describe('spying on properties', function() {
|
||||
it('restores the original properties on the spied-upon objects', function() {
|
||||
const spies = [],
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
const spies = [];
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
},
|
||||
createSpy: createSpy
|
||||
}),
|
||||
originalReturn = 1,
|
||||
target = {};
|
||||
});
|
||||
const originalReturn = 1;
|
||||
const target = {};
|
||||
|
||||
Object.defineProperty(target, 'spiedProp', {
|
||||
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() {
|
||||
const spies = [],
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
const spies = [];
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
},
|
||||
createSpy: createSpy
|
||||
}),
|
||||
originalReturn = 1,
|
||||
targetParent = {};
|
||||
});
|
||||
const originalReturn = 1;
|
||||
const targetParent = {};
|
||||
|
||||
Object.defineProperty(targetParent, 'spiedProp', {
|
||||
get: function() {
|
||||
|
||||
@@ -106,8 +106,8 @@ describe('Spies', function() {
|
||||
];
|
||||
|
||||
for (let arity = 0; arity < functions.length; arity++) {
|
||||
const someFunction = functions[arity],
|
||||
spy = env.createSpy(someFunction.name, someFunction);
|
||||
const someFunction = functions[arity];
|
||||
const spy = env.createSpy(someFunction.name, someFunction);
|
||||
|
||||
expect(spy.length).toEqual(arity);
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ describe('SpyStrategy', function() {
|
||||
});
|
||||
|
||||
it('stubs an original function, if provided', function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
const originalFn = jasmine.createSpy('original');
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
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() {
|
||||
const originalFn = jasmine.createSpy('original').and.returnValue(42),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
const originalFn = jasmine.createSpy('original').and.returnValue(42);
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.callThrough();
|
||||
const returnValue = spyStrategy.exec(null, ['foo']);
|
||||
@@ -33,8 +33,8 @@ describe('SpyStrategy', function() {
|
||||
});
|
||||
|
||||
it('can return a specified value when executed', function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
const originalFn = jasmine.createSpy('original');
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.returnValue(17);
|
||||
const returnValue = spyStrategy.exec();
|
||||
@@ -44,8 +44,8 @@ describe('SpyStrategy', function() {
|
||||
});
|
||||
|
||||
it('can return specified values in order specified when executed', function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
const originalFn = jasmine.createSpy('original');
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.returnValues('value1', 'value2', 'value3');
|
||||
|
||||
@@ -57,8 +57,8 @@ describe('SpyStrategy', function() {
|
||||
});
|
||||
|
||||
it('allows an exception to be thrown when executed', function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
const originalFn = jasmine.createSpy('original');
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
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() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
const originalFn = jasmine.createSpy('original');
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.throwError('bar');
|
||||
|
||||
@@ -81,8 +81,8 @@ describe('SpyStrategy', function() {
|
||||
});
|
||||
|
||||
it('allows a non-Error to be thrown when executed', function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
const originalFn = jasmine.createSpy('original');
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.throwError({ code: 'ESRCH' });
|
||||
|
||||
@@ -93,9 +93,9 @@ describe('SpyStrategy', function() {
|
||||
});
|
||||
|
||||
it('allows a fake function to be called instead', function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
fakeFn = jasmine.createSpy('fake').and.returnValue(67),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
const originalFn = jasmine.createSpy('original');
|
||||
const fakeFn = jasmine.createSpy('fake').and.returnValue(67);
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.callFake(fakeFn);
|
||||
const returnValue = spyStrategy.exec();
|
||||
@@ -105,11 +105,11 @@ describe('SpyStrategy', function() {
|
||||
});
|
||||
|
||||
it('allows a fake async function to be called instead', function(done) {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
fakeFn = jasmine.createSpy('fake').and.callFake(async () => {
|
||||
const originalFn = jasmine.createSpy('original');
|
||||
const fakeFn = jasmine.createSpy('fake').and.callFake(async () => {
|
||||
return 67;
|
||||
}),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
});
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.callFake(fakeFn);
|
||||
spyStrategy
|
||||
@@ -127,8 +127,8 @@ describe('SpyStrategy', function() {
|
||||
|
||||
describe('#resolveTo', function() {
|
||||
it('allows a resolved promise to be returned', function(done) {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
const originalFn = jasmine.createSpy('original');
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
fn: originalFn
|
||||
});
|
||||
|
||||
@@ -143,8 +143,8 @@ describe('SpyStrategy', function() {
|
||||
});
|
||||
|
||||
it('allows an empty resolved promise to be returned', function(done) {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
const originalFn = jasmine.createSpy('original');
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
fn: originalFn
|
||||
});
|
||||
|
||||
@@ -161,8 +161,8 @@ describe('SpyStrategy', function() {
|
||||
|
||||
describe('#rejectWith', function() {
|
||||
it('allows a rejected promise to be returned', function(done) {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
const originalFn = jasmine.createSpy('original');
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
fn: originalFn
|
||||
});
|
||||
|
||||
@@ -178,8 +178,8 @@ describe('SpyStrategy', function() {
|
||||
});
|
||||
|
||||
it('allows an empty rejected promise to be returned', function(done) {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
const originalFn = jasmine.createSpy('original');
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
fn: originalFn
|
||||
});
|
||||
|
||||
@@ -195,8 +195,8 @@ describe('SpyStrategy', function() {
|
||||
});
|
||||
|
||||
it('allows a non-Error to be rejected', function(done) {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
const originalFn = jasmine.createSpy('original');
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
fn: originalFn
|
||||
});
|
||||
|
||||
@@ -215,12 +215,12 @@ describe('SpyStrategy', function() {
|
||||
it('allows a custom strategy to be used', function() {
|
||||
const plan = jasmine
|
||||
.createSpy('custom strategy')
|
||||
.and.returnValue('custom strategy result'),
|
||||
customStrategy = jasmine
|
||||
.and.returnValue('custom strategy result');
|
||||
const customStrategy = jasmine
|
||||
.createSpy('custom strategy')
|
||||
.and.returnValue(plan),
|
||||
originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
.and.returnValue(plan);
|
||||
const originalFn = jasmine.createSpy('original');
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
fn: originalFn,
|
||||
customStrategies: {
|
||||
doSomething: customStrategy
|
||||
@@ -236,8 +236,8 @@ describe('SpyStrategy', function() {
|
||||
});
|
||||
|
||||
it("throws an error if a custom strategy doesn't return a function", function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
const originalFn = jasmine.createSpy('original');
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({
|
||||
fn: originalFn,
|
||||
customStrategies: {
|
||||
doSomething: function() {
|
||||
@@ -263,8 +263,8 @@ describe('SpyStrategy', function() {
|
||||
});
|
||||
|
||||
it('throws an error when a non-function is passed to callFake strategy', function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
const originalFn = jasmine.createSpy('original');
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
expect(function() {
|
||||
spyStrategy.callFake('not a function');
|
||||
@@ -276,8 +276,8 @@ describe('SpyStrategy', function() {
|
||||
it('allows generator functions to be passed to callFake strategy', function() {
|
||||
const generator = function*() {
|
||||
yield 'ok';
|
||||
},
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: function() {} });
|
||||
};
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: function() {} });
|
||||
|
||||
spyStrategy.callFake(generator);
|
||||
|
||||
@@ -285,9 +285,9 @@ describe('SpyStrategy', function() {
|
||||
});
|
||||
|
||||
it('allows a return to plan stubbing after another strategy', function() {
|
||||
const originalFn = jasmine.createSpy('original'),
|
||||
fakeFn = jasmine.createSpy('fake').and.returnValue(67),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
const originalFn = jasmine.createSpy('original');
|
||||
const fakeFn = jasmine.createSpy('fake').and.returnValue(67);
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn });
|
||||
|
||||
spyStrategy.callFake(fakeFn);
|
||||
let returnValue = spyStrategy.exec();
|
||||
@@ -302,9 +302,9 @@ describe('SpyStrategy', function() {
|
||||
});
|
||||
|
||||
it('returns the spy after changing the strategy', function() {
|
||||
const spy = {},
|
||||
spyFn = jasmine.createSpy('spyFn').and.returnValue(spy),
|
||||
spyStrategy = new privateUnderTest.SpyStrategy({ getSpy: spyFn });
|
||||
const spy = {};
|
||||
const spyFn = jasmine.createSpy('spyFn').and.returnValue(spy);
|
||||
const spyStrategy = new privateUnderTest.SpyStrategy({ getSpy: spyFn });
|
||||
|
||||
expect(spyStrategy.callThrough()).toBe(spy);
|
||||
expect(spyStrategy.returnValue()).toBe(spy);
|
||||
|
||||
@@ -33,8 +33,8 @@ describe('Suite', function() {
|
||||
env: env,
|
||||
description: 'I am a parent suite',
|
||||
parentSuite: jasmine.createSpy('pretend top level suite')
|
||||
}),
|
||||
suite = new privateUnderTest.Suite({
|
||||
});
|
||||
const suite = new privateUnderTest.Suite({
|
||||
env: env,
|
||||
description: 'I am a suite',
|
||||
parentSuite: parentSuite
|
||||
@@ -47,9 +47,9 @@ describe('Suite', function() {
|
||||
const suite = new privateUnderTest.Suite({
|
||||
env: env,
|
||||
description: 'I am a suite'
|
||||
}),
|
||||
outerBefore = { fn: 'outerBeforeEach' },
|
||||
innerBefore = { fn: 'insideBeforeEach' };
|
||||
});
|
||||
const outerBefore = { fn: 'outerBeforeEach' };
|
||||
const innerBefore = { fn: 'insideBeforeEach' };
|
||||
|
||||
suite.beforeEach(outerBefore);
|
||||
suite.beforeEach(innerBefore);
|
||||
@@ -64,9 +64,9 @@ describe('Suite', function() {
|
||||
const suite = new privateUnderTest.Suite({
|
||||
env: env,
|
||||
description: 'I am a suite'
|
||||
}),
|
||||
outerBefore = { fn: 'outerBeforeAll' },
|
||||
innerBefore = { fn: 'insideBeforeAll' };
|
||||
});
|
||||
const outerBefore = { fn: 'outerBeforeAll' };
|
||||
const innerBefore = { fn: 'insideBeforeAll' };
|
||||
|
||||
suite.beforeAll(outerBefore);
|
||||
suite.beforeAll(innerBefore);
|
||||
@@ -81,9 +81,9 @@ describe('Suite', function() {
|
||||
const suite = new privateUnderTest.Suite({
|
||||
env: env,
|
||||
description: 'I am a suite'
|
||||
}),
|
||||
outerAfter = { fn: 'outerAfterEach' },
|
||||
innerAfter = { fn: 'insideAfterEach' };
|
||||
});
|
||||
const outerAfter = { fn: 'outerAfterEach' };
|
||||
const innerAfter = { fn: 'insideAfterEach' };
|
||||
|
||||
suite.afterEach(outerAfter);
|
||||
suite.afterEach(innerAfter);
|
||||
@@ -98,9 +98,9 @@ describe('Suite', function() {
|
||||
const suite = new privateUnderTest.Suite({
|
||||
env: env,
|
||||
description: 'I am a suite'
|
||||
}),
|
||||
outerAfter = { fn: 'outerAfterAll' },
|
||||
innerAfter = { fn: 'insideAfterAl' };
|
||||
});
|
||||
const outerAfter = { fn: 'outerAfterAll' };
|
||||
const innerAfter = { fn: 'insideAfterAl' };
|
||||
|
||||
suite.afterAll(outerAfter);
|
||||
suite.afterAll(innerAfter);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('Timer', function() {
|
||||
it('reports the time elapsed', function() {
|
||||
const fakeNow = jasmine.createSpy('fake Date.now'),
|
||||
timer = new jasmineUnderTest.Timer({ now: fakeNow });
|
||||
const fakeNow = jasmine.createSpy('fake Date.now');
|
||||
const timer = new jasmineUnderTest.Timer({ now: fakeNow });
|
||||
|
||||
fakeNow.and.returnValue(100);
|
||||
timer.start();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
describe('TreeProcessor', function() {
|
||||
let nodeNumber = 0,
|
||||
leafNumber = 0;
|
||||
let nodeNumber = 0;
|
||||
let leafNumber = 0;
|
||||
|
||||
function Node(attrs) {
|
||||
attrs = attrs || {};
|
||||
@@ -24,8 +24,8 @@ describe('TreeProcessor', function() {
|
||||
}
|
||||
|
||||
it('processes a single leaf', function() {
|
||||
const leaf = new Leaf(),
|
||||
processor = new privateUnderTest.TreeProcessor({
|
||||
const leaf = new Leaf();
|
||||
const processor = new privateUnderTest.TreeProcessor({
|
||||
tree: leaf,
|
||||
runnableIds: [leaf.id]
|
||||
});
|
||||
@@ -36,8 +36,8 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('processes a single pending leaf', function() {
|
||||
const leaf = new Leaf({ markedPending: true }),
|
||||
processor = new privateUnderTest.TreeProcessor({
|
||||
const leaf = new Leaf({ markedPending: true });
|
||||
const processor = new privateUnderTest.TreeProcessor({
|
||||
tree: leaf,
|
||||
runnableIds: [leaf.id]
|
||||
});
|
||||
@@ -48,8 +48,8 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('processes a single non-specified leaf', function() {
|
||||
const leaf = new Leaf(),
|
||||
processor = new privateUnderTest.TreeProcessor({
|
||||
const leaf = new Leaf();
|
||||
const processor = new privateUnderTest.TreeProcessor({
|
||||
tree: leaf,
|
||||
runnableIds: []
|
||||
});
|
||||
@@ -60,8 +60,8 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('processes a single excluded leaf', function() {
|
||||
const leaf = new Leaf(),
|
||||
processor = new privateUnderTest.TreeProcessor({
|
||||
const leaf = new Leaf();
|
||||
const processor = new privateUnderTest.TreeProcessor({
|
||||
tree: leaf,
|
||||
runnableIds: [leaf.id],
|
||||
excludeNode: function() {
|
||||
@@ -75,9 +75,9 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('processes a tree with a single leaf with the root specified', function() {
|
||||
const leaf = new Leaf(),
|
||||
parent = new Node({ children: [leaf] }),
|
||||
processor = new privateUnderTest.TreeProcessor({
|
||||
const leaf = new Leaf();
|
||||
const parent = new Node({ children: [leaf] });
|
||||
const processor = new privateUnderTest.TreeProcessor({
|
||||
tree: parent,
|
||||
runnableIds: [parent.id]
|
||||
});
|
||||
@@ -90,9 +90,9 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('processes a tree with a single pending leaf, with the root specified', function() {
|
||||
const leaf = new Leaf({ markedPending: true }),
|
||||
parent = new Node({ children: [leaf] }),
|
||||
processor = new privateUnderTest.TreeProcessor({
|
||||
const leaf = new Leaf({ markedPending: true });
|
||||
const parent = new Node({ children: [leaf] });
|
||||
const processor = new privateUnderTest.TreeProcessor({
|
||||
tree: parent,
|
||||
runnableIds: [parent.id]
|
||||
});
|
||||
@@ -139,21 +139,21 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('processes a complicated tree with the root specified', function() {
|
||||
const pendingLeaf = new Leaf({ markedPending: true }),
|
||||
executableLeaf = new Leaf({ markedPending: false }),
|
||||
parent = new Node({ children: [pendingLeaf, executableLeaf] }),
|
||||
childless = new Node(),
|
||||
childOfPending = new Leaf({ markedPending: true }),
|
||||
pendingNode = new Node({
|
||||
const pendingLeaf = new Leaf({ markedPending: true });
|
||||
const executableLeaf = new Leaf({ markedPending: false });
|
||||
const parent = new Node({ children: [pendingLeaf, executableLeaf] });
|
||||
const childless = new Node();
|
||||
const childOfPending = new Leaf({ markedPending: true });
|
||||
const pendingNode = new Node({
|
||||
markedPending: true,
|
||||
children: [childOfPending]
|
||||
}),
|
||||
parentOfPendings = new Node({
|
||||
});
|
||||
const parentOfPendings = new Node({
|
||||
markedPending: false,
|
||||
children: [childless, pendingNode]
|
||||
}),
|
||||
root = new Node({ children: [parent, parentOfPendings] }),
|
||||
processor = new privateUnderTest.TreeProcessor({
|
||||
});
|
||||
const root = new Node({ children: [parent, parentOfPendings] });
|
||||
const processor = new privateUnderTest.TreeProcessor({
|
||||
tree: root,
|
||||
runnableIds: [root.id]
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('UserContext', function() {
|
||||
it('Behaves just like an plain object', function() {
|
||||
const context = new privateUnderTest.UserContext(),
|
||||
properties = [];
|
||||
const context = new privateUnderTest.UserContext();
|
||||
const properties = [];
|
||||
|
||||
for (const prop in context) {
|
||||
if (obj.hasOwnProperty(prop)) {
|
||||
|
||||
@@ -142,17 +142,17 @@ describe('util', function() {
|
||||
|
||||
describe('getPropertyDescriptor', function() {
|
||||
it('get property descriptor from object', function() {
|
||||
const obj = { prop: 1 },
|
||||
actual = privateUnderTest.util.getPropertyDescriptor(obj, 'prop'),
|
||||
expected = Object.getOwnPropertyDescriptor(obj, 'prop');
|
||||
const obj = { prop: 1 };
|
||||
const actual = privateUnderTest.util.getPropertyDescriptor(obj, 'prop');
|
||||
const expected = Object.getOwnPropertyDescriptor(obj, 'prop');
|
||||
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
|
||||
it('get property descriptor from object property', function() {
|
||||
const proto = { prop: 1 },
|
||||
actual = privateUnderTest.util.getPropertyDescriptor(proto, 'prop'),
|
||||
expected = Object.getOwnPropertyDescriptor(proto, 'prop');
|
||||
const proto = { prop: 1 };
|
||||
const actual = privateUnderTest.util.getPropertyDescriptor(proto, 'prop');
|
||||
const expected = Object.getOwnPropertyDescriptor(proto, 'prop');
|
||||
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
|
||||
@@ -54,8 +54,8 @@ describe('Any', function() {
|
||||
});
|
||||
|
||||
it('matches another constructed object', function() {
|
||||
const Thing = function() {},
|
||||
any = new privateUnderTest.Any(Thing);
|
||||
const Thing = function() {};
|
||||
const any = new privateUnderTest.Any(Thing);
|
||||
|
||||
expect(any.asymmetricMatch(new Thing())).toBe(true);
|
||||
});
|
||||
|
||||
@@ -42,9 +42,9 @@ describe('ArrayContaining', function() {
|
||||
});
|
||||
|
||||
it('jasmineToStrings itself', function() {
|
||||
const sample = [],
|
||||
matcher = new privateUnderTest.ArrayContaining(sample),
|
||||
pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||
const sample = [];
|
||||
const matcher = new privateUnderTest.ArrayContaining(sample);
|
||||
const pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||
|
||||
expect(matcher.jasmineToString(pp)).toEqual(
|
||||
'<jasmine.arrayContaining(sample)>'
|
||||
|
||||
@@ -32,9 +32,9 @@ describe('ArrayWithExactContents', function() {
|
||||
});
|
||||
|
||||
it('jasmineToStrings itself', function() {
|
||||
const sample = [],
|
||||
matcher = new privateUnderTest.ArrayWithExactContents(sample),
|
||||
pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||
const sample = [];
|
||||
const matcher = new privateUnderTest.ArrayWithExactContents(sample);
|
||||
const pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||
|
||||
expect(matcher.jasmineToString(pp)).toEqual(
|
||||
'<jasmine.arrayWithExactContents(sample)>'
|
||||
|
||||
@@ -151,9 +151,9 @@ describe('MapContaining', function() {
|
||||
});
|
||||
|
||||
it('defines a `jasmineToString` method', function() {
|
||||
const sample = new Map(),
|
||||
containing = new privateUnderTest.MapContaining(sample),
|
||||
pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||
const sample = new Map();
|
||||
const containing = new privateUnderTest.MapContaining(sample);
|
||||
const pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||
|
||||
expect(containing.jasmineToString(pp)).toEqual(
|
||||
'<jasmine.mapContaining(sample)>'
|
||||
|
||||
@@ -53,9 +53,9 @@ describe('ObjectContaining', function() {
|
||||
});
|
||||
|
||||
it("jasmineToString's itself", function() {
|
||||
const sample = {},
|
||||
matcher = new privateUnderTest.ObjectContaining(sample),
|
||||
pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||
const sample = {};
|
||||
const matcher = new privateUnderTest.ObjectContaining(sample);
|
||||
const pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||
|
||||
expect(matcher.jasmineToString(pp)).toEqual(
|
||||
'<jasmine.objectContaining(sample)>'
|
||||
@@ -144,9 +144,9 @@ describe('ObjectContaining', function() {
|
||||
describe('valuesForDiff_', function() {
|
||||
describe('when other is not an object', function() {
|
||||
it('sets self to jasmineToString()', function() {
|
||||
const containing = new privateUnderTest.ObjectContaining({}),
|
||||
pp = privateUnderTest.makePrettyPrinter(),
|
||||
result = containing.valuesForDiff_('a', pp);
|
||||
const containing = new privateUnderTest.ObjectContaining({});
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const result = containing.valuesForDiff_('a', pp);
|
||||
|
||||
expect(result).toEqual({
|
||||
self: '<jasmine.objectContaining(Object({ }))>',
|
||||
@@ -157,10 +157,10 @@ describe('ObjectContaining', function() {
|
||||
|
||||
describe('when other is an object', function() {
|
||||
it('includes keys that are present in both other and sample', function() {
|
||||
const sample = { a: 1, b: 2 },
|
||||
other = { a: 3, b: 4 },
|
||||
containing = new privateUnderTest.ObjectContaining(sample),
|
||||
result = containing.valuesForDiff_(other);
|
||||
const sample = { a: 1, b: 2 };
|
||||
const other = { a: 3, b: 4 };
|
||||
const containing = new privateUnderTest.ObjectContaining(sample);
|
||||
const result = containing.valuesForDiff_(other);
|
||||
|
||||
expect(result.self).not.toBeInstanceOf(
|
||||
privateUnderTest.ObjectContaining
|
||||
@@ -172,10 +172,10 @@ describe('ObjectContaining', function() {
|
||||
});
|
||||
|
||||
it('includes keys that are present only in sample', function() {
|
||||
const sample = { a: 1, b: 2 },
|
||||
other = { a: 3 },
|
||||
containing = new privateUnderTest.ObjectContaining(sample),
|
||||
result = containing.valuesForDiff_(other);
|
||||
const sample = { a: 1, b: 2 };
|
||||
const other = { a: 3 };
|
||||
const containing = new privateUnderTest.ObjectContaining(sample);
|
||||
const result = containing.valuesForDiff_(other);
|
||||
|
||||
expect(result.self).not.toBeInstanceOf(
|
||||
privateUnderTest.ObjectContaining
|
||||
@@ -190,10 +190,10 @@ describe('ObjectContaining', function() {
|
||||
});
|
||||
|
||||
it('omits keys that are present only in other', function() {
|
||||
const sample = { a: 1, b: 2 },
|
||||
other = { a: 3, b: 4, c: 5 },
|
||||
containing = new privateUnderTest.ObjectContaining(sample),
|
||||
result = containing.valuesForDiff_(other);
|
||||
const sample = { a: 1, b: 2 };
|
||||
const other = { a: 3, b: 4, c: 5 };
|
||||
const containing = new privateUnderTest.ObjectContaining(sample);
|
||||
const result = containing.valuesForDiff_(other);
|
||||
|
||||
expect(result.self).not.toBeInstanceOf(
|
||||
privateUnderTest.ObjectContaining
|
||||
|
||||
@@ -103,9 +103,9 @@ describe('SetContaining', function() {
|
||||
});
|
||||
|
||||
it('defines a `jasmineToString` method', function() {
|
||||
const sample = new Set(),
|
||||
containing = new privateUnderTest.SetContaining(sample),
|
||||
pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||
const sample = new Set();
|
||||
const containing = new privateUnderTest.SetContaining(sample);
|
||||
const pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||
|
||||
expect(containing.jasmineToString(pp)).toEqual(
|
||||
'<jasmine.setContaining(sample)>'
|
||||
|
||||
@@ -145,8 +145,8 @@ describe('base helpers', function() {
|
||||
});
|
||||
|
||||
it('is consistent with setTimeout in this environment', function(done) {
|
||||
const f1 = jasmine.createSpy('setTimeout callback for ' + max),
|
||||
f2 = jasmine.createSpy('setTimeout callback for ' + (max + 1));
|
||||
const f1 = jasmine.createSpy('setTimeout callback for ' + max);
|
||||
const f2 = jasmine.createSpy('setTimeout callback for ' + (max + 1));
|
||||
|
||||
// Suppress printing of TimeoutOverflowWarning in node
|
||||
if (typeof process !== 'undefined' && process.emitWarning) {
|
||||
|
||||
@@ -91,8 +91,8 @@ describe('Custom Async Matchers (Integration)', function() {
|
||||
return Promise.resolve({ pass: true });
|
||||
}
|
||||
};
|
||||
},
|
||||
matcherFactorySpy = jasmine.createSpy(
|
||||
};
|
||||
const matcherFactorySpy = jasmine.createSpy(
|
||||
'matcherFactorySpy',
|
||||
matcherFactory
|
||||
);
|
||||
@@ -124,8 +124,8 @@ describe('Custom Async Matchers (Integration)', function() {
|
||||
});
|
||||
}
|
||||
};
|
||||
},
|
||||
customEqualityFn = jasmine
|
||||
};
|
||||
const customEqualityFn = jasmine
|
||||
.createSpy('customEqualityFn')
|
||||
.and.callFake(function(a, b) {
|
||||
return a.toString() === b;
|
||||
|
||||
@@ -215,8 +215,8 @@ describe('Custom Matchers (Integration)', function() {
|
||||
return { pass: true };
|
||||
}
|
||||
};
|
||||
},
|
||||
matcherFactorySpy = jasmine
|
||||
};
|
||||
const matcherFactorySpy = jasmine
|
||||
.createSpy('matcherFactorySpy')
|
||||
.and.callFake(matcherFactory);
|
||||
|
||||
@@ -241,8 +241,8 @@ describe('Custom Matchers (Integration)', function() {
|
||||
return { pass: matchersUtil.equals(actual[0], expected) };
|
||||
}
|
||||
};
|
||||
},
|
||||
customEqualityFn = jasmine
|
||||
};
|
||||
const customEqualityFn = jasmine
|
||||
.createSpy('customEqualityFn')
|
||||
.and.callFake(function(a, b) {
|
||||
return a.toString() === b;
|
||||
|
||||
@@ -82,11 +82,11 @@ describe('Custom Spy Strategies (Integration)', function() {
|
||||
});
|
||||
|
||||
it('allows multiple custom strategies to be used', async function() {
|
||||
const plan1 = jasmine.createSpy('plan 1').and.returnValue(42),
|
||||
strategy1 = jasmine.createSpy('strat 1').and.returnValue(plan1),
|
||||
plan2 = jasmine.createSpy('plan 2').and.returnValue(24),
|
||||
strategy2 = jasmine.createSpy('strat 2').and.returnValue(plan2),
|
||||
specDone = jasmine.createSpy('specDone');
|
||||
const plan1 = jasmine.createSpy('plan 1').and.returnValue(42);
|
||||
const strategy1 = jasmine.createSpy('strat 1').and.returnValue(plan1);
|
||||
const plan2 = jasmine.createSpy('plan 2').and.returnValue(24);
|
||||
const strategy2 = jasmine.createSpy('strat 2').and.returnValue(plan2);
|
||||
const specDone = jasmine.createSpy('specDone');
|
||||
|
||||
env.beforeEach(function() {
|
||||
env.addSpyStrategy('frobnicate', strategy1);
|
||||
|
||||
@@ -246,8 +246,8 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('calls associated beforeAlls/afterAlls only once per suite', async function() {
|
||||
const before = jasmine.createSpy('beforeAll'),
|
||||
after = jasmine.createSpy('afterAll');
|
||||
const before = jasmine.createSpy('beforeAll');
|
||||
const after = jasmine.createSpy('afterAll');
|
||||
|
||||
env.describe('with beforeAll and afterAll', 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() {
|
||||
const before = jasmine.createSpy('beforeAll'),
|
||||
after = jasmine.createSpy('afterAll');
|
||||
const before = jasmine.createSpy('beforeAll');
|
||||
const after = jasmine.createSpy('afterAll');
|
||||
|
||||
env.describe('with beforeAll and afterAll', function() {
|
||||
env.it('spec', function() {
|
||||
@@ -675,8 +675,8 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('reports when afterAll throws an exception', async function() {
|
||||
const error = new Error('After All Exception'),
|
||||
reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']);
|
||||
const error = new Error('After All Exception');
|
||||
const reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']);
|
||||
|
||||
env.addReporter(reporter);
|
||||
|
||||
@@ -719,8 +719,8 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('reports when an async afterAll throws an exception', async function() {
|
||||
const error = new Error('After All Exception'),
|
||||
reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']);
|
||||
const error = new Error('After All Exception');
|
||||
const reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']);
|
||||
|
||||
env.addReporter(reporter);
|
||||
|
||||
@@ -838,8 +838,8 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('Allows specifying which specs and suites to run', async function() {
|
||||
const calls = [],
|
||||
suiteCallback = jasmine.createSpy('suite callback');
|
||||
const calls = [];
|
||||
const suiteCallback = jasmine.createSpy('suite callback');
|
||||
let firstSpec;
|
||||
let secondSuite;
|
||||
|
||||
@@ -892,8 +892,8 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('Allows filtering out specs and suites to run programmatically', async function() {
|
||||
const calls = [],
|
||||
suiteCallback = jasmine.createSpy('suite callback');
|
||||
const calls = [];
|
||||
const suiteCallback = jasmine.createSpy('suite callback');
|
||||
|
||||
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() {
|
||||
const originalFoo = function() {},
|
||||
testObj = {
|
||||
const originalFoo = function() {};
|
||||
const testObj = {
|
||||
foo: originalFoo
|
||||
},
|
||||
firstSpec = jasmine.createSpy('firstSpec').and.callFake(function() {
|
||||
};
|
||||
const firstSpec = jasmine.createSpy('firstSpec').and.callFake(function() {
|
||||
env.spyOn(testObj, 'foo');
|
||||
}),
|
||||
secondSpec = jasmine.createSpy('secondSpec').and.callFake(function() {
|
||||
});
|
||||
const secondSpec = jasmine.createSpy('secondSpec').and.callFake(function() {
|
||||
expect(testObj.foo).toBe(originalFoo);
|
||||
});
|
||||
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() {
|
||||
const originalFoo = function() {},
|
||||
testObj = {
|
||||
const originalFoo = function() {};
|
||||
const testObj = {
|
||||
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() {
|
||||
const originalFoo = function() {},
|
||||
testObj = {
|
||||
const originalFoo = function() {};
|
||||
const testObj = {
|
||||
foo: originalFoo
|
||||
};
|
||||
|
||||
@@ -1101,11 +1101,11 @@ describe('Env integration', function() {
|
||||
.createSpy('globalSetTimeout')
|
||||
.and.callFake(function(cb, t) {
|
||||
return setTimeout(cb, t);
|
||||
}),
|
||||
delayedFunctionForGlobalClock = jasmine.createSpy(
|
||||
});
|
||||
const delayedFunctionForGlobalClock = jasmine.createSpy(
|
||||
'delayedFunctionForGlobalClock'
|
||||
),
|
||||
delayedFunctionForMockClock = jasmine.createSpy(
|
||||
);
|
||||
const delayedFunctionForMockClock = jasmine.createSpy(
|
||||
'delayedFunctionForMockClock'
|
||||
);
|
||||
|
||||
@@ -1255,8 +1255,8 @@ describe('Env integration', function() {
|
||||
|
||||
it('should not use the mock clock for asynchronous timeouts', async function() {
|
||||
createMockedEnv();
|
||||
const reporter = jasmine.createSpyObj('fakeReporter', ['specDone']),
|
||||
clock = env.clock;
|
||||
const reporter = jasmine.createSpyObj('fakeReporter', ['specDone']);
|
||||
const clock = env.clock;
|
||||
|
||||
reporter.specDone.and.callFake(function() {
|
||||
realSetTimeout(function() {
|
||||
@@ -2121,8 +2121,8 @@ describe('Env integration', function() {
|
||||
|
||||
await env.execute();
|
||||
|
||||
const firstSpecResult = reporter.specDone.calls.first().args[0],
|
||||
secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
||||
const firstSpecResult = reporter.specDone.calls.first().args[0];
|
||||
const secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
||||
|
||||
expect(firstSpecResult.status).toEqual('passed');
|
||||
expect(secondSpecResult.status).toEqual('failed');
|
||||
@@ -2158,9 +2158,9 @@ describe('Env integration', function() {
|
||||
|
||||
await env.execute();
|
||||
|
||||
const firstSpecResult = reporter.specDone.calls.first().args[0],
|
||||
secondSpecResult = reporter.specDone.calls.argsFor(0)[0],
|
||||
thirdSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
||||
const firstSpecResult = reporter.specDone.calls.first().args[0];
|
||||
const secondSpecResult = reporter.specDone.calls.argsFor(0)[0];
|
||||
const thirdSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
||||
|
||||
expect(firstSpecResult.status).toEqual('passed');
|
||||
expect(secondSpecResult.status).toEqual('passed');
|
||||
@@ -2188,8 +2188,8 @@ describe('Env integration', function() {
|
||||
|
||||
await env.execute();
|
||||
|
||||
const firstSpecResult = reporter.specDone.calls.first().args[0],
|
||||
secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
||||
const firstSpecResult = reporter.specDone.calls.first().args[0];
|
||||
const secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
||||
|
||||
expect(firstSpecResult.status).toEqual('passed');
|
||||
expect(secondSpecResult.status).toEqual('failed');
|
||||
@@ -2240,9 +2240,9 @@ describe('Env integration', function() {
|
||||
|
||||
await env.execute();
|
||||
|
||||
const firstSpecResult = reporter.specDone.calls.first().args[0],
|
||||
secondSpecResult = reporter.specDone.calls.argsFor(1)[0],
|
||||
thirdSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
||||
const firstSpecResult = reporter.specDone.calls.first().args[0];
|
||||
const secondSpecResult = reporter.specDone.calls.argsFor(1)[0];
|
||||
const thirdSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
||||
|
||||
expect(firstSpecResult.status).toEqual('passed');
|
||||
expect(secondSpecResult.status).toEqual('passed');
|
||||
@@ -2410,8 +2410,11 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('reports test properties on specs', async function() {
|
||||
const env = new privateUnderTest.Env(),
|
||||
reporter = jasmine.createSpyObj('reporter', ['suiteDone', 'specDone']);
|
||||
const env = new privateUnderTest.Env();
|
||||
const reporter = jasmine.createSpyObj('reporter', [
|
||||
'suiteDone',
|
||||
'specDone'
|
||||
]);
|
||||
|
||||
reporter.specDone.and.callFake(function(e) {
|
||||
expect(e.properties).toEqual({
|
||||
@@ -2464,8 +2467,8 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('reports test properties on suites', async function() {
|
||||
const env = new privateUnderTest.Env(),
|
||||
reporter = jasmine.createSpyObj('reporter', [
|
||||
const env = new privateUnderTest.Env();
|
||||
const reporter = jasmine.createSpyObj('reporter', [
|
||||
'jasmineDone',
|
||||
'suiteDone',
|
||||
'specDone'
|
||||
@@ -2937,15 +2940,15 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('should report deprecation stack with an error object', async function() {
|
||||
const exceptionFormatter = new privateUnderTest.ExceptionFormatter(),
|
||||
reporter = jasmine.createSpyObj('reporter', [
|
||||
const exceptionFormatter = new privateUnderTest.ExceptionFormatter();
|
||||
const reporter = jasmine.createSpyObj('reporter', [
|
||||
'jasmineDone',
|
||||
'suiteDone',
|
||||
'specDone'
|
||||
]),
|
||||
topLevelError = new Error('top level deprecation'),
|
||||
suiteLevelError = new Error('suite level deprecation'),
|
||||
specLevelError = new Error('spec level deprecation');
|
||||
]);
|
||||
const topLevelError = new Error('top level deprecation');
|
||||
const suiteLevelError = new Error('suite level deprecation');
|
||||
const specLevelError = new Error('spec level deprecation');
|
||||
|
||||
// prevent deprecation from being displayed
|
||||
spyOn(console, 'error');
|
||||
@@ -3004,9 +3007,9 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('supports async matchers', async function() {
|
||||
const specDone = jasmine.createSpy('specDone'),
|
||||
suiteDone = jasmine.createSpy('suiteDone'),
|
||||
jasmineDone = jasmine.createSpy('jasmineDone');
|
||||
const specDone = jasmine.createSpy('specDone');
|
||||
const suiteDone = jasmine.createSpy('suiteDone');
|
||||
const jasmineDone = jasmine.createSpy('jasmineDone');
|
||||
|
||||
env.addReporter({
|
||||
specDone: specDone,
|
||||
|
||||
@@ -560,16 +560,16 @@ describe('Matchers (Integration)', function() {
|
||||
|
||||
describe('toHaveBeenCalledBefore', function() {
|
||||
verifyPasses(function(env) {
|
||||
const a = env.createSpy('a'),
|
||||
b = env.createSpy('b');
|
||||
const a = env.createSpy('a');
|
||||
const b = env.createSpy('b');
|
||||
a();
|
||||
b();
|
||||
env.expect(a).toHaveBeenCalledBefore(b);
|
||||
});
|
||||
|
||||
verifyFails(function(env) {
|
||||
const a = env.createSpy('a'),
|
||||
b = env.createSpy('b');
|
||||
const a = env.createSpy('a');
|
||||
const b = env.createSpy('b');
|
||||
b();
|
||||
a();
|
||||
env.expect(a).toHaveBeenCalledBefore(b);
|
||||
|
||||
@@ -517,8 +517,8 @@ describe('spec running', function() {
|
||||
});
|
||||
|
||||
it('should allow top level suites to be disabled', async function() {
|
||||
const specInADisabledSuite = jasmine.createSpy('specInADisabledSuite'),
|
||||
otherSpec = jasmine.createSpy('otherSpec');
|
||||
const specInADisabledSuite = jasmine.createSpy('specInADisabledSuite');
|
||||
const otherSpec = jasmine.createSpy('otherSpec');
|
||||
|
||||
env.xdescribe('A disabled suite', function() {
|
||||
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() {
|
||||
const specs = [],
|
||||
reporter = jasmine.createSpyObj(['specDone', 'suiteDone']);
|
||||
const specs = [];
|
||||
const reporter = jasmine.createSpyObj(['specDone', 'suiteDone']);
|
||||
|
||||
reporter.specDone.and.callFake(function(result) {
|
||||
specs.push(result.fullName);
|
||||
|
||||
@@ -67,8 +67,8 @@ describe('DiffBuilder', function() {
|
||||
it('uses the injected pretty-printer', function() {
|
||||
const prettyPrinter = function(val) {
|
||||
return '|' + val + '|';
|
||||
},
|
||||
diffBuilder = new privateUnderTest.DiffBuilder({
|
||||
};
|
||||
const diffBuilder = new privateUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
});
|
||||
prettyPrinter.customFormat_ = function() {};
|
||||
@@ -84,9 +84,9 @@ describe('DiffBuilder', function() {
|
||||
});
|
||||
|
||||
it('passes the injected pretty-printer to the diff formatter', function() {
|
||||
const diffFormatter = jasmine.createSpy('diffFormatter'),
|
||||
prettyPrinter = function() {},
|
||||
diffBuilder = new privateUnderTest.DiffBuilder({
|
||||
const diffFormatter = jasmine.createSpy('diffFormatter');
|
||||
const prettyPrinter = function() {};
|
||||
const diffBuilder = new privateUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
});
|
||||
prettyPrinter.customFormat_ = function() {};
|
||||
@@ -219,11 +219,11 @@ describe('DiffBuilder', function() {
|
||||
});
|
||||
|
||||
it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ at the root', function() {
|
||||
const prettyPrinter = privateUnderTest.makePrettyPrinter([]),
|
||||
diffBuilder = new privateUnderTest.DiffBuilder({
|
||||
const prettyPrinter = privateUnderTest.makePrettyPrinter([]);
|
||||
const diffBuilder = new privateUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
}),
|
||||
expectedMsg =
|
||||
});
|
||||
const expectedMsg =
|
||||
'Expected $.foo = 1 to equal 2.\n' +
|
||||
'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() {
|
||||
const prettyPrinter = privateUnderTest.makePrettyPrinter([]),
|
||||
diffBuilder = new privateUnderTest.DiffBuilder({
|
||||
const prettyPrinter = privateUnderTest.makePrettyPrinter([]);
|
||||
const diffBuilder = new privateUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
}),
|
||||
expectedMsg =
|
||||
});
|
||||
const expectedMsg =
|
||||
'Expected $.x.foo = 1 to equal 2.\n' +
|
||||
'Expected $.x.baz = undefined to equal 3.';
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
describe('toBePending', function() {
|
||||
it('passes if the actual promise is pending', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil),
|
||||
actual = new Promise(function() {});
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil);
|
||||
const actual = new Promise(function() {});
|
||||
|
||||
return matcher.compare(actual).then(function(result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
||||
@@ -10,9 +10,9 @@ describe('toBePending', function() {
|
||||
});
|
||||
|
||||
it('fails if the actual promise is resolved', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil),
|
||||
actual = Promise.resolve();
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil);
|
||||
const actual = Promise.resolve();
|
||||
|
||||
return matcher.compare(actual).then(function(result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
|
||||
@@ -20,9 +20,9 @@ describe('toBePending', function() {
|
||||
});
|
||||
|
||||
it('fails if the actual promise is rejected', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil),
|
||||
actual = Promise.reject(new Error('promise was rejected'));
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil);
|
||||
const actual = Promise.reject(new Error('promise was rejected'));
|
||||
|
||||
return matcher.compare(actual).then(function(result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
|
||||
@@ -30,9 +30,9 @@ describe('toBePending', function() {
|
||||
});
|
||||
|
||||
it('fails if actual is not a promise', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil),
|
||||
actual = 'not a promise';
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil);
|
||||
const actual = 'not a promise';
|
||||
|
||||
function f() {
|
||||
return matcher.compare(actual);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
describe('toBeRejected', function() {
|
||||
it('passes if the actual is rejected', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil),
|
||||
actual = Promise.reject('AsyncExpectationSpec rejection');
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil);
|
||||
const actual = Promise.reject('AsyncExpectationSpec rejection');
|
||||
|
||||
return matcher.compare(actual).then(function(result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
||||
@@ -10,9 +10,9 @@ describe('toBeRejected', function() {
|
||||
});
|
||||
|
||||
it('fails if the actual is resolved', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil),
|
||||
actual = Promise.resolve();
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil);
|
||||
const actual = Promise.resolve();
|
||||
|
||||
return matcher.compare(actual).then(function(result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
|
||||
@@ -20,9 +20,9 @@ describe('toBeRejected', function() {
|
||||
});
|
||||
|
||||
it('fails if actual is not a promise', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil),
|
||||
actual = 'not a promise';
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil);
|
||||
const actual = 'not a promise';
|
||||
|
||||
function f() {
|
||||
return matcher.compare(actual);
|
||||
|
||||
@@ -2,11 +2,11 @@ describe('#toBeRejectedWithError', function() {
|
||||
it('passes when Error type matches', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new TypeError('foo'));
|
||||
);
|
||||
const actual = Promise.reject(new TypeError('foo'));
|
||||
|
||||
return matcher.compare(actual, TypeError).then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -22,11 +22,11 @@ describe('#toBeRejectedWithError', function() {
|
||||
it('passes when Error type and message matches', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new TypeError('foo'));
|
||||
);
|
||||
const actual = Promise.reject(new TypeError('foo'));
|
||||
|
||||
return matcher.compare(actual, TypeError, 'foo').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -42,11 +42,11 @@ describe('#toBeRejectedWithError', function() {
|
||||
it('passes when Error matches and is exactly Error', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error());
|
||||
);
|
||||
const actual = Promise.reject(new Error());
|
||||
|
||||
return matcher.compare(actual, Error).then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -62,11 +62,11 @@ describe('#toBeRejectedWithError', function() {
|
||||
it('passes when Error message matches a string', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error('foo'));
|
||||
);
|
||||
const actual = Promise.reject(new Error('foo'));
|
||||
|
||||
return matcher.compare(actual, 'foo').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -82,11 +82,11 @@ describe('#toBeRejectedWithError', function() {
|
||||
it('passes when Error message matches a RegExp', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error('foo'));
|
||||
);
|
||||
const actual = Promise.reject(new Error('foo'));
|
||||
|
||||
return matcher.compare(actual, /foo/).then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -102,11 +102,11 @@ describe('#toBeRejectedWithError', function() {
|
||||
it('passes when Error message is empty', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error());
|
||||
);
|
||||
const actual = Promise.reject(new Error());
|
||||
|
||||
return matcher.compare(actual, '').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -122,11 +122,11 @@ describe('#toBeRejectedWithError', function() {
|
||||
it('passes when no arguments', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error());
|
||||
);
|
||||
const actual = Promise.reject(new Error());
|
||||
|
||||
return matcher.compare(actual, void 0).then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -142,11 +142,11 @@ describe('#toBeRejectedWithError', function() {
|
||||
it('fails when resolved', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.resolve(new Error('foo'));
|
||||
);
|
||||
const actual = Promise.resolve(new Error('foo'));
|
||||
|
||||
return matcher.compare(actual, 'foo').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -161,11 +161,11 @@ describe('#toBeRejectedWithError', function() {
|
||||
it('fails when rejected with non Error type', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject('foo');
|
||||
);
|
||||
const actual = Promise.reject('foo');
|
||||
|
||||
return matcher.compare(actual, 'foo').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -181,11 +181,11 @@ describe('#toBeRejectedWithError', function() {
|
||||
it('fails when Error type mismatches', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error('foo'));
|
||||
);
|
||||
const actual = Promise.reject(new Error('foo'));
|
||||
|
||||
return matcher.compare(actual, TypeError, 'foo').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -201,11 +201,11 @@ describe('#toBeRejectedWithError', function() {
|
||||
it('fails when Error message mismatches', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error('foo'));
|
||||
);
|
||||
const actual = Promise.reject(new Error('foo'));
|
||||
|
||||
return matcher.compare(actual, 'bar').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -221,11 +221,11 @@ describe('#toBeRejectedWithError', function() {
|
||||
it('fails if actual is not a promise', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = 'not a promise';
|
||||
);
|
||||
const actual = 'not a promise';
|
||||
|
||||
function f() {
|
||||
return matcher.compare(actual);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
describe('#toBeRejectedWithMatching', function() {
|
||||
it('passes if the promise is rejected with something matching the predicate', function() {
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
|
||||
actual = Promise.reject(new Error('nope')),
|
||||
predicate = value => value.message === 'nope';
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching();
|
||||
const actual = Promise.reject(new Error('nope'));
|
||||
const predicate = value => value.message === 'nope';
|
||||
|
||||
return matcher.compare(actual, predicate).then(function(result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
||||
@@ -10,9 +10,9 @@ describe('#toBeRejectedWithMatching', function() {
|
||||
});
|
||||
|
||||
it('fails if the promise resolves', function() {
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
|
||||
actual = Promise.resolve(),
|
||||
predicate = () => true;
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching();
|
||||
const actual = Promise.resolve();
|
||||
const predicate = () => true;
|
||||
|
||||
return matcher.compare(actual, predicate).then(function(result) {
|
||||
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() {
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
|
||||
actual = Promise.reject('A Bad Apple'),
|
||||
predicate = value => value === 'A Good Orange';
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching();
|
||||
const actual = Promise.reject('A Bad Apple');
|
||||
const predicate = value => value === 'A Good Orange';
|
||||
|
||||
return matcher.compare(actual, predicate).then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -36,9 +36,9 @@ describe('#toBeRejectedWithMatching', function() {
|
||||
});
|
||||
|
||||
it('should build its error correctly when negated', function() {
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
|
||||
actual = Promise.reject(true),
|
||||
predicate = () => true;
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching();
|
||||
const actual = Promise.reject(true);
|
||||
const predicate = () => true;
|
||||
|
||||
return matcher.compare(actual, predicate).then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -52,8 +52,8 @@ describe('#toBeRejectedWithMatching', function() {
|
||||
});
|
||||
|
||||
it('fails if actual is not a promise', function() {
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
|
||||
actual = 'not a promise';
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching();
|
||||
const actual = 'not a promise';
|
||||
|
||||
function f() {
|
||||
return matcher.compare(actual);
|
||||
@@ -65,9 +65,9 @@ describe('#toBeRejectedWithMatching', function() {
|
||||
});
|
||||
|
||||
it('fails if predicate is not a function', function() {
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
|
||||
actual = Promise.resolve(),
|
||||
predicate = 'not a function';
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching();
|
||||
const actual = Promise.resolve();
|
||||
const predicate = 'not a function';
|
||||
|
||||
function f() {
|
||||
return matcher.compare(actual, predicate);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
describe('#toBeRejectedWith', function() {
|
||||
it('should return true if the promise is rejected with the expected value', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
|
||||
actual = Promise.reject({ error: 'PEBCAK' });
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = Promise.reject({ error: 'PEBCAK' });
|
||||
|
||||
return matcher.compare(actual, { error: 'PEBCAK' }).then(function(result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
||||
@@ -10,9 +12,11 @@ describe('#toBeRejectedWith', function() {
|
||||
});
|
||||
|
||||
it('should fail if the promise resolves', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
|
||||
actual = Promise.resolve();
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = Promise.resolve();
|
||||
|
||||
return matcher.compare(actual, '').then(function(result) {
|
||||
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() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
|
||||
actual = Promise.reject('A Bad Apple');
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = Promise.reject('A Bad Apple');
|
||||
|
||||
return matcher.compare(actual, 'Some Cool Thing').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -40,9 +46,11 @@ describe('#toBeRejectedWith', function() {
|
||||
it('should build its error correctly when negated', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
|
||||
actual = Promise.reject(true);
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = Promise.reject(true);
|
||||
|
||||
return matcher.compare(actual, true).then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -59,12 +67,14 @@ describe('#toBeRejectedWith', function() {
|
||||
function() {
|
||||
return true;
|
||||
}
|
||||
],
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
];
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
customTesters: customEqualityTesters
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
|
||||
actual = Promise.reject('actual');
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = Promise.reject('actual');
|
||||
|
||||
return matcher.compare(actual, 'expected').then(function(result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
||||
@@ -74,9 +84,11 @@ describe('#toBeRejectedWith', function() {
|
||||
it('fails if actual is not a promise', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
|
||||
actual = 'not a promise';
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = 'not a promise';
|
||||
|
||||
function f() {
|
||||
return matcher.compare(actual);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
describe('toBeResolved', function() {
|
||||
it('passes if the actual is resolved', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil),
|
||||
actual = Promise.resolve();
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil);
|
||||
const actual = Promise.resolve();
|
||||
|
||||
return matcher.compare(actual).then(function(result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
||||
@@ -12,9 +12,9 @@ describe('toBeResolved', function() {
|
||||
it('fails if the actual is rejected', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter([])
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil),
|
||||
actual = Promise.reject(new Error('AsyncExpectationSpec rejection'));
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil);
|
||||
const actual = Promise.reject(new Error('AsyncExpectationSpec rejection'));
|
||||
|
||||
return matcher.compare(actual).then(function(result) {
|
||||
expect(result).toEqual({
|
||||
@@ -27,9 +27,9 @@ describe('toBeResolved', function() {
|
||||
});
|
||||
|
||||
it('fails if actual is not a promise', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil),
|
||||
actual = 'not a promise';
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil);
|
||||
const actual = 'not a promise';
|
||||
|
||||
function f() {
|
||||
return matcher.compare(actual);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
describe('#toBeResolvedTo', function() {
|
||||
it('passes if the promise is resolved to the expected value', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
|
||||
actual = Promise.resolve({ foo: 42 });
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil);
|
||||
const actual = Promise.resolve({ foo: 42 });
|
||||
|
||||
return matcher.compare(actual, { foo: 42 }).then(function(result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
||||
@@ -12,9 +12,9 @@ describe('#toBeResolvedTo', function() {
|
||||
it('fails if the promise is rejected', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
|
||||
actual = Promise.reject(new Error('AsyncExpectationSpec error'));
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil);
|
||||
const actual = Promise.reject(new Error('AsyncExpectationSpec error'));
|
||||
|
||||
return matcher.compare(actual, '').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -31,9 +31,9 @@ describe('#toBeResolvedTo', function() {
|
||||
it('fails if the promise is resolved to a different value', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
|
||||
actual = Promise.resolve({ foo: 17 });
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil);
|
||||
const actual = Promise.resolve({ foo: 17 });
|
||||
|
||||
return matcher.compare(actual, { foo: 42 }).then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -49,9 +49,9 @@ describe('#toBeResolvedTo', function() {
|
||||
it('builds its message correctly when negated', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
|
||||
actual = Promise.resolve(true);
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil);
|
||||
const actual = Promise.resolve(true);
|
||||
|
||||
return matcher.compare(actual, true).then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -68,13 +68,13 @@ describe('#toBeResolvedTo', function() {
|
||||
function() {
|
||||
return true;
|
||||
}
|
||||
],
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
];
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
customTesters: customEqualityTesters,
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
|
||||
actual = Promise.resolve('actual');
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil);
|
||||
const actual = Promise.resolve('actual');
|
||||
|
||||
return matcher.compare(actual, 'expected').then(function(result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
||||
@@ -84,9 +84,9 @@ describe('#toBeResolvedTo', function() {
|
||||
it('fails if actual is not a promise', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
|
||||
actual = 'not a promise';
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil);
|
||||
const actual = 'not a promise';
|
||||
|
||||
function f() {
|
||||
return matcher.compare(actual);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('matchersUtil', function() {
|
||||
it('exposes the injected pretty-printer as .pp', function() {
|
||||
const pp = function() {},
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||
const pp = function() {};
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({ pp: 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() {
|
||||
const foo = [],
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const foo = [];
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
foo.length = 1;
|
||||
|
||||
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() {
|
||||
const one = [1, 2, 3],
|
||||
two = [1, 2, 3],
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const one = [1, 2, 3];
|
||||
const two = [1, 2, 3];
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
one.foo = 'bar';
|
||||
two.foo = 'baz';
|
||||
@@ -115,9 +115,9 @@ describe('matchersUtil', function() {
|
||||
});
|
||||
|
||||
it('passes for Arrays with equivalent contents and properties', function() {
|
||||
const one = [1, 2, 3],
|
||||
two = [1, 2, 3],
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const one = [1, 2, 3];
|
||||
const two = [1, 2, 3];
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
one.foo = 'bar';
|
||||
two.foo = 'bar';
|
||||
@@ -126,9 +126,9 @@ describe('matchersUtil', function() {
|
||||
});
|
||||
|
||||
it('handles symbol keys in Arrays', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
sym = Symbol('foo'),
|
||||
arr1 = [];
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const sym = Symbol('foo');
|
||||
const arr1 = [];
|
||||
let arr2 = [];
|
||||
|
||||
arr1[sym] = 'bar';
|
||||
@@ -200,9 +200,9 @@ describe('matchersUtil', function() {
|
||||
});
|
||||
|
||||
it('passes for Objects that are equivalent (with cycles)', function() {
|
||||
const actual = { a: 'foo' },
|
||||
expected = { a: 'foo' },
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const actual = { a: 'foo' };
|
||||
const expected = { a: 'foo' };
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
actual.b = actual;
|
||||
expected.b = actual;
|
||||
@@ -211,9 +211,9 @@ describe('matchersUtil', function() {
|
||||
});
|
||||
|
||||
it('fails for Objects that are not equivalent (with cycles)', function() {
|
||||
const actual = { a: 'foo' },
|
||||
expected = { a: 'bar' },
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const actual = { a: 'foo' };
|
||||
const expected = { a: 'bar' };
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
actual.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() {
|
||||
const expected = { a: undefined },
|
||||
actual = { b: 1 },
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const expected = { a: undefined };
|
||||
const actual = { b: 1 };
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(matchersUtil.equals(actual, expected)).toBe(false);
|
||||
});
|
||||
|
||||
it('fails when comparing an empty object to an empty array (issue #114)', function() {
|
||||
const emptyObject = {},
|
||||
emptyArray = [],
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const emptyObject = {};
|
||||
const emptyArray = [];
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(matchersUtil.equals(emptyObject, emptyArray)).toBe(false);
|
||||
expect(matchersUtil.equals(emptyArray, emptyObject)).toBe(false);
|
||||
});
|
||||
|
||||
it('passes for equivalent frozen objects (GitHub issue #266)', function() {
|
||||
const a = { foo: 1 },
|
||||
b = { foo: 1 },
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const a = { foo: 1 };
|
||||
const b = { foo: 1 };
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
Object.freeze(a);
|
||||
Object.freeze(b);
|
||||
@@ -250,9 +250,9 @@ describe('matchersUtil', function() {
|
||||
});
|
||||
|
||||
it('passes for equivalent Promises (GitHub issue #1314)', function() {
|
||||
const p1 = new Promise(function() {}),
|
||||
p2 = new Promise(function() {}),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const p1 = new Promise(function() {});
|
||||
const p2 = new Promise(function() {});
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(matchersUtil.equals(p1, p1)).toBe(true);
|
||||
expect(matchersUtil.equals(p1, p2)).toBe(false);
|
||||
@@ -344,18 +344,18 @@ describe('matchersUtil', function() {
|
||||
});
|
||||
|
||||
it('passes when Any is used', function() {
|
||||
const number = 3,
|
||||
anyNumber = new privateUnderTest.Any(Number),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const number = 3;
|
||||
const anyNumber = new privateUnderTest.Any(Number);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(matchersUtil.equals(number, anyNumber)).toBe(true);
|
||||
expect(matchersUtil.equals(anyNumber, number)).toBe(true);
|
||||
});
|
||||
|
||||
it('fails when Any is compared to something unexpected', function() {
|
||||
const number = 3,
|
||||
anyString = new privateUnderTest.Any(String),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const number = 3;
|
||||
const anyString = new privateUnderTest.Any(String);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(matchersUtil.equals(number, anyString)).toBe(false);
|
||||
expect(matchersUtil.equals(anyString, number)).toBe(false);
|
||||
@@ -365,9 +365,9 @@ describe('matchersUtil', function() {
|
||||
const obj = {
|
||||
foo: 3,
|
||||
bar: 7
|
||||
},
|
||||
containing = new privateUnderTest.ObjectContaining({ foo: 3 }),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
};
|
||||
const containing = new privateUnderTest.ObjectContaining({ foo: 3 });
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(matchersUtil.equals(obj, containing)).toBe(true);
|
||||
expect(matchersUtil.equals(containing, obj)).toBe(true);
|
||||
@@ -402,8 +402,8 @@ describe('matchersUtil', function() {
|
||||
asymmetricMatch: function() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
};
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(matchersUtil.equals(false, tester)).toBe(true);
|
||||
expect(matchersUtil.equals(tester, false)).toBe(true);
|
||||
@@ -414,16 +414,16 @@ describe('matchersUtil', function() {
|
||||
asymmetricMatch: function() {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
};
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(matchersUtil.equals(true, tester)).toBe(false);
|
||||
expect(matchersUtil.equals(tester, true)).toBe(false);
|
||||
});
|
||||
|
||||
it('passes when ArrayContaining is used', function() {
|
||||
const arr = ['foo', 'bar'],
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const arr = ['foo', 'bar'];
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(
|
||||
matchersUtil.equals(arr, new privateUnderTest.ArrayContaining(['bar']))
|
||||
@@ -433,8 +433,8 @@ describe('matchersUtil', function() {
|
||||
it('passes when a custom equality matcher returns true', function() {
|
||||
const tester = function() {
|
||||
return true;
|
||||
},
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
};
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
customTesters: [tester],
|
||||
pp: function() {}
|
||||
});
|
||||
@@ -464,8 +464,8 @@ describe('matchersUtil', function() {
|
||||
it('fails for equivalents when a custom equality matcher returns false', function() {
|
||||
const tester = function() {
|
||||
return false;
|
||||
},
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
};
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
customTesters: [tester],
|
||||
pp: function() {}
|
||||
});
|
||||
@@ -478,11 +478,11 @@ describe('matchersUtil', function() {
|
||||
asymmetricMatch: function() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
symmetricTester = function() {
|
||||
};
|
||||
const symmetricTester = function() {
|
||||
return false;
|
||||
},
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
};
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
customTesters: [symmetricTester()],
|
||||
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() {
|
||||
const any1 = new privateUnderTest.Any(Function),
|
||||
any2 = new privateUnderTest.Any(Function),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const any1 = new privateUnderTest.Any(Function);
|
||||
const any2 = new privateUnderTest.Any(Function);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
expect(matchersUtil.equals(any1, any2)).toBe(true);
|
||||
});
|
||||
|
||||
it('passes for null prototype objects with same properties', function() {
|
||||
const objA = Object.create(null),
|
||||
objB = Object.create(null),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const objA = Object.create(null);
|
||||
const objB = Object.create(null);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
objA.name = 'test';
|
||||
objB.name = 'test';
|
||||
@@ -511,9 +511,9 @@ describe('matchersUtil', function() {
|
||||
});
|
||||
|
||||
it('fails for null prototype objects with different properties', function() {
|
||||
const objA = Object.create(null),
|
||||
objB = Object.create(null),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const objA = Object.create(null);
|
||||
const objB = Object.create(null);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
objA.name = 'test';
|
||||
objB.test = 'name';
|
||||
@@ -673,8 +673,8 @@ describe('matchersUtil', function() {
|
||||
});
|
||||
|
||||
it('fails when comparing two different URLs', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
url1 = new URL('http://localhost/1');
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const url1 = new URL('http://localhost/1');
|
||||
|
||||
expect(matchersUtil.equals(url1, new URL('http://localhost/2'))).toBe(
|
||||
false
|
||||
@@ -923,15 +923,15 @@ describe('matchersUtil', function() {
|
||||
other: 'other value'
|
||||
};
|
||||
}
|
||||
},
|
||||
actual = { x: 42 },
|
||||
expected = { x: tester },
|
||||
diffBuilder = jasmine.createSpyObj('diffBuilder', [
|
||||
};
|
||||
const actual = { x: 42 };
|
||||
const expected = { x: tester };
|
||||
const diffBuilder = jasmine.createSpyObj('diffBuilder', [
|
||||
'recordMismatch',
|
||||
'withPath',
|
||||
'setRoots'
|
||||
]),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
]);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
diffBuilder.withPath.and.callFake(function(p, block) {
|
||||
block();
|
||||
@@ -951,15 +951,15 @@ describe('matchersUtil', function() {
|
||||
asymmetricMatch: function() {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
actual = { x: 42 },
|
||||
expected = { x: tester },
|
||||
diffBuilder = jasmine.createSpyObj('diffBuilder', [
|
||||
};
|
||||
const actual = { x: 42 };
|
||||
const expected = { x: tester };
|
||||
const diffBuilder = jasmine.createSpyObj('diffBuilder', [
|
||||
'recordMismatch',
|
||||
'withPath',
|
||||
'setRoots'
|
||||
]),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
]);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
diffBuilder.withPath.and.callFake(function(p, block) {
|
||||
block();
|
||||
@@ -976,8 +976,8 @@ describe('matchersUtil', function() {
|
||||
});
|
||||
|
||||
it('uses a diffBuilder if one is provided as the third argument', function() {
|
||||
const diffBuilder = new privateUnderTest.DiffBuilder(),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const diffBuilder = new privateUnderTest.DiffBuilder();
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
|
||||
spyOn(diffBuilder, 'recordMismatch');
|
||||
spyOn(diffBuilder, 'withPath').and.callThrough();
|
||||
@@ -1027,8 +1027,8 @@ describe('matchersUtil', function() {
|
||||
it('uses custom equality testers if actual is an Array', function() {
|
||||
const customTester = function() {
|
||||
return true;
|
||||
},
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
};
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
customTesters: [customTester],
|
||||
pp: function() {}
|
||||
});
|
||||
@@ -1091,32 +1091,32 @@ describe('matchersUtil', function() {
|
||||
|
||||
describe('buildFailureMessage', function() {
|
||||
it('builds an English sentence for a failure case', function() {
|
||||
const actual = 'foo',
|
||||
name = 'toBar',
|
||||
pp = privateUnderTest.makePrettyPrinter(),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
message = matchersUtil.buildFailureMessage(name, false, actual);
|
||||
const actual = 'foo';
|
||||
const name = 'toBar';
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||
const message = matchersUtil.buildFailureMessage(name, false, actual);
|
||||
|
||||
expect(message).toEqual("Expected 'foo' to bar.");
|
||||
});
|
||||
|
||||
it("builds an English sentence for a 'not' failure case", function() {
|
||||
const actual = 'foo',
|
||||
name = 'toBar',
|
||||
isNot = true,
|
||||
pp = privateUnderTest.makePrettyPrinter(),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
message = matchersUtil.buildFailureMessage(name, isNot, actual);
|
||||
const actual = 'foo';
|
||||
const name = 'toBar';
|
||||
const isNot = true;
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||
const message = matchersUtil.buildFailureMessage(name, isNot, actual);
|
||||
|
||||
expect(message).toEqual("Expected 'foo' not to bar.");
|
||||
});
|
||||
|
||||
it('builds an English sentence for an arbitrary array of expected arguments', function() {
|
||||
const actual = 'foo',
|
||||
name = 'toBar',
|
||||
pp = privateUnderTest.makePrettyPrinter(),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
message = matchersUtil.buildFailureMessage(
|
||||
const actual = 'foo';
|
||||
const name = 'toBar';
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||
const message = matchersUtil.buildFailureMessage(
|
||||
name,
|
||||
false,
|
||||
actual,
|
||||
@@ -1128,16 +1128,16 @@ describe('matchersUtil', function() {
|
||||
});
|
||||
|
||||
it('uses the injected pretty-printer to format the expecteds and actual', function() {
|
||||
const actual = 'foo',
|
||||
expected1 = 'qux',
|
||||
expected2 = 'grault',
|
||||
name = 'toBar',
|
||||
isNot = false,
|
||||
pp = function(value) {
|
||||
const actual = 'foo';
|
||||
const expected1 = 'qux';
|
||||
const expected2 = 'grault';
|
||||
const name = 'toBar';
|
||||
const isNot = false;
|
||||
const pp = function(value) {
|
||||
return '<' + value + '>';
|
||||
},
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
message = matchersUtil.buildFailureMessage(
|
||||
};
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||
const message = matchersUtil.buildFailureMessage(
|
||||
name,
|
||||
isNot,
|
||||
actual,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('nothing', function() {
|
||||
it('should pass', function() {
|
||||
const matcher = privateUnderTest.matchers.nothing(),
|
||||
result = matcher.compare();
|
||||
const matcher = privateUnderTest.matchers.nothing();
|
||||
const result = matcher.compare();
|
||||
|
||||
expect(result.pass).toBe(true);
|
||||
});
|
||||
|
||||
@@ -29,8 +29,8 @@ describe('toBeNaN', function() {
|
||||
it('has a custom message on failure', function() {
|
||||
const matcher = privateUnderTest.matchers.toBeNaN({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
result = matcher.compare(0);
|
||||
});
|
||||
const result = matcher.compare(0);
|
||||
|
||||
expect(result.message()).toEqual('Expected 0 to be NaN.');
|
||||
});
|
||||
|
||||
@@ -16,15 +16,15 @@ describe('toBeNegativeInfinity', function() {
|
||||
it('has a custom message on failure', function() {
|
||||
const matcher = privateUnderTest.matchers.toBeNegativeInfinity({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
result = matcher.compare(0);
|
||||
});
|
||||
const result = matcher.compare(0);
|
||||
|
||||
expect(result.message()).toEqual('Expected 0 to be -Infinity.');
|
||||
});
|
||||
|
||||
it('succeeds for -Infinity', function() {
|
||||
const matcher = privateUnderTest.matchers.toBeNegativeInfinity(),
|
||||
result = matcher.compare(Number.NEGATIVE_INFINITY);
|
||||
const matcher = privateUnderTest.matchers.toBeNegativeInfinity();
|
||||
const result = matcher.compare(Number.NEGATIVE_INFINITY);
|
||||
|
||||
expect(result.pass).toBe(true);
|
||||
expect(result.message).toEqual('Expected actual not to be -Infinity.');
|
||||
|
||||
@@ -16,15 +16,15 @@ describe('toBePositiveInfinity', function() {
|
||||
it('has a custom message on failure', function() {
|
||||
const matcher = privateUnderTest.matchers.toBePositiveInfinity({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
result = matcher.compare(0);
|
||||
});
|
||||
const result = matcher.compare(0);
|
||||
|
||||
expect(result.message()).toEqual('Expected 0 to be Infinity.');
|
||||
});
|
||||
|
||||
it('succeeds for Infinity', function() {
|
||||
const matcher = privateUnderTest.matchers.toBePositiveInfinity(),
|
||||
result = matcher.compare(Number.POSITIVE_INFINITY);
|
||||
const matcher = privateUnderTest.matchers.toBePositiveInfinity();
|
||||
const result = matcher.compare(Number.POSITIVE_INFINITY);
|
||||
|
||||
expect(result.pass).toBe(true);
|
||||
expect(result.message).toEqual('Expected actual not to be Infinity.');
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
describe('toBe', function() {
|
||||
it('passes with no message when actual === expected', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.matchers.toBe(matchersUtil),
|
||||
result = matcher.compare(1, 1);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
|
||||
const result = matcher.compare(1, 1);
|
||||
expect(result.pass).toBe(true);
|
||||
});
|
||||
|
||||
it('passes with a custom message when expected is an array', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.matchers.toBe(matchersUtil),
|
||||
array = [1];
|
||||
});
|
||||
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
|
||||
const array = [1];
|
||||
|
||||
const result = matcher.compare(array, array);
|
||||
expect(result.pass).toBe(true);
|
||||
@@ -23,9 +23,9 @@ describe('toBe', function() {
|
||||
it('passes with a custom message when expected is an object', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.matchers.toBe(matchersUtil),
|
||||
obj = { foo: 'bar' };
|
||||
});
|
||||
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
|
||||
const obj = { foo: 'bar' };
|
||||
|
||||
const result = matcher.compare(obj, obj);
|
||||
expect(result.pass).toBe(true);
|
||||
@@ -35,9 +35,9 @@ describe('toBe', function() {
|
||||
});
|
||||
|
||||
it('fails with no message when actual !== expected', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil(),
|
||||
matcher = privateUnderTest.matchers.toBe(matchersUtil),
|
||||
result = matcher.compare(1, 2);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
|
||||
const result = matcher.compare(1, 2);
|
||||
expect(result.pass).toBe(false);
|
||||
expect(result.message).toBeUndefined();
|
||||
});
|
||||
@@ -45,9 +45,9 @@ describe('toBe', function() {
|
||||
it('fails with a custom message when expected is an array', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.matchers.toBe(matchersUtil),
|
||||
result = matcher.compare([1], [1]);
|
||||
});
|
||||
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
|
||||
const result = matcher.compare([1], [1]);
|
||||
|
||||
expect(result.pass).toBe(false);
|
||||
expect(result.message).toBe(
|
||||
@@ -58,9 +58,9 @@ describe('toBe', function() {
|
||||
it('fails with a custom message when expected is an object', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.matchers.toBe(matchersUtil),
|
||||
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.message).toBe(
|
||||
@@ -71,11 +71,13 @@ describe('toBe', function() {
|
||||
it('works with custom object formatters when expected is an object', function() {
|
||||
const formatter = function(x) {
|
||||
return '<' + x.foo + '>';
|
||||
},
|
||||
prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({ pp: prettyPrinter }),
|
||||
matcher = privateUnderTest.matchers.toBe(matchersUtil),
|
||||
result = matcher.compare({ foo: 'bar' }, { foo: 'bar' });
|
||||
};
|
||||
const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: prettyPrinter
|
||||
});
|
||||
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
|
||||
const result = matcher.compare({ foo: 'bar' }, { foo: 'bar' });
|
||||
|
||||
expect(result.pass).toBe(false);
|
||||
expect(result.message).toBe(
|
||||
|
||||
@@ -2,8 +2,8 @@ describe('toContain', function() {
|
||||
it('delegates to privateUnderTest.MatchersUtil.contains', function() {
|
||||
const matchersUtil = {
|
||||
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');
|
||||
expect(matchersUtil.contains).toHaveBeenCalledWith('ABC', 'B');
|
||||
@@ -13,11 +13,11 @@ describe('toContain', function() {
|
||||
it('works with custom equality testers', function() {
|
||||
const tester = function(a, b) {
|
||||
return a.toString() === b.toString();
|
||||
},
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
};
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
customTesters: [tester]
|
||||
}),
|
||||
matcher = privateUnderTest.matchers.toContain(matchersUtil);
|
||||
});
|
||||
const matcher = privateUnderTest.matchers.toContain(matchersUtil);
|
||||
|
||||
const result = matcher.compare(['1', '2'], 2);
|
||||
expect(result.pass).toBe(true);
|
||||
|
||||
@@ -4,8 +4,8 @@ describe('toEqual', function() {
|
||||
function compareEquals(actual, expected) {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.matchers.toEqual(matchersUtil);
|
||||
});
|
||||
const matcher = privateUnderTest.matchers.toEqual(matchersUtil);
|
||||
|
||||
const result = matcher.compare(actual, expected);
|
||||
|
||||
@@ -19,8 +19,8 @@ describe('toEqual', function() {
|
||||
return 'does not matter';
|
||||
},
|
||||
DiffBuilder: new privateUnderTest.DiffBuilder()
|
||||
},
|
||||
matcher = privateUnderTest.matchers.toEqual(matchersUtil);
|
||||
};
|
||||
const matcher = privateUnderTest.matchers.toEqual(matchersUtil);
|
||||
|
||||
const result = matcher.compare(1, 1);
|
||||
|
||||
@@ -31,11 +31,11 @@ describe('toEqual', function() {
|
||||
it('works with custom equality testers', function() {
|
||||
const tester = function(a, b) {
|
||||
return a.toString() === b.toString();
|
||||
},
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
};
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
customTesters: [tester]
|
||||
}),
|
||||
matcher = privateUnderTest.matchers.toEqual(matchersUtil);
|
||||
});
|
||||
const matcher = privateUnderTest.matchers.toEqual(matchersUtil);
|
||||
|
||||
const result = matcher.compare(1, '1');
|
||||
|
||||
@@ -43,18 +43,18 @@ describe('toEqual', function() {
|
||||
});
|
||||
|
||||
it('reports the difference between objects that are not equal', function() {
|
||||
const actual = { x: 1, y: 3 },
|
||||
expected = { x: 2, y: 3 },
|
||||
message = 'Expected $.x = 1 to equal 2.';
|
||||
const actual = { x: 1, y: 3 };
|
||||
const expected = { x: 2, y: 3 };
|
||||
const message = 'Expected $.x = 1 to equal 2.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports differences between enumerable symbol properties', function() {
|
||||
const x = Symbol('x'),
|
||||
actual = { [x]: 1, y: 3 },
|
||||
expected = { [x]: 2, y: 3 },
|
||||
message = 'Expected $[Symbol(x)] = 1 to equal 2.';
|
||||
const x = Symbol('x');
|
||||
const actual = { [x]: 1, y: 3 };
|
||||
const expected = { [x]: 2, y: 3 };
|
||||
const message = 'Expected $[Symbol(x)] = 1 to equal 2.';
|
||||
|
||||
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() {
|
||||
const actual = { x: { y: 1 } },
|
||||
expected = { x: { y: 2 } },
|
||||
message = 'Expected $.x.y = 1 to equal 2.';
|
||||
const actual = { x: { y: 1 } };
|
||||
const expected = { x: { y: 2 } };
|
||||
const message = 'Expected $.x.y = 1 to equal 2.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it("formats property access so that it's valid JavaScript", function() {
|
||||
const actual = { 'my prop': 1 },
|
||||
expected = { 'my prop': 2 },
|
||||
message = "Expected $['my prop'] = 1 to equal 2.";
|
||||
const actual = { 'my prop': 1 };
|
||||
const expected = { 'my prop': 2 };
|
||||
const message = "Expected $['my prop'] = 1 to equal 2.";
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports missing properties', function() {
|
||||
const actual = { x: {} },
|
||||
expected = { x: { y: 1 } },
|
||||
message = 'Expected $.x to have properties\n' + ' y: 1';
|
||||
const actual = { x: {} };
|
||||
const expected = { x: { y: 1 } };
|
||||
const message = 'Expected $.x to have properties\n' + ' y: 1';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports mismatches as well as missing or extra properties', function() {
|
||||
const actual = { x: { z: 2 } },
|
||||
expected = { x: { y: 1, z: 3 } },
|
||||
message =
|
||||
const actual = { x: { z: 2 } };
|
||||
const expected = { x: { y: 1, z: 3 } };
|
||||
const message =
|
||||
'Expected $.x to have properties\n' +
|
||||
' y: 1\n' +
|
||||
'Expected $.x.z = 2 to equal 3.';
|
||||
@@ -107,34 +107,36 @@ describe('toEqual', function() {
|
||||
});
|
||||
|
||||
it('reports missing symbol properties', function() {
|
||||
const actual = { x: {} },
|
||||
expected = { x: { [Symbol('y')]: 1 } },
|
||||
message = 'Expected $.x to have properties\n' + ' Symbol(y): 1';
|
||||
const actual = { x: {} };
|
||||
const expected = { x: { [Symbol('y')]: 1 } };
|
||||
const message = 'Expected $.x to have properties\n' + ' Symbol(y): 1';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports extra symbol properties', function() {
|
||||
const actual = { x: { [Symbol('y')]: 1 } },
|
||||
expected = { x: {} },
|
||||
message = 'Expected $.x not to have properties\n' + ' Symbol(y): 1';
|
||||
const actual = { x: { [Symbol('y')]: 1 } };
|
||||
const expected = { x: {} };
|
||||
const message =
|
||||
'Expected $.x not to have properties\n' + ' Symbol(y): 1';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports extra properties', function() {
|
||||
const actual = { x: { y: 1, z: 2 } },
|
||||
expected = { x: {} },
|
||||
message =
|
||||
const actual = { x: { y: 1, z: 2 } };
|
||||
const expected = { x: {} };
|
||||
const message =
|
||||
'Expected $.x not to have properties\n' + ' y: 1\n' + ' z: 2';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('pretty-prints properties', function() {
|
||||
const actual = { x: { y: 'foo bar' } },
|
||||
expected = { x: {} },
|
||||
message = 'Expected $.x not to have properties\n' + " y: 'foo bar'";
|
||||
const actual = { x: { y: 'foo bar' } };
|
||||
const expected = { x: {} };
|
||||
const message =
|
||||
'Expected $.x not to have properties\n' + " y: 'foo bar'";
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
@@ -146,12 +148,12 @@ describe('toEqual', function() {
|
||||
}
|
||||
}
|
||||
|
||||
const actual = { x: { y: 1, z: 2, f: 4 } },
|
||||
expected = { x: { y: 1, z: 2, g: 3 } },
|
||||
pp = privateUnderTest.makePrettyPrinter([formatter]),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
matcher = privateUnderTest.matchers.toEqual(matchersUtil),
|
||||
message =
|
||||
const actual = { x: { y: 1, z: 2, f: 4 } };
|
||||
const expected = { x: { y: 1, z: 2, g: 3 } };
|
||||
const pp = privateUnderTest.makePrettyPrinter([formatter]);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||
const matcher = privateUnderTest.matchers.toEqual(matchersUtil);
|
||||
const message =
|
||||
'Expected $.x to have properties\n' +
|
||||
' g: |3|\n' +
|
||||
'Expected $.x not to have properties\n' +
|
||||
@@ -167,12 +169,14 @@ describe('toEqual', function() {
|
||||
}
|
||||
}
|
||||
|
||||
const actual = [{ foo: 4 }],
|
||||
expected = [{ foo: 5 }],
|
||||
prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({ pp: prettyPrinter }),
|
||||
matcher = privateUnderTest.matchers.toEqual(matchersUtil),
|
||||
message = 'Expected $[0].foo = |4| to equal |5|.';
|
||||
const actual = [{ foo: 4 }];
|
||||
const expected = [{ foo: 5 }];
|
||||
const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: prettyPrinter
|
||||
});
|
||||
const matcher = privateUnderTest.matchers.toEqual(matchersUtil);
|
||||
const message = 'Expected $[0].foo = |4| to equal |5|.';
|
||||
|
||||
expect(matcher.compare(actual, expected).message).toEqual(message);
|
||||
});
|
||||
@@ -189,17 +193,19 @@ describe('toEqual', function() {
|
||||
foo: { a: 1, b: 2 },
|
||||
bar: 'should not be pretty printed'
|
||||
}
|
||||
],
|
||||
expected = [
|
||||
];
|
||||
const expected = [
|
||||
{
|
||||
foo: { a: 5, b: 2 },
|
||||
bar: "shouldn't be pretty printed"
|
||||
}
|
||||
],
|
||||
prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({ pp: prettyPrinter }),
|
||||
matcher = privateUnderTest.matchers.toEqual(matchersUtil),
|
||||
message =
|
||||
];
|
||||
const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: prettyPrinter
|
||||
});
|
||||
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].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() {
|
||||
const actual = { x: 1 },
|
||||
expected = { a: 1 },
|
||||
message =
|
||||
const actual = { x: 1 };
|
||||
const expected = { a: 1 };
|
||||
const message =
|
||||
'Expected object to have properties\n' +
|
||||
' a: 1\n' +
|
||||
'Expected object not to have properties\n' +
|
||||
@@ -219,42 +225,42 @@ describe('toEqual', function() {
|
||||
});
|
||||
|
||||
it('reports multiple incorrect values', function() {
|
||||
const actual = { x: 1, y: 2 },
|
||||
expected = { x: 3, y: 4 },
|
||||
message =
|
||||
const actual = { x: 1, y: 2 };
|
||||
const expected = { x: 3, y: 4 };
|
||||
const message =
|
||||
'Expected $.x = 1 to equal 3.\n' + 'Expected $.y = 2 to equal 4.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports mismatch between actual child object and expected child number', function() {
|
||||
const actual = { x: { y: 2 } },
|
||||
expected = { x: 1 },
|
||||
message = 'Expected $.x = Object({ y: 2 }) to equal 1.';
|
||||
const actual = { x: { y: 2 } };
|
||||
const expected = { x: 1 };
|
||||
const message = 'Expected $.x = Object({ y: 2 }) to equal 1.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('uses the default failure message if actual is not an object', function() {
|
||||
const actual = 1,
|
||||
expected = { x: {} },
|
||||
message = 'Expected 1 to equal Object({ x: Object({ }) }).';
|
||||
const actual = 1;
|
||||
const expected = { x: {} };
|
||||
const message = 'Expected 1 to equal Object({ x: Object({ }) }).';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('uses the default failure message if expected is not an object', function() {
|
||||
const actual = { x: {} },
|
||||
expected = 1,
|
||||
message = 'Expected Object({ x: Object({ }) }) to equal 1.';
|
||||
const actual = { x: {} };
|
||||
const expected = 1;
|
||||
const message = 'Expected Object({ x: Object({ }) }) to equal 1.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('uses the default failure message given arrays with different lengths', function() {
|
||||
const actual = [1, 2],
|
||||
expected = [1, 2, 3],
|
||||
message =
|
||||
const actual = [1, 2];
|
||||
const expected = [1, 2, 3];
|
||||
const message =
|
||||
'Expected $.length = 2 to equal 3.\n' +
|
||||
'Expected $[2] = undefined to equal 3.';
|
||||
|
||||
@@ -262,107 +268,107 @@ describe('toEqual', function() {
|
||||
});
|
||||
|
||||
it('reports a mismatch between elements of equal-length arrays', function() {
|
||||
const actual = [1, 2, 5],
|
||||
expected = [1, 2, 3],
|
||||
message = 'Expected $[2] = 5 to equal 3.';
|
||||
const actual = [1, 2, 5];
|
||||
const expected = [1, 2, 3];
|
||||
const message = 'Expected $[2] = 5 to equal 3.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports a mismatch between multiple array elements', function() {
|
||||
const actual = [2, 2, 5],
|
||||
expected = [1, 2, 3],
|
||||
message =
|
||||
const actual = [2, 2, 5];
|
||||
const expected = [1, 2, 3];
|
||||
const message =
|
||||
'Expected $[0] = 2 to equal 1.\n' + 'Expected $[2] = 5 to equal 3.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports a mismatch between properties of objects in arrays', function() {
|
||||
const actual = [{ x: 1 }],
|
||||
expected = [{ x: 2 }],
|
||||
message = 'Expected $[0].x = 1 to equal 2.';
|
||||
const actual = [{ x: 1 }];
|
||||
const expected = [{ x: 2 }];
|
||||
const message = 'Expected $[0].x = 1 to equal 2.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports a mismatch between arrays in objects', function() {
|
||||
const actual = { x: [1] },
|
||||
expected = { x: [2] },
|
||||
message = 'Expected $.x[0] = 1 to equal 2.';
|
||||
const actual = { x: [1] };
|
||||
const expected = { x: [2] };
|
||||
const message = 'Expected $.x[0] = 1 to equal 2.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports mismatches between nested arrays', function() {
|
||||
const actual = [[1]],
|
||||
expected = [[2]],
|
||||
message = 'Expected $[0][0] = 1 to equal 2.';
|
||||
const actual = [[1]];
|
||||
const expected = [[2]];
|
||||
const message = 'Expected $[0][0] = 1 to equal 2.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports mismatches between arrays of different types', function() {
|
||||
const actual = new Uint32Array([1, 2, 3]),
|
||||
expected = new Uint16Array([1, 2, 3]),
|
||||
message =
|
||||
const actual = new Uint32Array([1, 2, 3]);
|
||||
const expected = new Uint16Array([1, 2, 3]);
|
||||
const message =
|
||||
'Expected Uint32Array [ 1, 2, 3 ] to equal Uint16Array [ 1, 2, 3 ].';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports mismatches involving NaN', function() {
|
||||
const actual = { x: 0 },
|
||||
expected = { x: 0 / 0 },
|
||||
message = 'Expected $.x = 0 to equal NaN.';
|
||||
const actual = { x: 0 };
|
||||
const expected = { x: 0 / 0 };
|
||||
const message = 'Expected $.x = 0 to equal NaN.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports mismatches involving regular expressions', function() {
|
||||
const actual = { x: '1' },
|
||||
expected = { x: /1/ },
|
||||
message = "Expected $.x = '1' to equal /1/.";
|
||||
const actual = { x: '1' };
|
||||
const expected = { x: /1/ };
|
||||
const message = "Expected $.x = '1' to equal /1/.";
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports mismatches involving infinities', function() {
|
||||
const actual = { x: 0 },
|
||||
expected = { x: 1 / 0 },
|
||||
message = 'Expected $.x = 0 to equal Infinity.';
|
||||
const actual = { x: 0 };
|
||||
const expected = { x: 1 / 0 };
|
||||
const message = 'Expected $.x = 0 to equal Infinity.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports mismatches involving booleans', function() {
|
||||
const actual = { x: false },
|
||||
expected = { x: true },
|
||||
message = 'Expected $.x = false to equal true.';
|
||||
const actual = { x: false };
|
||||
const expected = { x: true };
|
||||
const message = 'Expected $.x = false to equal true.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports mismatches involving strings', function() {
|
||||
const actual = { x: 'foo' },
|
||||
expected = { x: 'bar' },
|
||||
message = "Expected $.x = 'foo' to equal 'bar'.";
|
||||
const actual = { x: 'foo' };
|
||||
const expected = { x: 'bar' };
|
||||
const message = "Expected $.x = 'foo' to equal 'bar'.";
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports mismatches involving undefined', function() {
|
||||
const actual = { x: void 0 },
|
||||
expected = { x: 0 },
|
||||
message = 'Expected $.x = undefined to equal 0.';
|
||||
const actual = { x: void 0 };
|
||||
const expected = { x: 0 };
|
||||
const message = 'Expected $.x = undefined to equal 0.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports mismatches involving null', function() {
|
||||
const actual = { x: null },
|
||||
expected = { x: 0 },
|
||||
message = 'Expected $.x = null to equal 0.';
|
||||
const actual = { x: null };
|
||||
const expected = { x: 0 };
|
||||
const message = 'Expected $.x = null to equal 0.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
@@ -371,9 +377,9 @@ describe('toEqual', function() {
|
||||
function Foo() {}
|
||||
function Bar() {}
|
||||
|
||||
const actual = { x: new Foo() },
|
||||
expected = { x: new Bar() },
|
||||
message = 'Expected $.x to be a kind of Bar, but was Foo({ }).';
|
||||
const actual = { x: new Foo() };
|
||||
const expected = { x: new Bar() };
|
||||
const message = 'Expected $.x to be a kind of Bar, but was Foo({ }).';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
@@ -387,12 +393,13 @@ describe('toEqual', function() {
|
||||
}
|
||||
}
|
||||
|
||||
const actual = { x: new Foo() },
|
||||
expected = { x: new Bar() },
|
||||
message = 'Expected $.x to be a kind of Bar, but was |[object Object]|.',
|
||||
pp = privateUnderTest.makePrettyPrinter([formatter]),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
matcher = privateUnderTest.matchers.toEqual(matchersUtil);
|
||||
const actual = { x: new Foo() };
|
||||
const expected = { x: new Bar() };
|
||||
const message =
|
||||
'Expected $.x to be a kind of Bar, but was |[object Object]|.';
|
||||
const pp = privateUnderTest.makePrettyPrinter([formatter]);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||
const matcher = privateUnderTest.matchers.toEqual(matchersUtil);
|
||||
|
||||
expect(matcher.compare(actual, expected).message).toEqual(message);
|
||||
});
|
||||
@@ -401,9 +408,9 @@ describe('toEqual', function() {
|
||||
function Foo() {}
|
||||
function Bar() {}
|
||||
|
||||
const actual = new Foo(),
|
||||
expected = new Bar(),
|
||||
message = 'Expected object to be a kind of Bar, but was Foo({ }).';
|
||||
const actual = new Foo();
|
||||
const expected = new Bar();
|
||||
const message = 'Expected object to be a kind of Bar, but was Foo({ }).';
|
||||
|
||||
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() {
|
||||
const actual = { x: { constructor: 'blerf' } },
|
||||
expected = { x: { constructor: 'ftarrh' } },
|
||||
message = "Expected $.x.constructor = 'blerf' to equal 'ftarrh'.";
|
||||
const actual = { x: { constructor: 'blerf' } };
|
||||
const expected = { x: { constructor: 'ftarrh' } };
|
||||
const message = "Expected $.x.constructor = 'blerf' to equal 'ftarrh'.";
|
||||
|
||||
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() {
|
||||
const actual = { x: {} },
|
||||
expected = { x: { constructor: 'ftarrh' } },
|
||||
message =
|
||||
const actual = { x: {} };
|
||||
const expected = { x: { constructor: 'ftarrh' } };
|
||||
const message =
|
||||
'Expected $.x to have properties\n' + " constructor: 'ftarrh'";
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
@@ -433,25 +440,25 @@ describe('toEqual', function() {
|
||||
});
|
||||
|
||||
it('reports mismatches between 0 and -0', function() {
|
||||
const actual = { x: 0 },
|
||||
expected = { x: -0 },
|
||||
message = 'Expected $.x = 0 to equal -0.';
|
||||
const actual = { x: 0 };
|
||||
const expected = { x: -0 };
|
||||
const message = 'Expected $.x = 0 to equal -0.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports mismatches between 0 and Number.MIN_VALUE', function() {
|
||||
const actual = { x: 0 },
|
||||
expected = { x: Number.MIN_VALUE },
|
||||
message = 'Expected $.x = 0 to equal 5e-324.';
|
||||
const actual = { x: 0 };
|
||||
const expected = { x: Number.MIN_VALUE };
|
||||
const message = 'Expected $.x = 0 to equal 5e-324.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports mismatches between Errors', function() {
|
||||
const actual = { x: new Error('the error you got') },
|
||||
expected = { x: new Error('the error you want') },
|
||||
message =
|
||||
const actual = { x: new Error('the error you got') };
|
||||
const expected = { x: new Error('the error you want') };
|
||||
const message =
|
||||
'Expected $.x = Error: the error you got to equal Error: the error you want.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
@@ -713,24 +720,24 @@ describe('toEqual', function() {
|
||||
});
|
||||
|
||||
it('reports mismatches between DOM nodes with different tags', function() {
|
||||
const actual = { a: this.doc.createElement('div') },
|
||||
expected = { a: this.doc.createElement('p') },
|
||||
message = 'Expected $.a = <div> to equal <p>.';
|
||||
const actual = { a: this.doc.createElement('div') };
|
||||
const expected = { a: this.doc.createElement('p') };
|
||||
const message = 'Expected $.a = <div> to equal <p>.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports mismatches between DOM nodes with different content', function() {
|
||||
const nodeA = this.doc.createElement('div'),
|
||||
nodeB = this.doc.createElement('div');
|
||||
const nodeA = this.doc.createElement('div');
|
||||
const nodeB = this.doc.createElement('div');
|
||||
|
||||
nodeA.setAttribute('thing', 'foo');
|
||||
nodeB.setAttribute('thing', 'bar');
|
||||
|
||||
expect(nodeA.isEqualNode(nodeB)).toBe(false);
|
||||
const actual = { a: nodeA },
|
||||
expected = { a: nodeB },
|
||||
message =
|
||||
const actual = { a: nodeA };
|
||||
const expected = { a: nodeB };
|
||||
const message =
|
||||
'Expected $.a = <div thing="foo"> to equal <div thing="bar">.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
@@ -740,8 +747,11 @@ describe('toEqual', function() {
|
||||
const nodeA = this.doc.createElementNS(
|
||||
'http://www.w3.org/2000/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');
|
||||
nodeB.setAttribute('height', '30');
|
||||
@@ -754,33 +764,33 @@ describe('toEqual', function() {
|
||||
nodeA.appendChild(rect);
|
||||
|
||||
expect(nodeA.isEqualNode(nodeB)).toBe(false);
|
||||
const actual = { a: nodeA },
|
||||
expected = { a: nodeB },
|
||||
message =
|
||||
const actual = { a: nodeA };
|
||||
const expected = { a: nodeB };
|
||||
const message =
|
||||
'Expected $.a = <svg height="50">...</svg> to equal <svg height="30">.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports whole DOM node when attribute contains > character', function() {
|
||||
const nodeA = this.doc.createElement('div'),
|
||||
nodeB = this.doc.createElement('div');
|
||||
const nodeA = this.doc.createElement('div');
|
||||
const nodeB = this.doc.createElement('div');
|
||||
|
||||
nodeA.setAttribute('thing', '>>>');
|
||||
nodeB.setAttribute('thing', 'bar');
|
||||
|
||||
expect(nodeA.isEqualNode(nodeB)).toBe(false);
|
||||
const actual = { a: nodeA },
|
||||
expected = { a: nodeB },
|
||||
message =
|
||||
const actual = { a: nodeA };
|
||||
const expected = { a: nodeB };
|
||||
const message =
|
||||
'Expected $.a = <div thing=">>>"> to equal <div thing="bar">.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports no content when DOM node has multiple empty text nodes', function() {
|
||||
const nodeA = this.doc.createElement('div'),
|
||||
nodeB = this.doc.createElement('div');
|
||||
const nodeA = this.doc.createElement('div');
|
||||
const nodeB = this.doc.createElement('div');
|
||||
|
||||
nodeA.appendChild(this.doc.createTextNode(''));
|
||||
nodeA.appendChild(this.doc.createTextNode(''));
|
||||
@@ -788,85 +798,86 @@ describe('toEqual', function() {
|
||||
nodeA.appendChild(this.doc.createTextNode(''));
|
||||
|
||||
expect(nodeA.isEqualNode(nodeB)).toBe(false);
|
||||
const actual = { a: nodeA },
|
||||
expected = { a: nodeB },
|
||||
message = 'Expected $.a = <div> to equal <div>.';
|
||||
const actual = { a: nodeA };
|
||||
const expected = { a: nodeB };
|
||||
const message = 'Expected $.a = <div> to equal <div>.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports content when DOM node has non empty text node', function() {
|
||||
const nodeA = this.doc.createElement('div'),
|
||||
nodeB = this.doc.createElement('div');
|
||||
const nodeA = this.doc.createElement('div');
|
||||
const nodeB = this.doc.createElement('div');
|
||||
|
||||
nodeA.appendChild(this.doc.createTextNode('Hello Jasmine!'));
|
||||
|
||||
expect(nodeA.isEqualNode(nodeB)).toBe(false);
|
||||
const actual = { a: nodeA },
|
||||
expected = { a: nodeB },
|
||||
message = 'Expected $.a = <div>...</div> to equal <div>.';
|
||||
const actual = { a: nodeA };
|
||||
const expected = { a: nodeB };
|
||||
const message = 'Expected $.a = <div>...</div> to equal <div>.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports empty DOM attributes', function() {
|
||||
const nodeA = this.doc.createElement('div'),
|
||||
nodeB = this.doc.createElement('div');
|
||||
const nodeA = this.doc.createElement('div');
|
||||
const nodeB = this.doc.createElement('div');
|
||||
|
||||
nodeA.setAttribute('contenteditable', '');
|
||||
|
||||
expect(nodeA.isEqualNode(nodeB)).toBe(false);
|
||||
const actual = { a: nodeA },
|
||||
expected = { a: nodeB },
|
||||
message = 'Expected $.a = <div contenteditable> to equal <div>.';
|
||||
const actual = { a: nodeA };
|
||||
const expected = { a: nodeB };
|
||||
const message = 'Expected $.a = <div contenteditable> to equal <div>.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports 0 attr value as non empty DOM attribute', function() {
|
||||
const nodeA = this.doc.createElement('div'),
|
||||
nodeB = this.doc.createElement('div');
|
||||
const nodeA = this.doc.createElement('div');
|
||||
const nodeB = this.doc.createElement('div');
|
||||
|
||||
nodeA.setAttribute('contenteditable', 0);
|
||||
|
||||
expect(nodeA.isEqualNode(nodeB)).toBe(false);
|
||||
const actual = { a: nodeA },
|
||||
expected = { a: nodeB },
|
||||
message = 'Expected $.a = <div contenteditable="0"> to equal <div>.';
|
||||
const actual = { a: nodeA };
|
||||
const expected = { a: nodeB };
|
||||
const message =
|
||||
'Expected $.a = <div contenteditable="0"> to equal <div>.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('reports mismatches between a DOM node and a bare Object', function() {
|
||||
const actual = { a: this.doc.createElement('div') },
|
||||
expected = { a: {} },
|
||||
message = 'Expected $.a = <div> to equal Object({ }).';
|
||||
const actual = { a: this.doc.createElement('div') };
|
||||
const expected = { a: {} };
|
||||
const message = 'Expected $.a = <div> to equal Object({ }).';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
});
|
||||
|
||||
it('reports asymmetric mismatches', function() {
|
||||
const actual = { a: 1 },
|
||||
expected = { a: jasmineUnderTest.any(String) },
|
||||
message = 'Expected $.a = 1 to equal <jasmine.any(String)>.';
|
||||
const actual = { a: 1 };
|
||||
const expected = { a: jasmineUnderTest.any(String) };
|
||||
const message = 'Expected $.a = 1 to equal <jasmine.any(String)>.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
expect(compareEquals(actual, expected).pass).toBe(false);
|
||||
});
|
||||
|
||||
it('reports asymmetric mismatches when the asymmetric comparand is the actual value', function() {
|
||||
const actual = { a: jasmineUnderTest.any(String) },
|
||||
expected = { a: 1 },
|
||||
message = 'Expected $.a = <jasmine.any(String)> to equal 1.';
|
||||
const actual = { a: jasmineUnderTest.any(String) };
|
||||
const expected = { a: 1 };
|
||||
const message = 'Expected $.a = <jasmine.any(String)> to equal 1.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
expect(compareEquals(actual, expected).pass).toBe(false);
|
||||
});
|
||||
|
||||
it('does not report a mismatch when asymmetric matchers are satisfied', function() {
|
||||
const actual = { a: 'a' },
|
||||
expected = { a: jasmineUnderTest.any(String) };
|
||||
const actual = { a: 'a' };
|
||||
const expected = { a: jasmineUnderTest.any(String) };
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual('');
|
||||
expect(compareEquals(actual, expected).pass).toBe(true);
|
||||
@@ -920,11 +931,10 @@ describe('toEqual', function() {
|
||||
|
||||
describe('different length arrays', function() {
|
||||
it('actual array is longer', function() {
|
||||
const actual = [1, 1, 2, 3, 5],
|
||||
expected = [1, 1, 2, 3],
|
||||
message =
|
||||
'Expected $.length = 5 to equal 4.\n' +
|
||||
'Unexpected $[4] = 5 in array.';
|
||||
const actual = [1, 1, 2, 3, 5];
|
||||
const expected = [1, 1, 2, 3];
|
||||
const message =
|
||||
'Expected $.length = 5 to equal 4.\n' + 'Unexpected $[4] = 5 in array.';
|
||||
|
||||
expect(compareEquals(actual, expected).pass).toBe(false);
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
@@ -937,12 +947,12 @@ describe('toEqual', function() {
|
||||
}
|
||||
}
|
||||
|
||||
const actual = [1, 1, 2, 3, 5],
|
||||
expected = [1, 1, 2, 3],
|
||||
pp = privateUnderTest.makePrettyPrinter([formatter]),
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
matcher = privateUnderTest.matchers.toEqual(matchersUtil),
|
||||
message =
|
||||
const actual = [1, 1, 2, 3, 5];
|
||||
const expected = [1, 1, 2, 3];
|
||||
const pp = privateUnderTest.makePrettyPrinter([formatter]);
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||
const matcher = privateUnderTest.matchers.toEqual(matchersUtil);
|
||||
const message =
|
||||
'Expected $.length = |5| to equal |4|.\n' +
|
||||
'Unexpected $[4] = |5| in array.';
|
||||
|
||||
@@ -950,9 +960,9 @@ describe('toEqual', function() {
|
||||
});
|
||||
|
||||
it('expected array is longer', function() {
|
||||
const actual = [1, 1, 2, 3],
|
||||
expected = [1, 1, 2, 3, 5],
|
||||
message =
|
||||
const actual = [1, 1, 2, 3];
|
||||
const expected = [1, 1, 2, 3, 5];
|
||||
const message =
|
||||
'Expected $.length = 4 to equal 5.\n' +
|
||||
'Expected $[4] = undefined to equal 5.';
|
||||
|
||||
@@ -961,27 +971,27 @@ describe('toEqual', function() {
|
||||
});
|
||||
|
||||
it('undefined in middle of actual array', function() {
|
||||
const actual = [1, void 0, 3],
|
||||
expected = [1, 2, 3],
|
||||
message = 'Expected $[1] = undefined to equal 2.';
|
||||
const actual = [1, void 0, 3];
|
||||
const expected = [1, 2, 3];
|
||||
const message = 'Expected $[1] = undefined to equal 2.';
|
||||
|
||||
expect(compareEquals(actual, expected).pass).toBe(false);
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('undefined in middle of expected array', function() {
|
||||
const actual = [1, 2, 3],
|
||||
expected = [1, void 0, 3],
|
||||
message = 'Expected $[1] = 2 to equal undefined.';
|
||||
const actual = [1, 2, 3];
|
||||
const expected = [1, void 0, 3];
|
||||
const message = 'Expected $[1] = 2 to equal undefined.';
|
||||
|
||||
expect(compareEquals(actual, expected).pass).toBe(false);
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
it('actual array is longer by 4 elements', function() {
|
||||
const actual = [1, 1, 2, 3, 5, 8, 13],
|
||||
expected = [1, 1, 2],
|
||||
message =
|
||||
const actual = [1, 1, 2, 3, 5, 8, 13];
|
||||
const expected = [1, 1, 2];
|
||||
const message =
|
||||
'Expected $.length = 7 to equal 3.\n' +
|
||||
'Unexpected $[3] = 3 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() {
|
||||
const actual = [1, 1, 2],
|
||||
expected = [1, 1, 2, 3, 5, 8, 13],
|
||||
message =
|
||||
const actual = [1, 1, 2];
|
||||
const expected = [1, 1, 2, 3, 5, 8, 13];
|
||||
const message =
|
||||
'Expected $.length = 3 to equal 7.\n' +
|
||||
'Expected $[3] = undefined to equal 3.\n' +
|
||||
'Expected $[4] = undefined to equal 5.\n' +
|
||||
@@ -1007,9 +1017,9 @@ describe('toEqual', function() {
|
||||
});
|
||||
|
||||
it('different length and different elements', function() {
|
||||
const actual = [1],
|
||||
expected = [2, 3],
|
||||
message =
|
||||
const actual = [1];
|
||||
const expected = [2, 3];
|
||||
const message =
|
||||
'Expected $.length = 1 to equal 2.\n' +
|
||||
'Expected $[0] = 1 to equal 2.\n' +
|
||||
'Expected $[1] = undefined to equal 3.';
|
||||
@@ -1019,9 +1029,9 @@ describe('toEqual', function() {
|
||||
});
|
||||
|
||||
it('object with nested array (actual longer than expected)', function() {
|
||||
const actual = { values: [1, 1, 2, 3] },
|
||||
expected = { values: [1, 1, 2] },
|
||||
message =
|
||||
const actual = { values: [1, 1, 2, 3] };
|
||||
const expected = { values: [1, 1, 2] };
|
||||
const message =
|
||||
'Expected $.values.length = 4 to equal 3.\n' +
|
||||
'Unexpected $.values[3] = 3 in array.';
|
||||
|
||||
@@ -1030,9 +1040,9 @@ describe('toEqual', function() {
|
||||
});
|
||||
|
||||
it('object with nested array (expected longer than actual)', function() {
|
||||
const actual = { values: [1, 1, 2] },
|
||||
expected = { values: [1, 1, 2, 3] },
|
||||
message =
|
||||
const actual = { values: [1, 1, 2] };
|
||||
const expected = { values: [1, 1, 2, 3] };
|
||||
const message =
|
||||
'Expected $.values.length = 3 to equal 4.\n' +
|
||||
'Expected $.values[3] = undefined to equal 3.';
|
||||
|
||||
@@ -1041,9 +1051,9 @@ describe('toEqual', function() {
|
||||
});
|
||||
|
||||
it('array with unexpected nested object', function() {
|
||||
const actual = [1, 1, 2, { value: 3 }],
|
||||
expected = [1, 1, 2],
|
||||
message =
|
||||
const actual = [1, 1, 2, { value: 3 }];
|
||||
const expected = [1, 1, 2];
|
||||
const message =
|
||||
'Expected $.length = 4 to equal 3.\n' +
|
||||
'Unexpected $[3] = Object({ value: 3 }) in array.';
|
||||
|
||||
@@ -1052,9 +1062,9 @@ describe('toEqual', function() {
|
||||
});
|
||||
|
||||
it('array with missing nested object', function() {
|
||||
const actual = [1, 1, 2],
|
||||
expected = [1, 1, 2, { value: 3 }],
|
||||
message =
|
||||
const actual = [1, 1, 2];
|
||||
const expected = [1, 1, 2, { value: 3 }];
|
||||
const message =
|
||||
'Expected $.length = 3 to equal 4.\n' +
|
||||
'Expected $[3] = undefined to equal Object({ value: 3 }).';
|
||||
|
||||
@@ -1063,9 +1073,9 @@ describe('toEqual', function() {
|
||||
});
|
||||
|
||||
it('array with nested different length array', function() {
|
||||
const actual = [[1], [1, 2]],
|
||||
expected = [[1, 1], [2]],
|
||||
message =
|
||||
const actual = [[1], [1, 2]];
|
||||
const expected = [[1, 1], [2]];
|
||||
const message =
|
||||
'Expected $[0].length = 1 to equal 2.\n' +
|
||||
'Expected $[0][1] = undefined 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() {
|
||||
const actual = [1, 2],
|
||||
expected = [1, 2, void 0],
|
||||
message = 'Expected $.length = 2 to equal 3.';
|
||||
const actual = [1, 2];
|
||||
const expected = [1, 2, void 0];
|
||||
const message = 'Expected $.length = 2 to equal 3.';
|
||||
|
||||
expect(compareEquals(actual, expected).pass).toBe(false);
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
|
||||
@@ -2,9 +2,9 @@ describe('toHaveBeenCalledBefore', function() {
|
||||
it('throws an exception when the actual is not a spy', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {},
|
||||
spy = new privateUnderTest.Env().createSpy('a spy');
|
||||
});
|
||||
const fn = function() {};
|
||||
const spy = new privateUnderTest.Env().createSpy('a spy');
|
||||
|
||||
expect(function() {
|
||||
matcher.compare(fn, spy);
|
||||
@@ -14,9 +14,9 @@ describe('toHaveBeenCalledBefore', function() {
|
||||
it('throws an exception when the expected is not a spy', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
spy = new privateUnderTest.Env().createSpy('a spy'),
|
||||
fn = function() {};
|
||||
});
|
||||
const spy = new privateUnderTest.Env().createSpy('a spy');
|
||||
const fn = function() {};
|
||||
|
||||
expect(function() {
|
||||
matcher.compare(spy, fn);
|
||||
@@ -24,9 +24,9 @@ describe('toHaveBeenCalledBefore', function() {
|
||||
});
|
||||
|
||||
it('fails when the actual was not called', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(),
|
||||
firstSpy = new privateUnderTest.Spy('first spy'),
|
||||
secondSpy = new privateUnderTest.Spy('second spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore();
|
||||
const firstSpy = new privateUnderTest.Spy('first spy');
|
||||
const secondSpy = new privateUnderTest.Spy('second spy');
|
||||
|
||||
secondSpy();
|
||||
|
||||
@@ -38,9 +38,9 @@ describe('toHaveBeenCalledBefore', function() {
|
||||
});
|
||||
|
||||
it('fails when the expected was not called', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(),
|
||||
firstSpy = new privateUnderTest.Spy('first spy'),
|
||||
secondSpy = new privateUnderTest.Spy('second spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore();
|
||||
const firstSpy = new privateUnderTest.Spy('first spy');
|
||||
const secondSpy = new privateUnderTest.Spy('second spy');
|
||||
|
||||
firstSpy();
|
||||
|
||||
@@ -52,9 +52,9 @@ describe('toHaveBeenCalledBefore', function() {
|
||||
});
|
||||
|
||||
it('fails when the actual is called after the expected', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(),
|
||||
firstSpy = new privateUnderTest.Spy('first spy'),
|
||||
secondSpy = new privateUnderTest.Spy('second spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore();
|
||||
const firstSpy = new privateUnderTest.Spy('first spy');
|
||||
const secondSpy = new privateUnderTest.Spy('second spy');
|
||||
|
||||
secondSpy();
|
||||
firstSpy();
|
||||
@@ -67,9 +67,9 @@ describe('toHaveBeenCalledBefore', function() {
|
||||
});
|
||||
|
||||
it('fails when the actual is called before and after the expected', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(),
|
||||
firstSpy = new privateUnderTest.Spy('first spy'),
|
||||
secondSpy = new privateUnderTest.Spy('second spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore();
|
||||
const firstSpy = new privateUnderTest.Spy('first spy');
|
||||
const secondSpy = new privateUnderTest.Spy('second spy');
|
||||
|
||||
firstSpy();
|
||||
secondSpy();
|
||||
@@ -83,9 +83,9 @@ describe('toHaveBeenCalledBefore', function() {
|
||||
});
|
||||
|
||||
it('fails when the expected is called before and after the actual', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(),
|
||||
firstSpy = new privateUnderTest.Spy('first spy'),
|
||||
secondSpy = new privateUnderTest.Spy('second spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore();
|
||||
const firstSpy = new privateUnderTest.Spy('first spy');
|
||||
const secondSpy = new privateUnderTest.Spy('second spy');
|
||||
|
||||
secondSpy();
|
||||
firstSpy();
|
||||
@@ -99,9 +99,9 @@ describe('toHaveBeenCalledBefore', function() {
|
||||
});
|
||||
|
||||
it('passes when the actual is called before the expected', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(),
|
||||
firstSpy = new privateUnderTest.Spy('first spy'),
|
||||
secondSpy = new privateUnderTest.Spy('second spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore();
|
||||
const firstSpy = new privateUnderTest.Spy('first spy');
|
||||
const secondSpy = new privateUnderTest.Spy('second spy');
|
||||
|
||||
firstSpy();
|
||||
secondSpy();
|
||||
@@ -114,9 +114,9 @@ describe('toHaveBeenCalledBefore', function() {
|
||||
});
|
||||
|
||||
it('set the correct calls as verified when passing', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(),
|
||||
firstSpy = new privateUnderTest.Spy('first spy'),
|
||||
secondSpy = new privateUnderTest.Spy('second spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore();
|
||||
const firstSpy = new privateUnderTest.Spy('first spy');
|
||||
const secondSpy = new privateUnderTest.Spy('second spy');
|
||||
|
||||
firstSpy();
|
||||
secondSpy();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
describe('toHaveBeenCalledOnceWith', function() {
|
||||
it('passes when the actual was called only once and with matching parameters', function() {
|
||||
const pp = privateUnderTest.makePrettyPrinter(),
|
||||
util = new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util),
|
||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const util = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util);
|
||||
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
|
||||
calledSpy('a', 'b');
|
||||
const result = matcher.compare(calledSpy, 'a', 'b');
|
||||
@@ -19,14 +19,14 @@ describe('toHaveBeenCalledOnceWith', function() {
|
||||
function() {
|
||||
return true;
|
||||
}
|
||||
],
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
];
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
customTesters: customEqualityTesters
|
||||
}),
|
||||
matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(
|
||||
});
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(
|
||||
matchersUtil
|
||||
),
|
||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
);
|
||||
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
|
||||
calledSpy('a', 'b');
|
||||
const result = matcher.compare(calledSpy, 'a', 'a');
|
||||
@@ -35,10 +35,10 @@ describe('toHaveBeenCalledOnceWith', function() {
|
||||
});
|
||||
|
||||
it('fails when the actual was never called', function() {
|
||||
const pp = privateUnderTest.makePrettyPrinter(),
|
||||
util = new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util),
|
||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const util = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util);
|
||||
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
|
||||
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() {
|
||||
const pp = privateUnderTest.makePrettyPrinter(),
|
||||
util = new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util),
|
||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const util = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util);
|
||||
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
|
||||
calledSpy('a', 'c');
|
||||
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() {
|
||||
const pp = privateUnderTest.makePrettyPrinter(),
|
||||
util = new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util),
|
||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const util = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util);
|
||||
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
|
||||
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() {
|
||||
const pp = privateUnderTest.makePrettyPrinter(),
|
||||
util = new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util),
|
||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const util = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util);
|
||||
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
|
||||
calledSpy('a', 'b');
|
||||
calledSpy('a', 'c');
|
||||
@@ -96,10 +96,10 @@ describe('toHaveBeenCalledOnceWith', function() {
|
||||
});
|
||||
|
||||
it('throws an exception when the actual is not a spy', function() {
|
||||
const pp = privateUnderTest.makePrettyPrinter(),
|
||||
util = new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util),
|
||||
fn = function() {};
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const util = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util);
|
||||
const fn = function() {};
|
||||
|
||||
expect(function() {
|
||||
matcher.compare(fn);
|
||||
@@ -107,10 +107,10 @@ describe('toHaveBeenCalledOnceWith', function() {
|
||||
});
|
||||
|
||||
it('set the correct calls as verified when passing', function() {
|
||||
const pp = privateUnderTest.makePrettyPrinter(),
|
||||
util = new privateUnderTest.MatchersUtil({ pp: pp }),
|
||||
matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util),
|
||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
const pp = privateUnderTest.makePrettyPrinter();
|
||||
const util = new privateUnderTest.MatchersUtil({ pp: pp });
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util);
|
||||
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
|
||||
calledSpy('x');
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('toHaveBeenCalled', function() {
|
||||
it('passes when the actual was called, with a custom .not fail message', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalled(),
|
||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalled();
|
||||
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
|
||||
calledSpy();
|
||||
|
||||
@@ -13,8 +13,8 @@ describe('toHaveBeenCalled', function() {
|
||||
});
|
||||
|
||||
it('fails when the actual was not called', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalled(),
|
||||
uncalledSpy = new privateUnderTest.Spy('uncalled spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalled();
|
||||
const uncalledSpy = new privateUnderTest.Spy('uncalled spy');
|
||||
|
||||
const result = matcher.compare(uncalledSpy);
|
||||
expect(result.pass).toBe(false);
|
||||
@@ -23,8 +23,8 @@ describe('toHaveBeenCalled', function() {
|
||||
it('throws an exception when the actual is not a spy', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalled({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {};
|
||||
});
|
||||
const fn = function() {};
|
||||
|
||||
expect(function() {
|
||||
matcher.compare(fn);
|
||||
@@ -32,8 +32,8 @@ describe('toHaveBeenCalled', function() {
|
||||
});
|
||||
|
||||
it('throws an exception when invoked with any arguments', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalled(),
|
||||
spy = new privateUnderTest.Spy('sample spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalled();
|
||||
const spy = new privateUnderTest.Spy('sample spy');
|
||||
|
||||
expect(function() {
|
||||
matcher.compare(spy, 'foo');
|
||||
@@ -41,8 +41,8 @@ describe('toHaveBeenCalled', function() {
|
||||
});
|
||||
|
||||
it('has a custom message on failure', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalled(),
|
||||
spy = new privateUnderTest.Spy('sample-spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalled();
|
||||
const spy = new privateUnderTest.Spy('sample-spy');
|
||||
|
||||
const result = matcher.compare(spy);
|
||||
|
||||
@@ -52,8 +52,8 @@ describe('toHaveBeenCalled', function() {
|
||||
});
|
||||
|
||||
it('set the correct calls as verified when passing', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalled(),
|
||||
spy = new privateUnderTest.Spy('sample-spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalled();
|
||||
const spy = new privateUnderTest.Spy('sample-spy');
|
||||
|
||||
spy();
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
describe('toHaveBeenCalledTimes', function() {
|
||||
it('passes when the actual 0 matches the expected 0 ', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||
calledSpy = new privateUnderTest.Spy('called-spy'),
|
||||
result = matcher.compare(calledSpy, 0);
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes();
|
||||
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
const result = matcher.compare(calledSpy, 0);
|
||||
expect(result.pass).toBeTruthy();
|
||||
});
|
||||
it('passes when the actual matches the expected', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes();
|
||||
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
calledSpy();
|
||||
|
||||
const result = matcher.compare(calledSpy, 1);
|
||||
@@ -15,8 +15,8 @@ describe('toHaveBeenCalledTimes', function() {
|
||||
});
|
||||
|
||||
it('fails when expected numbers is not supplied', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||
spy = new privateUnderTest.Spy('spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes();
|
||||
const spy = new privateUnderTest.Spy('spy');
|
||||
|
||||
spy();
|
||||
expect(function() {
|
||||
@@ -27,16 +27,16 @@ describe('toHaveBeenCalledTimes', function() {
|
||||
});
|
||||
|
||||
it('fails when the actual was called less than the expected', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||
uncalledSpy = new privateUnderTest.Spy('uncalled spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes();
|
||||
const uncalledSpy = new privateUnderTest.Spy('uncalled spy');
|
||||
|
||||
const result = matcher.compare(uncalledSpy, 2);
|
||||
expect(result.pass).toBe(false);
|
||||
});
|
||||
|
||||
it('fails when the actual was called more than expected', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||
uncalledSpy = new privateUnderTest.Spy('uncalled spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes();
|
||||
const uncalledSpy = new privateUnderTest.Spy('uncalled spy');
|
||||
|
||||
uncalledSpy();
|
||||
uncalledSpy();
|
||||
@@ -48,8 +48,8 @@ describe('toHaveBeenCalledTimes', function() {
|
||||
it('throws an exception when the actual is not a spy', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {};
|
||||
});
|
||||
const fn = function() {};
|
||||
|
||||
expect(function() {
|
||||
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() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||
spy = new privateUnderTest.Spy('sample-spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes();
|
||||
const spy = new privateUnderTest.Spy('sample-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() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||
spy = new privateUnderTest.Spy('sample-spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes();
|
||||
const spy = new privateUnderTest.Spy('sample-spy');
|
||||
spy();
|
||||
spy();
|
||||
spy();
|
||||
@@ -89,8 +89,8 @@ describe('toHaveBeenCalledTimes', function() {
|
||||
});
|
||||
|
||||
it('set the correct calls as verified when passing', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||
spy = new privateUnderTest.Spy('sample-spy');
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes();
|
||||
const spy = new privateUnderTest.Spy('sample-spy');
|
||||
|
||||
spy();
|
||||
spy();
|
||||
|
||||
@@ -4,9 +4,11 @@ describe('toHaveBeenCalledWith', function() {
|
||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
|
||||
equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
|
||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
};
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
|
||||
matchersUtil
|
||||
);
|
||||
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
|
||||
calledSpy('a', 'b');
|
||||
const result = matcher.compare(calledSpy, 'a', 'b');
|
||||
@@ -22,12 +24,14 @@ describe('toHaveBeenCalledWith', function() {
|
||||
function() {
|
||||
return true;
|
||||
}
|
||||
],
|
||||
matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
];
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
customTesters: customEqualityTesters
|
||||
}),
|
||||
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
|
||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
});
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
|
||||
matchersUtil
|
||||
);
|
||||
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
|
||||
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() {
|
||||
const matchersUtil = {
|
||||
contains: jasmine
|
||||
.createSpy('delegated-contains')
|
||||
.and.returnValue(false),
|
||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(false),
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
|
||||
uncalledSpy = new privateUnderTest.Spy('uncalled spy');
|
||||
};
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
|
||||
matchersUtil
|
||||
);
|
||||
const uncalledSpy = new privateUnderTest.Spy('uncalled spy');
|
||||
|
||||
const result = matcher.compare(uncalledSpy);
|
||||
expect(result.pass).toBe(false);
|
||||
@@ -54,9 +58,11 @@ describe('toHaveBeenCalledWith', function() {
|
||||
it('fails when the actual was called with different parameters', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
|
||||
calledSpy = new privateUnderTest.Spy('called spy');
|
||||
});
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
|
||||
matchersUtil
|
||||
);
|
||||
const calledSpy = new privateUnderTest.Spy('called spy');
|
||||
|
||||
calledSpy('a');
|
||||
calledSpy('c', 'd');
|
||||
@@ -86,8 +92,8 @@ describe('toHaveBeenCalledWith', function() {
|
||||
it('throws an exception when the actual is not a spy', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {};
|
||||
});
|
||||
const fn = function() {};
|
||||
|
||||
expect(function() {
|
||||
matcher.compare(fn);
|
||||
@@ -99,9 +105,11 @@ describe('toHaveBeenCalledWith', function() {
|
||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
|
||||
equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
|
||||
calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
};
|
||||
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
|
||||
matchersUtil
|
||||
);
|
||||
const calledSpy = new privateUnderTest.Spy('called-spy');
|
||||
|
||||
calledSpy('a', 'b');
|
||||
matcher.compare(calledSpy, 'a', 'b');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('toHaveClass', function() {
|
||||
it('fails for a DOM element that lacks the expected class', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveClass(),
|
||||
result = matcher.compare(
|
||||
const matcher = privateUnderTest.matchers.toHaveClass();
|
||||
const result = matcher.compare(
|
||||
specHelpers.domHelpers.createElementWithClassName(''),
|
||||
'foo'
|
||||
);
|
||||
@@ -10,8 +10,8 @@ describe('toHaveClass', function() {
|
||||
});
|
||||
|
||||
it('passes for a DOM element that has the expected class', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveClass(),
|
||||
el = specHelpers.domHelpers.createElementWithClassName('foo bar baz');
|
||||
const matcher = privateUnderTest.matchers.toHaveClass();
|
||||
const el = specHelpers.domHelpers.createElementWithClassName('foo bar baz');
|
||||
|
||||
expect(matcher.compare(el, 'foo').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() {
|
||||
const matcher = privateUnderTest.matchers.toHaveClass(),
|
||||
el = specHelpers.domHelpers.createElementWithClassName('foo bar');
|
||||
const matcher = privateUnderTest.matchers.toHaveClass();
|
||||
const el = specHelpers.domHelpers.createElementWithClassName('foo bar');
|
||||
|
||||
expect(matcher.compare(el, 'fo').pass).toBe(false);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('toHaveClasses', function() {
|
||||
it('fails for a DOM element that lacks all the expected classes', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveClasses(),
|
||||
result = matcher.compare(
|
||||
const matcher = privateUnderTest.matchers.toHaveClasses();
|
||||
const result = matcher.compare(
|
||||
specHelpers.domHelpers.createElementWithClassName(''),
|
||||
['foo', 'bar']
|
||||
);
|
||||
@@ -10,15 +10,15 @@ describe('toHaveClasses', function() {
|
||||
});
|
||||
|
||||
it('passes for a DOM element that has all the expected classes', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveClasses(),
|
||||
el = specHelpers.domHelpers.createElementWithClassName('foo bar baz');
|
||||
const matcher = privateUnderTest.matchers.toHaveClasses();
|
||||
const el = specHelpers.domHelpers.createElementWithClassName('foo bar baz');
|
||||
|
||||
expect(matcher.compare(el, ['foo', 'bar']).pass).toBe(true);
|
||||
});
|
||||
|
||||
it('fails for a DOM element that only has some matching classes', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveClasses(),
|
||||
el = specHelpers.domHelpers.createElementWithClassName('foo bar');
|
||||
const matcher = privateUnderTest.matchers.toHaveClasses();
|
||||
const el = specHelpers.domHelpers.createElementWithClassName('foo bar');
|
||||
|
||||
expect(matcher.compare(el, ['foo', 'can']).pass).toBe(false);
|
||||
});
|
||||
|
||||
@@ -131,14 +131,14 @@ describe('toHaveNoOtherSpyInteractions', function() {
|
||||
it('handles multiple interactions with a single spy', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.matchers.toHaveNoOtherSpyInteractions(
|
||||
});
|
||||
const matcher = privateUnderTest.matchers.toHaveNoOtherSpyInteractions(
|
||||
matchersUtil
|
||||
),
|
||||
toHaveBeenCalledWithMatcher = privateUnderTest.matchers.toHaveBeenCalledWith(
|
||||
);
|
||||
const toHaveBeenCalledWithMatcher = privateUnderTest.matchers.toHaveBeenCalledWith(
|
||||
matchersUtil
|
||||
),
|
||||
spyObj = jasmineUnderTest
|
||||
);
|
||||
const spyObj = jasmineUnderTest
|
||||
.getEnv()
|
||||
.createSpyObj('NewClass', ['spyA', 'spyB']);
|
||||
|
||||
|
||||
@@ -2,15 +2,15 @@ describe('toHaveSize', function() {
|
||||
'use strict';
|
||||
|
||||
it('passes for an array whose length matches', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
||||
result = matcher.compare([1, 2], 2);
|
||||
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||
const result = matcher.compare([1, 2], 2);
|
||||
|
||||
expect(result.pass).toBe(true);
|
||||
});
|
||||
|
||||
it('fails for an array whose length does not match', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
||||
result = matcher.compare([1, 2, 3], 2);
|
||||
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||
const result = matcher.compare([1, 2, 3], 2);
|
||||
|
||||
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() {
|
||||
const matcher = privateUnderTest.matchers.toHaveSize({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
result = matcher.compare([1, 2, 3], 2);
|
||||
});
|
||||
const result = matcher.compare([1, 2, 3], 2);
|
||||
|
||||
expect(result.message()).toEqual(
|
||||
'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() {
|
||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
||||
result = matcher.compare({ a: 1, b: 2 }, 2);
|
||||
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||
const result = matcher.compare({ a: 1, b: 2 }, 2);
|
||||
|
||||
expect(result.pass).toBe(true);
|
||||
});
|
||||
|
||||
it('fails for an object with a different number of keys', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
||||
result = matcher.compare({ a: 1, b: 2 }, 1);
|
||||
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||
const result = matcher.compare({ a: 1, b: 2 }, 1);
|
||||
|
||||
expect(result.pass).toBe(false);
|
||||
});
|
||||
|
||||
it('passes for an object with an explicit `length` property that matches', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
||||
result = matcher.compare({ a: 1, b: 2, length: 5 }, 5);
|
||||
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||
const result = matcher.compare({ a: 1, b: 2, length: 5 }, 5);
|
||||
|
||||
expect(result.pass).toBe(true);
|
||||
});
|
||||
|
||||
it('fails for an object with an explicit `length` property that does not match', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
||||
result = matcher.compare({ a: 1, b: 2, length: 5 }, 1);
|
||||
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||
const result = matcher.compare({ a: 1, b: 2, length: 5 }, 1);
|
||||
|
||||
expect(result.pass).toBe(false);
|
||||
});
|
||||
|
||||
it('passes for a string whose length matches', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
||||
result = matcher.compare('ab', 2);
|
||||
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||
const result = matcher.compare('ab', 2);
|
||||
|
||||
expect(result.pass).toBe(true);
|
||||
});
|
||||
|
||||
it('fails for a string whose length does not match', function() {
|
||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
||||
result = matcher.compare('abc', 2);
|
||||
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||
const result = matcher.compare('abc', 2);
|
||||
|
||||
expect(result.pass).toBe(false);
|
||||
});
|
||||
@@ -73,8 +73,8 @@ describe('toHaveSize', function() {
|
||||
map.set('a', 1);
|
||||
map.set('b', 2);
|
||||
|
||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
||||
result = matcher.compare(map, 2);
|
||||
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||
const result = matcher.compare(map, 2);
|
||||
|
||||
expect(result.pass).toBe(true);
|
||||
});
|
||||
@@ -84,8 +84,8 @@ describe('toHaveSize', function() {
|
||||
map.set('a', 1);
|
||||
map.set('b', 2);
|
||||
|
||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
||||
result = matcher.compare(map, 1);
|
||||
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||
const result = matcher.compare(map, 1);
|
||||
|
||||
expect(result.pass).toBe(false);
|
||||
});
|
||||
@@ -95,8 +95,8 @@ describe('toHaveSize', function() {
|
||||
set.add('a');
|
||||
set.add('b');
|
||||
|
||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
||||
result = matcher.compare(set, 2);
|
||||
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||
const result = matcher.compare(set, 2);
|
||||
|
||||
expect(result.pass).toBe(true);
|
||||
});
|
||||
@@ -106,8 +106,8 @@ describe('toHaveSize', function() {
|
||||
set.add('a');
|
||||
set.add('b');
|
||||
|
||||
const matcher = privateUnderTest.matchers.toHaveSize(),
|
||||
result = matcher.compare(set, 1);
|
||||
const matcher = privateUnderTest.matchers.toHaveSize();
|
||||
const result = matcher.compare(set, 1);
|
||||
|
||||
expect(result.pass).toBe(false);
|
||||
});
|
||||
|
||||
@@ -8,8 +8,8 @@ describe('toThrowError', function() {
|
||||
});
|
||||
|
||||
it('throws an error when the expected is not an Error, string, or RegExp', function() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
||||
fn = function() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError();
|
||||
const fn = function() {
|
||||
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() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
||||
fn = function() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError();
|
||||
const fn = function() {
|
||||
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() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
||||
fn = function() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError();
|
||||
const fn = function() {
|
||||
throw new Error('foo');
|
||||
};
|
||||
|
||||
@@ -41,8 +41,8 @@ describe('toThrowError', function() {
|
||||
});
|
||||
|
||||
it('fails if actual does not throw at all', function() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
||||
fn = function() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError();
|
||||
const fn = function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -55,8 +55,8 @@ describe('toThrowError', function() {
|
||||
it('fails if thrown is not an instanceof Error', function() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {
|
||||
});
|
||||
const fn = function() {
|
||||
throw 4;
|
||||
};
|
||||
|
||||
@@ -105,8 +105,8 @@ describe('toThrowError', function() {
|
||||
it('fails with the correct message if thrown is a falsy value', function() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {
|
||||
});
|
||||
const fn = function() {
|
||||
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() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
||||
fn = function() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError();
|
||||
const fn = function() {
|
||||
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() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {
|
||||
});
|
||||
const fn = function() {
|
||||
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() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {
|
||||
});
|
||||
const fn = function() {
|
||||
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() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {
|
||||
});
|
||||
const fn = function() {
|
||||
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() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {
|
||||
});
|
||||
const fn = function() {
|
||||
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() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
||||
fn = function() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError();
|
||||
const fn = function() {
|
||||
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() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
||||
CustomError = function CustomError(arg) {
|
||||
const matcher = privateUnderTest.matchers.toThrowError();
|
||||
const CustomError = function CustomError(arg) {
|
||||
arg.x;
|
||||
},
|
||||
fn = function() {
|
||||
};
|
||||
const fn = function() {
|
||||
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() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
||||
fn = function() {
|
||||
const matcher = privateUnderTest.matchers.toThrowError();
|
||||
const fn = function() {
|
||||
throw new Error();
|
||||
};
|
||||
|
||||
@@ -244,9 +244,9 @@ describe('toThrowError', function() {
|
||||
const matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
|
||||
fn = function() {
|
||||
};
|
||||
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
|
||||
const fn = function() {
|
||||
throw new TypeError('foo');
|
||||
};
|
||||
|
||||
@@ -262,12 +262,12 @@ describe('toThrowError', function() {
|
||||
const matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
|
||||
CustomError = function CustomError(arg) {
|
||||
};
|
||||
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
|
||||
const CustomError = function CustomError(arg) {
|
||||
this.message = arg.message;
|
||||
},
|
||||
fn = function() {
|
||||
};
|
||||
const fn = function() {
|
||||
throw new CustomError({ message: 'foo' });
|
||||
};
|
||||
|
||||
@@ -286,9 +286,9 @@ describe('toThrowError', function() {
|
||||
const matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
|
||||
fn = function() {
|
||||
};
|
||||
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
|
||||
const fn = function() {
|
||||
throw new TypeError('foo');
|
||||
};
|
||||
|
||||
@@ -306,9 +306,9 @@ describe('toThrowError', function() {
|
||||
const matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
|
||||
fn = function() {
|
||||
};
|
||||
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
|
||||
const fn = function() {
|
||||
throw new TypeError('foo');
|
||||
};
|
||||
|
||||
@@ -325,9 +325,9 @@ describe('toThrowError', function() {
|
||||
const matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
|
||||
fn = function() {
|
||||
};
|
||||
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
|
||||
const fn = function() {
|
||||
throw new TypeError('foo');
|
||||
};
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ describe('toThrowMatching', function() {
|
||||
});
|
||||
|
||||
it('throws an error when the expected is not a function', function() {
|
||||
const matcher = privateUnderTest.matchers.toThrowMatching(),
|
||||
fn = function() {
|
||||
const matcher = privateUnderTest.matchers.toThrowMatching();
|
||||
const fn = function() {
|
||||
throw new Error('foo');
|
||||
};
|
||||
|
||||
@@ -21,8 +21,8 @@ describe('toThrowMatching', function() {
|
||||
});
|
||||
|
||||
it('fails if actual does not throw at all', function() {
|
||||
const matcher = privateUnderTest.matchers.toThrowMatching(),
|
||||
fn = function() {
|
||||
const matcher = privateUnderTest.matchers.toThrowMatching();
|
||||
const fn = function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -37,8 +37,8 @@ describe('toThrowMatching', function() {
|
||||
it('fails with the correct message if thrown is a falsy value', function() {
|
||||
const matcher = privateUnderTest.matchers.toThrowMatching({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {
|
||||
});
|
||||
const fn = function() {
|
||||
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() {
|
||||
const matcher = privateUnderTest.matchers.toThrowMatching(),
|
||||
predicate = function(e) {
|
||||
const matcher = privateUnderTest.matchers.toThrowMatching();
|
||||
const predicate = function(e) {
|
||||
return e.message === 'nope';
|
||||
},
|
||||
fn = function() {
|
||||
};
|
||||
const fn = function() {
|
||||
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() {
|
||||
const matcher = privateUnderTest.matchers.toThrowMatching({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
predicate = function(e) {
|
||||
});
|
||||
const predicate = function(e) {
|
||||
return e.message === 'oh no';
|
||||
},
|
||||
fn = function() {
|
||||
};
|
||||
const fn = function() {
|
||||
throw new TypeError('nope');
|
||||
};
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ describe('toThrow', function() {
|
||||
});
|
||||
|
||||
it('fails if actual does not throw', function() {
|
||||
const matcher = privateUnderTest.matchers.toThrow(),
|
||||
fn = function() {
|
||||
const matcher = privateUnderTest.matchers.toThrow();
|
||||
const fn = function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -24,9 +24,9 @@ describe('toThrow', function() {
|
||||
const matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = privateUnderTest.matchers.toThrow(matchersUtil),
|
||||
fn = function() {
|
||||
};
|
||||
const matcher = privateUnderTest.matchers.toThrow(matchersUtil);
|
||||
const fn = function() {
|
||||
throw 5;
|
||||
};
|
||||
|
||||
@@ -41,8 +41,8 @@ describe('toThrow', function() {
|
||||
it('passes even if what is thrown is falsy', function() {
|
||||
const matcher = privateUnderTest.matchers.toThrow({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {
|
||||
});
|
||||
const fn = function() {
|
||||
throw undefined;
|
||||
};
|
||||
|
||||
@@ -57,9 +57,9 @@ describe('toThrow', function() {
|
||||
const matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = privateUnderTest.matchers.toThrow(matchersUtil),
|
||||
fn = function() {
|
||||
};
|
||||
const matcher = privateUnderTest.matchers.toThrow(matchersUtil);
|
||||
const fn = function() {
|
||||
throw 5;
|
||||
};
|
||||
|
||||
@@ -73,9 +73,9 @@ describe('toThrow', function() {
|
||||
const matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = privateUnderTest.matchers.toThrow(matchersUtil),
|
||||
fn = function() {
|
||||
};
|
||||
const matcher = privateUnderTest.matchers.toThrow(matchersUtil);
|
||||
const fn = function() {
|
||||
throw 5;
|
||||
};
|
||||
|
||||
@@ -91,9 +91,9 @@ describe('toThrow', function() {
|
||||
const matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = privateUnderTest.matchers.toThrow(matchersUtil),
|
||||
fn = function() {
|
||||
};
|
||||
const matcher = privateUnderTest.matchers.toThrow(matchersUtil);
|
||||
const fn = function() {
|
||||
throw 5;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
toHaveFailedExpectationsForRunnable: function() {
|
||||
return {
|
||||
compare: function(actual, fullName, expectedFailures) {
|
||||
let foundRunnable = false,
|
||||
expectations = true,
|
||||
foundFailures = [];
|
||||
let foundRunnable = false;
|
||||
let expectations = true;
|
||||
let foundFailures = [];
|
||||
|
||||
for (let i = 0; i < actual.calls.count(); i++) {
|
||||
const args = actual.calls.argsFor(i)[0];
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(function() {
|
||||
const path = require('path'),
|
||||
glob = require('glob');
|
||||
const path = require('path');
|
||||
const glob = require('glob');
|
||||
|
||||
const jasmineUnderTestRequire = require(path.join(
|
||||
__dirname,
|
||||
|
||||
@@ -14,11 +14,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('emits a deprecation warning', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -32,11 +32,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('builds the initial DOM elements, including the title banner', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -62,11 +62,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('builds a single reporter even if initialized multiple times', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -130,11 +130,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('reports the status symbol of a excluded spec', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -156,11 +156,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('reports the status symbol of a pending spec', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -179,11 +179,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('reports the status symbol of a passing spec', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -203,11 +203,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('reports the status symbol of a failing spec', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -229,11 +229,11 @@ describe('HtmlReporter', function() {
|
||||
|
||||
describe('when there are deprecation warnings', function() {
|
||||
it('displays the messages in their own alert bars', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -278,11 +278,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('displays expandable stack traces', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -322,11 +322,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('omits the expander when there is no stack trace', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -349,11 +349,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('nicely formats the verboseDeprecations note', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -384,11 +384,11 @@ describe('HtmlReporter', function() {
|
||||
if (!window.console) {
|
||||
window.console = { error: function() {} };
|
||||
}
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -422,11 +422,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('reports the run time', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -444,11 +444,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('reports the suite names with status, and spec names with status and duration', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
addToExistingQueryString: function(key, value) {
|
||||
@@ -561,11 +561,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('has an options menu', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -575,8 +575,8 @@ describe('HtmlReporter', function() {
|
||||
|
||||
const trigger = container.querySelector(
|
||||
'.jasmine-run-options .jasmine-trigger'
|
||||
),
|
||||
payload = container.querySelector(
|
||||
);
|
||||
const payload = container.querySelector(
|
||||
'.jasmine-run-options .jasmine-payload'
|
||||
);
|
||||
|
||||
@@ -593,11 +593,11 @@ describe('HtmlReporter', function() {
|
||||
|
||||
describe('when there are global errors', function() {
|
||||
it('displays the exceptions in their own alert bars', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -671,11 +671,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('displays file and line information if available', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -707,11 +707,11 @@ describe('HtmlReporter', function() {
|
||||
|
||||
describe('UI for stop on spec failure', function() {
|
||||
it('should be unchecked for full execution', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -724,11 +724,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('should be checked if stopping short', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -743,12 +743,12 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('should navigate and turn the setting on', function() {
|
||||
const container = document.createElement('div'),
|
||||
navigationHandler = jasmine.createSpy('navigate'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const navigationHandler = jasmine.createSpy('navigate');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
navigateWithNewParam: navigationHandler,
|
||||
getContainer: getContainer
|
||||
@@ -767,12 +767,12 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('should navigate and turn the setting off', function() {
|
||||
const container = document.createElement('div'),
|
||||
navigationHandler = jasmine.createSpy('navigate'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const navigationHandler = jasmine.createSpy('navigate');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
navigateWithNewParam: navigationHandler,
|
||||
getContainer: getContainer
|
||||
@@ -795,11 +795,11 @@ describe('HtmlReporter', function() {
|
||||
|
||||
describe('UI for throwing errors on expectation failures', function() {
|
||||
it('should be unchecked if not throwing', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -814,11 +814,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('should be checked if throwing', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -835,12 +835,12 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('should navigate and change the setting to on', function() {
|
||||
const container = document.createElement('div'),
|
||||
navigateHandler = jasmine.createSpy('navigate'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const navigateHandler = jasmine.createSpy('navigate');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
navigateWithNewParam: navigateHandler
|
||||
@@ -861,12 +861,12 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('should navigate and change the setting to off', function() {
|
||||
const container = document.createElement('div'),
|
||||
navigateHandler = jasmine.createSpy('navigate'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const navigateHandler = jasmine.createSpy('navigate');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
navigateWithNewParam: navigateHandler
|
||||
@@ -937,11 +937,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('should not display specs that have been disabled', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -965,11 +965,11 @@ describe('HtmlReporter', function() {
|
||||
|
||||
describe('UI for running tests in random order', function() {
|
||||
it('should be unchecked if not randomizing', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -983,11 +983,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('should be checked if randomizing', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -1001,12 +1001,12 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('should navigate and change the setting to on', function() {
|
||||
const container = document.createElement('div'),
|
||||
navigateHandler = jasmine.createSpy('navigate'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const navigateHandler = jasmine.createSpy('navigate');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
navigateWithNewParam: navigateHandler
|
||||
@@ -1023,12 +1023,12 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('should navigate and change the setting to off', function() {
|
||||
const container = document.createElement('div'),
|
||||
navigateHandler = jasmine.createSpy('navigate'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const navigateHandler = jasmine.createSpy('navigate');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
navigateWithNewParam: navigateHandler
|
||||
@@ -1045,11 +1045,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('should show the seed bar if randomizing', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -1069,11 +1069,11 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('should not show the current seed bar if not randomizing', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -1114,8 +1114,8 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
|
||||
it('should include non-spec query params in the jasmine-skipped link when present', function() {
|
||||
const container = document.createElement('div'),
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
const container = document.createElement('div');
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: function() {
|
||||
return container;
|
||||
@@ -1141,8 +1141,8 @@ describe('HtmlReporter', function() {
|
||||
container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -1465,8 +1465,8 @@ describe('HtmlReporter', function() {
|
||||
it('reports traces when present', function() {
|
||||
const specFailure = container.querySelectorAll(
|
||||
'.jasmine-spec-detail.jasmine-failed'
|
||||
)[2],
|
||||
debugLogs = specFailure.querySelector('.jasmine-debug-log table');
|
||||
)[2];
|
||||
const debugLogs = specFailure.querySelector('.jasmine-debug-log table');
|
||||
|
||||
expect(debugLogs).toBeTruthy();
|
||||
const rows = debugLogs.querySelectorAll('tbody tr');
|
||||
@@ -1570,11 +1570,11 @@ describe('HtmlReporter', function() {
|
||||
describe('The overall result bar', function() {
|
||||
describe("When the jasmineDone event's overallStatus is 'passed'", function() {
|
||||
it('has class jasmine-passed', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -1594,11 +1594,11 @@ describe('HtmlReporter', function() {
|
||||
|
||||
describe("When the jasmineDone event's overallStatus is 'failed'", function() {
|
||||
it('has class jasmine-failed', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
@@ -1618,11 +1618,11 @@ describe('HtmlReporter', function() {
|
||||
|
||||
describe("When the jasmineDone event's overallStatus is 'incomplete'", function() {
|
||||
it('has class jasmine-incomplete', function() {
|
||||
const container = document.createElement('div'),
|
||||
getContainer = function() {
|
||||
const container = document.createElement('div');
|
||||
const getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
};
|
||||
const reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer
|
||||
});
|
||||
|
||||
@@ -607,8 +607,8 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
const trigger = container.querySelector(
|
||||
'.jasmine-run-options .jasmine-trigger'
|
||||
),
|
||||
payload = container.querySelector(
|
||||
);
|
||||
const payload = container.querySelector(
|
||||
'.jasmine-run-options .jasmine-payload'
|
||||
);
|
||||
|
||||
@@ -1203,8 +1203,8 @@ describe('HtmlReporterV2', function() {
|
||||
it('reports traces when present', function() {
|
||||
const specFailure = container.querySelectorAll(
|
||||
'.jasmine-spec-detail.jasmine-failed'
|
||||
)[2],
|
||||
debugLogs = specFailure.querySelector('.jasmine-debug-log table');
|
||||
)[2];
|
||||
const debugLogs = specFailure.querySelector('.jasmine-debug-log table');
|
||||
|
||||
expect(debugLogs).toBeTruthy();
|
||||
const rows = debugLogs.querySelectorAll('tbody tr');
|
||||
|
||||
@@ -3,8 +3,8 @@ describe('QueryString', function() {
|
||||
it('sets the query string to include the given key/value pair', function() {
|
||||
const windowLocation = {
|
||||
search: ''
|
||||
},
|
||||
queryString = new jasmineUnderTest.QueryString({
|
||||
};
|
||||
const queryString = new jasmineUnderTest.QueryString({
|
||||
getWindowLocation: function() {
|
||||
return windowLocation;
|
||||
}
|
||||
@@ -18,8 +18,8 @@ describe('QueryString', function() {
|
||||
it('leaves existing params alone', function() {
|
||||
const windowLocation = {
|
||||
search: '?foo=bar'
|
||||
},
|
||||
queryString = new jasmineUnderTest.QueryString({
|
||||
};
|
||||
const queryString = new jasmineUnderTest.QueryString({
|
||||
getWindowLocation: function() {
|
||||
return windowLocation;
|
||||
}
|
||||
@@ -36,8 +36,8 @@ describe('QueryString', function() {
|
||||
it('gets the query string including the given key/value pair', function() {
|
||||
const windowLocation = {
|
||||
search: '?foo=bar'
|
||||
},
|
||||
queryString = new jasmineUnderTest.QueryString({
|
||||
};
|
||||
const queryString = new jasmineUnderTest.QueryString({
|
||||
getWindowLocation: function() {
|
||||
return windowLocation;
|
||||
}
|
||||
@@ -54,8 +54,8 @@ describe('QueryString', function() {
|
||||
it('returns the value of the requested key', function() {
|
||||
const windowLocation = {
|
||||
search: '?baz=quux%20corge'
|
||||
},
|
||||
queryString = new jasmineUnderTest.QueryString({
|
||||
};
|
||||
const queryString = new jasmineUnderTest.QueryString({
|
||||
getWindowLocation: function() {
|
||||
return windowLocation;
|
||||
}
|
||||
@@ -67,8 +67,8 @@ describe('QueryString', function() {
|
||||
it('returns null if the key is not present', function() {
|
||||
const windowLocation = {
|
||||
search: ''
|
||||
},
|
||||
queryString = new jasmineUnderTest.QueryString({
|
||||
};
|
||||
const queryString = new jasmineUnderTest.QueryString({
|
||||
getWindowLocation: function() {
|
||||
return windowLocation;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ describe('ResultsNode', function() {
|
||||
const fakeResult = {
|
||||
id: 123,
|
||||
message: 'foo'
|
||||
},
|
||||
node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
|
||||
};
|
||||
const node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
|
||||
|
||||
expect(node.result).toBe(fakeResult);
|
||||
expect(node.type).toEqual('suite');
|
||||
@@ -14,12 +14,12 @@ describe('ResultsNode', function() {
|
||||
const fakeResult = {
|
||||
id: 123,
|
||||
message: 'foo'
|
||||
},
|
||||
fakeChildResult = {
|
||||
};
|
||||
const fakeChildResult = {
|
||||
id: 456,
|
||||
message: 'bar'
|
||||
},
|
||||
node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
|
||||
};
|
||||
const node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
|
||||
|
||||
node.addChild(fakeChildResult, 'spec');
|
||||
|
||||
@@ -32,12 +32,12 @@ describe('ResultsNode', function() {
|
||||
const fakeResult = {
|
||||
id: 123,
|
||||
message: 'foo'
|
||||
},
|
||||
fakeChildResult = {
|
||||
};
|
||||
const fakeChildResult = {
|
||||
id: 456,
|
||||
message: 'bar'
|
||||
},
|
||||
node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
|
||||
};
|
||||
const node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
|
||||
|
||||
node.addChild(fakeChildResult, 'spec');
|
||||
|
||||
@@ -48,12 +48,12 @@ describe('ResultsNode', function() {
|
||||
const fakeResult = {
|
||||
id: 123,
|
||||
message: 'foo'
|
||||
},
|
||||
fakeChildResult = {
|
||||
};
|
||||
const fakeChildResult = {
|
||||
id: 456,
|
||||
message: 'bar'
|
||||
},
|
||||
node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
|
||||
};
|
||||
const node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
|
||||
|
||||
node.addChild(fakeChildResult, 'spec');
|
||||
|
||||
|
||||
@@ -4,15 +4,15 @@ describe('Spy Registry browser-specific behavior', function() {
|
||||
}
|
||||
|
||||
it('can spy on and unspy window.onerror', function() {
|
||||
const spies = [],
|
||||
spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
const spies = [];
|
||||
const spyRegistry = new privateUnderTest.SpyRegistry({
|
||||
currentSpies: function() {
|
||||
return spies;
|
||||
},
|
||||
createSpy: createSpy,
|
||||
global: window
|
||||
}),
|
||||
originalHandler = window.onerror;
|
||||
});
|
||||
const originalHandler = window.onerror;
|
||||
|
||||
try {
|
||||
spyRegistry.spyOn(window, 'onerror');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const path = require('path'),
|
||||
jasmineBrowser = require('jasmine-browser-runner'),
|
||||
jasmineCore = require('../../lib/jasmine-core');
|
||||
const path = require('path');
|
||||
const jasmineBrowser = require('jasmine-browser-runner');
|
||||
const jasmineCore = require('../../lib/jasmine-core');
|
||||
|
||||
const config = require(path.resolve('spec/support/jasmine-browser.js'));
|
||||
config.clearReporters = true;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const path = require('path'),
|
||||
jasmineBrowser = require('jasmine-browser-runner'),
|
||||
jasmineCore = require('../../lib/jasmine-core.js');
|
||||
const path = require('path');
|
||||
const jasmineBrowser = require('jasmine-browser-runner');
|
||||
const jasmineCore = require('../../lib/jasmine-core.js');
|
||||
|
||||
const configFile = process.argv[2] || 'jasmine-browser.js';
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
*
|
||||
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
|
||||
*/
|
||||
const jasmine = jasmineRequire.core(jasmineRequire),
|
||||
global = jasmine.getGlobal();
|
||||
const jasmine = jasmineRequire.core(jasmineRequire);
|
||||
const global = jasmine.getGlobal();
|
||||
global.jasmine = jasmine;
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,15 +55,15 @@ module.exports.noGlobals = function() {
|
||||
return jasmineInterface;
|
||||
};
|
||||
|
||||
const path = require('path'),
|
||||
fs = require('fs');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const rootPath = path.join(__dirname, 'jasmine-core'),
|
||||
bootFiles = ['boot0.js', 'boot1.js'],
|
||||
legacyBootFiles = ['boot.js'],
|
||||
cssFiles = [],
|
||||
jsFiles = [],
|
||||
jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles);
|
||||
const rootPath = path.join(__dirname, 'jasmine-core');
|
||||
const bootFiles = ['boot0.js', 'boot1.js'];
|
||||
const legacyBootFiles = ['boot.js'];
|
||||
const cssFiles = [];
|
||||
const jsFiles = [];
|
||||
const jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles);
|
||||
|
||||
fs.readdirSync(rootPath).forEach(function(file) {
|
||||
if (fs.statSync(path.join(rootPath, file)).isFile()) {
|
||||
|
||||
@@ -43,8 +43,8 @@ getJasmineRequireObj().JsApiReporter = function(j$) {
|
||||
return status;
|
||||
};
|
||||
|
||||
const suites = [],
|
||||
suites_hash = {};
|
||||
const suites = [];
|
||||
const suites_hash = {};
|
||||
|
||||
this.suiteStarted = function(result) {
|
||||
suites_hash[result.id] = result;
|
||||
|
||||
@@ -364,9 +364,11 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
}
|
||||
|
||||
const extractCustomPendingMessage = function(e) {
|
||||
const fullMessage = e.toString(),
|
||||
boilerplateStart = fullMessage.indexOf(Spec.pendingSpecExceptionMessage),
|
||||
boilerplateEnd =
|
||||
const fullMessage = e.toString();
|
||||
const boilerplateStart = fullMessage.indexOf(
|
||||
Spec.pendingSpecExceptionMessage
|
||||
);
|
||||
const boilerplateEnd =
|
||||
boilerplateStart + Spec.pendingSpecExceptionMessage.length;
|
||||
|
||||
return fullMessage.slice(boilerplateEnd);
|
||||
|
||||
@@ -40,11 +40,11 @@ getJasmineRequireObj().Spy = function(j$) {
|
||||
};
|
||||
const { originalFn, customStrategies, defaultStrategyFn } = optionals || {};
|
||||
|
||||
const numArgs = typeof originalFn === 'function' ? originalFn.length : 0,
|
||||
wrapper = makeFunc(numArgs, function(context, args, invokeNew) {
|
||||
const numArgs = typeof originalFn === 'function' ? originalFn.length : 0;
|
||||
const wrapper = makeFunc(numArgs, function(context, args, invokeNew) {
|
||||
return spy(context, args, invokeNew);
|
||||
}),
|
||||
strategyDispatcher = new SpyStrategyDispatcher(
|
||||
});
|
||||
const strategyDispatcher = new SpyStrategyDispatcher(
|
||||
{
|
||||
name: name,
|
||||
fn: originalFn,
|
||||
@@ -54,8 +54,8 @@ getJasmineRequireObj().Spy = function(j$) {
|
||||
customStrategies: customStrategies
|
||||
},
|
||||
matchersUtil
|
||||
),
|
||||
callTracker = new j$.private.CallTracker();
|
||||
);
|
||||
const callTracker = new j$.private.CallTracker();
|
||||
|
||||
function makeFunc(length, fn) {
|
||||
switch (length) {
|
||||
|
||||
@@ -200,10 +200,10 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
|
||||
);
|
||||
}
|
||||
|
||||
let pointer = obj,
|
||||
propsToSpyOn = [],
|
||||
properties,
|
||||
propertiesToSkip = [];
|
||||
let pointer = obj;
|
||||
let propsToSpyOn = [];
|
||||
let properties;
|
||||
let propertiesToSkip = [];
|
||||
|
||||
while (
|
||||
pointer &&
|
||||
|
||||
@@ -323,9 +323,9 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
|
||||
function beforeAndAfterFns(targetSuite) {
|
||||
return function() {
|
||||
let befores = [],
|
||||
afters = [],
|
||||
suite = targetSuite;
|
||||
let befores = [];
|
||||
let afters = [];
|
||||
let suite = targetSuite;
|
||||
|
||||
while (suite) {
|
||||
befores = befores.concat(suite.beforeFns);
|
||||
|
||||
@@ -149,10 +149,10 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
|
||||
nodes: [],
|
||||
min: startingMin(executableIndex),
|
||||
max: startingMax(executableIndex)
|
||||
},
|
||||
result = [currentSegment],
|
||||
lastMax = defaultMax,
|
||||
orderedChildSegments = orderChildSegments(orderedChildren, stats);
|
||||
};
|
||||
let result = [currentSegment];
|
||||
let lastMax = defaultMax;
|
||||
let orderedChildSegments = orderChildSegments(orderedChildren, stats);
|
||||
|
||||
function isSegmentBoundary(minIndex) {
|
||||
return (
|
||||
@@ -163,9 +163,9 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
|
||||
}
|
||||
|
||||
for (let i = 0; i < orderedChildSegments.length; i++) {
|
||||
const childSegment = orderedChildSegments[i],
|
||||
maxIndex = childSegment.max,
|
||||
minIndex = childSegment.min;
|
||||
const childSegment = orderedChildSegments[i];
|
||||
const maxIndex = childSegment.max;
|
||||
const minIndex = childSegment.min;
|
||||
|
||||
if (isSegmentBoundary(minIndex)) {
|
||||
currentSegment = {
|
||||
@@ -188,12 +188,12 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
|
||||
}
|
||||
|
||||
function orderChildSegments(children, stats) {
|
||||
const specifiedOrder = [],
|
||||
unspecifiedOrder = [];
|
||||
const specifiedOrder = [];
|
||||
const unspecifiedOrder = [];
|
||||
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const child = children[i],
|
||||
segments = stats[child.id].segments;
|
||||
const child = children[i];
|
||||
const segments = stats[child.id].segments;
|
||||
|
||||
for (let j = 0; j < segments.length; j++) {
|
||||
const seg = segments[j];
|
||||
|
||||
@@ -76,12 +76,12 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
};
|
||||
|
||||
MatchersUtil.prototype.buildFailureMessage = function() {
|
||||
const args = Array.prototype.slice.call(arguments, 0),
|
||||
matcherName = args[0],
|
||||
isNot = args[1],
|
||||
actual = args[2],
|
||||
expected = args.slice(3),
|
||||
englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) {
|
||||
const args = Array.prototype.slice.call(arguments, 0);
|
||||
const matcherName = args[0];
|
||||
const isNot = args[1];
|
||||
const actual = args[2];
|
||||
const expected = args.slice(3);
|
||||
const englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) {
|
||||
return ' ' + s.toLowerCase();
|
||||
});
|
||||
|
||||
@@ -465,8 +465,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
} else {
|
||||
// Objects with different constructors are not equivalent, but `Object`s
|
||||
// or `Array`s from different frames are.
|
||||
const aCtor = a.constructor,
|
||||
bCtor = b.constructor;
|
||||
const aCtor = a.constructor;
|
||||
const bCtor = b.constructor;
|
||||
if (
|
||||
aCtor !== bCtor &&
|
||||
isFunction(aCtor) &&
|
||||
@@ -572,11 +572,11 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
}
|
||||
|
||||
function objectKeysAreDifferentFormatter(pp, actual, expected, path) {
|
||||
const missingProperties = extraKeysAndValues(expected, actual),
|
||||
extraProperties = extraKeysAndValues(actual, expected),
|
||||
missingPropertiesMessage = formatKeyValuePairs(pp, missingProperties),
|
||||
extraPropertiesMessage = formatKeyValuePairs(pp, extraProperties),
|
||||
messages = [];
|
||||
const missingProperties = extraKeysAndValues(expected, actual);
|
||||
const extraProperties = extraKeysAndValues(actual, expected);
|
||||
const missingPropertiesMessage = formatKeyValuePairs(pp, missingProperties);
|
||||
const extraPropertiesMessage = formatKeyValuePairs(pp, extraProperties);
|
||||
const messages = [];
|
||||
|
||||
if (!path.depth()) {
|
||||
path = 'object';
|
||||
|
||||
@@ -9,8 +9,8 @@ getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$) {
|
||||
'toBeRejectedWith',
|
||||
'toBeRejectedWithError',
|
||||
'toBeRejectedWithMatching'
|
||||
],
|
||||
matchers = {};
|
||||
];
|
||||
const matchers = {};
|
||||
|
||||
for (const name of availableMatchers) {
|
||||
matchers[name] = jRequire[name](j$);
|
||||
|
||||
@@ -37,8 +37,8 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
|
||||
'toThrow',
|
||||
'toThrowError',
|
||||
'toThrowMatching'
|
||||
],
|
||||
matchers = {};
|
||||
];
|
||||
const matchers = {};
|
||||
|
||||
for (const name of availableMatchers) {
|
||||
matchers[name] = jRequire[name](j$);
|
||||
|
||||
@@ -15,8 +15,8 @@ getJasmineRequireObj().toEqual = function(j$) {
|
||||
compare: function(actual, expected) {
|
||||
const result = {
|
||||
pass: false
|
||||
},
|
||||
diffBuilder = new j$.private.DiffBuilder({
|
||||
};
|
||||
const diffBuilder = new j$.private.DiffBuilder({
|
||||
prettyPrinter: matchersUtil.pp
|
||||
});
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) {
|
||||
function toHaveBeenCalledOnceWith(matchersUtil) {
|
||||
return {
|
||||
compare: function() {
|
||||
const args = Array.prototype.slice.call(arguments, 0),
|
||||
actual = args[0],
|
||||
expectedArgs = args.slice(1);
|
||||
const args = Array.prototype.slice.call(arguments, 0);
|
||||
const actual = args[0];
|
||||
const expectedArgs = args.slice(1);
|
||||
|
||||
if (!j$.isSpy(actual)) {
|
||||
throw new Error(
|
||||
|
||||
@@ -26,8 +26,8 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
||||
);
|
||||
}
|
||||
|
||||
const args = Array.prototype.slice.call(arguments, 0),
|
||||
result = { pass: false };
|
||||
const args = Array.prototype.slice.call(arguments, 0);
|
||||
const result = { pass: false };
|
||||
|
||||
if (!j$.private.isNumber(expected)) {
|
||||
throw new Error(
|
||||
|
||||
@@ -18,10 +18,10 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
||||
function toHaveBeenCalledWith(matchersUtil) {
|
||||
return {
|
||||
compare: function() {
|
||||
const args = Array.prototype.slice.call(arguments, 0),
|
||||
actual = args[0],
|
||||
expectedArgs = args.slice(1),
|
||||
result = { pass: false };
|
||||
const args = Array.prototype.slice.call(arguments, 0);
|
||||
const actual = args[0];
|
||||
const expectedArgs = args.slice(1);
|
||||
const result = { pass: false };
|
||||
|
||||
if (!j$.isSpy(actual)) {
|
||||
throw new Error(
|
||||
|
||||
@@ -20,8 +20,8 @@ getJasmineRequireObj().util = function(j$) {
|
||||
|
||||
util.cloneArgs = function(args) {
|
||||
return Array.from(args).map(function(arg) {
|
||||
const str = Object.prototype.toString.apply(arg),
|
||||
primitives = /^\[object (Boolean|String|RegExp|Number)/;
|
||||
const str = Object.prototype.toString.apply(arg);
|
||||
const primitives = /^\[object (Boolean|String|RegExp|Number)/;
|
||||
|
||||
// All falsey values are either primitives, `null`, or `undefined.
|
||||
if (!arg || str.match(primitives)) {
|
||||
@@ -35,8 +35,8 @@ getJasmineRequireObj().util = function(j$) {
|
||||
};
|
||||
|
||||
util.getPropertyDescriptor = function(obj, methodName) {
|
||||
let descriptor,
|
||||
proto = obj;
|
||||
let descriptor;
|
||||
let proto = obj;
|
||||
|
||||
do {
|
||||
descriptor = Object.getOwnPropertyDescriptor(proto, methodName);
|
||||
|
||||
@@ -138,9 +138,9 @@ jasmineRequire.Banner = function(j$) {
|
||||
};
|
||||
}
|
||||
|
||||
const optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger'),
|
||||
optionsPayload = optionsMenuDom.querySelector('.jasmine-payload'),
|
||||
isOpen = /\bjasmine-open\b/;
|
||||
const optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger');
|
||||
const optionsPayload = optionsMenuDom.querySelector('.jasmine-payload');
|
||||
const isOpen = /\bjasmine-open\b/;
|
||||
|
||||
optionsTrigger.onclick = function() {
|
||||
if (isOpen.test(optionsPayload.className)) {
|
||||
|
||||
Reference in New Issue
Block a user