Use const/let in specs, not var

This commit is contained in:
Steve Gravrock
2022-04-16 13:41:44 -07:00
parent 482dc883eb
commit 1166d10e43
111 changed files with 2522 additions and 2675 deletions

View File

@@ -1,6 +1,6 @@
describe('DiffBuilder', function() {
it('records the actual and expected objects', function() {
var diffBuilder = jasmineUnderTest.DiffBuilder();
const diffBuilder = jasmineUnderTest.DiffBuilder();
diffBuilder.setRoots({ x: 'actual' }, { x: 'expected' });
diffBuilder.recordMismatch();
@@ -10,7 +10,7 @@ describe('DiffBuilder', function() {
});
it('prints the path at which the difference was found', function() {
var diffBuilder = jasmineUnderTest.DiffBuilder();
const diffBuilder = jasmineUnderTest.DiffBuilder();
diffBuilder.setRoots({ foo: { x: 'actual' } }, { foo: { x: 'expected' } });
diffBuilder.withPath('foo', function() {
@@ -23,7 +23,7 @@ describe('DiffBuilder', function() {
});
it('prints multiple messages, separated by newlines', function() {
var diffBuilder = jasmineUnderTest.DiffBuilder();
const diffBuilder = jasmineUnderTest.DiffBuilder();
diffBuilder.setRoots({ foo: 1, bar: 3 }, { foo: 2, bar: 4 });
diffBuilder.withPath('foo', function() {
@@ -33,14 +33,14 @@ describe('DiffBuilder', function() {
diffBuilder.recordMismatch();
});
var message =
const message =
'Expected $.foo = 1 to equal 2.\n' + 'Expected $.bar = 3 to equal 4.';
expect(diffBuilder.getMessage()).toEqual(message);
});
it('allows customization of the message', function() {
var diffBuilder = jasmineUnderTest.DiffBuilder();
const diffBuilder = jasmineUnderTest.DiffBuilder();
diffBuilder.setRoots({ x: 'bar' }, { x: 'foo' });
function darthVaderFormatter(actual, expected, path) {
@@ -65,7 +65,7 @@ describe('DiffBuilder', function() {
});
it('uses the injected pretty-printer', function() {
var prettyPrinter = function(val) {
const prettyPrinter = function(val) {
return '|' + val + '|';
},
diffBuilder = jasmineUnderTest.DiffBuilder({
@@ -84,7 +84,7 @@ describe('DiffBuilder', function() {
});
it('passes the injected pretty-printer to the diff formatter', function() {
var diffFormatter = jasmine.createSpy('diffFormatter'),
const diffFormatter = jasmine.createSpy('diffFormatter'),
prettyPrinter = function() {},
diffBuilder = jasmineUnderTest.DiffBuilder({
prettyPrinter: prettyPrinter
@@ -107,13 +107,13 @@ describe('DiffBuilder', function() {
});
it('uses custom object formatters on leaf nodes', function() {
var formatter = function(x) {
const formatter = function(x) {
if (typeof x === 'number') {
return '[number:' + x + ']';
}
};
const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]);
var diffBuilder = new jasmineUnderTest.DiffBuilder({
const diffBuilder = new jasmineUnderTest.DiffBuilder({
prettyPrinter: prettyPrinter
});
@@ -126,16 +126,16 @@ describe('DiffBuilder', function() {
});
it('uses custom object formatters on non leaf nodes', function() {
var formatter = function(x) {
const formatter = function(x) {
if (x.hasOwnProperty('a')) {
return '[thing with a=' + x.a + ', b=' + JSON.stringify(x.b) + ']';
}
};
const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]);
var diffBuilder = new jasmineUnderTest.DiffBuilder({
const diffBuilder = new jasmineUnderTest.DiffBuilder({
prettyPrinter: prettyPrinter
});
var expectedMsg =
const expectedMsg =
'Expected $[0].foo = [thing with a=1, b={"x":42}] to equal [thing with a=1, b={"x":43}].\n' +
"Expected $[0].bar = 'yes' to equal 'no'.";
@@ -162,7 +162,7 @@ describe('DiffBuilder', function() {
});
it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ at the root', function() {
var prettyPrinter = jasmineUnderTest.makePrettyPrinter([]),
const prettyPrinter = jasmineUnderTest.makePrettyPrinter([]),
diffBuilder = new jasmineUnderTest.DiffBuilder({
prettyPrinter: prettyPrinter
}),
@@ -186,7 +186,7 @@ describe('DiffBuilder', function() {
});
it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ below the root', function() {
var prettyPrinter = jasmineUnderTest.makePrettyPrinter([]),
const prettyPrinter = jasmineUnderTest.makePrettyPrinter([]),
diffBuilder = new jasmineUnderTest.DiffBuilder({
prettyPrinter: prettyPrinter
}),

View File

@@ -2,7 +2,7 @@ describe('MismatchTree', function() {
describe('#add', function() {
describe('When the path is empty', function() {
it('flags the root node as mismatched', function() {
var tree = new jasmineUnderTest.MismatchTree();
const tree = new jasmineUnderTest.MismatchTree();
tree.add(new jasmineUnderTest.ObjectPath([]));
expect(tree.isMismatch).toBe(true);
});
@@ -10,7 +10,7 @@ describe('MismatchTree', function() {
describe('When the path is not empty', function() {
it('flags the node as mismatched', function() {
var tree = new jasmineUnderTest.MismatchTree();
const tree = new jasmineUnderTest.MismatchTree();
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']));
@@ -18,7 +18,7 @@ describe('MismatchTree', function() {
});
it('does not flag ancestors as mismatched', function() {
var tree = new jasmineUnderTest.MismatchTree();
const tree = new jasmineUnderTest.MismatchTree();
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']));
@@ -28,7 +28,7 @@ describe('MismatchTree', function() {
});
it('stores the formatter on only the target node', function() {
var tree = new jasmineUnderTest.MismatchTree();
const tree = new jasmineUnderTest.MismatchTree();
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']), formatter);
@@ -38,7 +38,7 @@ describe('MismatchTree', function() {
});
it('stores the path to the node', function() {
var tree = new jasmineUnderTest.MismatchTree();
const tree = new jasmineUnderTest.MismatchTree();
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']), formatter);
@@ -48,10 +48,10 @@ describe('MismatchTree', function() {
describe('#traverse', function() {
it('calls the callback for all nodes that are or contain mismatches', function() {
var tree = new jasmineUnderTest.MismatchTree();
const tree = new jasmineUnderTest.MismatchTree();
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']), formatter);
tree.add(new jasmineUnderTest.ObjectPath(['c']));
var visit = jasmine.createSpy('visit').and.returnValue(true);
const visit = jasmine.createSpy('visit').and.returnValue(true);
tree.traverse(visit);
@@ -78,8 +78,8 @@ describe('MismatchTree', function() {
});
it('does not call the callback if there are no mismatches', function() {
var tree = new jasmineUnderTest.MismatchTree();
var visit = jasmine.createSpy('visit');
const tree = new jasmineUnderTest.MismatchTree();
const visit = jasmine.createSpy('visit');
tree.traverse(visit);
@@ -87,9 +87,9 @@ describe('MismatchTree', function() {
});
it('visits parents before children', function() {
var tree = new jasmineUnderTest.MismatchTree();
const tree = new jasmineUnderTest.MismatchTree();
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']));
var visited = [];
const visited = [];
tree.traverse(function(path) {
visited.push(path);
@@ -104,10 +104,10 @@ describe('MismatchTree', function() {
});
it('visits children in the order they were recorded', function() {
var tree = new jasmineUnderTest.MismatchTree();
const tree = new jasmineUnderTest.MismatchTree();
tree.add(new jasmineUnderTest.ObjectPath(['length']));
tree.add(new jasmineUnderTest.ObjectPath([1]));
var visited = [];
const visited = [];
tree.traverse(function(path) {
visited.push(path);
@@ -122,9 +122,9 @@ describe('MismatchTree', function() {
});
it('does not visit children if the callback returns falsy', function() {
var tree = new jasmineUnderTest.MismatchTree();
const tree = new jasmineUnderTest.MismatchTree();
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']));
var visited = [];
const visited = [];
tree.traverse(function(path) {
visited.push(path);

View File

@@ -1,6 +1,6 @@
describe('NullDiffBuilder', function() {
it('responds to withPath() by calling the passed function', function() {
var spy = jasmine.createSpy('callback');
const spy = jasmine.createSpy('callback');
jasmineUnderTest.NullDiffBuilder().withPath('does not matter', spy);
expect(spy).toHaveBeenCalled();
});

View File

@@ -1,5 +1,5 @@
describe('ObjectPath', function() {
var ObjectPath = jasmineUnderTest.ObjectPath;
const ObjectPath = jasmineUnderTest.ObjectPath;
it('represents the path to a node in an object tree', function() {
expect(new ObjectPath(['foo', 'bar']).toString()).toEqual('$.foo.bar');
@@ -34,8 +34,8 @@ describe('ObjectPath', function() {
});
it('can be created based on another path', function() {
var root = new ObjectPath();
var path = root.add('foo');
const root = new ObjectPath();
const path = root.add('foo');
expect(path.toString()).toEqual('$.foo');
expect(root.toString()).toEqual('');

View File

@@ -1,6 +1,6 @@
describe('toBePending', function() {
it('passes if the actual promise is pending', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
actual = new Promise(function() {});
@@ -10,7 +10,7 @@ describe('toBePending', function() {
});
it('fails if the actual promise is resolved', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
actual = Promise.resolve();
@@ -20,7 +20,7 @@ describe('toBePending', function() {
});
it('fails if the actual promise is rejected', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
actual = Promise.reject(new Error('promise was rejected'));
@@ -30,7 +30,7 @@ describe('toBePending', function() {
});
it('fails if actual is not a promise', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
actual = 'not a promise';

View File

@@ -1,6 +1,6 @@
describe('toBeRejected', function() {
it('passes if the actual is rejected', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil),
actual = Promise.reject('AsyncExpectationSpec rejection');
@@ -10,7 +10,7 @@ describe('toBeRejected', function() {
});
it('fails if the actual is resolved', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil),
actual = Promise.resolve();
@@ -20,7 +20,7 @@ describe('toBeRejected', function() {
});
it('fails if actual is not a promise', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil),
actual = 'not a promise';

View File

@@ -1,6 +1,6 @@
describe('#toBeRejectedWithError', function() {
it('passes when Error type matches', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
@@ -20,7 +20,7 @@ describe('#toBeRejectedWithError', function() {
});
it('passes when Error type and message matches', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
@@ -40,7 +40,7 @@ describe('#toBeRejectedWithError', function() {
});
it('passes when Error matches and is exactly Error', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
@@ -60,7 +60,7 @@ describe('#toBeRejectedWithError', function() {
});
it('passes when Error message matches a string', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
@@ -80,7 +80,7 @@ describe('#toBeRejectedWithError', function() {
});
it('passes when Error message matches a RegExp', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
@@ -100,7 +100,7 @@ describe('#toBeRejectedWithError', function() {
});
it('passes when Error message is empty', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
@@ -120,7 +120,7 @@ describe('#toBeRejectedWithError', function() {
});
it('passes when no arguments', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
@@ -140,7 +140,7 @@ describe('#toBeRejectedWithError', function() {
});
it('fails when resolved', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
@@ -159,7 +159,7 @@ describe('#toBeRejectedWithError', function() {
});
it('fails when rejected with non Error type', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
@@ -179,7 +179,7 @@ describe('#toBeRejectedWithError', function() {
});
it('fails when Error type mismatches', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
@@ -199,7 +199,7 @@ describe('#toBeRejectedWithError', function() {
});
it('fails when Error message mismatches', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
@@ -219,7 +219,7 @@ describe('#toBeRejectedWithError', function() {
});
it('fails if actual is not a promise', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(

View File

@@ -1,6 +1,6 @@
describe('#toBeRejectedWith', function() {
it('should return true if the promise is rejected with the expected value', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
actual = Promise.reject({ error: 'PEBCAK' });
@@ -10,7 +10,7 @@ describe('#toBeRejectedWith', function() {
});
it('should fail if the promise resolves', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
actual = Promise.resolve();
@@ -20,7 +20,7 @@ describe('#toBeRejectedWith', function() {
});
it('should fail if the promise is rejected with a different value', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
@@ -38,7 +38,7 @@ describe('#toBeRejectedWith', function() {
});
it('should build its error correctly when negated', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
@@ -55,7 +55,7 @@ describe('#toBeRejectedWith', function() {
});
it('should support custom equality testers', function() {
var customEqualityTesters = [
const customEqualityTesters = [
function() {
return true;
}
@@ -72,7 +72,7 @@ describe('#toBeRejectedWith', function() {
});
it('fails if actual is not a promise', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),

View File

@@ -1,6 +1,6 @@
describe('toBeResolved', function() {
it('passes if the actual is resolved', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeResolved(matchersUtil),
actual = Promise.resolve();
@@ -10,7 +10,7 @@ describe('toBeResolved', function() {
});
it('fails if the actual is rejected', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter([])
}),
matcher = jasmineUnderTest.asyncMatchers.toBeResolved(matchersUtil),
@@ -27,7 +27,7 @@ describe('toBeResolved', function() {
});
it('fails if actual is not a promise', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeResolved(matchersUtil),
actual = 'not a promise';

View File

@@ -1,6 +1,6 @@
describe('#toBeResolvedTo', function() {
it('passes if the promise is resolved to the expected value', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
actual = Promise.resolve({ foo: 42 });
@@ -10,7 +10,7 @@ describe('#toBeResolvedTo', function() {
});
it('fails if the promise is rejected', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
@@ -29,7 +29,7 @@ describe('#toBeResolvedTo', function() {
});
it('fails if the promise is resolved to a different value', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
@@ -47,7 +47,7 @@ describe('#toBeResolvedTo', function() {
});
it('builds its message correctly when negated', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
@@ -64,7 +64,7 @@ describe('#toBeResolvedTo', function() {
});
it('supports custom equality testers', function() {
var customEqualityTesters = [
const customEqualityTesters = [
function() {
return true;
}
@@ -82,7 +82,7 @@ describe('#toBeResolvedTo', function() {
});
it('fails if actual is not a promise', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),

View File

@@ -1,6 +1,6 @@
describe('matchersUtil', function() {
it('exposes the injected pretty-printer as .pp', function() {
var pp = function() {},
const pp = function() {},
matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp });
expect(matchersUtil.pp).toBe(pp);
@@ -8,72 +8,72 @@ describe('matchersUtil', function() {
describe('equals', function() {
it('passes for literals that are triple-equal', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(null, null)).toBe(true);
expect(matchersUtil.equals(void 0, void 0)).toBe(true);
});
it('fails for things that are not equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals({ a: 'foo' }, 1)).toBe(false);
});
it('passes for Strings that are equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals('foo', 'foo')).toBe(true);
});
it('fails for Strings that are not equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals('foo', 'bar')).toBe(false);
});
it('passes for Numbers that are equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(123, 123)).toBe(true);
});
it('fails for Numbers that are not equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(123, 456)).toBe(false);
});
it('fails for a Number and a String that have equivalent values', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(123, '123')).toBe(false);
});
it('passes for Dates that are equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(
matchersUtil.equals(new Date('Jan 1, 1970'), new Date('Jan 1, 1970'))
).toBe(true);
});
it('fails for Dates that are not equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(
matchersUtil.equals(new Date('Jan 1, 1970'), new Date('Feb 3, 1991'))
).toBe(false);
});
it('passes for Booleans that are equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(true, true)).toBe(true);
});
it('fails for Booleans that are not equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(true, false)).toBe(false);
});
it('passes for RegExps that are equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(/foo/, /foo/)).toBe(true);
});
it('fails for RegExps that are not equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(/foo/, /bar/)).toBe(false);
expect(
matchersUtil.equals(new RegExp('foo', 'i'), new RegExp('foo'))
@@ -81,12 +81,12 @@ describe('matchersUtil', function() {
});
it('passes for Arrays that are equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals([1, 2], [1, 2])).toBe(true);
});
it('passes for Arrays that are equivalent, with elements added by changing length', function() {
var foo = [],
const foo = [],
matchersUtil = new jasmineUnderTest.MatchersUtil();
foo.length = 1;
@@ -99,12 +99,12 @@ describe('matchersUtil', function() {
});
it('fails for Arrays that have different elements', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals([1, 2, 3], [1, 5, 3])).toBe(false);
});
it('fails for Arrays whose contents are equivalent, but have differing properties', function() {
var one = [1, 2, 3],
const one = [1, 2, 3],
two = [1, 2, 3],
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -115,7 +115,7 @@ describe('matchersUtil', function() {
});
it('passes for Arrays with equivalent contents and properties', function() {
var one = [1, 2, 3],
const one = [1, 2, 3],
two = [1, 2, 3],
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -126,21 +126,21 @@ describe('matchersUtil', function() {
});
it('passes for Errors that are the same type and have the same message', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(new Error('foo'), new Error('foo'))).toBe(
true
);
});
it('fails for Errors that are the same type and have different messages', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(new Error('foo'), new Error('bar'))).toBe(
false
);
});
it('fails for objects with different constructors', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
function One() {}
function Two() {}
@@ -148,17 +148,17 @@ describe('matchersUtil', function() {
});
it('passes for Objects that are equivalent (simple case)', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals({ a: 'foo' }, { a: 'foo' })).toBe(true);
});
it('fails for Objects that are not equivalent (simple case)', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals({ a: 'foo' }, { a: 'bar' })).toBe(false);
});
it('passes for Objects that are equivalent (deep case)', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(
matchersUtil.equals(
{ a: 'foo', b: { c: 'bar' } },
@@ -168,7 +168,7 @@ describe('matchersUtil', function() {
});
it('fails for Objects that are not equivalent (deep case)', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(
matchersUtil.equals(
{ a: 'foo', b: { c: 'baz' } },
@@ -178,7 +178,7 @@ describe('matchersUtil', function() {
});
it('passes for Objects that are equivalent (with cycles)', function() {
var actual = { a: 'foo' },
const actual = { a: 'foo' },
expected = { a: 'foo' },
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -189,7 +189,7 @@ describe('matchersUtil', function() {
});
it('fails for Objects that are not equivalent (with cycles)', function() {
var actual = { a: 'foo' },
const actual = { a: 'foo' },
expected = { a: 'bar' },
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -200,7 +200,7 @@ describe('matchersUtil', function() {
});
it('fails for Objects that have the same number of keys, but different keys/values', function() {
var expected = { a: undefined },
const expected = { a: undefined },
actual = { b: 1 },
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -208,7 +208,7 @@ describe('matchersUtil', function() {
});
it('fails when comparing an empty object to an empty array (issue #114)', function() {
var emptyObject = {},
const emptyObject = {},
emptyArray = [],
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -217,7 +217,7 @@ describe('matchersUtil', function() {
});
it('passes for equivalent frozen objects (GitHub issue #266)', function() {
var a = { foo: 1 },
const a = { foo: 1 },
b = { foo: 1 },
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -232,7 +232,7 @@ describe('matchersUtil', function() {
return;
}
var p1 = new Promise(function() {}),
const p1 = new Promise(function() {}),
p2 = new Promise(function() {}),
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -249,13 +249,13 @@ describe('matchersUtil', function() {
if (isNotRunningInBrowser()) {
return;
}
var a = document.createElement('div');
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const a = document.createElement('div');
const matchersUtil = new jasmineUnderTest.MatchersUtil();
a.setAttribute('test-attr', 'attr-value');
a.appendChild(document.createTextNode('test'));
var b = document.createElement('div');
const b = document.createElement('div');
b.setAttribute('test-attr', 'attr-value');
b.appendChild(document.createTextNode('test'));
@@ -266,8 +266,8 @@ describe('matchersUtil', function() {
if (isNotRunningInBrowser()) {
return;
}
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var iframe = document.createElement('iframe');
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const iframe = document.createElement('iframe');
document.body.appendChild(iframe);
iframe.contentWindow.eval('window.testObject = {}');
expect(matchersUtil.equals({}, iframe.contentWindow.testObject)).toBe(
@@ -280,12 +280,12 @@ describe('matchersUtil', function() {
if (isNotRunningInBrowser()) {
return;
}
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var a = document.createElement('div');
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const a = document.createElement('div');
a.setAttribute('test-attr', 'attr-value');
a.appendChild(document.createTextNode('test'));
var b = document.createElement('div');
const b = document.createElement('div');
b.setAttribute('test-attr', 'attr-value2');
b.appendChild(document.createTextNode('test'));
@@ -311,9 +311,9 @@ describe('matchersUtil', function() {
if (isNotRunningInNode()) {
return;
}
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var vm = require('vm');
var sandbox = {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const vm = require('vm');
const sandbox = {
obj: null
};
vm.runInNewContext('obj = {a: 1, b: 2}', sandbox);
@@ -325,9 +325,9 @@ describe('matchersUtil', function() {
if (isNotRunningInNode()) {
return;
}
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var vm = require('vm');
var sandbox = {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const vm = require('vm');
const sandbox = {
arr: null
};
vm.runInNewContext('arr = [1, 2]', sandbox);
@@ -337,7 +337,7 @@ describe('matchersUtil', function() {
});
it('passes when Any is used', function() {
var number = 3,
const number = 3,
anyNumber = new jasmineUnderTest.Any(Number),
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -346,7 +346,7 @@ describe('matchersUtil', function() {
});
it('fails when Any is compared to something unexpected', function() {
var number = 3,
const number = 3,
anyString = new jasmineUnderTest.Any(String),
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -355,7 +355,7 @@ describe('matchersUtil', function() {
});
it('passes when ObjectContaining is used', function() {
var obj = {
const obj = {
foo: 3,
bar: 7
},
@@ -367,11 +367,11 @@ describe('matchersUtil', function() {
});
it('passes when MapContaining is used', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var obj = new Map();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const obj = new Map();
obj.set(1, 2);
obj.set('foo', 'bar');
var containing = new jasmineUnderTest.MapContaining(new Map());
const containing = new jasmineUnderTest.MapContaining(new Map());
containing.sample.set('foo', 'bar');
expect(matchersUtil.equals(obj, containing)).toBe(true);
@@ -379,11 +379,11 @@ describe('matchersUtil', function() {
});
it('passes when SetContaining is used', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var obj = new Set();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const obj = new Set();
obj.add(1);
obj.add('foo');
var containing = new jasmineUnderTest.SetContaining(new Set());
const containing = new jasmineUnderTest.SetContaining(new Set());
containing.sample.add(1);
expect(matchersUtil.equals(obj, containing)).toBe(true);
@@ -391,7 +391,7 @@ describe('matchersUtil', function() {
});
it('passes when an asymmetric equality tester returns true', function() {
var tester = {
const tester = {
asymmetricMatch: function() {
return true;
}
@@ -403,7 +403,7 @@ describe('matchersUtil', function() {
});
it('fails when an asymmetric equality tester returns false', function() {
var tester = {
const tester = {
asymmetricMatch: function() {
return false;
}
@@ -415,7 +415,7 @@ describe('matchersUtil', function() {
});
it('passes when ArrayContaining is used', function() {
var arr = ['foo', 'bar'],
const arr = ['foo', 'bar'],
matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(
@@ -424,7 +424,7 @@ describe('matchersUtil', function() {
});
it('passes when a custom equality matcher returns true', function() {
var tester = function() {
const tester = function() {
return true;
},
matchersUtil = new jasmineUnderTest.MatchersUtil({
@@ -436,17 +436,17 @@ describe('matchersUtil', function() {
});
it('passes for two empty Objects', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals({}, {})).toBe(true);
});
describe("when a custom equality matcher returns 'undefined'", function() {
var tester = function() {
const tester = function() {
return jasmine.undefined;
};
it('passes for two empty Objects', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
customTesters: [tester],
pp: function() {}
});
@@ -455,7 +455,7 @@ describe('matchersUtil', function() {
});
it('fails for equivalents when a custom equality matcher returns false', function() {
var tester = function() {
const tester = function() {
return false;
},
matchersUtil = new jasmineUnderTest.MatchersUtil({
@@ -467,7 +467,7 @@ describe('matchersUtil', function() {
});
it('passes for an asymmetric equality tester that returns true when a custom equality tester return false', function() {
var asymmetricTester = {
const asymmetricTester = {
asymmetricMatch: function() {
return true;
}
@@ -485,7 +485,7 @@ describe('matchersUtil', function() {
});
it('passes when an Any is compared to an Any that checks for the same type', function() {
var any1 = new jasmineUnderTest.Any(Function),
const any1 = new jasmineUnderTest.Any(Function),
any2 = new jasmineUnderTest.Any(Function),
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -493,7 +493,7 @@ describe('matchersUtil', function() {
});
it('passes for null prototype objects with same properties', function() {
var objA = Object.create(null),
const objA = Object.create(null),
objB = Object.create(null),
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -504,7 +504,7 @@ describe('matchersUtil', function() {
});
it('fails for null prototype objects with different properties', function() {
var objA = Object.create(null),
const objA = Object.create(null),
objB = Object.create(null),
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -515,16 +515,16 @@ describe('matchersUtil', function() {
});
it('passes when comparing two empty sets', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(new Set(), new Set())).toBe(true);
});
it('passes when comparing identical sets', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var setA = new Set();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const setA = new Set();
setA.add(6);
setA.add(5);
var setB = new Set();
const setB = new Set();
setB.add(6);
setB.add(5);
@@ -532,11 +532,11 @@ describe('matchersUtil', function() {
});
it('passes when comparing identical sets with different insertion order and simple elements', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var setA = new Set();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const setA = new Set();
setA.add(3);
setA.add(6);
var setB = new Set();
const setB = new Set();
setB.add(6);
setB.add(3);
@@ -544,24 +544,24 @@ describe('matchersUtil', function() {
});
it('passes when comparing identical sets with different insertion order and complex elements 1', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var setA1 = new Set();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const setA1 = new Set();
setA1.add(['a', 3]);
setA1.add([6, 1]);
var setA2 = new Set();
const setA2 = new Set();
setA1.add(['y', 3]);
setA1.add([6, 1]);
var setA = new Set();
const setA = new Set();
setA.add(setA1);
setA.add(setA2);
var setB1 = new Set();
const setB1 = new Set();
setB1.add([6, 1]);
setB1.add(['a', 3]);
var setB2 = new Set();
const setB2 = new Set();
setB1.add([6, 1]);
setB1.add(['y', 3]);
var setB = new Set();
const setB = new Set();
setB.add(setB1);
setB.add(setB2);
@@ -569,11 +569,11 @@ describe('matchersUtil', function() {
});
it('passes when comparing identical sets with different insertion order and complex elements 2', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var setA = new Set();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const setA = new Set();
setA.add([[1, 2], [3, 4]]);
setA.add([[5, 6], [7, 8]]);
var setB = new Set();
const setB = new Set();
setB.add([[5, 6], [7, 8]]);
setB.add([[1, 2], [3, 4]]);
@@ -581,12 +581,12 @@ describe('matchersUtil', function() {
});
it('fails for sets with different elements', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var setA = new Set();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const setA = new Set();
setA.add(6);
setA.add(3);
setA.add(5);
var setB = new Set();
const setB = new Set();
setB.add(6);
setB.add(4);
setB.add(5);
@@ -595,11 +595,11 @@ describe('matchersUtil', function() {
});
it('fails for sets of different size', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var setA = new Set();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const setA = new Set();
setA.add(6);
setA.add(3);
var setB = new Set();
const setB = new Set();
setB.add(6);
setB.add(4);
setB.add(5);
@@ -608,36 +608,36 @@ describe('matchersUtil', function() {
});
it('passes when comparing two empty maps', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(new Map(), new Map())).toBe(true);
});
it('passes when comparing identical maps', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var mapA = new Map();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const mapA = new Map();
mapA.set(6, 5);
var mapB = new Map();
const mapB = new Map();
mapB.set(6, 5);
expect(matchersUtil.equals(mapA, mapB)).toBe(true);
});
it('passes when comparing identical maps with different insertion order', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var mapA = new Map();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const mapA = new Map();
mapA.set('a', 3);
mapA.set(6, 1);
var mapB = new Map();
const mapB = new Map();
mapB.set(6, 1);
mapB.set('a', 3);
expect(matchersUtil.equals(mapA, mapB)).toBe(true);
});
it('fails for maps with different elements', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var mapA = new Map();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const mapA = new Map();
mapA.set(6, 3);
mapA.set(5, 1);
var mapB = new Map();
const mapB = new Map();
mapB.set(6, 4);
mapB.set(5, 1);
@@ -645,17 +645,17 @@ describe('matchersUtil', function() {
});
it('fails for maps of different size', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var mapA = new Map();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const mapA = new Map();
mapA.set(6, 3);
var mapB = new Map();
const mapB = new Map();
mapB.set(6, 4);
mapB.set(5, 1);
expect(matchersUtil.equals(mapA, mapB)).toBe(false);
});
it('passes when comparing two identical URLs', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(
matchersUtil.equals(
@@ -666,7 +666,7 @@ describe('matchersUtil', function() {
});
it('fails when comparing two different URLs', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
url1 = new URL('http://localhost/1');
expect(matchersUtil.equals(url1, new URL('http://localhost/2'))).toBe(
@@ -690,26 +690,26 @@ describe('matchersUtil', function() {
});
it('passes for ArrayBuffers with same length and content', function() {
var buffer1 = new ArrayBuffer(4);
var buffer2 = new ArrayBuffer(4);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const buffer1 = new ArrayBuffer(4);
const buffer2 = new ArrayBuffer(4);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(buffer1, buffer2)).toBe(true);
});
it('fails for ArrayBuffers with same length but different content', function() {
var buffer1 = new ArrayBuffer(4);
var buffer2 = new ArrayBuffer(4);
var array1 = new Uint8Array(buffer1);
const buffer1 = new ArrayBuffer(4);
const buffer2 = new ArrayBuffer(4);
const array1 = new Uint8Array(buffer1);
array1[0] = 1;
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(buffer1, buffer2)).toBe(false);
});
describe('Typed arrays', function() {
it('fails for typed arrays of same length and contents but different types', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var a1 = new Int8Array(1);
var a2 = new Uint8Array(1);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const a1 = new Int8Array(1);
const a2 = new Uint8Array(1);
a1[0] = a2[0] = 0;
expect(matchersUtil.equals(a1, a2)).toBe(false);
});
@@ -725,14 +725,14 @@ describe('matchersUtil', function() {
'Float32Array',
'Float64Array'
].forEach(function(typeName) {
var TypedArrayCtor = jasmine.getGlobal()[typeName];
const TypedArrayCtor = jasmine.getGlobal()[typeName];
it(
'passes for ' + typeName + 's with same length and content',
function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var a1 = new TypedArrayCtor(2);
var a2 = new TypedArrayCtor(2);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const a1 = new TypedArrayCtor(2);
const a2 = new TypedArrayCtor(2);
a1[0] = a2[0] = 0;
a1[1] = a2[1] = 1;
expect(matchersUtil.equals(a1, a2)).toBe(true);
@@ -740,9 +740,9 @@ describe('matchersUtil', function() {
);
it('fails for ' + typeName + 's with different length', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var a1 = new TypedArrayCtor(2);
var a2 = new TypedArrayCtor(1);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const a1 = new TypedArrayCtor(2);
const a2 = new TypedArrayCtor(1);
a1[0] = a1[1] = a2[0] = 0;
expect(matchersUtil.equals(a1, a2)).toBe(false);
});
@@ -750,9 +750,9 @@ describe('matchersUtil', function() {
it(
'fails for ' + typeName + 's with same length but different content',
function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var a1 = new TypedArrayCtor(1);
var a2 = new TypedArrayCtor(1);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const a1 = new TypedArrayCtor(1);
const a2 = new TypedArrayCtor(1);
a1[0] = 0;
a2[0] = 1;
expect(matchersUtil.equals(a1, a2)).toBe(false);
@@ -760,18 +760,18 @@ describe('matchersUtil', function() {
);
it('checks nonstandard properties of ' + typeName, function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var a1 = new TypedArrayCtor(1);
var a2 = new TypedArrayCtor(1);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const a1 = new TypedArrayCtor(1);
const a2 = new TypedArrayCtor(1);
a1[0] = a2[0] = 0;
a1.extra = 'yes';
expect(matchersUtil.equals(a1, a2)).toBe(false);
});
it('works with custom equality testers with ' + typeName, function() {
var a1 = new TypedArrayCtor(1);
var a2 = new TypedArrayCtor(1);
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const a1 = new TypedArrayCtor(1);
const a2 = new TypedArrayCtor(1);
const matchersUtil = new jasmineUnderTest.MatchersUtil({
customTesters: [
function() {
return true;
@@ -786,7 +786,7 @@ describe('matchersUtil', function() {
['BigInt64Array', 'BigUint64Array'].forEach(function(typeName) {
function requireType() {
var TypedArrayCtor = jasmine.getGlobal()[typeName];
const TypedArrayCtor = jasmine.getGlobal()[typeName];
if (!TypedArrayCtor) {
pending('Browser does not support ' + typeName);
@@ -798,10 +798,10 @@ describe('matchersUtil', function() {
it(
'passes for ' + typeName + 's with same length and content',
function() {
var TypedArrayCtor = requireType();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var a1 = new TypedArrayCtor(2);
var a2 = new TypedArrayCtor(2);
const TypedArrayCtor = requireType();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const a1 = new TypedArrayCtor(2);
const a2 = new TypedArrayCtor(2);
// eslint-disable-next-line compat/compat
a1[0] = a2[0] = BigInt(0);
// eslint-disable-next-line compat/compat
@@ -811,10 +811,10 @@ describe('matchersUtil', function() {
);
it('fails for ' + typeName + 's with different length', function() {
var TypedArrayCtor = requireType();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var a1 = new TypedArrayCtor(2);
var a2 = new TypedArrayCtor(1);
const TypedArrayCtor = requireType();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const a1 = new TypedArrayCtor(2);
const a2 = new TypedArrayCtor(1);
// eslint-disable-next-line compat/compat
a1[0] = a1[1] = a2[0] = BigInt(0);
expect(matchersUtil.equals(a1, a2)).toBe(false);
@@ -823,10 +823,10 @@ describe('matchersUtil', function() {
it(
'fails for ' + typeName + 's with same length but different content',
function() {
var TypedArrayCtor = requireType();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var a1 = new TypedArrayCtor(2);
var a2 = new TypedArrayCtor(2);
const TypedArrayCtor = requireType();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const a1 = new TypedArrayCtor(2);
const a2 = new TypedArrayCtor(2);
// eslint-disable-next-line compat/compat
a1[0] = a1[1] = a2[0] = BigInt(0);
// eslint-disable-next-line compat/compat
@@ -838,7 +838,7 @@ describe('matchersUtil', function() {
});
describe('when running in an environment with array polyfills', function() {
var findIndexDescriptor = Object.getOwnPropertyDescriptor(
const findIndexDescriptor = Object.getOwnPropertyDescriptor(
Array.prototype,
'findIndex'
);
@@ -865,13 +865,12 @@ describe('matchersUtil', function() {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
var thisArg = arguments[1];
var value;
const list = Object(this);
const length = list.length >>> 0;
const thisArg = arguments[1];
for (var i = 0; i < length; i++) {
value = list[i];
for (let i = 0; i < length; i++) {
const value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return i;
}
@@ -897,7 +896,7 @@ describe('matchersUtil', function() {
describe('Building diffs for asymmetric equality testers', function() {
it('diffs the values returned by valuesForDiff_', function() {
var tester = {
const tester = {
asymmetricMatch: function() {
return false;
},
@@ -931,7 +930,7 @@ describe('matchersUtil', function() {
});
it('records both objects when the tester does not implement valuesForDiff', function() {
var tester = {
const tester = {
asymmetricMatch: function() {
return false;
}
@@ -960,7 +959,7 @@ describe('matchersUtil', function() {
});
it('uses a diffBuilder if one is provided as the third argument', function() {
var diffBuilder = new jasmineUnderTest.DiffBuilder(),
const diffBuilder = new jasmineUnderTest.DiffBuilder(),
matchersUtil = new jasmineUnderTest.MatchersUtil();
spyOn(diffBuilder, 'recordMismatch');
@@ -981,27 +980,27 @@ describe('matchersUtil', function() {
describe('contains', function() {
it('passes when expected is a substring of actual', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.contains('ABC', 'BC')).toBe(true);
});
it('fails when expected is a not substring of actual', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.contains('ABC', 'X')).toBe(false);
});
it('passes when expected is an element in an actual array', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.contains(['foo', 'bar'], 'foo')).toBe(true);
});
it('fails when expected is not an element in an actual array', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.contains(['foo', 'bar'], 'baz')).toBe(false);
});
it('passes with mixed-element arrays', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.contains(['foo', { some: 'bar' }], 'foo')).toBe(true);
expect(
matchersUtil.contains(['foo', { some: 'bar' }], { some: 'bar' })
@@ -1009,7 +1008,7 @@ describe('matchersUtil', function() {
});
it('uses custom equality testers if actual is an Array', function() {
var customTester = function() {
const customTester = function() {
return true;
},
matchersUtil = new jasmineUnderTest.MatchersUtil({
@@ -1021,18 +1020,18 @@ describe('matchersUtil', function() {
});
it('fails when actual is undefined', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.contains(undefined, 'A')).toBe(false);
});
it('fails when actual is null', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.contains(null, 'A')).toBe(false);
});
it('works with array-like objects that implement iterable', function() {
var capturedArgs = null,
matchersUtil = new jasmineUnderTest.MatchersUtil();
let capturedArgs = null;
const matchersUtil = new jasmineUnderTest.MatchersUtil();
function testFunction() {
capturedArgs = arguments;
@@ -1056,17 +1055,17 @@ describe('matchersUtil', function() {
});
it('passes for set members', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var setItem = { foo: 'bar' };
var set = new Set();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const setItem = { foo: 'bar' };
const set = new Set();
set.add(setItem);
expect(matchersUtil.contains(set, setItem)).toBe(true);
});
it('passes for objects that equal to a set member', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var set = new Set();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const set = new Set();
set.add({ foo: 'bar' });
expect(matchersUtil.contains(set, { foo: 'bar' })).toBe(true);
@@ -1075,7 +1074,7 @@ describe('matchersUtil', function() {
describe('buildFailureMessage', function() {
it('builds an English sentence for a failure case', function() {
var actual = 'foo',
const actual = 'foo',
name = 'toBar',
pp = jasmineUnderTest.makePrettyPrinter(),
matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }),
@@ -1085,22 +1084,18 @@ describe('matchersUtil', function() {
});
it("builds an English sentence for a 'not' failure case", function() {
var actual = 'foo',
const actual = 'foo',
name = 'toBar',
isNot = true,
pp = jasmineUnderTest.makePrettyPrinter(),
matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }),
message = (message = matchersUtil.buildFailureMessage(
name,
isNot,
actual
));
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() {
var actual = 'foo',
const actual = 'foo',
name = 'toBar',
pp = jasmineUnderTest.makePrettyPrinter(),
matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }),
@@ -1116,7 +1111,7 @@ describe('matchersUtil', function() {
});
it('uses the injected pretty-printer to format the expecteds and actual', function() {
var actual = 'foo',
const actual = 'foo',
expected1 = 'qux',
expected2 = 'grault',
name = 'toBar',
@@ -1125,13 +1120,13 @@ describe('matchersUtil', function() {
return '<' + value + '>';
},
matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }),
message = (message = matchersUtil.buildFailureMessage(
message = matchersUtil.buildFailureMessage(
name,
isNot,
actual,
expected1,
expected2
));
);
expect(message).toEqual('Expected <foo> to bar <qux>, <grault>.');
});

View File

@@ -1,6 +1,6 @@
describe('nothing', function() {
it('should pass', function() {
var matcher = jasmineUnderTest.matchers.nothing(),
const matcher = jasmineUnderTest.matchers.nothing(),
result = matcher.compare();
expect(result.pass).toBe(true);

View File

@@ -1,7 +1,7 @@
describe('toBeCloseTo', function() {
it('passes when within two decimal places by default', function() {
var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
result;
const matcher = jasmineUnderTest.matchers.toBeCloseTo();
let result;
result = matcher.compare(0, 0);
expect(result.pass).toBe(true);
@@ -14,8 +14,8 @@ describe('toBeCloseTo', function() {
});
it('fails when not within two decimal places by default', function() {
var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
result;
const matcher = jasmineUnderTest.matchers.toBeCloseTo();
let result;
result = matcher.compare(0, 0.01);
expect(result.pass).toBe(false);
@@ -25,8 +25,8 @@ describe('toBeCloseTo', function() {
});
it('accepts an optional precision argument', function() {
var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
result;
const matcher = jasmineUnderTest.matchers.toBeCloseTo();
let result;
result = matcher.compare(0, 0.1, 0);
expect(result.pass).toBe(true);
@@ -48,7 +48,7 @@ describe('toBeCloseTo', function() {
});
it('fails when one of the arguments is null', function() {
var matcher = jasmineUnderTest.matchers.toBeCloseTo();
const matcher = jasmineUnderTest.matchers.toBeCloseTo();
expect(function() {
matcher.compare(null, null);
@@ -70,8 +70,8 @@ describe('toBeCloseTo', function() {
});
it('rounds expected values', function() {
var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
result;
const matcher = jasmineUnderTest.matchers.toBeCloseTo();
let result;
result = matcher.compare(1.23, 1.229);
expect(result.pass).toBe(true);
@@ -98,8 +98,8 @@ describe('toBeCloseTo', function() {
});
it('handles edge cases with rounding', function() {
var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
result;
const matcher = jasmineUnderTest.matchers.toBeCloseTo();
let result;
// these cases resulted in false negatives in version of V8
// included in Node.js 12 and Chrome 74 (and Edge Chromium)

View File

@@ -1,17 +1,13 @@
describe('toBeDefined', function() {
it('matches for defined values', function() {
var matcher = jasmineUnderTest.matchers.toBeDefined(),
result;
result = matcher.compare('foo');
const matcher = jasmineUnderTest.matchers.toBeDefined();
const result = matcher.compare('foo');
expect(result.pass).toBe(true);
});
it('fails when matching undefined values', function() {
var matcher = jasmineUnderTest.matchers.toBeDefined(),
result;
result = matcher.compare(void 0);
const matcher = jasmineUnderTest.matchers.toBeDefined();
const result = matcher.compare(void 0);
expect(result.pass).toBe(false);
});
});

View File

@@ -1,25 +1,19 @@
describe('toBeFalse', function() {
it('passes for false', function() {
var matcher = jasmineUnderTest.matchers.toBeFalse(),
result;
result = matcher.compare(false);
const matcher = jasmineUnderTest.matchers.toBeFalse();
const result = matcher.compare(false);
expect(result.pass).toBe(true);
});
it('fails for non-false', function() {
var matcher = jasmineUnderTest.matchers.toBeFalse(),
result;
result = matcher.compare('foo');
const matcher = jasmineUnderTest.matchers.toBeFalse();
const result = matcher.compare('foo');
expect(result.pass).toBe(false);
});
it('fails for falsy', function() {
var matcher = jasmineUnderTest.matchers.toBeFalse(),
result;
result = matcher.compare(undefined);
const matcher = jasmineUnderTest.matchers.toBeFalse();
const result = matcher.compare(undefined);
expect(result.pass).toBe(false);
});
});

View File

@@ -1,7 +1,7 @@
describe('toBeFalsy', function() {
it("passes for 'falsy' values", function() {
var matcher = jasmineUnderTest.matchers.toBeFalsy(),
result;
const matcher = jasmineUnderTest.matchers.toBeFalsy();
let result;
result = matcher.compare(false);
expect(result.pass).toBe(true);
@@ -23,8 +23,8 @@ describe('toBeFalsy', function() {
});
it("fails for 'truthy' values", function() {
var matcher = jasmineUnderTest.matchers.toBeFalsy(),
result;
const matcher = jasmineUnderTest.matchers.toBeFalsy();
let result;
result = matcher.compare(true);
expect(result.pass).toBe(false);

View File

@@ -1,7 +1,7 @@
describe('toBeGreaterThanOrEqual', function() {
it('passes when actual >= expected', function() {
var matcher = jasmineUnderTest.matchers.toBeGreaterThanOrEqual(),
result;
const matcher = jasmineUnderTest.matchers.toBeGreaterThanOrEqual();
let result;
result = matcher.compare(2, 1);
expect(result.pass).toBe(true);
@@ -17,8 +17,8 @@ describe('toBeGreaterThanOrEqual', function() {
});
it('fails when actual < expected', function() {
var matcher = jasmineUnderTest.matchers.toBeGreaterThanOrEqual(),
result;
const matcher = jasmineUnderTest.matchers.toBeGreaterThanOrEqual();
let result;
result = matcher.compare(1, 2);
expect(result.pass).toBe(false);

View File

@@ -1,15 +1,13 @@
describe('toBeGreaterThan', function() {
it('passes when actual > expected', function() {
var matcher = jasmineUnderTest.matchers.toBeGreaterThan(),
result;
result = matcher.compare(2, 1);
const matcher = jasmineUnderTest.matchers.toBeGreaterThan();
const result = matcher.compare(2, 1);
expect(result.pass).toBe(true);
});
it('fails when actual <= expected', function() {
var matcher = jasmineUnderTest.matchers.toBeGreaterThan(),
result;
const matcher = jasmineUnderTest.matchers.toBeGreaterThan();
let result;
result = matcher.compare(1, 1);
expect(result.pass).toBe(false);

View File

@@ -1,8 +1,8 @@
describe('toBeInstanceOf', function() {
describe('when expecting Number', function() {
it('passes for literal number', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(3, Number);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(3, Number);
expect(result).toEqual({
pass: true,
message: 'Expected instance of Number not to be an instance of Number'
@@ -10,10 +10,10 @@ describe('toBeInstanceOf', function() {
});
it('passes for NaN', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf({
const matcher = jasmineUnderTest.matchers.toBeInstanceOf({
pp: jasmineUnderTest.makePrettyPrinter()
});
var result = matcher.compare(NaN, Number);
const result = matcher.compare(NaN, Number);
expect(result).toEqual({
pass: true,
message: 'Expected instance of NaN not to be an instance of Number'
@@ -21,8 +21,8 @@ describe('toBeInstanceOf', function() {
});
it('passes for Infinity', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(Infinity, Number);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(Infinity, Number);
expect(result).toEqual({
pass: true,
message: 'Expected instance of Number not to be an instance of Number'
@@ -30,8 +30,8 @@ describe('toBeInstanceOf', function() {
});
it('fails for a non-number', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare('foo', Number);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare('foo', Number);
expect(result).toEqual({
pass: false,
message: 'Expected instance of String to be an instance of Number'
@@ -41,8 +41,8 @@ describe('toBeInstanceOf', function() {
describe('when expecting String', function() {
it('passes for a string', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare('foo', String);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare('foo', String);
expect(result).toEqual({
pass: true,
message: 'Expected instance of String not to be an instance of String'
@@ -50,8 +50,8 @@ describe('toBeInstanceOf', function() {
});
it('fails for a non-string', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare({}, String);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare({}, String);
expect(result).toEqual({
pass: false,
message: 'Expected instance of Object to be an instance of String'
@@ -61,8 +61,8 @@ describe('toBeInstanceOf', function() {
describe('when expecting Boolean', function() {
it('passes for a boolean', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(true, Boolean);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(true, Boolean);
expect(result).toEqual({
pass: true,
message: 'Expected instance of Boolean not to be an instance of Boolean'
@@ -70,8 +70,8 @@ describe('toBeInstanceOf', function() {
});
it('fails for a non-boolean', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare('false', Boolean);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare('false', Boolean);
expect(result).toEqual({
pass: false,
message: 'Expected instance of String to be an instance of Boolean'
@@ -81,8 +81,8 @@ describe('toBeInstanceOf', function() {
describe('when expecting RegExp', function() {
it('passes for a literal regular expression', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(/foo/, RegExp);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(/foo/, RegExp);
expect(result).toEqual({
pass: true,
message: 'Expected instance of RegExp not to be an instance of RegExp'
@@ -92,10 +92,10 @@ describe('toBeInstanceOf', function() {
describe('when expecting Function', function() {
it('passes for a function', function() {
var fn = function() {};
const fn = function() {};
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(fn, Function);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(fn, Function);
expect(result).toEqual({
pass: true,
message:
@@ -104,10 +104,10 @@ describe('toBeInstanceOf', function() {
});
it('passes for an async function', function() {
var fn = eval("(async function fn() { return 'foo'; })");
const fn = eval("(async function fn() { return 'foo'; })");
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(fn, Function);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(fn, Function);
expect(result).toEqual({
pass: true,
message:
@@ -120,8 +120,8 @@ describe('toBeInstanceOf', function() {
function Animal() {}
it('passes for any object', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare({ foo: 'bar' }, Object);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare({ foo: 'bar' }, Object);
expect(result).toEqual({
pass: true,
message: 'Expected instance of Object not to be an instance of Object'
@@ -129,8 +129,8 @@ describe('toBeInstanceOf', function() {
});
it('passes for an Error object', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(new Error('example'), Object);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(new Error('example'), Object);
expect(result).toEqual({
pass: true,
message: 'Expected instance of Error not to be an instance of Object'
@@ -138,8 +138,8 @@ describe('toBeInstanceOf', function() {
});
it('passes for a user-defined class', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(new Animal(), Object);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(new Animal(), Object);
expect(result).toEqual({
pass: true,
message: 'Expected instance of Animal not to be an instance of Object'
@@ -147,8 +147,8 @@ describe('toBeInstanceOf', function() {
});
it('fails for a non-object', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare('foo', Object);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare('foo', Object);
expect(result).toEqual({
pass: false,
message: 'Expected instance of String to be an instance of Object'
@@ -156,12 +156,12 @@ describe('toBeInstanceOf', function() {
});
it('passes for objects with no constructor', function() {
var object = Object.create(null);
const object = Object.create(null);
var matcher = jasmineUnderTest.matchers.toBeInstanceOf({
const matcher = jasmineUnderTest.matchers.toBeInstanceOf({
pp: jasmineUnderTest.makePrettyPrinter()
});
var result = matcher.compare(object, Object);
const result = matcher.compare(object, Object);
expect(result).toEqual({
pass: true,
message:
@@ -188,8 +188,8 @@ describe('toBeInstanceOf', function() {
Cat.prototype.constructor = Cat;
it('passes for instances of that class', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(new Animal(), Animal);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(new Animal(), Animal);
expect(result).toEqual({
pass: true,
message: 'Expected instance of Animal not to be an instance of Animal'
@@ -197,8 +197,8 @@ describe('toBeInstanceOf', function() {
});
it('passes for instances of a subclass', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(new Cat(), Animal);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(new Cat(), Animal);
expect(result).toEqual({
pass: true,
message: 'Expected instance of Cat not to be an instance of Animal'
@@ -206,8 +206,8 @@ describe('toBeInstanceOf', function() {
});
it('does not pass for sibling classes', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(new Dog(), Cat);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(new Dog(), Cat);
expect(result).toEqual({
pass: false,
message: 'Expected instance of Dog to be an instance of Cat'
@@ -216,7 +216,7 @@ describe('toBeInstanceOf', function() {
});
it('raises an error if passed an invalid expected value', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
expect(function() {
matcher.compare({}, 'Error');
}).toThrowError(
@@ -226,7 +226,7 @@ describe('toBeInstanceOf', function() {
});
it('raises an error if missing an expected value', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf({
const matcher = jasmineUnderTest.matchers.toBeInstanceOf({
pp: jasmineUnderTest.makePrettyPrinter()
});
expect(function() {

View File

@@ -1,7 +1,7 @@
describe('toBeLessThanOrEqual', function() {
it('passes when actual <= expected', function() {
var matcher = jasmineUnderTest.matchers.toBeLessThanOrEqual(),
result;
const matcher = jasmineUnderTest.matchers.toBeLessThanOrEqual();
let result;
result = matcher.compare(1, 2);
expect(result.pass).toBe(true);
@@ -17,8 +17,8 @@ describe('toBeLessThanOrEqual', function() {
});
it('fails when actual < expected', function() {
var matcher = jasmineUnderTest.matchers.toBeLessThanOrEqual(),
result;
const matcher = jasmineUnderTest.matchers.toBeLessThanOrEqual();
let result;
result = matcher.compare(2, 1);
expect(result.pass).toBe(false);

View File

@@ -1,15 +1,13 @@
describe('toBeLessThan', function() {
it('passes when actual < expected', function() {
var matcher = jasmineUnderTest.matchers.toBeLessThan(),
result;
result = matcher.compare(1, 2);
const matcher = jasmineUnderTest.matchers.toBeLessThan();
const result = matcher.compare(1, 2);
expect(result.pass).toBe(true);
});
it('fails when actual <= expected', function() {
var matcher = jasmineUnderTest.matchers.toBeLessThan(),
result;
const matcher = jasmineUnderTest.matchers.toBeLessThan();
let result;
result = matcher.compare(1, 1);
expect(result.pass).toBe(false);

View File

@@ -1,16 +1,14 @@
describe('toBeNaN', function() {
it('passes for NaN with a custom .not fail', function() {
var matcher = jasmineUnderTest.matchers.toBeNaN(),
result;
result = matcher.compare(Number.NaN);
const matcher = jasmineUnderTest.matchers.toBeNaN();
const result = matcher.compare(Number.NaN);
expect(result.pass).toBe(true);
expect(result.message).toEqual('Expected actual not to be NaN.');
});
it('fails for anything not a NaN', function() {
var matcher = jasmineUnderTest.matchers.toBeNaN(),
result;
const matcher = jasmineUnderTest.matchers.toBeNaN();
let result;
result = matcher.compare(1);
expect(result.pass).toBe(false);
@@ -29,7 +27,7 @@ describe('toBeNaN', function() {
});
it('has a custom message on failure', function() {
var matcher = jasmineUnderTest.matchers.toBeNaN({
const matcher = jasmineUnderTest.matchers.toBeNaN({
pp: jasmineUnderTest.makePrettyPrinter()
}),
result = matcher.compare(0);

View File

@@ -1,7 +1,7 @@
describe('toBeNegativeInfinity', function() {
it("fails for anything that isn't -Infinity", function() {
var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(),
result;
const matcher = jasmineUnderTest.matchers.toBeNegativeInfinity();
let result;
result = matcher.compare(1);
expect(result.pass).toBe(false);
@@ -14,7 +14,7 @@ describe('toBeNegativeInfinity', function() {
});
it('has a custom message on failure', function() {
var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity({
const matcher = jasmineUnderTest.matchers.toBeNegativeInfinity({
pp: jasmineUnderTest.makePrettyPrinter()
}),
result = matcher.compare(0);
@@ -23,7 +23,7 @@ describe('toBeNegativeInfinity', function() {
});
it('succeeds for -Infinity', function() {
var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(),
const matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(),
result = matcher.compare(Number.NEGATIVE_INFINITY);
expect(result.pass).toBe(true);

View File

@@ -1,17 +1,13 @@
describe('toBeNull', function() {
it('passes for null', function() {
var matcher = jasmineUnderTest.matchers.toBeNull(),
result;
result = matcher.compare(null);
const matcher = jasmineUnderTest.matchers.toBeNull();
const result = matcher.compare(null);
expect(result.pass).toBe(true);
});
it('fails for non-null', function() {
var matcher = jasmineUnderTest.matchers.toBeNull(),
result;
result = matcher.compare('foo');
const matcher = jasmineUnderTest.matchers.toBeNull();
const result = matcher.compare('foo');
expect(result.pass).toBe(false);
});
});

View File

@@ -1,7 +1,7 @@
describe('toBePositiveInfinity', function() {
it("fails for anything that isn't Infinity", function() {
var matcher = jasmineUnderTest.matchers.toBePositiveInfinity(),
result;
const matcher = jasmineUnderTest.matchers.toBePositiveInfinity();
let result;
result = matcher.compare(1);
expect(result.pass).toBe(false);
@@ -14,7 +14,7 @@ describe('toBePositiveInfinity', function() {
});
it('has a custom message on failure', function() {
var matcher = jasmineUnderTest.matchers.toBePositiveInfinity({
const matcher = jasmineUnderTest.matchers.toBePositiveInfinity({
pp: jasmineUnderTest.makePrettyPrinter()
}),
result = matcher.compare(0);
@@ -23,7 +23,7 @@ describe('toBePositiveInfinity', function() {
});
it('succeeds for Infinity', function() {
var matcher = jasmineUnderTest.matchers.toBePositiveInfinity(),
const matcher = jasmineUnderTest.matchers.toBePositiveInfinity(),
result = matcher.compare(Number.POSITIVE_INFINITY);
expect(result.pass).toBe(true);

View File

@@ -1,22 +1,19 @@
describe('toBe', function() {
it('passes with no message when actual === expected', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result;
result = matcher.compare(1, 1);
result = matcher.compare(1, 1);
expect(result.pass).toBe(true);
});
it('passes with a custom message when expected is an array', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result,
array = [1];
result = matcher.compare(array, array);
const result = matcher.compare(array, array);
expect(result.pass).toBe(true);
expect(result.message).toBe(
'Expected [ 1 ] not to be [ 1 ]. Tip: To check for deep equality, use .toEqual() instead of .toBe().'
@@ -24,14 +21,13 @@ describe('toBe', function() {
});
it('passes with a custom message when expected is an object', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result,
obj = { foo: 'bar' };
result = matcher.compare(obj, obj);
const result = matcher.compare(obj, obj);
expect(result.pass).toBe(true);
expect(result.message).toBe(
"Expected Object({ foo: 'bar' }) not to be Object({ foo: 'bar' }). Tip: To check for deep equality, use .toEqual() instead of .toBe()."
@@ -39,23 +35,20 @@ describe('toBe', function() {
});
it('fails with no message when actual !== expected', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result;
result = matcher.compare(1, 2);
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() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result;
result = matcher.compare([1], [1]);
result = matcher.compare([1], [1]);
expect(result.pass).toBe(false);
expect(result.message).toBe(
'Expected [ 1 ] to be [ 1 ]. Tip: To check for deep equality, use .toEqual() instead of .toBe().'
@@ -63,13 +56,12 @@ describe('toBe', function() {
});
it('fails with a custom message when expected is an object', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result;
result = matcher.compare({ foo: 'bar' }, { foo: 'bar' });
result = matcher.compare({ foo: 'bar' }, { foo: 'bar' });
expect(result.pass).toBe(false);
expect(result.message).toBe(
"Expected Object({ foo: 'bar' }) to be Object({ foo: 'bar' }). Tip: To check for deep equality, use .toEqual() instead of .toBe()."
@@ -77,15 +69,14 @@ describe('toBe', function() {
});
it('works with custom object formatters when expected is an object', function() {
var formatter = function(x) {
const formatter = function(x) {
return '<' + x.foo + '>';
},
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]),
matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: prettyPrinter }),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result;
result = matcher.compare({ foo: 'bar' }, { foo: 'bar' });
result = matcher.compare({ foo: 'bar' }, { foo: 'bar' });
expect(result.pass).toBe(false);
expect(result.message).toBe(
'Expected <bar> to be <bar>. Tip: To check for deep equality, use .toEqual() instead of .toBe().'

View File

@@ -1,17 +1,13 @@
describe('toBeTrue', function() {
it('passes for true', function() {
var matcher = jasmineUnderTest.matchers.toBeTrue(),
result;
result = matcher.compare(true);
const matcher = jasmineUnderTest.matchers.toBeTrue();
const result = matcher.compare(true);
expect(result.pass).toBe(true);
});
it('fails for non-true', function() {
var matcher = jasmineUnderTest.matchers.toBeTrue(),
result;
result = matcher.compare('foo');
const matcher = jasmineUnderTest.matchers.toBeTrue();
const result = matcher.compare('foo');
expect(result.pass).toBe(false);
});
});

View File

@@ -1,7 +1,7 @@
describe('toBeTruthy', function() {
it("passes for 'truthy' values", function() {
var matcher = jasmineUnderTest.matchers.toBeTruthy(),
result;
const matcher = jasmineUnderTest.matchers.toBeTruthy();
let result;
result = matcher.compare(true);
expect(result.pass).toBe(true);
@@ -23,8 +23,8 @@ describe('toBeTruthy', function() {
});
it("fails for 'falsy' values", function() {
var matcher = jasmineUnderTest.matchers.toBeTruthy(),
result;
const matcher = jasmineUnderTest.matchers.toBeTruthy();
let result;
result = matcher.compare(false);
expect(result.pass).toBe(false);

View File

@@ -1,17 +1,13 @@
describe('toBeUndefined', function() {
it('passes for undefined values', function() {
var matcher = jasmineUnderTest.matchers.toBeUndefined(),
result;
result = matcher.compare(void 0);
const matcher = jasmineUnderTest.matchers.toBeUndefined();
const result = matcher.compare(void 0);
expect(result.pass).toBe(true);
});
it('fails when matching defined values', function() {
var matcher = jasmineUnderTest.matchers.toBeUndefined(),
result;
result = matcher.compare('foo');
const matcher = jasmineUnderTest.matchers.toBeUndefined();
const result = matcher.compare('foo');
expect(result.pass).toBe(false);
});
});

View File

@@ -1,27 +1,25 @@
describe('toContain', function() {
it('delegates to jasmineUnderTest.matchersUtil.contains', function() {
var matchersUtil = {
const matchersUtil = {
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
},
matcher = jasmineUnderTest.matchers.toContain(matchersUtil),
result;
matcher = jasmineUnderTest.matchers.toContain(matchersUtil);
result = matcher.compare('ABC', 'B');
const result = matcher.compare('ABC', 'B');
expect(matchersUtil.contains).toHaveBeenCalledWith('ABC', 'B');
expect(result.pass).toBe(true);
});
it('works with custom equality testers', function() {
var tester = function(a, b) {
const tester = function(a, b) {
return a.toString() === b.toString();
},
matchersUtil = new jasmineUnderTest.MatchersUtil({
customTesters: [tester]
}),
matcher = jasmineUnderTest.matchers.toContain(matchersUtil),
result;
matcher = jasmineUnderTest.matchers.toContain(matchersUtil);
result = matcher.compare(['1', '2'], 2);
const result = matcher.compare(['1', '2'], 2);
expect(result.pass).toBe(true);
});
});

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
describe('toHaveBeenCalledBefore', function() {
it('throws an exception when the actual is not a spy', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore({
const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {},
@@ -12,7 +12,7 @@ describe('toHaveBeenCalledBefore', function() {
});
it('throws an exception when the expected is not a spy', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore({
const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore({
pp: jasmineUnderTest.makePrettyPrinter()
}),
spy = new jasmineUnderTest.Env().createSpy('a spy'),
@@ -24,7 +24,7 @@ describe('toHaveBeenCalledBefore', function() {
});
it('fails when the actual was not called', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy');
@@ -38,7 +38,7 @@ describe('toHaveBeenCalledBefore', function() {
});
it('fails when the expected was not called', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy');
@@ -52,15 +52,14 @@ describe('toHaveBeenCalledBefore', function() {
});
it('fails when the actual is called after the expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy'),
result;
secondSpy = new jasmineUnderTest.Spy('second spy');
secondSpy();
firstSpy();
result = matcher.compare(firstSpy, secondSpy);
const result = matcher.compare(firstSpy, secondSpy);
expect(result.pass).toBe(false);
expect(result.message).toEqual(
'Expected spy first spy to have been called before spy second spy'
@@ -68,16 +67,15 @@ describe('toHaveBeenCalledBefore', function() {
});
it('fails when the actual is called before and after the expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy'),
result;
secondSpy = new jasmineUnderTest.Spy('second spy');
firstSpy();
secondSpy();
firstSpy();
result = matcher.compare(firstSpy, secondSpy);
const result = matcher.compare(firstSpy, secondSpy);
expect(result.pass).toBe(false);
expect(result.message).toEqual(
'Expected latest call to spy first spy to have been called before first call to spy second spy (no interleaved calls)'
@@ -85,16 +83,15 @@ describe('toHaveBeenCalledBefore', function() {
});
it('fails when the expected is called before and after the actual', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy'),
result;
secondSpy = new jasmineUnderTest.Spy('second spy');
secondSpy();
firstSpy();
secondSpy();
result = matcher.compare(firstSpy, secondSpy);
const result = matcher.compare(firstSpy, secondSpy);
expect(result.pass).toBe(false);
expect(result.message).toEqual(
'Expected first call to spy second spy to have been called after latest call to spy first spy (no interleaved calls)'
@@ -102,15 +99,14 @@ describe('toHaveBeenCalledBefore', function() {
});
it('passes when the actual is called before the expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy'),
result;
secondSpy = new jasmineUnderTest.Spy('second spy');
firstSpy();
secondSpy();
result = matcher.compare(firstSpy, secondSpy);
const result = matcher.compare(firstSpy, secondSpy);
expect(result.pass).toBe(true);
expect(result.message).toEqual(
'Expected spy first spy to not have been called before spy second spy, but it was'

View File

@@ -1,13 +1,12 @@
describe('toHaveBeenCalledOnceWith', function() {
it('passes when the actual was called only once and with matching parameters', function() {
var pp = jasmineUnderTest.makePrettyPrinter(),
const pp = jasmineUnderTest.makePrettyPrinter(),
util = new jasmineUnderTest.MatchersUtil({ pp: pp }),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
calledSpy = new jasmineUnderTest.Spy('called-spy');
calledSpy('a', 'b');
result = matcher.compare(calledSpy, 'a', 'b');
const result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(true);
expect(result.message).toEqual(
@@ -16,7 +15,7 @@ describe('toHaveBeenCalledOnceWith', function() {
});
it('supports custom equality testers', function() {
var customEqualityTesters = [
const customEqualityTesters = [
function() {
return true;
}
@@ -27,23 +26,21 @@ describe('toHaveBeenCalledOnceWith', function() {
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(
matchersUtil
),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
calledSpy = new jasmineUnderTest.Spy('called-spy');
calledSpy('a', 'b');
result = matcher.compare(calledSpy, 'a', 'a');
const result = matcher.compare(calledSpy, 'a', 'a');
expect(result.pass).toBe(true);
});
it('fails when the actual was never called', function() {
var pp = jasmineUnderTest.makePrettyPrinter(),
const pp = jasmineUnderTest.makePrettyPrinter(),
util = new jasmineUnderTest.MatchersUtil({ pp: pp }),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
calledSpy = new jasmineUnderTest.Spy('called-spy');
result = matcher.compare(calledSpy, 'a', 'b');
const result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(false);
expect(result.message).toEqual(
@@ -52,14 +49,13 @@ describe('toHaveBeenCalledOnceWith', function() {
});
it('fails when the actual was called once with different parameters', function() {
var pp = jasmineUnderTest.makePrettyPrinter(),
const pp = jasmineUnderTest.makePrettyPrinter(),
util = new jasmineUnderTest.MatchersUtil({ pp: pp }),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
calledSpy = new jasmineUnderTest.Spy('called-spy');
calledSpy('a', 'c');
result = matcher.compare(calledSpy, 'a', 'b');
const result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(false);
expect(result.message).toEqual(
@@ -68,15 +64,14 @@ describe('toHaveBeenCalledOnceWith', function() {
});
it('fails when the actual was called multiple times with expected parameters', function() {
var pp = jasmineUnderTest.makePrettyPrinter(),
const pp = jasmineUnderTest.makePrettyPrinter(),
util = new jasmineUnderTest.MatchersUtil({ pp: pp }),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
calledSpy = new jasmineUnderTest.Spy('called-spy');
calledSpy('a', 'b');
calledSpy('a', 'b');
result = matcher.compare(calledSpy, 'a', 'b');
const result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(false);
expect(result.message).toEqual(
@@ -85,15 +80,14 @@ describe('toHaveBeenCalledOnceWith', function() {
});
it('fails when the actual was called multiple times (one of them - with expected parameters)', function() {
var pp = jasmineUnderTest.makePrettyPrinter(),
const pp = jasmineUnderTest.makePrettyPrinter(),
util = new jasmineUnderTest.MatchersUtil({ pp: pp }),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
calledSpy = new jasmineUnderTest.Spy('called-spy');
calledSpy('a', 'b');
calledSpy('a', 'c');
result = matcher.compare(calledSpy, 'a', 'b');
const result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(false);
expect(result.message).toEqual(
@@ -102,7 +96,7 @@ describe('toHaveBeenCalledOnceWith', function() {
});
it('throws an exception when the actual is not a spy', function() {
var pp = jasmineUnderTest.makePrettyPrinter(),
const pp = jasmineUnderTest.makePrettyPrinter(),
util = new jasmineUnderTest.MatchersUtil({ pp: pp }),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util),
fn = function() {};

View File

@@ -1,12 +1,11 @@
describe('toHaveBeenCalled', function() {
it('passes when the actual was called, with a custom .not fail message', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
const matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
calledSpy = new jasmineUnderTest.Spy('called-spy');
calledSpy();
result = matcher.compare(calledSpy);
const result = matcher.compare(calledSpy);
expect(result.pass).toBe(true);
expect(result.message).toEqual(
'Expected spy called-spy not to have been called.'
@@ -14,16 +13,15 @@ describe('toHaveBeenCalled', function() {
});
it('fails when the actual was not called', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'),
result;
const matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
uncalledSpy = new jasmineUnderTest.Spy('uncalled spy');
result = matcher.compare(uncalledSpy);
const result = matcher.compare(uncalledSpy);
expect(result.pass).toBe(false);
});
it('throws an exception when the actual is not a spy', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled({
const matcher = jasmineUnderTest.matchers.toHaveBeenCalled({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {};
@@ -34,7 +32,7 @@ describe('toHaveBeenCalled', function() {
});
it('throws an exception when invoked with any arguments', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
const matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
spy = new jasmineUnderTest.Spy('sample spy');
expect(function() {
@@ -43,11 +41,10 @@ describe('toHaveBeenCalled', function() {
});
it('has a custom message on failure', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
spy = new jasmineUnderTest.Spy('sample-spy'),
result;
const matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
spy = new jasmineUnderTest.Spy('sample-spy');
result = matcher.compare(spy);
const result = matcher.compare(spy);
expect(result.message).toEqual(
'Expected spy sample-spy to have been called.'

View File

@@ -1,23 +1,21 @@
describe('toHaveBeenCalledTimes', function() {
it('passes when the actual 0 matches the expected 0 ', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
result = matcher.compare(calledSpy, 0);
result = matcher.compare(calledSpy, 0);
expect(result.pass).toBeTruthy();
});
it('passes when the actual matches the expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
calledSpy = new jasmineUnderTest.Spy('called-spy');
calledSpy();
result = matcher.compare(calledSpy, 1);
const result = matcher.compare(calledSpy, 1);
expect(result.pass).toBe(true);
});
it('fails when expected numbers is not supplied', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
spy = new jasmineUnderTest.Spy('spy');
spy();
@@ -29,28 +27,26 @@ describe('toHaveBeenCalledTimes', function() {
});
it('fails when the actual was called less than the expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'),
result;
const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
uncalledSpy = new jasmineUnderTest.Spy('uncalled spy');
result = matcher.compare(uncalledSpy, 2);
const result = matcher.compare(uncalledSpy, 2);
expect(result.pass).toBe(false);
});
it('fails when the actual was called more than expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'),
result;
const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
uncalledSpy = new jasmineUnderTest.Spy('uncalled spy');
uncalledSpy();
uncalledSpy();
result = matcher.compare(uncalledSpy, 1);
const result = matcher.compare(uncalledSpy, 1);
expect(result.pass).toBe(false);
});
it('throws an exception when the actual is not a spy', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes({
const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {};
@@ -61,15 +57,14 @@ describe('toHaveBeenCalledTimes', function() {
});
it('has a custom message on failure that tells it was called only once', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
spy = new jasmineUnderTest.Spy('sample-spy'),
result;
const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
spy = new jasmineUnderTest.Spy('sample-spy');
spy();
spy();
spy();
spy();
result = matcher.compare(spy, 1);
const result = matcher.compare(spy, 1);
expect(result.message).toEqual(
'Expected spy sample-spy to have been called once. It was called ' +
4 +
@@ -78,15 +73,14 @@ describe('toHaveBeenCalledTimes', function() {
});
it('has a custom message on failure that tells how many times it was called', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
spy = new jasmineUnderTest.Spy('sample-spy'),
result;
const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
spy = new jasmineUnderTest.Spy('sample-spy');
spy();
spy();
spy();
spy();
result = matcher.compare(spy, 2);
const result = matcher.compare(spy, 2);
expect(result.message).toEqual(
'Expected spy sample-spy to have been called 2 times. It was called ' +
4 +

View File

@@ -1,15 +1,14 @@
describe('toHaveBeenCalledWith', function() {
it('passes when the actual was called with matching parameters', function() {
var matchersUtil = {
const matchersUtil = {
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
calledSpy = new jasmineUnderTest.Spy('called-spy');
calledSpy('a', 'b');
result = matcher.compare(calledSpy, 'a', 'b');
const result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(true);
expect(result.message()).toEqual(
@@ -18,7 +17,7 @@ describe('toHaveBeenCalledWith', function() {
});
it('supports custom equality testers', function() {
var customEqualityTesters = [
const customEqualityTesters = [
function() {
return true;
}
@@ -27,26 +26,24 @@ describe('toHaveBeenCalledWith', function() {
customTesters: customEqualityTesters
}),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
calledSpy = new jasmineUnderTest.Spy('called-spy');
calledSpy('a', 'b');
result = matcher.compare(calledSpy, 'a', 'b');
const result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(true);
});
it('fails when the actual was not called', function() {
var matchersUtil = {
const matchersUtil = {
contains: jasmine
.createSpy('delegated-contains')
.and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'),
result;
uncalledSpy = new jasmineUnderTest.Spy('uncalled spy');
result = matcher.compare(uncalledSpy);
const result = matcher.compare(uncalledSpy);
expect(result.pass).toBe(false);
expect(result.message()).toEqual(
'Expected spy uncalled spy to have been called with:\n [ ]\nbut it was never called.'
@@ -54,17 +51,16 @@ describe('toHaveBeenCalledWith', function() {
});
it('fails when the actual was called with different parameters', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
calledSpy = new jasmineUnderTest.Spy('called spy'),
result;
calledSpy = new jasmineUnderTest.Spy('called spy');
calledSpy('a');
calledSpy('c', 'd');
calledSpy('a', 'b', 'c');
result = matcher.compare(calledSpy, 'a', 'b');
const result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(false);
expect(result.message()).toEqual(
@@ -87,7 +83,7 @@ describe('toHaveBeenCalledWith', function() {
});
it('throws an exception when the actual is not a spy', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith({
const matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {};

View File

@@ -4,7 +4,7 @@ describe('toHaveClass', function() {
});
it('fails for a DOM element that lacks the expected class', function() {
var matcher = jasmineUnderTest.matchers.toHaveClass(),
const matcher = jasmineUnderTest.matchers.toHaveClass(),
result = matcher.compare(
this.domHelpers.createElementWithClassName(''),
'foo'
@@ -14,7 +14,7 @@ describe('toHaveClass', function() {
});
it('passes for a DOM element that has the expected class', function() {
var matcher = jasmineUnderTest.matchers.toHaveClass(),
const matcher = jasmineUnderTest.matchers.toHaveClass(),
el = this.domHelpers.createElementWithClassName('foo bar baz');
expect(matcher.compare(el, 'foo').pass).toBe(true);
@@ -23,14 +23,14 @@ describe('toHaveClass', function() {
});
it('fails for a DOM element that only has other classes', function() {
var matcher = jasmineUnderTest.matchers.toHaveClass(),
const matcher = jasmineUnderTest.matchers.toHaveClass(),
el = this.domHelpers.createElementWithClassName('foo bar');
expect(matcher.compare(el, 'fo').pass).toBe(false);
});
it('throws an exception when actual is not a DOM element', function() {
var matcher = jasmineUnderTest.matchers.toHaveClass({
const matcher = jasmineUnderTest.matchers.toHaveClass({
pp: jasmineUnderTest.makePrettyPrinter()
});
@@ -42,7 +42,7 @@ describe('toHaveClass', function() {
matcher.compare(undefined, 'foo');
}).toThrowError('undefined is not a DOM element');
var textNode = this.domHelpers.document.createTextNode('');
const textNode = this.domHelpers.document.createTextNode('');
expect(function() {
matcher.compare(textNode, 'foo');
}).toThrowError('HTMLNode is not a DOM element');

View File

@@ -2,107 +2,107 @@ describe('toHaveSize', function() {
'use strict';
it('passes for an array whose length matches', function() {
var matcher = jasmineUnderTest.matchers.toHaveSize(),
const matcher = jasmineUnderTest.matchers.toHaveSize(),
result = matcher.compare([1, 2], 2);
expect(result.pass).toBe(true);
});
it('fails for an array whose length does not match', function() {
var matcher = jasmineUnderTest.matchers.toHaveSize(),
const matcher = jasmineUnderTest.matchers.toHaveSize(),
result = matcher.compare([1, 2, 3], 2);
expect(result.pass).toBe(false);
});
it('passes for an object with the proper number of keys', function() {
var matcher = jasmineUnderTest.matchers.toHaveSize(),
const matcher = jasmineUnderTest.matchers.toHaveSize(),
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() {
var matcher = jasmineUnderTest.matchers.toHaveSize(),
const matcher = jasmineUnderTest.matchers.toHaveSize(),
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() {
var matcher = jasmineUnderTest.matchers.toHaveSize(),
const matcher = jasmineUnderTest.matchers.toHaveSize(),
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() {
var matcher = jasmineUnderTest.matchers.toHaveSize(),
const matcher = jasmineUnderTest.matchers.toHaveSize(),
result = matcher.compare({ a: 1, b: 2, length: 5 }, 1);
expect(result.pass).toBe(false);
});
it('passes for a string whose length matches', function() {
var matcher = jasmineUnderTest.matchers.toHaveSize(),
const matcher = jasmineUnderTest.matchers.toHaveSize(),
result = matcher.compare('ab', 2);
expect(result.pass).toBe(true);
});
it('fails for a string whose length does not match', function() {
var matcher = jasmineUnderTest.matchers.toHaveSize(),
const matcher = jasmineUnderTest.matchers.toHaveSize(),
result = matcher.compare('abc', 2);
expect(result.pass).toBe(false);
});
it('passes for a Map whose length matches', function() {
var map = new Map();
const map = new Map();
map.set('a', 1);
map.set('b', 2);
var matcher = jasmineUnderTest.matchers.toHaveSize(),
const matcher = jasmineUnderTest.matchers.toHaveSize(),
result = matcher.compare(map, 2);
expect(result.pass).toBe(true);
});
it('fails for a Map whose length does not match', function() {
var map = new Map();
const map = new Map();
map.set('a', 1);
map.set('b', 2);
var matcher = jasmineUnderTest.matchers.toHaveSize(),
const matcher = jasmineUnderTest.matchers.toHaveSize(),
result = matcher.compare(map, 1);
expect(result.pass).toBe(false);
});
it('passes for a Set whose length matches', function() {
var set = new Set();
const set = new Set();
set.add('a');
set.add('b');
var matcher = jasmineUnderTest.matchers.toHaveSize(),
const matcher = jasmineUnderTest.matchers.toHaveSize(),
result = matcher.compare(set, 2);
expect(result.pass).toBe(true);
});
it('fails for a Set whose length does not match', function() {
var set = new Set();
const set = new Set();
set.add('a');
set.add('b');
var matcher = jasmineUnderTest.matchers.toHaveSize(),
const matcher = jasmineUnderTest.matchers.toHaveSize(),
result = matcher.compare(set, 1);
expect(result.pass).toBe(false);
});
it('throws an error for WeakSet', function() {
var matcher = jasmineUnderTest.matchers.toHaveSize();
const matcher = jasmineUnderTest.matchers.toHaveSize();
expect(function() {
matcher.compare(new WeakSet(), 2);
@@ -110,7 +110,7 @@ describe('toHaveSize', function() {
});
it('throws an error for WeakMap', function() {
var matcher = jasmineUnderTest.matchers.toHaveSize();
const matcher = jasmineUnderTest.matchers.toHaveSize();
expect(function() {
matcher.compare(new WeakMap(), 2);
@@ -118,7 +118,7 @@ describe('toHaveSize', function() {
});
it('throws an error for DataView', function() {
var matcher = jasmineUnderTest.matchers.toHaveSize();
const matcher = jasmineUnderTest.matchers.toHaveSize();
expect(function() {
matcher.compare(new DataView(new ArrayBuffer(128)), 2);

View File

@@ -1,38 +1,34 @@
describe('toMatch', function() {
it('passes when RegExps are equivalent', function() {
var matcher = jasmineUnderTest.matchers.toMatch(),
result;
const matcher = jasmineUnderTest.matchers.toMatch();
result = matcher.compare(/foo/, /foo/);
const result = matcher.compare(/foo/, /foo/);
expect(result.pass).toBe(true);
});
it('fails when RegExps are not equivalent', function() {
var matcher = jasmineUnderTest.matchers.toMatch(),
result;
const matcher = jasmineUnderTest.matchers.toMatch();
result = matcher.compare(/bar/, /foo/);
const result = matcher.compare(/bar/, /foo/);
expect(result.pass).toBe(false);
});
it('passes when the actual matches the expected string as a pattern', function() {
var matcher = jasmineUnderTest.matchers.toMatch(),
result;
const matcher = jasmineUnderTest.matchers.toMatch();
result = matcher.compare('foosball', 'foo');
const result = matcher.compare('foosball', 'foo');
expect(result.pass).toBe(true);
});
it('fails when the actual matches the expected string as a pattern', function() {
var matcher = jasmineUnderTest.matchers.toMatch(),
result;
const matcher = jasmineUnderTest.matchers.toMatch();
result = matcher.compare('bar', 'foo');
const result = matcher.compare('bar', 'foo');
expect(result.pass).toBe(false);
});
it('throws an Error when the expected is not a String or RegExp', function() {
var matcher = jasmineUnderTest.matchers.toMatch();
const matcher = jasmineUnderTest.matchers.toMatch();
expect(function() {
matcher.compare('foo', { bar: 'baz' });

View File

@@ -1,6 +1,6 @@
describe('toThrowError', function() {
it('throws an error when the actual is not a function', function() {
var matcher = jasmineUnderTest.matchers.toThrowError();
const matcher = jasmineUnderTest.matchers.toThrowError();
expect(function() {
matcher.compare({});
@@ -8,7 +8,7 @@ describe('toThrowError', function() {
});
it('throws an error when the expected is not an Error, string, or RegExp', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
const matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error('foo');
};
@@ -19,7 +19,7 @@ describe('toThrowError', function() {
});
it('throws an error when the expected error type is not an Error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
const matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error('foo');
};
@@ -30,7 +30,7 @@ describe('toThrowError', function() {
});
it('throws an error when the expected error message is not a string or RegExp', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
const matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error('foo');
};
@@ -41,28 +41,26 @@ describe('toThrowError', function() {
});
it('fails if actual does not throw at all', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
const matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
return true;
},
result;
};
result = matcher.compare(fn);
const result = matcher.compare(fn);
expect(result.pass).toBe(false);
expect(result.message).toEqual('Expected function to throw an Error.');
});
it('fails if thrown is not an instanceof Error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
const matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {
throw 4;
},
result;
};
result = matcher.compare(fn);
const result = matcher.compare(fn);
expect(result.pass).toBe(false);
expect(result.message()).toEqual(
'Expected function to throw an Error, but it threw 4.'
@@ -74,7 +72,7 @@ describe('toThrowError', function() {
return typeof document === 'undefined';
}
var iframe = null;
let iframe = null;
afterEach(function() {
if (iframe !== null) {
@@ -87,16 +85,16 @@ describe('toThrowError', function() {
return;
}
var matcher = jasmineUnderTest.matchers.toThrowError();
const matcher = jasmineUnderTest.matchers.toThrowError();
iframe = document.body.appendChild(document.createElement('iframe'));
iframe.src = 'about:blank';
var iframeDocument = iframe.contentWindow.document;
const iframeDocument = iframe.contentWindow.document;
iframeDocument.body.appendChild(
iframeDocument.createElement('script')
).textContent = "function method() { throw new Error('foo'); }";
var result = matcher.compare(iframe.contentWindow.method);
const result = matcher.compare(iframe.contentWindow.method);
expect(result.pass).toBe(true);
expect(result.message).toEqual(
'Expected function not to throw an Error, but it threw Error.'
@@ -105,15 +103,14 @@ describe('toThrowError', function() {
});
it('fails with the correct message if thrown is a falsy value', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
const matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {
throw undefined;
},
result;
};
result = matcher.compare(fn);
const result = matcher.compare(fn);
expect(result.pass).toBe(false);
expect(result.message()).toEqual(
'Expected function to throw an Error, but it threw undefined.'
@@ -121,13 +118,12 @@ describe('toThrowError', function() {
});
it('passes if thrown is a type of Error, but there is no expected error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
const matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
throw new TypeError();
},
result;
};
result = matcher.compare(fn);
const result = matcher.compare(fn);
expect(result.pass).toBe(true);
expect(result.message).toEqual(
@@ -136,15 +132,14 @@ describe('toThrowError', function() {
});
it('passes if thrown is an Error and the expected is the same message', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
const matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {
throw new Error('foo');
},
result;
};
result = matcher.compare(fn, 'foo');
const result = matcher.compare(fn, 'foo');
expect(result.pass).toBe(true);
expect(result.message()).toEqual(
@@ -153,15 +148,14 @@ describe('toThrowError', function() {
});
it('fails if thrown is an Error and the expected is not the same message', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
const matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {
throw new Error('foo');
},
result;
};
result = matcher.compare(fn, 'bar');
const result = matcher.compare(fn, 'bar');
expect(result.pass).toBe(false);
expect(result.message()).toEqual(
@@ -170,15 +164,14 @@ describe('toThrowError', function() {
});
it('passes if thrown is an Error and the expected is a RegExp that matches the message', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
const matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {
throw new Error('a long message');
},
result;
};
result = matcher.compare(fn, /long/);
const result = matcher.compare(fn, /long/);
expect(result.pass).toBe(true);
expect(result.message()).toEqual(
@@ -187,15 +180,14 @@ describe('toThrowError', function() {
});
it('fails if thrown is an Error and the expected is a RegExp that does not match the message', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
const matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {
throw new Error('a long message');
},
result;
};
result = matcher.compare(fn, /foo/);
const result = matcher.compare(fn, /foo/);
expect(result.pass).toBe(false);
expect(result.message()).toEqual(
@@ -204,31 +196,29 @@ describe('toThrowError', function() {
});
it('passes if thrown is an Error and the expected the same Error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
const matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error();
},
result;
};
result = matcher.compare(fn, Error);
const result = matcher.compare(fn, Error);
expect(result.pass).toBe(true);
expect(result.message()).toEqual('Expected function not to throw Error.');
});
it('passes if thrown is a custom error that takes arguments and the expected is the same error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
const matcher = jasmineUnderTest.matchers.toThrowError(),
CustomError = function CustomError(arg) {
arg.x;
},
fn = function() {
throw new CustomError({ x: 1 });
},
result;
};
CustomError.prototype = new Error();
result = matcher.compare(fn, CustomError);
const result = matcher.compare(fn, CustomError);
expect(result.pass).toBe(true);
expect(result.message()).toEqual(
@@ -237,13 +227,12 @@ describe('toThrowError', function() {
});
it('fails if thrown is an Error and the expected is a different Error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
const matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error();
},
result;
};
result = matcher.compare(fn, TypeError);
const result = matcher.compare(fn, TypeError);
expect(result.pass).toBe(false);
expect(result.message()).toEqual(
@@ -252,17 +241,16 @@ describe('toThrowError', function() {
});
it('passes if thrown is a type of Error and it is equal to the expected Error and message', function() {
var matchersUtil = {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
throw new TypeError('foo');
},
result;
};
result = matcher.compare(fn, TypeError, 'foo');
const result = matcher.compare(fn, TypeError, 'foo');
expect(result.pass).toBe(true);
expect(result.message()).toEqual(
@@ -271,7 +259,7 @@ 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() {
var matchersUtil = {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
@@ -281,12 +269,11 @@ describe('toThrowError', function() {
},
fn = function() {
throw new CustomError({ message: 'foo' });
},
result;
};
CustomError.prototype = new Error();
result = matcher.compare(fn, CustomError, 'foo');
const result = matcher.compare(fn, CustomError, 'foo');
expect(result.pass).toBe(true);
expect(result.message()).toEqual(
@@ -295,17 +282,16 @@ describe('toThrowError', function() {
});
it('fails if thrown is a type of Error and the expected is a different Error', function() {
var matchersUtil = {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
throw new TypeError('foo');
},
result;
};
result = matcher.compare(fn, TypeError, 'bar');
const result = matcher.compare(fn, TypeError, 'bar');
expect(result.pass).toBe(false);
expect(result.message()).toEqual(
@@ -314,17 +300,16 @@ 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() {
var matchersUtil = {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
throw new TypeError('foo');
},
result;
};
result = matcher.compare(fn, TypeError, /foo/);
const result = matcher.compare(fn, TypeError, /foo/);
expect(result.pass).toBe(true);
expect(result.message()).toEqual(
@@ -333,17 +318,16 @@ describe('toThrowError', function() {
});
it('fails if thrown is a type of Error and the expected is a different Error', function() {
var matchersUtil = {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
throw new TypeError('foo');
},
result;
};
result = matcher.compare(fn, TypeError, /bar/);
const result = matcher.compare(fn, TypeError, /bar/);
expect(result.pass).toBe(false);
expect(result.message()).toEqual(

View File

@@ -1,6 +1,6 @@
describe('toThrowMatching', function() {
it('throws an error when the actual is not a function', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching();
const matcher = jasmineUnderTest.matchers.toThrowMatching();
expect(function() {
matcher.compare({}, function() {
@@ -10,7 +10,7 @@ describe('toThrowMatching', function() {
});
it('throws an error when the expected is not a function', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching(),
const matcher = jasmineUnderTest.matchers.toThrowMatching(),
fn = function() {
throw new Error('foo');
};
@@ -21,13 +21,12 @@ describe('toThrowMatching', function() {
});
it('fails if actual does not throw at all', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching(),
const matcher = jasmineUnderTest.matchers.toThrowMatching(),
fn = function() {
return true;
},
result;
};
result = matcher.compare(fn, function() {
const result = matcher.compare(fn, function() {
return true;
});
@@ -36,15 +35,14 @@ describe('toThrowMatching', function() {
});
it('fails with the correct message if thrown is a falsy value', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching({
const matcher = jasmineUnderTest.matchers.toThrowMatching({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {
throw undefined;
},
result;
};
result = matcher.compare(fn, function() {
const result = matcher.compare(fn, function() {
return false;
});
expect(result.pass).toBe(false);
@@ -54,16 +52,15 @@ describe('toThrowMatching', function() {
});
it('passes if the argument is a function that returns true when called with the error', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching(),
const matcher = jasmineUnderTest.matchers.toThrowMatching(),
predicate = function(e) {
return e.message === 'nope';
},
fn = function() {
throw new TypeError('nope');
},
result;
};
result = matcher.compare(fn, predicate);
const result = matcher.compare(fn, predicate);
expect(result.pass).toBe(true);
expect(result.message).toEqual(
@@ -72,7 +69,7 @@ describe('toThrowMatching', function() {
});
it('fails if the argument is a function that returns false when called with the error', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching({
const matcher = jasmineUnderTest.matchers.toThrowMatching({
pp: jasmineUnderTest.makePrettyPrinter()
}),
predicate = function(e) {
@@ -80,10 +77,9 @@ describe('toThrowMatching', function() {
},
fn = function() {
throw new TypeError('nope');
},
result;
};
result = matcher.compare(fn, predicate);
const result = matcher.compare(fn, predicate);
expect(result.pass).toBe(false);
expect(result.message()).toEqual(

View File

@@ -1,6 +1,6 @@
describe('toThrow', function() {
it('throws an error when the actual is not a function', function() {
var matcher = jasmineUnderTest.matchers.toThrow();
const matcher = jasmineUnderTest.matchers.toThrow();
expect(function() {
matcher.compare({});
@@ -9,30 +9,28 @@ describe('toThrow', function() {
});
it('fails if actual does not throw', function() {
var matcher = jasmineUnderTest.matchers.toThrow(),
const matcher = jasmineUnderTest.matchers.toThrow(),
fn = function() {
return true;
},
result;
};
result = matcher.compare(fn);
const result = matcher.compare(fn);
expect(result.pass).toBe(false);
expect(result.message).toEqual('Expected function to throw an exception.');
});
it('passes if it throws but there is no expected', function() {
var matchersUtil = {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
fn = function() {
throw 5;
},
result;
};
result = matcher.compare(fn);
const result = matcher.compare(fn);
expect(result.pass).toBe(true);
expect(result.message()).toEqual(
@@ -41,15 +39,14 @@ describe('toThrow', function() {
});
it('passes even if what is thrown is falsy', function() {
var matcher = jasmineUnderTest.matchers.toThrow({
const matcher = jasmineUnderTest.matchers.toThrow({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {
throw undefined;
},
result;
};
result = matcher.compare(fn);
const result = matcher.compare(fn);
expect(result.pass).toBe(true);
expect(result.message()).toEqual(
'Expected function not to throw, but it threw undefined.'
@@ -57,34 +54,32 @@ describe('toThrow', function() {
});
it('passes if what is thrown is equivalent to what is expected', function() {
var matchersUtil = {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
fn = function() {
throw 5;
},
result;
};
result = matcher.compare(fn, 5);
const result = matcher.compare(fn, 5);
expect(result.pass).toBe(true);
expect(result.message()).toEqual('Expected function not to throw 5.');
});
it('fails if what is thrown is not equivalent to what is expected', function() {
var matchersUtil = {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
fn = function() {
throw 5;
},
result;
};
result = matcher.compare(fn, 'foo');
const result = matcher.compare(fn, 'foo');
expect(result.pass).toBe(false);
expect(result.message()).toEqual(
@@ -93,17 +88,16 @@ describe('toThrow', function() {
});
it('fails if what is thrown is not equivalent to undefined', function() {
var matchersUtil = {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
fn = function() {
throw 5;
},
result;
};
result = matcher.compare(fn, void 0);
const result = matcher.compare(fn, void 0);
expect(result.pass).toBe(false);
expect(result.message()).toEqual(