Merge branch '6.0'

This commit is contained in:
Steve Gravrock
2025-12-01 17:48:49 -08:00
266 changed files with 10971 additions and 6448 deletions

View File

@@ -1,79 +1,79 @@
describe('matchersUtil', function() {
it('exposes the injected pretty-printer as .pp', function() {
const pp = function() {},
matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp });
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp });
expect(matchersUtil.pp).toBe(pp);
});
describe('equals', function() {
it('passes for literals that are triple-equal', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.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() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals({ a: 'foo' }, 1)).toBe(false);
});
it('passes for Strings that are equivalent', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals('foo', 'foo')).toBe(true);
});
it('fails for Strings that are not equivalent', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals('foo', 'bar')).toBe(false);
});
it('passes for Numbers that are equivalent', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(123, 123)).toBe(true);
});
it('fails for Numbers that are not equivalent', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(123, 456)).toBe(false);
});
it('fails for a Number and a String that have equivalent values', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(123, '123')).toBe(false);
});
it('passes for Dates that are equivalent', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.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() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(
matchersUtil.equals(new Date('Jan 1, 1970'), new Date('Feb 3, 1991'))
).toBe(false);
});
it('passes for Booleans that are equivalent', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(true, true)).toBe(true);
});
it('fails for Booleans that are not equivalent', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(true, false)).toBe(false);
});
it('passes for RegExps that are equivalent', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(/foo/, /foo/)).toBe(true);
});
it('fails for RegExps that are not equivalent', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(/foo/, /bar/)).toBe(false);
expect(
matchersUtil.equals(new RegExp('foo', 'i'), new RegExp('foo'))
@@ -81,32 +81,32 @@ describe('matchersUtil', function() {
});
it('passes for Arrays that are equivalent', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals([1, 2], [1, 2])).toBe(true);
});
it('passes for Arrays that are equivalent, with elements added by changing length', function() {
const foo = [],
matchersUtil = new jasmineUnderTest.MatchersUtil();
matchersUtil = new privateUnderTest.MatchersUtil();
foo.length = 1;
expect(matchersUtil.equals(foo, [undefined])).toBe(true);
});
it('fails for Arrays that have different lengths', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals([1, 2], [1, 2, 3])).toBe(false);
});
it('fails for Arrays that have different elements', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.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() {
const one = [1, 2, 3],
two = [1, 2, 3],
matchersUtil = new jasmineUnderTest.MatchersUtil();
matchersUtil = new privateUnderTest.MatchersUtil();
one.foo = 'bar';
two.foo = 'baz';
@@ -117,7 +117,7 @@ describe('matchersUtil', function() {
it('passes for Arrays with equivalent contents and properties', function() {
const one = [1, 2, 3],
two = [1, 2, 3],
matchersUtil = new jasmineUnderTest.MatchersUtil();
matchersUtil = new privateUnderTest.MatchersUtil();
one.foo = 'bar';
two.foo = 'bar';
@@ -126,7 +126,7 @@ describe('matchersUtil', function() {
});
it('handles symbol keys in Arrays', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
const matchersUtil = new privateUnderTest.MatchersUtil(),
sym = Symbol('foo'),
arr1 = [];
let arr2 = [];
@@ -148,21 +148,21 @@ describe('matchersUtil', function() {
});
it('passes for Errors that are the same type and have the same message', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.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() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(new Error('foo'), new Error('bar'))).toBe(
false
);
});
it('fails for objects with different constructors', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
function One() {}
function Two() {}
@@ -170,17 +170,17 @@ describe('matchersUtil', function() {
});
it('passes for Objects that are equivalent (simple case)', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals({ a: 'foo' }, { a: 'foo' })).toBe(true);
});
it('fails for Objects that are not equivalent (simple case)', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals({ a: 'foo' }, { a: 'bar' })).toBe(false);
});
it('passes for Objects that are equivalent (deep case)', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(
matchersUtil.equals(
{ a: 'foo', b: { c: 'bar' } },
@@ -190,7 +190,7 @@ describe('matchersUtil', function() {
});
it('fails for Objects that are not equivalent (deep case)', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(
matchersUtil.equals(
{ a: 'foo', b: { c: 'baz' } },
@@ -202,7 +202,7 @@ describe('matchersUtil', function() {
it('passes for Objects that are equivalent (with cycles)', function() {
const actual = { a: 'foo' },
expected = { a: 'foo' },
matchersUtil = new jasmineUnderTest.MatchersUtil();
matchersUtil = new privateUnderTest.MatchersUtil();
actual.b = actual;
expected.b = actual;
@@ -213,7 +213,7 @@ describe('matchersUtil', function() {
it('fails for Objects that are not equivalent (with cycles)', function() {
const actual = { a: 'foo' },
expected = { a: 'bar' },
matchersUtil = new jasmineUnderTest.MatchersUtil();
matchersUtil = new privateUnderTest.MatchersUtil();
actual.b = actual;
expected.b = actual;
@@ -224,7 +224,7 @@ describe('matchersUtil', function() {
it('fails for Objects that have the same number of keys, but different keys/values', function() {
const expected = { a: undefined },
actual = { b: 1 },
matchersUtil = new jasmineUnderTest.MatchersUtil();
matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(actual, expected)).toBe(false);
});
@@ -232,7 +232,7 @@ describe('matchersUtil', function() {
it('fails when comparing an empty object to an empty array (issue #114)', function() {
const emptyObject = {},
emptyArray = [],
matchersUtil = new jasmineUnderTest.MatchersUtil();
matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(emptyObject, emptyArray)).toBe(false);
expect(matchersUtil.equals(emptyArray, emptyObject)).toBe(false);
@@ -241,7 +241,7 @@ describe('matchersUtil', function() {
it('passes for equivalent frozen objects (GitHub issue #266)', function() {
const a = { foo: 1 },
b = { foo: 1 },
matchersUtil = new jasmineUnderTest.MatchersUtil();
matchersUtil = new privateUnderTest.MatchersUtil();
Object.freeze(a);
Object.freeze(b);
@@ -252,7 +252,7 @@ describe('matchersUtil', function() {
it('passes for equivalent Promises (GitHub issue #1314)', function() {
const p1 = new Promise(function() {}),
p2 = new Promise(function() {}),
matchersUtil = new jasmineUnderTest.MatchersUtil();
matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(p1, p1)).toBe(true);
expect(matchersUtil.equals(p1, p2)).toBe(false);
@@ -267,7 +267,7 @@ describe('matchersUtil', function() {
it('passes for equivalent DOM nodes', function() {
const a = document.createElement('div');
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
a.setAttribute('test-attr', 'attr-value');
a.appendChild(document.createTextNode('test'));
@@ -280,7 +280,7 @@ describe('matchersUtil', function() {
});
it('passes for equivalent objects from different frames', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const iframe = document.createElement('iframe');
document.body.appendChild(iframe);
iframe.contentWindow.eval('window.testObject = {}');
@@ -291,7 +291,7 @@ describe('matchersUtil', function() {
});
it('fails for DOM nodes with different attributes or child nodes', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const a = document.createElement('div');
a.setAttribute('test-attr', 'attr-value');
a.appendChild(document.createTextNode('test'));
@@ -321,7 +321,7 @@ describe('matchersUtil', function() {
});
it('passes for equivalent objects from different vm contexts', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const vm = require('vm');
const sandbox = {
obj: null
@@ -332,7 +332,7 @@ describe('matchersUtil', function() {
});
it('passes for equivalent arrays from different vm contexts', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const vm = require('vm');
const sandbox = {
arr: null
@@ -345,8 +345,8 @@ describe('matchersUtil', function() {
it('passes when Any is used', function() {
const number = 3,
anyNumber = new jasmineUnderTest.Any(Number),
matchersUtil = new jasmineUnderTest.MatchersUtil();
anyNumber = new privateUnderTest.Any(Number),
matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(number, anyNumber)).toBe(true);
expect(matchersUtil.equals(anyNumber, number)).toBe(true);
@@ -354,8 +354,8 @@ describe('matchersUtil', function() {
it('fails when Any is compared to something unexpected', function() {
const number = 3,
anyString = new jasmineUnderTest.Any(String),
matchersUtil = new jasmineUnderTest.MatchersUtil();
anyString = new privateUnderTest.Any(String),
matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(number, anyString)).toBe(false);
expect(matchersUtil.equals(anyString, number)).toBe(false);
@@ -366,19 +366,19 @@ describe('matchersUtil', function() {
foo: 3,
bar: 7
},
containing = new jasmineUnderTest.ObjectContaining({ foo: 3 }),
matchersUtil = new jasmineUnderTest.MatchersUtil();
containing = new privateUnderTest.ObjectContaining({ foo: 3 }),
matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(obj, containing)).toBe(true);
expect(matchersUtil.equals(containing, obj)).toBe(true);
});
it('passes when MapContaining is used', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const obj = new Map();
obj.set(1, 2);
obj.set('foo', 'bar');
const containing = new jasmineUnderTest.MapContaining(new Map());
const containing = new privateUnderTest.MapContaining(new Map());
containing.sample.set('foo', 'bar');
expect(matchersUtil.equals(obj, containing)).toBe(true);
@@ -386,11 +386,11 @@ describe('matchersUtil', function() {
});
it('passes when SetContaining is used', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const obj = new Set();
obj.add(1);
obj.add('foo');
const containing = new jasmineUnderTest.SetContaining(new Set());
const containing = new privateUnderTest.SetContaining(new Set());
containing.sample.add(1);
expect(matchersUtil.equals(obj, containing)).toBe(true);
@@ -403,7 +403,7 @@ describe('matchersUtil', function() {
return true;
}
},
matchersUtil = new jasmineUnderTest.MatchersUtil();
matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(false, tester)).toBe(true);
expect(matchersUtil.equals(tester, false)).toBe(true);
@@ -415,7 +415,7 @@ describe('matchersUtil', function() {
return false;
}
},
matchersUtil = new jasmineUnderTest.MatchersUtil();
matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(true, tester)).toBe(false);
expect(matchersUtil.equals(tester, true)).toBe(false);
@@ -423,10 +423,10 @@ describe('matchersUtil', function() {
it('passes when ArrayContaining is used', function() {
const arr = ['foo', 'bar'],
matchersUtil = new jasmineUnderTest.MatchersUtil();
matchersUtil = new privateUnderTest.MatchersUtil();
expect(
matchersUtil.equals(arr, new jasmineUnderTest.ArrayContaining(['bar']))
matchersUtil.equals(arr, new privateUnderTest.ArrayContaining(['bar']))
).toBe(true);
});
@@ -434,7 +434,7 @@ describe('matchersUtil', function() {
const tester = function() {
return true;
},
matchersUtil = new jasmineUnderTest.MatchersUtil({
matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [tester],
pp: function() {}
});
@@ -443,7 +443,7 @@ describe('matchersUtil', function() {
});
it('passes for two empty Objects', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals({}, {})).toBe(true);
});
@@ -453,7 +453,7 @@ describe('matchersUtil', function() {
};
it('passes for two empty Objects', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [tester],
pp: function() {}
});
@@ -465,7 +465,7 @@ describe('matchersUtil', function() {
const tester = function() {
return false;
},
matchersUtil = new jasmineUnderTest.MatchersUtil({
matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [tester],
pp: function() {}
});
@@ -482,7 +482,7 @@ describe('matchersUtil', function() {
symmetricTester = function() {
return false;
},
matchersUtil = new jasmineUnderTest.MatchersUtil({
matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [symmetricTester()],
pp: function() {}
});
@@ -492,9 +492,9 @@ describe('matchersUtil', function() {
});
it('passes when an Any is compared to an Any that checks for the same type', function() {
const any1 = new jasmineUnderTest.Any(Function),
any2 = new jasmineUnderTest.Any(Function),
matchersUtil = new jasmineUnderTest.MatchersUtil();
const any1 = new privateUnderTest.Any(Function),
any2 = new privateUnderTest.Any(Function),
matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(any1, any2)).toBe(true);
});
@@ -502,7 +502,7 @@ describe('matchersUtil', function() {
it('passes for null prototype objects with same properties', function() {
const objA = Object.create(null),
objB = Object.create(null),
matchersUtil = new jasmineUnderTest.MatchersUtil();
matchersUtil = new privateUnderTest.MatchersUtil();
objA.name = 'test';
objB.name = 'test';
@@ -513,7 +513,7 @@ describe('matchersUtil', function() {
it('fails for null prototype objects with different properties', function() {
const objA = Object.create(null),
objB = Object.create(null),
matchersUtil = new jasmineUnderTest.MatchersUtil();
matchersUtil = new privateUnderTest.MatchersUtil();
objA.name = 'test';
objB.test = 'name';
@@ -522,12 +522,12 @@ describe('matchersUtil', function() {
});
it('passes when comparing two empty sets', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(new Set(), new Set())).toBe(true);
});
it('passes when comparing identical sets', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const setA = new Set();
setA.add(6);
setA.add(5);
@@ -539,7 +539,7 @@ describe('matchersUtil', function() {
});
it('passes when comparing identical sets with different insertion order and simple elements', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const setA = new Set();
setA.add(3);
setA.add(6);
@@ -551,7 +551,7 @@ describe('matchersUtil', function() {
});
it('passes when comparing identical sets with different insertion order and complex elements 1', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const setA1 = new Set();
setA1.add(['a', 3]);
setA1.add([6, 1]);
@@ -576,7 +576,7 @@ describe('matchersUtil', function() {
});
it('passes when comparing identical sets with different insertion order and complex elements 2', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const setA = new Set();
setA.add([[1, 2], [3, 4]]);
setA.add([[5, 6], [7, 8]]);
@@ -588,7 +588,7 @@ describe('matchersUtil', function() {
});
it('fails for sets with different elements', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const setA = new Set();
setA.add(6);
setA.add(3);
@@ -602,7 +602,7 @@ describe('matchersUtil', function() {
});
it('fails for sets of different size', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const setA = new Set();
setA.add(6);
setA.add(3);
@@ -615,12 +615,12 @@ describe('matchersUtil', function() {
});
it('passes when comparing two empty maps', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(new Map(), new Map())).toBe(true);
});
it('passes when comparing identical maps', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const mapA = new Map();
mapA.set(6, 5);
const mapB = new Map();
@@ -629,7 +629,7 @@ describe('matchersUtil', function() {
});
it('passes when comparing identical maps with different insertion order', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const mapA = new Map();
mapA.set('a', 3);
mapA.set(6, 1);
@@ -640,7 +640,7 @@ describe('matchersUtil', function() {
});
it('fails for maps with different elements', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const mapA = new Map();
mapA.set(6, 3);
mapA.set(5, 1);
@@ -652,7 +652,7 @@ describe('matchersUtil', function() {
});
it('fails for maps of different size', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const mapA = new Map();
mapA.set(6, 3);
const mapB = new Map();
@@ -662,7 +662,7 @@ describe('matchersUtil', function() {
});
it('passes when comparing two identical URLs', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(
matchersUtil.equals(
@@ -673,7 +673,7 @@ describe('matchersUtil', function() {
});
it('fails when comparing two different URLs', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil(),
const matchersUtil = new privateUnderTest.MatchersUtil(),
url1 = new URL('http://localhost/1');
expect(matchersUtil.equals(url1, new URL('http://localhost/2'))).toBe(
@@ -699,7 +699,7 @@ describe('matchersUtil', function() {
it('passes for ArrayBuffers with same length and content', function() {
const buffer1 = new ArrayBuffer(4);
const buffer2 = new ArrayBuffer(4);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.equals(buffer1, buffer2)).toBe(true);
});
@@ -708,13 +708,13 @@ describe('matchersUtil', function() {
const buffer2 = new ArrayBuffer(4);
const array1 = new Uint8Array(buffer1);
array1[0] = 1;
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.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() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const a1 = new Int8Array(1);
const a2 = new Uint8Array(1);
a1[0] = a2[0] = 0;
@@ -737,23 +737,23 @@ describe('matchersUtil', function() {
it(
'passes for ' + typeName + 's with same length and content',
function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const a1 = new TypedArrayCtor(2);
const a2 = new TypedArrayCtor(2);
a1[0] = a2[0] = 0;
a1[1] = a2[1] = 1;
const diffBuilder = new jasmineUnderTest.DiffBuilder();
const diffBuilder = new privateUnderTest.DiffBuilder();
expect(matchersUtil.equals(a1, a2, diffBuilder)).toBe(true);
jasmine.debugLog('Diff: ' + diffBuilder.getMessage());
}
);
it('fails for ' + typeName + 's with different length', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const a1 = new TypedArrayCtor(2);
const a2 = new TypedArrayCtor(1);
a1[0] = a1[1] = a2[0] = 0;
const diffBuilder = new jasmineUnderTest.DiffBuilder();
const diffBuilder = new privateUnderTest.DiffBuilder();
expect(matchersUtil.equals(a1, a2, diffBuilder)).toBe(false);
jasmine.debugLog('Diff: ' + diffBuilder.getMessage());
});
@@ -761,24 +761,18 @@ describe('matchersUtil', function() {
it(
'fails for ' + typeName + 's with same length but different content',
function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const a1 = new TypedArrayCtor(1);
const a2 = new TypedArrayCtor(1);
a1[0] = 0;
a2[0] = 1;
const diffBuilder = new jasmineUnderTest.DiffBuilder();
const diffBuilder = new privateUnderTest.DiffBuilder();
expect(matchersUtil.equals(a1, a2, diffBuilder)).toBe(false);
jasmine.debugLog(
'a1 keys: ' +
jasmine.basicPrettyPrinter_(
jasmineUnderTest.MatchersUtil.keys(a1)
)
'a1 keys: ' + jasmine.pp(privateUnderTest.MatchersUtil.keys(a1))
);
jasmine.debugLog(
'a2 keys: ' +
jasmine.basicPrettyPrinter_(
jasmineUnderTest.MatchersUtil.keys(a2)
)
'a2 keys: ' + jasmine.pp(privateUnderTest.MatchersUtil.keys(a2))
);
jasmine.debugLog('a1 length:' + a1.length);
jasmine.debugLog('a2 length:' + a2.length);
@@ -788,7 +782,7 @@ describe('matchersUtil', function() {
);
it('checks nonstandard properties of ' + typeName, function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const a1 = new TypedArrayCtor(1);
const a2 = new TypedArrayCtor(1);
a1[0] = a2[0] = 0;
@@ -799,7 +793,7 @@ describe('matchersUtil', function() {
it('works with custom equality testers with ' + typeName, function() {
const a1 = new TypedArrayCtor(1);
const a2 = new TypedArrayCtor(1);
const matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [
function() {
return true;
@@ -827,7 +821,7 @@ describe('matchersUtil', function() {
'passes for ' + typeName + 's with same length and content',
function() {
const TypedArrayCtor = requireType();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const a1 = new TypedArrayCtor(2);
const a2 = new TypedArrayCtor(2);
a1[0] = a2[0] = BigInt(0);
@@ -838,7 +832,7 @@ describe('matchersUtil', function() {
it('fails for ' + typeName + 's with different length', function() {
const TypedArrayCtor = requireType();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const a1 = new TypedArrayCtor(2);
const a2 = new TypedArrayCtor(1);
a1[0] = a1[1] = a2[0] = BigInt(0);
@@ -849,7 +843,7 @@ describe('matchersUtil', function() {
'fails for ' + typeName + 's with same length but different content',
function() {
const TypedArrayCtor = requireType();
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const a1 = new TypedArrayCtor(2);
const a2 = new TypedArrayCtor(2);
a1[0] = a1[1] = a2[0] = BigInt(0);
@@ -937,7 +931,7 @@ describe('matchersUtil', function() {
'withPath',
'setRoots'
]),
matchersUtil = new jasmineUnderTest.MatchersUtil();
matchersUtil = new privateUnderTest.MatchersUtil();
diffBuilder.withPath.and.callFake(function(p, block) {
block();
@@ -965,7 +959,7 @@ describe('matchersUtil', function() {
'withPath',
'setRoots'
]),
matchersUtil = new jasmineUnderTest.MatchersUtil();
matchersUtil = new privateUnderTest.MatchersUtil();
diffBuilder.withPath.and.callFake(function(p, block) {
block();
@@ -982,8 +976,8 @@ describe('matchersUtil', function() {
});
it('uses a diffBuilder if one is provided as the third argument', function() {
const diffBuilder = new jasmineUnderTest.DiffBuilder(),
matchersUtil = new jasmineUnderTest.MatchersUtil();
const diffBuilder = new privateUnderTest.DiffBuilder(),
matchersUtil = new privateUnderTest.MatchersUtil();
spyOn(diffBuilder, 'recordMismatch');
spyOn(diffBuilder, 'withPath').and.callThrough();
@@ -1003,27 +997,27 @@ describe('matchersUtil', function() {
describe('contains', function() {
it('passes when expected is a substring of actual', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.contains('ABC', 'BC')).toBe(true);
});
it('fails when expected is a not substring of actual', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.contains('ABC', 'X')).toBe(false);
});
it('passes when expected is an element in an actual array', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.contains(['foo', 'bar'], 'foo')).toBe(true);
});
it('fails when expected is not an element in an actual array', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.contains(['foo', 'bar'], 'baz')).toBe(false);
});
it('passes with mixed-element arrays', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.contains(['foo', { some: 'bar' }], 'foo')).toBe(true);
expect(
matchersUtil.contains(['foo', { some: 'bar' }], { some: 'bar' })
@@ -1034,7 +1028,7 @@ describe('matchersUtil', function() {
const customTester = function() {
return true;
},
matchersUtil = new jasmineUnderTest.MatchersUtil({
matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [customTester],
pp: function() {}
});
@@ -1043,18 +1037,18 @@ describe('matchersUtil', function() {
});
it('fails when actual is undefined', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.contains(undefined, 'A')).toBe(false);
});
it('fails when actual is null', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.contains(null, 'A')).toBe(false);
});
it('works with array-like objects that implement iterable', function() {
let capturedArgs = null;
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
function testFunction() {
capturedArgs = arguments;
@@ -1071,14 +1065,14 @@ describe('matchersUtil', function() {
1: 'b',
length: 2
};
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matchersUtil.contains(arrayLike, 'b')).toBe(true);
expect(matchersUtil.contains(arrayLike, 'c')).toBe(false);
});
it('passes for set members', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const setItem = { foo: 'bar' };
const set = new Set();
set.add(setItem);
@@ -1087,7 +1081,7 @@ describe('matchersUtil', function() {
});
it('passes for objects that equal to a set member', function() {
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
const set = new Set();
set.add({ foo: 'bar' });
@@ -1099,8 +1093,8 @@ describe('matchersUtil', function() {
it('builds an English sentence for a failure case', function() {
const actual = 'foo',
name = 'toBar',
pp = jasmineUnderTest.makePrettyPrinter(),
matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }),
pp = privateUnderTest.makePrettyPrinter(),
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }),
message = matchersUtil.buildFailureMessage(name, false, actual);
expect(message).toEqual("Expected 'foo' to bar.");
@@ -1110,8 +1104,8 @@ describe('matchersUtil', function() {
const actual = 'foo',
name = 'toBar',
isNot = true,
pp = jasmineUnderTest.makePrettyPrinter(),
matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }),
pp = privateUnderTest.makePrettyPrinter(),
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }),
message = matchersUtil.buildFailureMessage(name, isNot, actual);
expect(message).toEqual("Expected 'foo' not to bar.");
@@ -1120,8 +1114,8 @@ describe('matchersUtil', function() {
it('builds an English sentence for an arbitrary array of expected arguments', function() {
const actual = 'foo',
name = 'toBar',
pp = jasmineUnderTest.makePrettyPrinter(),
matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }),
pp = privateUnderTest.makePrettyPrinter(),
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }),
message = matchersUtil.buildFailureMessage(
name,
false,
@@ -1142,7 +1136,7 @@ describe('matchersUtil', function() {
pp = function(value) {
return '<' + value + '>';
},
matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }),
matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }),
message = matchersUtil.buildFailureMessage(
name,
isNot,