@jest/expect-utils 29.7.0 → 30.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -1,28 +1,95 @@
1
- 'use strict';
1
+ /*!
2
+ * /**
3
+ * * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ * *
5
+ * * This source code is licensed under the MIT license found in the
6
+ * * LICENSE file in the root directory of this source tree.
7
+ * * /
8
+ */
9
+ /******/ (() => { // webpackBootstrap
10
+ /******/ "use strict";
11
+ /******/ var __webpack_modules__ = ({
2
12
 
3
- Object.defineProperty(exports, '__esModule', {
13
+ /***/ "./src/immutableUtils.ts":
14
+ /***/ ((__unused_webpack_module, exports) => {
15
+
16
+
17
+
18
+ Object.defineProperty(exports, "__esModule", ({
4
19
  value: true
5
- });
20
+ }));
21
+ exports.isImmutableList = isImmutableList;
22
+ exports.isImmutableOrderedKeyed = isImmutableOrderedKeyed;
23
+ exports.isImmutableOrderedSet = isImmutableOrderedSet;
24
+ exports.isImmutableRecord = isImmutableRecord;
25
+ exports.isImmutableUnorderedKeyed = isImmutableUnorderedKeyed;
26
+ exports.isImmutableUnorderedSet = isImmutableUnorderedSet;
27
+ /**
28
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
29
+ *
30
+ * This source code is licensed under the MIT license found in the
31
+ * LICENSE file in the root directory of this source tree.
32
+ *
33
+ */
34
+
35
+ // SENTINEL constants are from https://github.com/immutable-js/immutable-js/tree/main/src/predicates
36
+ const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
37
+ const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
38
+ const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
39
+ const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
40
+ const IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@';
41
+ function isObjectLiteral(source) {
42
+ return source != null && typeof source === 'object' && !Array.isArray(source);
43
+ }
44
+ function isImmutableUnorderedKeyed(source) {
45
+ return Boolean(source && isObjectLiteral(source) && source[IS_KEYED_SENTINEL] && !source[IS_ORDERED_SENTINEL]);
46
+ }
47
+ function isImmutableUnorderedSet(source) {
48
+ return Boolean(source && isObjectLiteral(source) && source[IS_SET_SENTINEL] && !source[IS_ORDERED_SENTINEL]);
49
+ }
50
+ function isImmutableList(source) {
51
+ return Boolean(source && isObjectLiteral(source) && source[IS_LIST_SENTINEL]);
52
+ }
53
+ function isImmutableOrderedKeyed(source) {
54
+ return Boolean(source && isObjectLiteral(source) && source[IS_KEYED_SENTINEL] && source[IS_ORDERED_SENTINEL]);
55
+ }
56
+ function isImmutableOrderedSet(source) {
57
+ return Boolean(source && isObjectLiteral(source) && source[IS_SET_SENTINEL] && source[IS_ORDERED_SENTINEL]);
58
+ }
59
+ function isImmutableRecord(source) {
60
+ return Boolean(source && isObjectLiteral(source) && source[IS_RECORD_SYMBOL]);
61
+ }
62
+
63
+ /***/ }),
64
+
65
+ /***/ "./src/index.ts":
66
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
67
+
68
+
69
+
70
+ Object.defineProperty(exports, "__esModule", ({
71
+ value: true
72
+ }));
6
73
  var _exportNames = {
7
74
  equals: true,
8
75
  isA: true
9
76
  };
10
- Object.defineProperty(exports, 'equals', {
77
+ Object.defineProperty(exports, "equals", ({
11
78
  enumerable: true,
12
79
  get: function () {
13
80
  return _jasmineUtils.equals;
14
81
  }
15
- });
16
- Object.defineProperty(exports, 'isA', {
82
+ }));
83
+ Object.defineProperty(exports, "isA", ({
17
84
  enumerable: true,
18
85
  get: function () {
19
86
  return _jasmineUtils.isA;
20
87
  }
21
- });
22
- var _jasmineUtils = require('./jasmineUtils');
23
- var _utils = require('./utils');
88
+ }));
89
+ var _jasmineUtils = __webpack_require__("./src/jasmineUtils.ts");
90
+ var _utils = __webpack_require__("./src/utils.ts");
24
91
  Object.keys(_utils).forEach(function (key) {
25
- if (key === 'default' || key === '__esModule') return;
92
+ if (key === "default" || key === "__esModule") return;
26
93
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
27
94
  if (key in exports && exports[key] === _utils[key]) return;
28
95
  Object.defineProperty(exports, key, {
@@ -32,3 +99,599 @@ Object.keys(_utils).forEach(function (key) {
32
99
  }
33
100
  });
34
101
  });
102
+
103
+ /***/ }),
104
+
105
+ /***/ "./src/jasmineUtils.ts":
106
+ /***/ ((__unused_webpack_module, exports) => {
107
+
108
+
109
+
110
+ Object.defineProperty(exports, "__esModule", ({
111
+ value: true
112
+ }));
113
+ exports.equals = void 0;
114
+ exports.isA = isA;
115
+ /*
116
+ Copyright (c) 2008-2016 Pivotal Labs
117
+
118
+ Permission is hereby granted, free of charge, to any person obtaining
119
+ a copy of this software and associated documentation files (the
120
+ "Software"), to deal in the Software without restriction, including
121
+ without limitation the rights to use, copy, modify, merge, publish,
122
+ distribute, sublicense, and/or sell copies of the Software, and to
123
+ permit persons to whom the Software is furnished to do so, subject to
124
+ the following conditions:
125
+
126
+ The above copyright notice and this permission notice shall be
127
+ included in all copies or substantial portions of the Software.
128
+
129
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
130
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
131
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
132
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
133
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
134
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
135
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
136
+
137
+ */
138
+
139
+ // Extracted out of jasmine 2.5.2
140
+ const equals = (a, b, customTesters, strictCheck) => {
141
+ customTesters = customTesters || [];
142
+ return eq(a, b, [], [], customTesters, strictCheck);
143
+ };
144
+ exports.equals = equals;
145
+ function isAsymmetric(obj) {
146
+ return !!obj && isA('Function', obj.asymmetricMatch);
147
+ }
148
+ function asymmetricMatch(a, b) {
149
+ const asymmetricA = isAsymmetric(a);
150
+ const asymmetricB = isAsymmetric(b);
151
+ if (asymmetricA && asymmetricB) {
152
+ return undefined;
153
+ }
154
+ if (asymmetricA) {
155
+ return a.asymmetricMatch(b);
156
+ }
157
+ if (asymmetricB) {
158
+ return b.asymmetricMatch(a);
159
+ }
160
+ }
161
+
162
+ // Equality function lovingly adapted from isEqual in
163
+ // [Underscore](http://underscorejs.org)
164
+ function eq(a, b, aStack, bStack, customTesters, strictCheck) {
165
+ let result = true;
166
+ const asymmetricResult = asymmetricMatch(a, b);
167
+ if (asymmetricResult !== undefined) {
168
+ return asymmetricResult;
169
+ }
170
+ const testerContext = {
171
+ equals
172
+ };
173
+ for (let i = 0; i < customTesters.length; i++) {
174
+ const customTesterResult = customTesters[i].call(testerContext, a, b, customTesters);
175
+ if (customTesterResult !== undefined) {
176
+ return customTesterResult;
177
+ }
178
+ }
179
+ if (a instanceof Error && b instanceof Error) {
180
+ return a.message == b.message;
181
+ }
182
+ if (Object.is(a, b)) {
183
+ return true;
184
+ }
185
+ // A strict comparison is necessary because `null == undefined`.
186
+ if (a === null || b === null) {
187
+ return a === b;
188
+ }
189
+ const className = Object.prototype.toString.call(a);
190
+ if (className != Object.prototype.toString.call(b)) {
191
+ return false;
192
+ }
193
+ switch (className) {
194
+ case '[object Boolean]':
195
+ case '[object String]':
196
+ case '[object Number]':
197
+ if (typeof a !== typeof b) {
198
+ // One is a primitive, one a `new Primitive()`
199
+ return false;
200
+ } else if (typeof a !== 'object' && typeof b !== 'object') {
201
+ // both are proper primitives
202
+ return Object.is(a, b);
203
+ } else {
204
+ // both are `new Primitive()`s
205
+ return Object.is(a.valueOf(), b.valueOf());
206
+ }
207
+ case '[object Date]':
208
+ // Coerce dates to numeric primitive values. Dates are compared by their
209
+ // millisecond representations. Note that invalid dates with millisecond representations
210
+ // of `NaN` are not equivalent.
211
+ return +a == +b;
212
+ // RegExps are compared by their source patterns and flags.
213
+ case '[object RegExp]':
214
+ return a.source === b.source && a.flags === b.flags;
215
+ // URLs are compared by their href property which contains the entire url string.
216
+ case '[object URL]':
217
+ return a.href === b.href;
218
+ }
219
+ if (typeof a !== 'object' || typeof b !== 'object') {
220
+ return false;
221
+ }
222
+
223
+ // Use DOM3 method isEqualNode (IE>=9)
224
+ if (isDomNode(a) && isDomNode(b)) {
225
+ return a.isEqualNode(b);
226
+ }
227
+
228
+ // Used to detect circular references.
229
+ let length = aStack.length;
230
+ while (length--) {
231
+ // Linear search. Performance is inversely proportional to the number of
232
+ // unique nested structures.
233
+ // circular references at same depth are equal
234
+ // circular reference is not equal to non-circular one
235
+ if (aStack[length] === a) {
236
+ return bStack[length] === b;
237
+ } else if (bStack[length] === b) {
238
+ return false;
239
+ }
240
+ }
241
+ // Add the first object to the stack of traversed objects.
242
+ aStack.push(a);
243
+ bStack.push(b);
244
+ // Recursively compare objects and arrays.
245
+ // Compare array lengths to determine if a deep comparison is necessary.
246
+ if (strictCheck && className == '[object Array]' && a.length !== b.length) {
247
+ return false;
248
+ }
249
+
250
+ // Deep compare objects.
251
+ const aKeys = keys(a, hasKey);
252
+ let key;
253
+ const bKeys = keys(b, hasKey);
254
+ // Add keys corresponding to asymmetric matchers if they miss in non strict check mode
255
+ if (!strictCheck) {
256
+ for (let index = 0; index !== bKeys.length; ++index) {
257
+ key = bKeys[index];
258
+ if ((isAsymmetric(b[key]) || b[key] === undefined) && !hasKey(a, key)) {
259
+ aKeys.push(key);
260
+ }
261
+ }
262
+ for (let index = 0; index !== aKeys.length; ++index) {
263
+ key = aKeys[index];
264
+ if ((isAsymmetric(a[key]) || a[key] === undefined) && !hasKey(b, key)) {
265
+ bKeys.push(key);
266
+ }
267
+ }
268
+ }
269
+
270
+ // Ensure that both objects contain the same number of properties before comparing deep equality.
271
+ let size = aKeys.length;
272
+ if (bKeys.length !== size) {
273
+ return false;
274
+ }
275
+ while (size--) {
276
+ key = aKeys[size];
277
+
278
+ // Deep compare each member
279
+ if (strictCheck) result = hasKey(b, key) && eq(a[key], b[key], aStack, bStack, customTesters, strictCheck);else result = (hasKey(b, key) || isAsymmetric(a[key]) || a[key] === undefined) && eq(a[key], b[key], aStack, bStack, customTesters, strictCheck);
280
+ if (!result) {
281
+ return false;
282
+ }
283
+ }
284
+ // Remove the first object from the stack of traversed objects.
285
+ aStack.pop();
286
+ bStack.pop();
287
+ return result;
288
+ }
289
+ function keys(obj, hasKey) {
290
+ const keys = [];
291
+ for (const key in obj) {
292
+ if (hasKey(obj, key)) {
293
+ keys.push(key);
294
+ }
295
+ }
296
+ return keys.concat(Object.getOwnPropertySymbols(obj).filter(symbol => Object.getOwnPropertyDescriptor(obj, symbol).enumerable));
297
+ }
298
+ function hasKey(obj, key) {
299
+ return Object.prototype.hasOwnProperty.call(obj, key);
300
+ }
301
+ function isA(typeName, value) {
302
+ return Object.prototype.toString.apply(value) === `[object ${typeName}]`;
303
+ }
304
+ function isDomNode(obj) {
305
+ return obj !== null && typeof obj === 'object' && typeof obj.nodeType === 'number' && typeof obj.nodeName === 'string' && typeof obj.isEqualNode === 'function';
306
+ }
307
+
308
+ /***/ }),
309
+
310
+ /***/ "./src/utils.ts":
311
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
312
+
313
+
314
+
315
+ Object.defineProperty(exports, "__esModule", ({
316
+ value: true
317
+ }));
318
+ exports.arrayBufferEquality = void 0;
319
+ exports.emptyObject = emptyObject;
320
+ exports.typeEquality = exports.subsetEquality = exports.sparseArrayEquality = exports.pathAsArray = exports.partition = exports.iterableEquality = exports.isOneline = exports.isError = exports.getPath = exports.getObjectSubset = exports.getObjectKeys = void 0;
321
+ var _jestGetType = require("jest-get-type");
322
+ var _immutableUtils = __webpack_require__("./src/immutableUtils.ts");
323
+ var _jasmineUtils = __webpack_require__("./src/jasmineUtils.ts");
324
+ var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol;
325
+ /**
326
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
327
+ *
328
+ * This source code is licensed under the MIT license found in the
329
+ * LICENSE file in the root directory of this source tree.
330
+ *
331
+ */
332
+ /**
333
+ * Checks if `hasOwnProperty(object, key)` up the prototype chain, stopping at `Object.prototype`.
334
+ */
335
+ const hasPropertyInObject = (object, key) => {
336
+ const shouldTerminate = !object || typeof object !== 'object' || object === Object.prototype;
337
+ if (shouldTerminate) {
338
+ return false;
339
+ }
340
+ return Object.prototype.hasOwnProperty.call(object, key) || hasPropertyInObject(Object.getPrototypeOf(object), key);
341
+ };
342
+
343
+ // Retrieves an object's keys for evaluation by getObjectSubset. This evaluates
344
+ // the prototype chain for string keys but not for non-enumerable symbols.
345
+ // (Otherwise, it could find values such as a Set or Map's Symbol.toStringTag,
346
+ // with unexpected results.)
347
+ const getObjectKeys = object => {
348
+ return [...Object.keys(object), ...Object.getOwnPropertySymbols(object).filter(s => Object.getOwnPropertyDescriptor(object, s)?.enumerable)];
349
+ };
350
+ exports.getObjectKeys = getObjectKeys;
351
+ const getPath = (object, propertyPath) => {
352
+ if (!Array.isArray(propertyPath)) {
353
+ propertyPath = pathAsArray(propertyPath);
354
+ }
355
+ if (propertyPath.length > 0) {
356
+ const lastProp = propertyPath.length === 1;
357
+ const prop = propertyPath[0];
358
+ const newObject = object[prop];
359
+ if (!lastProp && (newObject === null || newObject === undefined)) {
360
+ // This is not the last prop in the chain. If we keep recursing it will
361
+ // hit a `can't access property X of undefined | null`. At this point we
362
+ // know that the chain has broken and we can return right away.
363
+ return {
364
+ hasEndProp: false,
365
+ lastTraversedObject: object,
366
+ traversedPath: []
367
+ };
368
+ }
369
+ const result = getPath(newObject, propertyPath.slice(1));
370
+ if (result.lastTraversedObject === null) {
371
+ result.lastTraversedObject = object;
372
+ }
373
+ result.traversedPath.unshift(prop);
374
+ if (lastProp) {
375
+ // Does object have the property with an undefined value?
376
+ // Although primitive values support bracket notation (above)
377
+ // they would throw TypeError for in operator (below).
378
+ result.endPropIsDefined = !(0, _jestGetType.isPrimitive)(object) && prop in object;
379
+ result.hasEndProp = newObject !== undefined || result.endPropIsDefined;
380
+ if (!result.hasEndProp) {
381
+ result.traversedPath.shift();
382
+ }
383
+ }
384
+ return result;
385
+ }
386
+ return {
387
+ lastTraversedObject: null,
388
+ traversedPath: [],
389
+ value: object
390
+ };
391
+ };
392
+
393
+ // Strip properties from object that are not present in the subset. Useful for
394
+ // printing the diff for toMatchObject() without adding unrelated noise.
395
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
396
+ exports.getPath = getPath;
397
+ const getObjectSubset = (object, subset, customTesters = [], seenReferences = new WeakMap()) => {
398
+ /* eslint-enable @typescript-eslint/explicit-module-boundary-types */
399
+ if (Array.isArray(object)) {
400
+ if (Array.isArray(subset) && subset.length === object.length) {
401
+ // The map method returns correct subclass of subset.
402
+ return subset.map((sub, i) => getObjectSubset(object[i], sub, customTesters));
403
+ }
404
+ } else if (object instanceof Date) {
405
+ return object;
406
+ } else if (isObject(object) && isObject(subset)) {
407
+ if ((0, _jasmineUtils.equals)(object, subset, [...customTesters, iterableEquality, subsetEquality])) {
408
+ // Avoid unnecessary copy which might return Object instead of subclass.
409
+ return subset;
410
+ }
411
+ const trimmed = {};
412
+ seenReferences.set(object, trimmed);
413
+ for (const key of getObjectKeys(object).filter(key => hasPropertyInObject(subset, key))) {
414
+ trimmed[key] = seenReferences.has(object[key]) ? seenReferences.get(object[key]) : getObjectSubset(object[key], subset[key], customTesters, seenReferences);
415
+ }
416
+ if (getObjectKeys(trimmed).length > 0) {
417
+ return trimmed;
418
+ }
419
+ }
420
+ return object;
421
+ };
422
+ exports.getObjectSubset = getObjectSubset;
423
+ const IteratorSymbol = Symbol.iterator;
424
+ const hasIterator = object => !!(object != null && object[IteratorSymbol]);
425
+
426
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
427
+ const iterableEquality = (a, b, customTesters = [], /* eslint-enable @typescript-eslint/explicit-module-boundary-types */
428
+ aStack = [], bStack = []) => {
429
+ if (typeof a !== 'object' || typeof b !== 'object' || Array.isArray(a) || Array.isArray(b) || !hasIterator(a) || !hasIterator(b)) {
430
+ return undefined;
431
+ }
432
+ if (a.constructor !== b.constructor) {
433
+ return false;
434
+ }
435
+ let length = aStack.length;
436
+ while (length--) {
437
+ // Linear search. Performance is inversely proportional to the number of
438
+ // unique nested structures.
439
+ // circular references at same depth are equal
440
+ // circular reference is not equal to non-circular one
441
+ if (aStack[length] === a) {
442
+ return bStack[length] === b;
443
+ }
444
+ }
445
+ aStack.push(a);
446
+ bStack.push(b);
447
+ const iterableEqualityWithStack = (a, b) => iterableEquality(a, b, [...filteredCustomTesters], [...aStack], [...bStack]);
448
+
449
+ // Replace any instance of iterableEquality with the new
450
+ // iterableEqualityWithStack so we can do circular detection
451
+ const filteredCustomTesters = [...customTesters.filter(t => t !== iterableEquality), iterableEqualityWithStack];
452
+ if (a.size !== undefined) {
453
+ if (a.size !== b.size) {
454
+ return false;
455
+ } else if ((0, _jasmineUtils.isA)('Set', a) || (0, _immutableUtils.isImmutableUnorderedSet)(a)) {
456
+ let allFound = true;
457
+ for (const aValue of a) {
458
+ if (!b.has(aValue)) {
459
+ let has = false;
460
+ for (const bValue of b) {
461
+ const isEqual = (0, _jasmineUtils.equals)(aValue, bValue, filteredCustomTesters);
462
+ if (isEqual === true) {
463
+ has = true;
464
+ }
465
+ }
466
+ if (has === false) {
467
+ allFound = false;
468
+ break;
469
+ }
470
+ }
471
+ }
472
+ // Remove the first value from the stack of traversed values.
473
+ aStack.pop();
474
+ bStack.pop();
475
+ return allFound;
476
+ } else if ((0, _jasmineUtils.isA)('Map', a) || (0, _immutableUtils.isImmutableUnorderedKeyed)(a)) {
477
+ let allFound = true;
478
+ for (const aEntry of a) {
479
+ if (!b.has(aEntry[0]) || !(0, _jasmineUtils.equals)(aEntry[1], b.get(aEntry[0]), filteredCustomTesters)) {
480
+ let has = false;
481
+ for (const bEntry of b) {
482
+ const matchedKey = (0, _jasmineUtils.equals)(aEntry[0], bEntry[0], filteredCustomTesters);
483
+ let matchedValue = false;
484
+ if (matchedKey === true) {
485
+ matchedValue = (0, _jasmineUtils.equals)(aEntry[1], bEntry[1], filteredCustomTesters);
486
+ }
487
+ if (matchedValue === true) {
488
+ has = true;
489
+ }
490
+ }
491
+ if (has === false) {
492
+ allFound = false;
493
+ break;
494
+ }
495
+ }
496
+ }
497
+ // Remove the first value from the stack of traversed values.
498
+ aStack.pop();
499
+ bStack.pop();
500
+ return allFound;
501
+ }
502
+ }
503
+ const bIterator = b[IteratorSymbol]();
504
+ for (const aValue of a) {
505
+ const nextB = bIterator.next();
506
+ if (nextB.done || !(0, _jasmineUtils.equals)(aValue, nextB.value, filteredCustomTesters)) {
507
+ return false;
508
+ }
509
+ }
510
+ if (!bIterator.next().done) {
511
+ return false;
512
+ }
513
+ if (!(0, _immutableUtils.isImmutableList)(a) && !(0, _immutableUtils.isImmutableOrderedKeyed)(a) && !(0, _immutableUtils.isImmutableOrderedSet)(a) && !(0, _immutableUtils.isImmutableRecord)(a)) {
514
+ const aEntries = entries(a);
515
+ const bEntries = entries(b);
516
+ if (!(0, _jasmineUtils.equals)(aEntries, bEntries)) {
517
+ return false;
518
+ }
519
+ }
520
+
521
+ // Remove the first value from the stack of traversed values.
522
+ aStack.pop();
523
+ bStack.pop();
524
+ return true;
525
+ };
526
+ exports.iterableEquality = iterableEquality;
527
+ const entries = obj => {
528
+ if (!isObject(obj)) return [];
529
+ return Object.getOwnPropertySymbols(obj).filter(key => key !== Symbol.iterator).map(key => [key, obj[key]]).concat(Object.entries(obj));
530
+ };
531
+ const isObject = a => a !== null && typeof a === 'object';
532
+ const isObjectWithKeys = a => isObject(a) && !(a instanceof Error) && !(a instanceof Array) && !(a instanceof Date);
533
+ const subsetEquality = (object, subset, customTesters = []) => {
534
+ const filteredCustomTesters = customTesters.filter(t => t !== subsetEquality);
535
+
536
+ // subsetEquality needs to keep track of the references
537
+ // it has already visited to avoid infinite loops in case
538
+ // there are circular references in the subset passed to it.
539
+ const subsetEqualityWithContext = (seenReferences = new WeakMap()) => (object, subset) => {
540
+ if (!isObjectWithKeys(subset)) {
541
+ return undefined;
542
+ }
543
+ return getObjectKeys(subset).every(key => {
544
+ if (isObjectWithKeys(subset[key])) {
545
+ if (seenReferences.has(subset[key])) {
546
+ return (0, _jasmineUtils.equals)(object[key], subset[key], filteredCustomTesters);
547
+ }
548
+ seenReferences.set(subset[key], true);
549
+ }
550
+ const result = object != null && hasPropertyInObject(object, key) && (0, _jasmineUtils.equals)(object[key], subset[key], [...filteredCustomTesters, subsetEqualityWithContext(seenReferences)]);
551
+ // The main goal of using seenReference is to avoid circular node on tree.
552
+ // It will only happen within a parent and its child, not a node and nodes next to it (same level)
553
+ // We should keep the reference for a parent and its child only
554
+ // Thus we should delete the reference immediately so that it doesn't interfere
555
+ // other nodes within the same level on tree.
556
+ seenReferences.delete(subset[key]);
557
+ return result;
558
+ });
559
+ };
560
+ return subsetEqualityWithContext()(object, subset);
561
+ };
562
+
563
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
564
+ exports.subsetEquality = subsetEquality;
565
+ const typeEquality = (a, b) => {
566
+ if (a == null || b == null || a.constructor === b.constructor ||
567
+ // Since Jest globals are different from Node globals,
568
+ // constructors are different even between arrays when comparing properties of mock objects.
569
+ // Both of them should be able to compare correctly when they are array-to-array.
570
+ // https://github.com/jestjs/jest/issues/2549
571
+ Array.isArray(a) && Array.isArray(b)) {
572
+ return undefined;
573
+ }
574
+ return false;
575
+ };
576
+ exports.typeEquality = typeEquality;
577
+ const arrayBufferEquality = (a, b) => {
578
+ let dataViewA = a;
579
+ let dataViewB = b;
580
+ if (a instanceof ArrayBuffer && b instanceof ArrayBuffer) {
581
+ dataViewA = new DataView(a);
582
+ dataViewB = new DataView(b);
583
+ }
584
+ if (!(dataViewA instanceof DataView && dataViewB instanceof DataView)) {
585
+ return undefined;
586
+ }
587
+
588
+ // Buffers are not equal when they do not have the same byte length
589
+ if (dataViewA.byteLength !== dataViewB.byteLength) {
590
+ return false;
591
+ }
592
+
593
+ // Check if every byte value is equal to each other
594
+ for (let i = 0; i < dataViewA.byteLength; i++) {
595
+ if (dataViewA.getUint8(i) !== dataViewB.getUint8(i)) {
596
+ return false;
597
+ }
598
+ }
599
+ return true;
600
+ };
601
+ exports.arrayBufferEquality = arrayBufferEquality;
602
+ const sparseArrayEquality = (a, b, customTesters = []) => {
603
+ if (!Array.isArray(a) || !Array.isArray(b)) {
604
+ return undefined;
605
+ }
606
+
607
+ // A sparse array [, , 1] will have keys ["2"] whereas [undefined, undefined, 1] will have keys ["0", "1", "2"]
608
+ const aKeys = Object.keys(a);
609
+ const bKeys = Object.keys(b);
610
+ return (0, _jasmineUtils.equals)(a, b, customTesters.filter(t => t !== sparseArrayEquality), true) && (0, _jasmineUtils.equals)(aKeys, bKeys);
611
+ };
612
+ exports.sparseArrayEquality = sparseArrayEquality;
613
+ const partition = (items, predicate) => {
614
+ const result = [[], []];
615
+ for (const item of items) result[predicate(item) ? 0 : 1].push(item);
616
+ return result;
617
+ };
618
+ exports.partition = partition;
619
+ const pathAsArray = propertyPath => {
620
+ const properties = [];
621
+ if (propertyPath === '') {
622
+ properties.push('');
623
+ return properties;
624
+ }
625
+
626
+ // will match everything that's not a dot or a bracket, and "" for consecutive dots.
627
+ const pattern = RegExp('[^.[\\]]+|(?=(?:\\.)(?:\\.|$))', 'g');
628
+
629
+ // Because the regex won't match a dot in the beginning of the path, if present.
630
+ if (propertyPath[0] === '.') {
631
+ properties.push('');
632
+ }
633
+ propertyPath.replace(pattern, match => {
634
+ properties.push(match);
635
+ return match;
636
+ });
637
+ return properties;
638
+ };
639
+
640
+ // Copied from https://github.com/graingert/angular.js/blob/a43574052e9775cbc1d7dd8a086752c979b0f020/src/Angular.js#L685-L693
641
+ exports.pathAsArray = pathAsArray;
642
+ const isError = value => {
643
+ switch (Object.prototype.toString.call(value)) {
644
+ case '[object Error]':
645
+ case '[object Exception]':
646
+ case '[object DOMException]':
647
+ return true;
648
+ default:
649
+ return value instanceof Error;
650
+ }
651
+ };
652
+ exports.isError = isError;
653
+ function emptyObject(obj) {
654
+ return obj && typeof obj === 'object' ? Object.keys(obj).length === 0 : false;
655
+ }
656
+ const MULTILINE_REGEXP = /[\r\n]/;
657
+ const isOneline = (expected, received) => typeof expected === 'string' && typeof received === 'string' && (!MULTILINE_REGEXP.test(expected) || !MULTILINE_REGEXP.test(received));
658
+ exports.isOneline = isOneline;
659
+
660
+ /***/ })
661
+
662
+ /******/ });
663
+ /************************************************************************/
664
+ /******/ // The module cache
665
+ /******/ var __webpack_module_cache__ = {};
666
+ /******/
667
+ /******/ // The require function
668
+ /******/ function __webpack_require__(moduleId) {
669
+ /******/ // Check if module is in cache
670
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
671
+ /******/ if (cachedModule !== undefined) {
672
+ /******/ return cachedModule.exports;
673
+ /******/ }
674
+ /******/ // Create a new module (and put it into the cache)
675
+ /******/ var module = __webpack_module_cache__[moduleId] = {
676
+ /******/ // no module.id needed
677
+ /******/ // no module.loaded needed
678
+ /******/ exports: {}
679
+ /******/ };
680
+ /******/
681
+ /******/ // Execute the module function
682
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
683
+ /******/
684
+ /******/ // Return the exports of the module
685
+ /******/ return module.exports;
686
+ /******/ }
687
+ /******/
688
+ /************************************************************************/
689
+ /******/
690
+ /******/ // startup
691
+ /******/ // Load entry module and return exports
692
+ /******/ // This entry module is referenced by other modules so it can't be inlined
693
+ /******/ var __webpack_exports__ = __webpack_require__("./src/index.ts");
694
+ /******/ module.exports = __webpack_exports__;
695
+ /******/
696
+ /******/ })()
697
+ ;