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