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

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,590 @@ 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
+ }
216
+ if (typeof a !== 'object' || typeof b !== 'object') {
217
+ return false;
218
+ }
219
+
220
+ // Use DOM3 method isEqualNode (IE>=9)
221
+ if (isDomNode(a) && isDomNode(b)) {
222
+ return a.isEqualNode(b);
223
+ }
224
+
225
+ // Used to detect circular references.
226
+ let length = aStack.length;
227
+ while (length--) {
228
+ // Linear search. Performance is inversely proportional to the number of
229
+ // unique nested structures.
230
+ // circular references at same depth are equal
231
+ // circular reference is not equal to non-circular one
232
+ if (aStack[length] === a) {
233
+ return bStack[length] === b;
234
+ } else if (bStack[length] === b) {
235
+ return false;
236
+ }
237
+ }
238
+ // Add the first object to the stack of traversed objects.
239
+ aStack.push(a);
240
+ bStack.push(b);
241
+ // Recursively compare objects and arrays.
242
+ // Compare array lengths to determine if a deep comparison is necessary.
243
+ if (strictCheck && className == '[object Array]' && a.length !== b.length) {
244
+ return false;
245
+ }
246
+
247
+ // Deep compare objects.
248
+ const aKeys = keys(a, hasKey);
249
+ let key;
250
+ const bKeys = keys(b, hasKey);
251
+ // Add keys corresponding to asymmetric matchers if they miss in non strict check mode
252
+ if (!strictCheck) {
253
+ for (let index = 0; index !== bKeys.length; ++index) {
254
+ key = bKeys[index];
255
+ if ((isAsymmetric(b[key]) || b[key] === undefined) && !hasKey(a, key)) {
256
+ aKeys.push(key);
257
+ }
258
+ }
259
+ for (let index = 0; index !== aKeys.length; ++index) {
260
+ key = aKeys[index];
261
+ if ((isAsymmetric(a[key]) || a[key] === undefined) && !hasKey(b, key)) {
262
+ bKeys.push(key);
263
+ }
264
+ }
265
+ }
266
+
267
+ // Ensure that both objects contain the same number of properties before comparing deep equality.
268
+ let size = aKeys.length;
269
+ if (bKeys.length !== size) {
270
+ return false;
271
+ }
272
+ while (size--) {
273
+ key = aKeys[size];
274
+
275
+ // Deep compare each member
276
+ 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);
277
+ if (!result) {
278
+ return false;
279
+ }
280
+ }
281
+ // Remove the first object from the stack of traversed objects.
282
+ aStack.pop();
283
+ bStack.pop();
284
+ return result;
285
+ }
286
+ function keys(obj, hasKey) {
287
+ const keys = [];
288
+ for (const key in obj) {
289
+ if (hasKey(obj, key)) {
290
+ keys.push(key);
291
+ }
292
+ }
293
+ return keys.concat(Object.getOwnPropertySymbols(obj).filter(symbol => Object.getOwnPropertyDescriptor(obj, symbol).enumerable));
294
+ }
295
+ function hasKey(obj, key) {
296
+ return Object.prototype.hasOwnProperty.call(obj, key);
297
+ }
298
+ function isA(typeName, value) {
299
+ return Object.prototype.toString.apply(value) === `[object ${typeName}]`;
300
+ }
301
+ function isDomNode(obj) {
302
+ return obj !== null && typeof obj === 'object' && typeof obj.nodeType === 'number' && typeof obj.nodeName === 'string' && typeof obj.isEqualNode === 'function';
303
+ }
304
+
305
+ /***/ }),
306
+
307
+ /***/ "./src/utils.ts":
308
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
309
+
310
+
311
+
312
+ Object.defineProperty(exports, "__esModule", ({
313
+ value: true
314
+ }));
315
+ exports.arrayBufferEquality = void 0;
316
+ exports.emptyObject = emptyObject;
317
+ exports.typeEquality = exports.subsetEquality = exports.sparseArrayEquality = exports.pathAsArray = exports.partition = exports.iterableEquality = exports.isOneline = exports.isError = exports.getPath = exports.getObjectSubset = exports.getObjectKeys = void 0;
318
+ var _jestGetType = require("jest-get-type");
319
+ var _immutableUtils = __webpack_require__("./src/immutableUtils.ts");
320
+ var _jasmineUtils = __webpack_require__("./src/jasmineUtils.ts");
321
+ var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol;
322
+ /**
323
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
324
+ *
325
+ * This source code is licensed under the MIT license found in the
326
+ * LICENSE file in the root directory of this source tree.
327
+ *
328
+ */
329
+ /**
330
+ * Checks if `hasOwnProperty(object, key)` up the prototype chain, stopping at `Object.prototype`.
331
+ */
332
+ const hasPropertyInObject = (object, key) => {
333
+ const shouldTerminate = !object || typeof object !== 'object' || object === Object.prototype;
334
+ if (shouldTerminate) {
335
+ return false;
336
+ }
337
+ return Object.prototype.hasOwnProperty.call(object, key) || hasPropertyInObject(Object.getPrototypeOf(object), key);
338
+ };
339
+
340
+ // Retrieves an object's keys for evaluation by getObjectSubset. This evaluates
341
+ // the prototype chain for string keys but not for symbols. (Otherwise, it
342
+ // could find values such as a Set or Map's Symbol.toStringTag, with unexpected
343
+ // results.)
344
+ const getObjectKeys = object => [...Object.keys(object), ...Object.getOwnPropertySymbols(object)];
345
+ exports.getObjectKeys = getObjectKeys;
346
+ const getPath = (object, propertyPath) => {
347
+ if (!Array.isArray(propertyPath)) {
348
+ propertyPath = pathAsArray(propertyPath);
349
+ }
350
+ if (propertyPath.length > 0) {
351
+ const lastProp = propertyPath.length === 1;
352
+ const prop = propertyPath[0];
353
+ const newObject = object[prop];
354
+ if (!lastProp && (newObject === null || newObject === undefined)) {
355
+ // This is not the last prop in the chain. If we keep recursing it will
356
+ // hit a `can't access property X of undefined | null`. At this point we
357
+ // know that the chain has broken and we can return right away.
358
+ return {
359
+ hasEndProp: false,
360
+ lastTraversedObject: object,
361
+ traversedPath: []
362
+ };
363
+ }
364
+ const result = getPath(newObject, propertyPath.slice(1));
365
+ if (result.lastTraversedObject === null) {
366
+ result.lastTraversedObject = object;
367
+ }
368
+ result.traversedPath.unshift(prop);
369
+ if (lastProp) {
370
+ // Does object have the property with an undefined value?
371
+ // Although primitive values support bracket notation (above)
372
+ // they would throw TypeError for in operator (below).
373
+ result.endPropIsDefined = !(0, _jestGetType.isPrimitive)(object) && prop in object;
374
+ result.hasEndProp = newObject !== undefined || result.endPropIsDefined;
375
+ if (!result.hasEndProp) {
376
+ result.traversedPath.shift();
377
+ }
378
+ }
379
+ return result;
380
+ }
381
+ return {
382
+ lastTraversedObject: null,
383
+ traversedPath: [],
384
+ value: object
385
+ };
386
+ };
387
+
388
+ // Strip properties from object that are not present in the subset. Useful for
389
+ // printing the diff for toMatchObject() without adding unrelated noise.
390
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
391
+ exports.getPath = getPath;
392
+ const getObjectSubset = (object, subset, customTesters = [], seenReferences = new WeakMap()) => {
393
+ /* eslint-enable @typescript-eslint/explicit-module-boundary-types */
394
+ if (Array.isArray(object)) {
395
+ if (Array.isArray(subset) && subset.length === object.length) {
396
+ // The map method returns correct subclass of subset.
397
+ return subset.map((sub, i) => getObjectSubset(object[i], sub, customTesters));
398
+ }
399
+ } else if (object instanceof Date) {
400
+ return object;
401
+ } else if (isObject(object) && isObject(subset)) {
402
+ if ((0, _jasmineUtils.equals)(object, subset, [...customTesters, iterableEquality, subsetEquality])) {
403
+ // Avoid unnecessary copy which might return Object instead of subclass.
404
+ return subset;
405
+ }
406
+ const trimmed = {};
407
+ seenReferences.set(object, trimmed);
408
+ for (const key of getObjectKeys(object).filter(key => hasPropertyInObject(subset, key))) {
409
+ trimmed[key] = seenReferences.has(object[key]) ? seenReferences.get(object[key]) : getObjectSubset(object[key], subset[key], customTesters, seenReferences);
410
+ }
411
+ if (getObjectKeys(trimmed).length > 0) {
412
+ return trimmed;
413
+ }
414
+ }
415
+ return object;
416
+ };
417
+ exports.getObjectSubset = getObjectSubset;
418
+ const IteratorSymbol = Symbol.iterator;
419
+ const hasIterator = object => !!(object != null && object[IteratorSymbol]);
420
+
421
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
422
+ const iterableEquality = (a, b, customTesters = [], /* eslint-enable @typescript-eslint/explicit-module-boundary-types */
423
+ aStack = [], bStack = []) => {
424
+ if (typeof a !== 'object' || typeof b !== 'object' || Array.isArray(a) || Array.isArray(b) || !hasIterator(a) || !hasIterator(b)) {
425
+ return undefined;
426
+ }
427
+ if (a.constructor !== b.constructor) {
428
+ return false;
429
+ }
430
+ let length = aStack.length;
431
+ while (length--) {
432
+ // Linear search. Performance is inversely proportional to the number of
433
+ // unique nested structures.
434
+ // circular references at same depth are equal
435
+ // circular reference is not equal to non-circular one
436
+ if (aStack[length] === a) {
437
+ return bStack[length] === b;
438
+ }
439
+ }
440
+ aStack.push(a);
441
+ bStack.push(b);
442
+ const iterableEqualityWithStack = (a, b) => iterableEquality(a, b, [...filteredCustomTesters], [...aStack], [...bStack]);
443
+
444
+ // Replace any instance of iterableEquality with the new
445
+ // iterableEqualityWithStack so we can do circular detection
446
+ const filteredCustomTesters = [...customTesters.filter(t => t !== iterableEquality), iterableEqualityWithStack];
447
+ if (a.size !== undefined) {
448
+ if (a.size !== b.size) {
449
+ return false;
450
+ } else if ((0, _jasmineUtils.isA)('Set', a) || (0, _immutableUtils.isImmutableUnorderedSet)(a)) {
451
+ let allFound = true;
452
+ for (const aValue of a) {
453
+ if (!b.has(aValue)) {
454
+ let has = false;
455
+ for (const bValue of b) {
456
+ const isEqual = (0, _jasmineUtils.equals)(aValue, bValue, filteredCustomTesters);
457
+ if (isEqual === true) {
458
+ has = true;
459
+ }
460
+ }
461
+ if (has === false) {
462
+ allFound = false;
463
+ break;
464
+ }
465
+ }
466
+ }
467
+ // Remove the first value from the stack of traversed values.
468
+ aStack.pop();
469
+ bStack.pop();
470
+ return allFound;
471
+ } else if ((0, _jasmineUtils.isA)('Map', a) || (0, _immutableUtils.isImmutableUnorderedKeyed)(a)) {
472
+ let allFound = true;
473
+ for (const aEntry of a) {
474
+ if (!b.has(aEntry[0]) || !(0, _jasmineUtils.equals)(aEntry[1], b.get(aEntry[0]), filteredCustomTesters)) {
475
+ let has = false;
476
+ for (const bEntry of b) {
477
+ const matchedKey = (0, _jasmineUtils.equals)(aEntry[0], bEntry[0], filteredCustomTesters);
478
+ let matchedValue = false;
479
+ if (matchedKey === true) {
480
+ matchedValue = (0, _jasmineUtils.equals)(aEntry[1], bEntry[1], filteredCustomTesters);
481
+ }
482
+ if (matchedValue === true) {
483
+ has = true;
484
+ }
485
+ }
486
+ if (has === false) {
487
+ allFound = false;
488
+ break;
489
+ }
490
+ }
491
+ }
492
+ // Remove the first value from the stack of traversed values.
493
+ aStack.pop();
494
+ bStack.pop();
495
+ return allFound;
496
+ }
497
+ }
498
+ const bIterator = b[IteratorSymbol]();
499
+ for (const aValue of a) {
500
+ const nextB = bIterator.next();
501
+ if (nextB.done || !(0, _jasmineUtils.equals)(aValue, nextB.value, filteredCustomTesters)) {
502
+ return false;
503
+ }
504
+ }
505
+ if (!bIterator.next().done) {
506
+ return false;
507
+ }
508
+ if (!(0, _immutableUtils.isImmutableList)(a) && !(0, _immutableUtils.isImmutableOrderedKeyed)(a) && !(0, _immutableUtils.isImmutableOrderedSet)(a) && !(0, _immutableUtils.isImmutableRecord)(a)) {
509
+ const aEntries = Object.entries(a);
510
+ const bEntries = Object.entries(b);
511
+ if (!(0, _jasmineUtils.equals)(aEntries, bEntries)) {
512
+ return false;
513
+ }
514
+ }
515
+
516
+ // Remove the first value from the stack of traversed values.
517
+ aStack.pop();
518
+ bStack.pop();
519
+ return true;
520
+ };
521
+ exports.iterableEquality = iterableEquality;
522
+ const isObject = a => a !== null && typeof a === 'object';
523
+ const isObjectWithKeys = a => isObject(a) && !(a instanceof Error) && !(a instanceof Array) && !(a instanceof Date);
524
+ const subsetEquality = (object, subset, customTesters = []) => {
525
+ const filteredCustomTesters = customTesters.filter(t => t !== subsetEquality);
526
+
527
+ // subsetEquality needs to keep track of the references
528
+ // it has already visited to avoid infinite loops in case
529
+ // there are circular references in the subset passed to it.
530
+ const subsetEqualityWithContext = (seenReferences = new WeakMap()) => (object, subset) => {
531
+ if (!isObjectWithKeys(subset)) {
532
+ return undefined;
533
+ }
534
+ return getObjectKeys(subset).every(key => {
535
+ if (isObjectWithKeys(subset[key])) {
536
+ if (seenReferences.has(subset[key])) {
537
+ return (0, _jasmineUtils.equals)(object[key], subset[key], filteredCustomTesters);
538
+ }
539
+ seenReferences.set(subset[key], true);
540
+ }
541
+ const result = object != null && hasPropertyInObject(object, key) && (0, _jasmineUtils.equals)(object[key], subset[key], [...filteredCustomTesters, subsetEqualityWithContext(seenReferences)]);
542
+ // The main goal of using seenReference is to avoid circular node on tree.
543
+ // It will only happen within a parent and its child, not a node and nodes next to it (same level)
544
+ // We should keep the reference for a parent and its child only
545
+ // Thus we should delete the reference immediately so that it doesn't interfere
546
+ // other nodes within the same level on tree.
547
+ seenReferences.delete(subset[key]);
548
+ return result;
549
+ });
550
+ };
551
+ return subsetEqualityWithContext()(object, subset);
552
+ };
553
+
554
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
555
+ exports.subsetEquality = subsetEquality;
556
+ const typeEquality = (a, b) => {
557
+ if (a == null || b == null || a.constructor === b.constructor ||
558
+ // Since Jest globals are different from Node globals,
559
+ // constructors are different even between arrays when comparing properties of mock objects.
560
+ // Both of them should be able to compare correctly when they are array-to-array.
561
+ // https://github.com/jestjs/jest/issues/2549
562
+ Array.isArray(a) && Array.isArray(b)) {
563
+ return undefined;
564
+ }
565
+ return false;
566
+ };
567
+ exports.typeEquality = typeEquality;
568
+ const arrayBufferEquality = (a, b) => {
569
+ let dataViewA = a;
570
+ let dataViewB = b;
571
+ if (a instanceof ArrayBuffer && b instanceof ArrayBuffer) {
572
+ dataViewA = new DataView(a);
573
+ dataViewB = new DataView(b);
574
+ }
575
+ if (!(dataViewA instanceof DataView && dataViewB instanceof DataView)) {
576
+ return undefined;
577
+ }
578
+
579
+ // Buffers are not equal when they do not have the same byte length
580
+ if (dataViewA.byteLength !== dataViewB.byteLength) {
581
+ return false;
582
+ }
583
+
584
+ // Check if every byte value is equal to each other
585
+ for (let i = 0; i < dataViewA.byteLength; i++) {
586
+ if (dataViewA.getUint8(i) !== dataViewB.getUint8(i)) {
587
+ return false;
588
+ }
589
+ }
590
+ return true;
591
+ };
592
+ exports.arrayBufferEquality = arrayBufferEquality;
593
+ const sparseArrayEquality = (a, b, customTesters = []) => {
594
+ if (!Array.isArray(a) || !Array.isArray(b)) {
595
+ return undefined;
596
+ }
597
+
598
+ // A sparse array [, , 1] will have keys ["2"] whereas [undefined, undefined, 1] will have keys ["0", "1", "2"]
599
+ const aKeys = Object.keys(a);
600
+ const bKeys = Object.keys(b);
601
+ return (0, _jasmineUtils.equals)(a, b, customTesters.filter(t => t !== sparseArrayEquality), true) && (0, _jasmineUtils.equals)(aKeys, bKeys);
602
+ };
603
+ exports.sparseArrayEquality = sparseArrayEquality;
604
+ const partition = (items, predicate) => {
605
+ const result = [[], []];
606
+ for (const item of items) result[predicate(item) ? 0 : 1].push(item);
607
+ return result;
608
+ };
609
+ exports.partition = partition;
610
+ const pathAsArray = propertyPath => {
611
+ const properties = [];
612
+ if (propertyPath === '') {
613
+ properties.push('');
614
+ return properties;
615
+ }
616
+
617
+ // will match everything that's not a dot or a bracket, and "" for consecutive dots.
618
+ const pattern = RegExp('[^.[\\]]+|(?=(?:\\.)(?:\\.|$))', 'g');
619
+
620
+ // Because the regex won't match a dot in the beginning of the path, if present.
621
+ if (propertyPath[0] === '.') {
622
+ properties.push('');
623
+ }
624
+ propertyPath.replace(pattern, match => {
625
+ properties.push(match);
626
+ return match;
627
+ });
628
+ return properties;
629
+ };
630
+
631
+ // Copied from https://github.com/graingert/angular.js/blob/a43574052e9775cbc1d7dd8a086752c979b0f020/src/Angular.js#L685-L693
632
+ exports.pathAsArray = pathAsArray;
633
+ const isError = value => {
634
+ switch (Object.prototype.toString.call(value)) {
635
+ case '[object Error]':
636
+ case '[object Exception]':
637
+ case '[object DOMException]':
638
+ return true;
639
+ default:
640
+ return value instanceof Error;
641
+ }
642
+ };
643
+ exports.isError = isError;
644
+ function emptyObject(obj) {
645
+ return obj && typeof obj === 'object' ? Object.keys(obj).length === 0 : false;
646
+ }
647
+ const MULTILINE_REGEXP = /[\r\n]/;
648
+ const isOneline = (expected, received) => typeof expected === 'string' && typeof received === 'string' && (!MULTILINE_REGEXP.test(expected) || !MULTILINE_REGEXP.test(received));
649
+ exports.isOneline = isOneline;
650
+
651
+ /***/ })
652
+
653
+ /******/ });
654
+ /************************************************************************/
655
+ /******/ // The module cache
656
+ /******/ var __webpack_module_cache__ = {};
657
+ /******/
658
+ /******/ // The require function
659
+ /******/ function __webpack_require__(moduleId) {
660
+ /******/ // Check if module is in cache
661
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
662
+ /******/ if (cachedModule !== undefined) {
663
+ /******/ return cachedModule.exports;
664
+ /******/ }
665
+ /******/ // Create a new module (and put it into the cache)
666
+ /******/ var module = __webpack_module_cache__[moduleId] = {
667
+ /******/ // no module.id needed
668
+ /******/ // no module.loaded needed
669
+ /******/ exports: {}
670
+ /******/ };
671
+ /******/
672
+ /******/ // Execute the module function
673
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
674
+ /******/
675
+ /******/ // Return the exports of the module
676
+ /******/ return module.exports;
677
+ /******/ }
678
+ /******/
679
+ /************************************************************************/
680
+ /******/
681
+ /******/ // startup
682
+ /******/ // Load entry module and return exports
683
+ /******/ // This entry module is referenced by other modules so it can't be inlined
684
+ /******/ var __webpack_exports__ = __webpack_require__("./src/index.ts");
685
+ /******/ module.exports = __webpack_exports__;
686
+ /******/
687
+ /******/ })()
688
+ ;