Use one declaration per statement

The old style of merging all of a function's variable declarations into
a single statement made some sense back in the days of var, but there's
no reason to keep doing it now that we use const and let.
This commit is contained in:
Steve Gravrock
2026-03-10 20:02:42 -07:00
parent 03ebebf6fb
commit 434575f49d
88 changed files with 3650 additions and 3604 deletions
+24 -24
View File
@@ -66,11 +66,11 @@ describe('DiffBuilder', function() {
it('uses the injected pretty-printer', function() {
const prettyPrinter = function(val) {
return '|' + val + '|';
},
diffBuilder = new privateUnderTest.DiffBuilder({
prettyPrinter: prettyPrinter
});
return '|' + val + '|';
};
const diffBuilder = new privateUnderTest.DiffBuilder({
prettyPrinter: prettyPrinter
});
prettyPrinter.customFormat_ = function() {};
diffBuilder.setRoots({ foo: 'actual' }, { foo: 'expected' });
@@ -84,11 +84,11 @@ 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({
prettyPrinter: prettyPrinter
});
const diffFormatter = jasmine.createSpy('diffFormatter');
const prettyPrinter = function() {};
const diffBuilder = new privateUnderTest.DiffBuilder({
prettyPrinter: prettyPrinter
});
prettyPrinter.customFormat_ = function() {};
diffBuilder.setRoots({ x: 'bar' }, { x: 'foo' });
@@ -219,13 +219,13 @@ describe('DiffBuilder', function() {
});
it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ at the root', function() {
const prettyPrinter = privateUnderTest.makePrettyPrinter([]),
diffBuilder = new privateUnderTest.DiffBuilder({
prettyPrinter: prettyPrinter
}),
expectedMsg =
'Expected $.foo = 1 to equal 2.\n' +
'Expected $.baz = undefined to equal 3.';
const prettyPrinter = privateUnderTest.makePrettyPrinter([]);
const diffBuilder = new privateUnderTest.DiffBuilder({
prettyPrinter: prettyPrinter
});
const expectedMsg =
'Expected $.foo = 1 to equal 2.\n' +
'Expected $.baz = undefined to equal 3.';
diffBuilder.setRoots(
{ foo: 1, bar: 2 },
@@ -243,13 +243,13 @@ describe('DiffBuilder', function() {
});
it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ below the root', function() {
const prettyPrinter = privateUnderTest.makePrettyPrinter([]),
diffBuilder = new privateUnderTest.DiffBuilder({
prettyPrinter: prettyPrinter
}),
expectedMsg =
'Expected $.x.foo = 1 to equal 2.\n' +
'Expected $.x.baz = undefined to equal 3.';
const prettyPrinter = privateUnderTest.makePrettyPrinter([]);
const diffBuilder = new privateUnderTest.DiffBuilder({
prettyPrinter: prettyPrinter
});
const expectedMsg =
'Expected $.x.foo = 1 to equal 2.\n' +
'Expected $.x.baz = undefined to equal 3.';
diffBuilder.setRoots(
{ x: { foo: 1, bar: 2 } },
+12 -12
View File
@@ -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);
+9 -9
View File
@@ -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);
@@ -1,12 +1,12 @@
describe('#toBeRejectedWithError', function() {
it('passes when Error type matches', function() {
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
),
actual = Promise.reject(new TypeError('foo'));
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
);
const actual = Promise.reject(new TypeError('foo'));
return matcher.compare(actual, TypeError).then(function(result) {
expect(result).toEqual(
@@ -21,12 +21,12 @@ describe('#toBeRejectedWithError', function() {
it('passes when Error type and message matches', function() {
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
),
actual = Promise.reject(new TypeError('foo'));
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
);
const actual = Promise.reject(new TypeError('foo'));
return matcher.compare(actual, TypeError, 'foo').then(function(result) {
expect(result).toEqual(
@@ -41,12 +41,12 @@ 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(
matchersUtil
),
actual = Promise.reject(new Error());
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
);
const actual = Promise.reject(new Error());
return matcher.compare(actual, Error).then(function(result) {
expect(result).toEqual(
@@ -61,12 +61,12 @@ describe('#toBeRejectedWithError', function() {
it('passes when Error message matches a string', function() {
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
),
actual = Promise.reject(new Error('foo'));
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
);
const actual = Promise.reject(new Error('foo'));
return matcher.compare(actual, 'foo').then(function(result) {
expect(result).toEqual(
@@ -81,12 +81,12 @@ describe('#toBeRejectedWithError', function() {
it('passes when Error message matches a RegExp', function() {
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
),
actual = Promise.reject(new Error('foo'));
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
);
const actual = Promise.reject(new Error('foo'));
return matcher.compare(actual, /foo/).then(function(result) {
expect(result).toEqual(
@@ -101,12 +101,12 @@ describe('#toBeRejectedWithError', function() {
it('passes when Error message is empty', function() {
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
),
actual = Promise.reject(new Error());
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
);
const actual = Promise.reject(new Error());
return matcher.compare(actual, '').then(function(result) {
expect(result).toEqual(
@@ -121,12 +121,12 @@ describe('#toBeRejectedWithError', function() {
it('passes when no arguments', function() {
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
),
actual = Promise.reject(new Error());
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
);
const actual = Promise.reject(new Error());
return matcher.compare(actual, void 0).then(function(result) {
expect(result).toEqual(
@@ -141,12 +141,12 @@ describe('#toBeRejectedWithError', function() {
it('fails when resolved', function() {
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
),
actual = Promise.resolve(new Error('foo'));
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
);
const actual = Promise.resolve(new Error('foo'));
return matcher.compare(actual, 'foo').then(function(result) {
expect(result).toEqual(
@@ -160,12 +160,12 @@ describe('#toBeRejectedWithError', function() {
it('fails when rejected with non Error type', function() {
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
),
actual = Promise.reject('foo');
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
);
const actual = Promise.reject('foo');
return matcher.compare(actual, 'foo').then(function(result) {
expect(result).toEqual(
@@ -180,12 +180,12 @@ describe('#toBeRejectedWithError', function() {
it('fails when Error type mismatches', function() {
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
),
actual = Promise.reject(new Error('foo'));
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
);
const actual = Promise.reject(new Error('foo'));
return matcher.compare(actual, TypeError, 'foo').then(function(result) {
expect(result).toEqual(
@@ -200,12 +200,12 @@ describe('#toBeRejectedWithError', function() {
it('fails when Error message mismatches', function() {
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
),
actual = Promise.reject(new Error('foo'));
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
);
const actual = Promise.reject(new Error('foo'));
return matcher.compare(actual, 'bar').then(function(result) {
expect(result).toEqual(
@@ -220,12 +220,12 @@ describe('#toBeRejectedWithError', function() {
it('fails if actual is not a promise', function() {
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
),
actual = 'not a promise';
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
matchersUtil
);
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 }));
@@ -21,10 +25,12 @@ 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');
pp: privateUnderTest.makePrettyPrinter()
});
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(
@@ -39,10 +45,12 @@ 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);
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(
matchersUtil
);
const actual = Promise.reject(true);
return matcher.compare(actual, true).then(function(result) {
expect(result).toEqual(
@@ -56,15 +64,17 @@ describe('#toBeRejectedWith', function() {
it('should support custom equality testers', function() {
const customEqualityTesters = [
function() {
return true;
}
],
matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: customEqualityTesters
}),
matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
actual = Promise.reject('actual');
function() {
return true;
}
];
const matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: customEqualityTesters
});
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 }));
@@ -73,10 +83,12 @@ 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';
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(
matchersUtil
);
const actual = 'not a promise';
function f() {
return matcher.compare(actual);
+10 -10
View File
@@ -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 }));
@@ -11,10 +11,10 @@ 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'));
pp: privateUnderTest.makePrettyPrinter([])
});
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);
+29 -29
View File
@@ -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 }));
@@ -11,10 +11,10 @@ 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'));
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil);
const actual = Promise.reject(new Error('AsyncExpectationSpec error'));
return matcher.compare(actual, '').then(function(result) {
expect(result).toEqual(
@@ -30,10 +30,10 @@ 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 });
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil);
const actual = Promise.resolve({ foo: 17 });
return matcher.compare(actual, { foo: 42 }).then(function(result) {
expect(result).toEqual(
@@ -48,10 +48,10 @@ 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);
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil);
const actual = Promise.resolve(true);
return matcher.compare(actual, true).then(function(result) {
expect(result).toEqual(
@@ -65,16 +65,16 @@ describe('#toBeResolvedTo', function() {
it('supports custom equality testers', function() {
const customEqualityTesters = [
function() {
return true;
}
],
matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: customEqualityTesters,
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
actual = Promise.resolve('actual');
function() {
return true;
}
];
const matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: customEqualityTesters,
pp: privateUnderTest.makePrettyPrinter()
});
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 }));
@@ -83,10 +83,10 @@ 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';
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil);
const actual = 'not a promise';
function f() {
return matcher.compare(actual);
+163 -163
View File
@@ -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);
@@ -363,11 +363,11 @@ describe('matchersUtil', function() {
it('passes when ObjectContaining is used', function() {
const obj = {
foo: 3,
bar: 7
},
containing = new privateUnderTest.ObjectContaining({ foo: 3 }),
matchersUtil = new privateUnderTest.MatchersUtil();
foo: 3,
bar: 7
};
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);
@@ -399,11 +399,11 @@ describe('matchersUtil', function() {
it('passes when an asymmetric equality tester returns true', function() {
const tester = {
asymmetricMatch: function() {
return true;
}
},
matchersUtil = new privateUnderTest.MatchersUtil();
asymmetricMatch: function() {
return true;
}
};
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(false, tester)).toBe(true);
expect(matchersUtil.equals(tester, false)).toBe(true);
@@ -411,19 +411,19 @@ describe('matchersUtil', function() {
it('fails when an asymmetric equality tester returns false', function() {
const tester = {
asymmetricMatch: function() {
return false;
}
},
matchersUtil = new privateUnderTest.MatchersUtil();
asymmetricMatch: function() {
return false;
}
};
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']))
@@ -432,12 +432,12 @@ describe('matchersUtil', function() {
it('passes when a custom equality matcher returns true', function() {
const tester = function() {
return true;
},
matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [tester],
pp: function() {}
});
return true;
};
const matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [tester],
pp: function() {}
});
expect(matchersUtil.equals(1, 2)).toBe(true);
});
@@ -463,46 +463,46 @@ describe('matchersUtil', function() {
it('fails for equivalents when a custom equality matcher returns false', function() {
const tester = function() {
return false;
},
matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [tester],
pp: function() {}
});
return false;
};
const matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [tester],
pp: function() {}
});
expect(matchersUtil.equals(1, 1)).toBe(false);
});
it('passes for an asymmetric equality tester that returns true when a custom equality tester return false', function() {
const asymmetricTester = {
asymmetricMatch: function() {
return true;
}
},
symmetricTester = function() {
return false;
},
matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [symmetricTester()],
pp: function() {}
});
asymmetricMatch: function() {
return true;
}
};
const symmetricTester = function() {
return false;
};
const matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [symmetricTester()],
pp: function() {}
});
expect(matchersUtil.equals(asymmetricTester, true)).toBe(true);
expect(matchersUtil.equals(true, asymmetricTester)).toBe(true);
});
it('passes when an Any is compared to an Any that checks for the same type', function() {
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
@@ -914,24 +914,24 @@ describe('matchersUtil', function() {
describe('Building diffs for asymmetric equality testers', function() {
it('diffs the values returned by valuesForDiff_', function() {
const tester = {
asymmetricMatch: function() {
return false;
},
valuesForDiff_: function() {
return {
self: 'asymmetric tester value',
other: 'other value'
};
}
asymmetricMatch: function() {
return false;
},
actual = { x: 42 },
expected = { x: tester },
diffBuilder = jasmine.createSpyObj('diffBuilder', [
'recordMismatch',
'withPath',
'setRoots'
]),
matchersUtil = new privateUnderTest.MatchersUtil();
valuesForDiff_: function() {
return {
self: 'asymmetric tester value',
other: 'other value'
};
}
};
const actual = { x: 42 };
const expected = { x: tester };
const diffBuilder = jasmine.createSpyObj('diffBuilder', [
'recordMismatch',
'withPath',
'setRoots'
]);
const matchersUtil = new privateUnderTest.MatchersUtil();
diffBuilder.withPath.and.callFake(function(p, block) {
block();
@@ -948,18 +948,18 @@ describe('matchersUtil', function() {
it('records both objects when the tester does not implement valuesForDiff', function() {
const tester = {
asymmetricMatch: function() {
return false;
}
},
actual = { x: 42 },
expected = { x: tester },
diffBuilder = jasmine.createSpyObj('diffBuilder', [
'recordMismatch',
'withPath',
'setRoots'
]),
matchersUtil = new privateUnderTest.MatchersUtil();
asymmetricMatch: function() {
return false;
}
};
const actual = { x: 42 };
const expected = { x: tester };
const diffBuilder = jasmine.createSpyObj('diffBuilder', [
'recordMismatch',
'withPath',
'setRoots'
]);
const matchersUtil = new privateUnderTest.MatchersUtil();
diffBuilder.withPath.and.callFake(function(p, block) {
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();
@@ -1026,12 +1026,12 @@ describe('matchersUtil', function() {
it('uses custom equality testers if actual is an Array', function() {
const customTester = function() {
return true;
},
matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [customTester],
pp: function() {}
});
return true;
};
const matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [customTester],
pp: function() {}
});
expect(matchersUtil.contains([1, 2], 3)).toBe(true);
});
@@ -1091,59 +1091,59 @@ 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(
name,
false,
actual,
'quux',
'corge'
);
const actual = 'foo';
const name = 'toBar';
const pp = privateUnderTest.makePrettyPrinter();
const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
const message = matchersUtil.buildFailureMessage(
name,
false,
actual,
'quux',
'corge'
);
expect(message).toEqual("Expected 'foo' to bar 'quux', 'corge'.");
});
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) {
return '<' + value + '>';
},
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }),
message = matchersUtil.buildFailureMessage(
name,
isNot,
actual,
expected1,
expected2
);
const actual = 'foo';
const expected1 = 'qux';
const expected2 = 'grault';
const name = 'toBar';
const isNot = false;
const pp = function(value) {
return '<' + value + '>';
};
const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
const message = matchersUtil.buildFailureMessage(
name,
isNot,
actual,
expected1,
expected2
);
expect(message).toEqual('Expected <foo> to bar <qux>, <grault>.');
});
+2 -2
View File
@@ -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);
});
+3 -3
View File
@@ -28,9 +28,9 @@ describe('toBeNaN', function() {
it('has a custom message on failure', function() {
const matcher = privateUnderTest.matchers.toBeNaN({
pp: privateUnderTest.makePrettyPrinter()
}),
result = matcher.compare(0);
pp: privateUnderTest.makePrettyPrinter()
});
const result = matcher.compare(0);
expect(result.message()).toEqual('Expected 0 to be NaN.');
});
@@ -15,16 +15,16 @@ describe('toBeNegativeInfinity', function() {
it('has a custom message on failure', function() {
const matcher = privateUnderTest.matchers.toBeNegativeInfinity({
pp: privateUnderTest.makePrettyPrinter()
}),
result = matcher.compare(0);
pp: privateUnderTest.makePrettyPrinter()
});
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.');
@@ -15,16 +15,16 @@ describe('toBePositiveInfinity', function() {
it('has a custom message on failure', function() {
const matcher = privateUnderTest.matchers.toBePositiveInfinity({
pp: privateUnderTest.makePrettyPrinter()
}),
result = matcher.compare(0);
pp: privateUnderTest.makePrettyPrinter()
});
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.');
+30 -28
View File
@@ -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];
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
const array = [1];
const result = matcher.compare(array, array);
expect(result.pass).toBe(true);
@@ -22,10 +22,10 @@ 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' };
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
const obj = { foo: 'bar' };
const result = matcher.compare(obj, obj);
expect(result.pass).toBe(true);
@@ -35,19 +35,19 @@ 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();
});
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]);
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
const result = matcher.compare([1], [1]);
expect(result.pass).toBe(false);
expect(result.message).toBe(
@@ -57,10 +57,10 @@ 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' });
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
const result = matcher.compare({ foo: 'bar' }, { foo: 'bar' });
expect(result.pass).toBe(false);
expect(result.message).toBe(
@@ -70,12 +70,14 @@ 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' });
return '<' + x.foo + '>';
};
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(
+9 -9
View File
@@ -1,9 +1,9 @@
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);
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
};
const matcher = privateUnderTest.matchers.toContain(matchersUtil);
const result = matcher.compare('ABC', 'B');
expect(matchersUtil.contains).toHaveBeenCalledWith('ABC', 'B');
@@ -12,12 +12,12 @@ describe('toContain', function() {
it('works with custom equality testers', function() {
const tester = function(a, b) {
return a.toString() === b.toString();
},
matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [tester]
}),
matcher = privateUnderTest.matchers.toContain(matchersUtil);
return a.toString() === b.toString();
};
const matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [tester]
});
const matcher = privateUnderTest.matchers.toContain(matchersUtil);
const result = matcher.compare(['1', '2'], 2);
expect(result.pass).toBe(true);
File diff suppressed because it is too large Load Diff
@@ -1,10 +1,10 @@
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');
pp: privateUnderTest.makePrettyPrinter()
});
const fn = function() {};
const spy = new privateUnderTest.Env().createSpy('a spy');
expect(function() {
matcher.compare(fn, spy);
@@ -13,10 +13,10 @@ 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() {};
pp: privateUnderTest.makePrettyPrinter()
});
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');
@@ -16,17 +16,17 @@ describe('toHaveBeenCalledOnceWith', function() {
it('supports custom equality testers', function() {
const customEqualityTesters = [
function() {
return true;
}
],
matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: customEqualityTesters
}),
matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(
matchersUtil
),
calledSpy = new privateUnderTest.Spy('called-spy');
function() {
return true;
}
];
const matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: customEqualityTesters
});
const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(
matchersUtil
);
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');
+13 -13
View File
@@ -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);
@@ -22,9 +22,9 @@ 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() {};
pp: privateUnderTest.makePrettyPrinter()
});
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();
+20 -20
View File
@@ -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();
@@ -47,9 +47,9 @@ 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() {};
pp: privateUnderTest.makePrettyPrinter()
});
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();
+43 -35
View File
@@ -1,12 +1,14 @@
describe('toHaveBeenCalledWith', function() {
it('passes when the actual was called with matching parameters', function() {
const matchersUtil = {
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');
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
matchersUtil
);
const calledSpy = new privateUnderTest.Spy('called-spy');
calledSpy('a', 'b');
const result = matcher.compare(calledSpy, 'a', 'b');
@@ -19,15 +21,17 @@ describe('toHaveBeenCalledWith', function() {
it('supports custom equality testers', function() {
const customEqualityTesters = [
function() {
return true;
}
],
matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: customEqualityTesters
}),
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
calledSpy = new privateUnderTest.Spy('called-spy');
function() {
return true;
}
];
const matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: customEqualityTesters
});
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),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
uncalledSpy = new privateUnderTest.Spy('uncalled spy');
contains: jasmine.createSpy('delegated-contains').and.returnValue(false),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
matchersUtil
);
const uncalledSpy = new privateUnderTest.Spy('uncalled spy');
const result = matcher.compare(uncalledSpy);
expect(result.pass).toBe(false);
@@ -53,10 +57,12 @@ 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');
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
matchersUtil
);
const calledSpy = new privateUnderTest.Spy('called spy');
calledSpy('a');
calledSpy('c', 'd');
@@ -85,9 +91,9 @@ 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() {};
pp: privateUnderTest.makePrettyPrinter()
});
const fn = function() {};
expect(function() {
matcher.compare(fn);
@@ -96,12 +102,14 @@ describe('toHaveBeenCalledWith', function() {
it('set the correct calls as verified when passing', function() {
const matchersUtil = {
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');
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
matchersUtil
);
const calledSpy = new privateUnderTest.Spy('called-spy');
calledSpy('a', 'b');
matcher.compare(calledSpy, 'a', 'b');
+9 -9
View File
@@ -1,17 +1,17 @@
describe('toHaveClass', function() {
it('fails for a DOM element that lacks the expected class', function() {
const matcher = privateUnderTest.matchers.toHaveClass(),
result = matcher.compare(
specHelpers.domHelpers.createElementWithClassName(''),
'foo'
);
const matcher = privateUnderTest.matchers.toHaveClass();
const result = matcher.compare(
specHelpers.domHelpers.createElementWithClassName(''),
'foo'
);
expect(result.pass).toBe(false);
});
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);
});
+9 -9
View File
@@ -1,24 +1,24 @@
describe('toHaveClasses', function() {
it('fails for a DOM element that lacks all the expected classes', function() {
const matcher = privateUnderTest.matchers.toHaveClasses(),
result = matcher.compare(
specHelpers.domHelpers.createElementWithClassName(''),
['foo', 'bar']
);
const matcher = privateUnderTest.matchers.toHaveClasses();
const result = matcher.compare(
specHelpers.domHelpers.createElementWithClassName(''),
['foo', 'bar']
);
expect(result.pass).toBe(false);
});
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);
});
@@ -130,17 +130,17 @@ describe('toHaveNoOtherSpyInteractions', function() {
it('handles multiple interactions with a single spy', function() {
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.matchers.toHaveNoOtherSpyInteractions(
matchersUtil
),
toHaveBeenCalledWithMatcher = privateUnderTest.matchers.toHaveBeenCalledWith(
matchersUtil
),
spyObj = jasmineUnderTest
.getEnv()
.createSpyObj('NewClass', ['spyA', 'spyB']);
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.matchers.toHaveNoOtherSpyInteractions(
matchersUtil
);
const toHaveBeenCalledWithMatcher = privateUnderTest.matchers.toHaveBeenCalledWith(
matchersUtil
);
const spyObj = jasmineUnderTest
.getEnv()
.createSpyObj('NewClass', ['spyA', 'spyB']);
spyObj.spyA('x');
spyObj.spyA('y');
+27 -27
View File
@@ -2,24 +2,24 @@ 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);
});
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);
pp: privateUnderTest.makePrettyPrinter()
});
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);
});
+103 -103
View File
@@ -8,10 +8,10 @@ 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() {
throw new Error('foo');
};
const matcher = privateUnderTest.matchers.toThrowError();
const fn = function() {
throw new Error('foo');
};
expect(function() {
matcher.compare(fn, 1);
@@ -19,10 +19,10 @@ describe('toThrowError', function() {
});
it('throws an error when the expected error type is not an Error', function() {
const matcher = privateUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error('foo');
};
const matcher = privateUnderTest.matchers.toThrowError();
const fn = function() {
throw new Error('foo');
};
expect(function() {
matcher.compare(fn, void 0, 'foo');
@@ -30,10 +30,10 @@ describe('toThrowError', function() {
});
it('throws an error when the expected error message is not a string or RegExp', function() {
const matcher = privateUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error('foo');
};
const matcher = privateUnderTest.matchers.toThrowError();
const fn = function() {
throw new Error('foo');
};
expect(function() {
matcher.compare(fn, Error, 1);
@@ -41,10 +41,10 @@ describe('toThrowError', function() {
});
it('fails if actual does not throw at all', function() {
const matcher = privateUnderTest.matchers.toThrowError(),
fn = function() {
return true;
};
const matcher = privateUnderTest.matchers.toThrowError();
const fn = function() {
return true;
};
const result = matcher.compare(fn);
@@ -54,11 +54,11 @@ describe('toThrowError', function() {
it('fails if thrown is not an instanceof Error', function() {
const matcher = privateUnderTest.matchers.toThrowError({
pp: privateUnderTest.makePrettyPrinter()
}),
fn = function() {
throw 4;
};
pp: privateUnderTest.makePrettyPrinter()
});
const fn = function() {
throw 4;
};
const result = matcher.compare(fn);
expect(result.pass).toBe(false);
@@ -104,11 +104,11 @@ describe('toThrowError', function() {
it('fails with the correct message if thrown is a falsy value', function() {
const matcher = privateUnderTest.matchers.toThrowError({
pp: privateUnderTest.makePrettyPrinter()
}),
fn = function() {
throw undefined;
};
pp: privateUnderTest.makePrettyPrinter()
});
const fn = function() {
throw undefined;
};
const result = matcher.compare(fn);
expect(result.pass).toBe(false);
@@ -118,10 +118,10 @@ describe('toThrowError', function() {
});
it('passes if thrown is a type of Error, but there is no expected error', function() {
const matcher = privateUnderTest.matchers.toThrowError(),
fn = function() {
throw new TypeError();
};
const matcher = privateUnderTest.matchers.toThrowError();
const fn = function() {
throw new TypeError();
};
const result = matcher.compare(fn);
@@ -133,11 +133,11 @@ describe('toThrowError', function() {
it('passes if thrown is an Error and the expected is the same message', function() {
const matcher = privateUnderTest.matchers.toThrowError({
pp: privateUnderTest.makePrettyPrinter()
}),
fn = function() {
throw new Error('foo');
};
pp: privateUnderTest.makePrettyPrinter()
});
const fn = function() {
throw new Error('foo');
};
const result = matcher.compare(fn, 'foo');
@@ -149,11 +149,11 @@ describe('toThrowError', function() {
it('fails if thrown is an Error and the expected is not the same message', function() {
const matcher = privateUnderTest.matchers.toThrowError({
pp: privateUnderTest.makePrettyPrinter()
}),
fn = function() {
throw new Error('foo');
};
pp: privateUnderTest.makePrettyPrinter()
});
const fn = function() {
throw new Error('foo');
};
const result = matcher.compare(fn, 'bar');
@@ -165,11 +165,11 @@ describe('toThrowError', function() {
it('passes if thrown is an Error and the expected is a RegExp that matches the message', function() {
const matcher = privateUnderTest.matchers.toThrowError({
pp: privateUnderTest.makePrettyPrinter()
}),
fn = function() {
throw new Error('a long message');
};
pp: privateUnderTest.makePrettyPrinter()
});
const fn = function() {
throw new Error('a long message');
};
const result = matcher.compare(fn, /long/);
@@ -181,11 +181,11 @@ describe('toThrowError', function() {
it('fails if thrown is an Error and the expected is a RegExp that does not match the message', function() {
const matcher = privateUnderTest.matchers.toThrowError({
pp: privateUnderTest.makePrettyPrinter()
}),
fn = function() {
throw new Error('a long message');
};
pp: privateUnderTest.makePrettyPrinter()
});
const fn = function() {
throw new Error('a long message');
};
const result = matcher.compare(fn, /foo/);
@@ -196,10 +196,10 @@ describe('toThrowError', function() {
});
it('passes if thrown is an Error and the expected the same Error', function() {
const matcher = privateUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error();
};
const matcher = privateUnderTest.matchers.toThrowError();
const fn = function() {
throw new Error();
};
const result = matcher.compare(fn, Error);
@@ -208,13 +208,13 @@ describe('toThrowError', function() {
});
it('passes if thrown is a custom error that takes arguments and the expected is the same error', function() {
const matcher = privateUnderTest.matchers.toThrowError(),
CustomError = function CustomError(arg) {
arg.x;
},
fn = function() {
throw new CustomError({ x: 1 });
};
const matcher = privateUnderTest.matchers.toThrowError();
const CustomError = function CustomError(arg) {
arg.x;
};
const fn = function() {
throw new CustomError({ x: 1 });
};
CustomError.prototype = new Error();
@@ -227,10 +227,10 @@ describe('toThrowError', function() {
});
it('fails if thrown is an Error and the expected is a different Error', function() {
const matcher = privateUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error();
};
const matcher = privateUnderTest.matchers.toThrowError();
const fn = function() {
throw new Error();
};
const result = matcher.compare(fn, TypeError);
@@ -242,13 +242,13 @@ describe('toThrowError', function() {
it('passes if thrown is a type of Error and it is equal to the expected Error and message', function() {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
throw new TypeError('foo');
};
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
const fn = function() {
throw new TypeError('foo');
};
const result = matcher.compare(fn, TypeError, 'foo');
@@ -260,16 +260,16 @@ describe('toThrowError', function() {
it('passes if thrown is a custom error that takes arguments and it is equal to the expected custom error and message', function() {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
CustomError = function CustomError(arg) {
this.message = arg.message;
},
fn = function() {
throw new CustomError({ message: 'foo' });
};
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
const CustomError = function CustomError(arg) {
this.message = arg.message;
};
const fn = function() {
throw new CustomError({ message: 'foo' });
};
CustomError.prototype = new Error();
@@ -284,13 +284,13 @@ describe('toThrowError', function() {
describe('with a string', function() {
it('fails if thrown is a type of Error and the expected is a different Error', function() {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
throw new TypeError('foo');
};
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
const fn = function() {
throw new TypeError('foo');
};
const result = matcher.compare(fn, TypeError, 'bar');
@@ -304,13 +304,13 @@ describe('toThrowError', function() {
describe('with a regex', function() {
it('fails if thrown is a type of Error and the expected is a different Error', function() {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
throw new TypeError('foo');
};
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
const fn = function() {
throw new TypeError('foo');
};
const result = matcher.compare(fn, TypeError, /bar/);
@@ -323,13 +323,13 @@ describe('toThrowError', function() {
it('passes if thrown is a type of Error and has the same type as the expected Error and the message matches the expected message', function() {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
throw new TypeError('foo');
};
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
const fn = function() {
throw new TypeError('foo');
};
const result = matcher.compare(fn, TypeError, /foo/);
+28 -28
View File
@@ -10,10 +10,10 @@ describe('toThrowMatching', function() {
});
it('throws an error when the expected is not a function', function() {
const matcher = privateUnderTest.matchers.toThrowMatching(),
fn = function() {
throw new Error('foo');
};
const matcher = privateUnderTest.matchers.toThrowMatching();
const fn = function() {
throw new Error('foo');
};
expect(function() {
matcher.compare(fn, 1);
@@ -21,10 +21,10 @@ describe('toThrowMatching', function() {
});
it('fails if actual does not throw at all', function() {
const matcher = privateUnderTest.matchers.toThrowMatching(),
fn = function() {
return true;
};
const matcher = privateUnderTest.matchers.toThrowMatching();
const fn = function() {
return true;
};
const result = matcher.compare(fn, function() {
return true;
@@ -36,11 +36,11 @@ 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() {
throw undefined;
};
pp: privateUnderTest.makePrettyPrinter()
});
const fn = function() {
throw undefined;
};
const result = matcher.compare(fn, function() {
return false;
@@ -52,13 +52,13 @@ describe('toThrowMatching', function() {
});
it('passes if the argument is a function that returns true when called with the error', function() {
const matcher = privateUnderTest.matchers.toThrowMatching(),
predicate = function(e) {
return e.message === 'nope';
},
fn = function() {
throw new TypeError('nope');
};
const matcher = privateUnderTest.matchers.toThrowMatching();
const predicate = function(e) {
return e.message === 'nope';
};
const fn = function() {
throw new TypeError('nope');
};
const result = matcher.compare(fn, predicate);
@@ -70,14 +70,14 @@ describe('toThrowMatching', function() {
it('fails if the argument is a function that returns false when called with the error', function() {
const matcher = privateUnderTest.matchers.toThrowMatching({
pp: privateUnderTest.makePrettyPrinter()
}),
predicate = function(e) {
return e.message === 'oh no';
},
fn = function() {
throw new TypeError('nope');
};
pp: privateUnderTest.makePrettyPrinter()
});
const predicate = function(e) {
return e.message === 'oh no';
};
const fn = function() {
throw new TypeError('nope');
};
const result = matcher.compare(fn, predicate);
+37 -37
View File
@@ -9,10 +9,10 @@ describe('toThrow', function() {
});
it('fails if actual does not throw', function() {
const matcher = privateUnderTest.matchers.toThrow(),
fn = function() {
return true;
};
const matcher = privateUnderTest.matchers.toThrow();
const fn = function() {
return true;
};
const result = matcher.compare(fn);
@@ -22,13 +22,13 @@ describe('toThrow', function() {
it('passes if it throws but there is no expected', function() {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toThrow(matchersUtil),
fn = function() {
throw 5;
};
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toThrow(matchersUtil);
const fn = function() {
throw 5;
};
const result = matcher.compare(fn);
@@ -40,11 +40,11 @@ describe('toThrow', function() {
it('passes even if what is thrown is falsy', function() {
const matcher = privateUnderTest.matchers.toThrow({
pp: privateUnderTest.makePrettyPrinter()
}),
fn = function() {
throw undefined;
};
pp: privateUnderTest.makePrettyPrinter()
});
const fn = function() {
throw undefined;
};
const result = matcher.compare(fn);
expect(result.pass).toBe(true);
@@ -55,13 +55,13 @@ describe('toThrow', function() {
it('passes if what is thrown is equivalent to what is expected', function() {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toThrow(matchersUtil),
fn = function() {
throw 5;
};
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toThrow(matchersUtil);
const fn = function() {
throw 5;
};
const result = matcher.compare(fn, 5);
@@ -71,13 +71,13 @@ describe('toThrow', function() {
it('fails if what is thrown is not equivalent to what is expected', function() {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toThrow(matchersUtil),
fn = function() {
throw 5;
};
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toThrow(matchersUtil);
const fn = function() {
throw 5;
};
const result = matcher.compare(fn, 'foo');
@@ -89,13 +89,13 @@ describe('toThrow', function() {
it('fails if what is thrown is not equivalent to undefined', function() {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toThrow(matchersUtil),
fn = function() {
throw 5;
};
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toThrow(matchersUtil);
const fn = function() {
throw 5;
};
const result = matcher.compare(fn, void 0);