@jest/expect-utils
Advanced tools
Comparing version 29.7.0 to 30.0.0-alpha.1
@@ -1,6 +0,73 @@ | ||
'use strict'; | ||
/*! | ||
* /** | ||
* * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* * | ||
* * This source code is licensed under the MIT license found in the | ||
* * LICENSE file in the root directory of this source tree. | ||
* * / | ||
*/ | ||
/******/ (() => { // webpackBootstrap | ||
/******/ "use strict"; | ||
/******/ var __webpack_modules__ = ({ | ||
Object.defineProperty(exports, '__esModule', { | ||
/***/ "./src/immutableUtils.ts": | ||
/***/ ((__unused_webpack_module, exports) => { | ||
Object.defineProperty(exports, "__esModule", ({ | ||
value: true | ||
}); | ||
})); | ||
exports.isImmutableList = isImmutableList; | ||
exports.isImmutableOrderedKeyed = isImmutableOrderedKeyed; | ||
exports.isImmutableOrderedSet = isImmutableOrderedSet; | ||
exports.isImmutableRecord = isImmutableRecord; | ||
exports.isImmutableUnorderedKeyed = isImmutableUnorderedKeyed; | ||
exports.isImmutableUnorderedSet = isImmutableUnorderedSet; | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
// SENTINEL constants are from https://github.com/immutable-js/immutable-js/tree/main/src/predicates | ||
const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; | ||
const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'; | ||
const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@'; | ||
const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'; | ||
const IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@'; | ||
function isObjectLiteral(source) { | ||
return source != null && typeof source === 'object' && !Array.isArray(source); | ||
} | ||
function isImmutableUnorderedKeyed(source) { | ||
return Boolean(source && isObjectLiteral(source) && source[IS_KEYED_SENTINEL] && !source[IS_ORDERED_SENTINEL]); | ||
} | ||
function isImmutableUnorderedSet(source) { | ||
return Boolean(source && isObjectLiteral(source) && source[IS_SET_SENTINEL] && !source[IS_ORDERED_SENTINEL]); | ||
} | ||
function isImmutableList(source) { | ||
return Boolean(source && isObjectLiteral(source) && source[IS_LIST_SENTINEL]); | ||
} | ||
function isImmutableOrderedKeyed(source) { | ||
return Boolean(source && isObjectLiteral(source) && source[IS_KEYED_SENTINEL] && source[IS_ORDERED_SENTINEL]); | ||
} | ||
function isImmutableOrderedSet(source) { | ||
return Boolean(source && isObjectLiteral(source) && source[IS_SET_SENTINEL] && source[IS_ORDERED_SENTINEL]); | ||
} | ||
function isImmutableRecord(source) { | ||
return Boolean(source && isObjectLiteral(source) && source[IS_RECORD_SYMBOL]); | ||
} | ||
/***/ }), | ||
/***/ "./src/index.ts": | ||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ | ||
value: true | ||
})); | ||
var _exportNames = { | ||
@@ -10,3 +77,3 @@ equals: true, | ||
}; | ||
Object.defineProperty(exports, 'equals', { | ||
Object.defineProperty(exports, "equals", ({ | ||
enumerable: true, | ||
@@ -16,4 +83,4 @@ get: function () { | ||
} | ||
}); | ||
Object.defineProperty(exports, 'isA', { | ||
})); | ||
Object.defineProperty(exports, "isA", ({ | ||
enumerable: true, | ||
@@ -23,7 +90,7 @@ get: function () { | ||
} | ||
}); | ||
var _jasmineUtils = require('./jasmineUtils'); | ||
var _utils = require('./utils'); | ||
})); | ||
var _jasmineUtils = __webpack_require__("./src/jasmineUtils.ts"); | ||
var _utils = __webpack_require__("./src/utils.ts"); | ||
Object.keys(_utils).forEach(function (key) { | ||
if (key === 'default' || key === '__esModule') return; | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
@@ -38,1 +105,588 @@ if (key in exports && exports[key] === _utils[key]) return; | ||
}); | ||
/***/ }), | ||
/***/ "./src/jasmineUtils.ts": | ||
/***/ ((__unused_webpack_module, exports) => { | ||
Object.defineProperty(exports, "__esModule", ({ | ||
value: true | ||
})); | ||
exports.equals = void 0; | ||
exports.isA = isA; | ||
/* | ||
Copyright (c) 2008-2016 Pivotal Labs | ||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
// Extracted out of jasmine 2.5.2 | ||
const equals = (a, b, customTesters, strictCheck) => { | ||
customTesters = customTesters || []; | ||
return eq(a, b, [], [], customTesters, strictCheck); | ||
}; | ||
exports.equals = equals; | ||
function isAsymmetric(obj) { | ||
return !!obj && isA('Function', obj.asymmetricMatch); | ||
} | ||
function asymmetricMatch(a, b) { | ||
const asymmetricA = isAsymmetric(a); | ||
const asymmetricB = isAsymmetric(b); | ||
if (asymmetricA && asymmetricB) { | ||
return undefined; | ||
} | ||
if (asymmetricA) { | ||
return a.asymmetricMatch(b); | ||
} | ||
if (asymmetricB) { | ||
return b.asymmetricMatch(a); | ||
} | ||
} | ||
// Equality function lovingly adapted from isEqual in | ||
// [Underscore](http://underscorejs.org) | ||
function eq(a, b, aStack, bStack, customTesters, strictCheck) { | ||
let result = true; | ||
const asymmetricResult = asymmetricMatch(a, b); | ||
if (asymmetricResult !== undefined) { | ||
return asymmetricResult; | ||
} | ||
const testerContext = { | ||
equals | ||
}; | ||
for (let i = 0; i < customTesters.length; i++) { | ||
const customTesterResult = customTesters[i].call(testerContext, a, b, customTesters); | ||
if (customTesterResult !== undefined) { | ||
return customTesterResult; | ||
} | ||
} | ||
if (a instanceof Error && b instanceof Error) { | ||
return a.message == b.message; | ||
} | ||
if (Object.is(a, b)) { | ||
return true; | ||
} | ||
// A strict comparison is necessary because `null == undefined`. | ||
if (a === null || b === null) { | ||
return a === b; | ||
} | ||
const className = Object.prototype.toString.call(a); | ||
if (className != Object.prototype.toString.call(b)) { | ||
return false; | ||
} | ||
switch (className) { | ||
case '[object Boolean]': | ||
case '[object String]': | ||
case '[object Number]': | ||
if (typeof a !== typeof b) { | ||
// One is a primitive, one a `new Primitive()` | ||
return false; | ||
} else if (typeof a !== 'object' && typeof b !== 'object') { | ||
// both are proper primitives | ||
return Object.is(a, b); | ||
} else { | ||
// both are `new Primitive()`s | ||
return Object.is(a.valueOf(), b.valueOf()); | ||
} | ||
case '[object Date]': | ||
// Coerce dates to numeric primitive values. Dates are compared by their | ||
// millisecond representations. Note that invalid dates with millisecond representations | ||
// of `NaN` are not equivalent. | ||
return +a == +b; | ||
// RegExps are compared by their source patterns and flags. | ||
case '[object RegExp]': | ||
return a.source === b.source && a.flags === b.flags; | ||
} | ||
if (typeof a !== 'object' || typeof b !== 'object') { | ||
return false; | ||
} | ||
// Use DOM3 method isEqualNode (IE>=9) | ||
if (isDomNode(a) && isDomNode(b)) { | ||
return a.isEqualNode(b); | ||
} | ||
// Used to detect circular references. | ||
let length = aStack.length; | ||
while (length--) { | ||
// Linear search. Performance is inversely proportional to the number of | ||
// unique nested structures. | ||
// circular references at same depth are equal | ||
// circular reference is not equal to non-circular one | ||
if (aStack[length] === a) { | ||
return bStack[length] === b; | ||
} else if (bStack[length] === b) { | ||
return false; | ||
} | ||
} | ||
// Add the first object to the stack of traversed objects. | ||
aStack.push(a); | ||
bStack.push(b); | ||
// Recursively compare objects and arrays. | ||
// Compare array lengths to determine if a deep comparison is necessary. | ||
if (strictCheck && className == '[object Array]' && a.length !== b.length) { | ||
return false; | ||
} | ||
// Deep compare objects. | ||
const aKeys = keys(a, hasKey); | ||
let key; | ||
const bKeys = keys(b, hasKey); | ||
// Add keys corresponding to asymmetric matchers if they miss in non strict check mode | ||
if (!strictCheck) { | ||
for (let index = 0; index !== bKeys.length; ++index) { | ||
key = bKeys[index]; | ||
if ((isAsymmetric(b[key]) || b[key] === undefined) && !hasKey(a, key)) { | ||
aKeys.push(key); | ||
} | ||
} | ||
for (let index = 0; index !== aKeys.length; ++index) { | ||
key = aKeys[index]; | ||
if ((isAsymmetric(a[key]) || a[key] === undefined) && !hasKey(b, key)) { | ||
bKeys.push(key); | ||
} | ||
} | ||
} | ||
// Ensure that both objects contain the same number of properties before comparing deep equality. | ||
let size = aKeys.length; | ||
if (bKeys.length !== size) { | ||
return false; | ||
} | ||
while (size--) { | ||
key = aKeys[size]; | ||
// Deep compare each member | ||
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); | ||
if (!result) { | ||
return false; | ||
} | ||
} | ||
// Remove the first object from the stack of traversed objects. | ||
aStack.pop(); | ||
bStack.pop(); | ||
return result; | ||
} | ||
function keys(obj, hasKey) { | ||
const keys = []; | ||
for (const key in obj) { | ||
if (hasKey(obj, key)) { | ||
keys.push(key); | ||
} | ||
} | ||
return keys.concat(Object.getOwnPropertySymbols(obj).filter(symbol => Object.getOwnPropertyDescriptor(obj, symbol).enumerable)); | ||
} | ||
function hasKey(obj, key) { | ||
return Object.prototype.hasOwnProperty.call(obj, key); | ||
} | ||
function isA(typeName, value) { | ||
return Object.prototype.toString.apply(value) === `[object ${typeName}]`; | ||
} | ||
function isDomNode(obj) { | ||
return obj !== null && typeof obj === 'object' && typeof obj.nodeType === 'number' && typeof obj.nodeName === 'string' && typeof obj.isEqualNode === 'function'; | ||
} | ||
/***/ }), | ||
/***/ "./src/utils.ts": | ||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ | ||
value: true | ||
})); | ||
exports.arrayBufferEquality = void 0; | ||
exports.emptyObject = emptyObject; | ||
exports.typeEquality = exports.subsetEquality = exports.sparseArrayEquality = exports.pathAsArray = exports.partition = exports.iterableEquality = exports.isOneline = exports.isError = exports.getPath = exports.getObjectSubset = exports.getObjectKeys = void 0; | ||
var _jestGetType = require("jest-get-type"); | ||
var _immutableUtils = __webpack_require__("./src/immutableUtils.ts"); | ||
var _jasmineUtils = __webpack_require__("./src/jasmineUtils.ts"); | ||
var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol; | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
/** | ||
* Checks if `hasOwnProperty(object, key)` up the prototype chain, stopping at `Object.prototype`. | ||
*/ | ||
const hasPropertyInObject = (object, key) => { | ||
const shouldTerminate = !object || typeof object !== 'object' || object === Object.prototype; | ||
if (shouldTerminate) { | ||
return false; | ||
} | ||
return Object.prototype.hasOwnProperty.call(object, key) || hasPropertyInObject(Object.getPrototypeOf(object), key); | ||
}; | ||
// Retrieves an object's keys for evaluation by getObjectSubset. This evaluates | ||
// the prototype chain for string keys but not for symbols. (Otherwise, it | ||
// could find values such as a Set or Map's Symbol.toStringTag, with unexpected | ||
// results.) | ||
const getObjectKeys = object => [...Object.keys(object), ...Object.getOwnPropertySymbols(object)]; | ||
exports.getObjectKeys = getObjectKeys; | ||
const getPath = (object, propertyPath) => { | ||
if (!Array.isArray(propertyPath)) { | ||
propertyPath = pathAsArray(propertyPath); | ||
} | ||
if (propertyPath.length > 0) { | ||
const lastProp = propertyPath.length === 1; | ||
const prop = propertyPath[0]; | ||
const newObject = object[prop]; | ||
if (!lastProp && (newObject === null || newObject === undefined)) { | ||
// This is not the last prop in the chain. If we keep recursing it will | ||
// hit a `can't access property X of undefined | null`. At this point we | ||
// know that the chain has broken and we can return right away. | ||
return { | ||
hasEndProp: false, | ||
lastTraversedObject: object, | ||
traversedPath: [] | ||
}; | ||
} | ||
const result = getPath(newObject, propertyPath.slice(1)); | ||
if (result.lastTraversedObject === null) { | ||
result.lastTraversedObject = object; | ||
} | ||
result.traversedPath.unshift(prop); | ||
if (lastProp) { | ||
// Does object have the property with an undefined value? | ||
// Although primitive values support bracket notation (above) | ||
// they would throw TypeError for in operator (below). | ||
result.endPropIsDefined = !(0, _jestGetType.isPrimitive)(object) && prop in object; | ||
result.hasEndProp = newObject !== undefined || result.endPropIsDefined; | ||
if (!result.hasEndProp) { | ||
result.traversedPath.shift(); | ||
} | ||
} | ||
return result; | ||
} | ||
return { | ||
lastTraversedObject: null, | ||
traversedPath: [], | ||
value: object | ||
}; | ||
}; | ||
// Strip properties from object that are not present in the subset. Useful for | ||
// printing the diff for toMatchObject() without adding unrelated noise. | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
exports.getPath = getPath; | ||
const getObjectSubset = (object, subset, customTesters = [], seenReferences = new WeakMap()) => { | ||
/* eslint-enable @typescript-eslint/explicit-module-boundary-types */ | ||
if (Array.isArray(object)) { | ||
if (Array.isArray(subset) && subset.length === object.length) { | ||
// The map method returns correct subclass of subset. | ||
return subset.map((sub, i) => getObjectSubset(object[i], sub, customTesters)); | ||
} | ||
} else if (object instanceof Date) { | ||
return object; | ||
} else if (isObject(object) && isObject(subset)) { | ||
if ((0, _jasmineUtils.equals)(object, subset, [...customTesters, iterableEquality, subsetEquality])) { | ||
// Avoid unnecessary copy which might return Object instead of subclass. | ||
return subset; | ||
} | ||
const trimmed = {}; | ||
seenReferences.set(object, trimmed); | ||
for (const key of getObjectKeys(object).filter(key => hasPropertyInObject(subset, key))) { | ||
trimmed[key] = seenReferences.has(object[key]) ? seenReferences.get(object[key]) : getObjectSubset(object[key], subset[key], customTesters, seenReferences); | ||
} | ||
if (getObjectKeys(trimmed).length > 0) { | ||
return trimmed; | ||
} | ||
} | ||
return object; | ||
}; | ||
exports.getObjectSubset = getObjectSubset; | ||
const IteratorSymbol = Symbol.iterator; | ||
const hasIterator = object => !!(object != null && object[IteratorSymbol]); | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
const iterableEquality = (a, b, customTesters = [], /* eslint-enable @typescript-eslint/explicit-module-boundary-types */ | ||
aStack = [], bStack = []) => { | ||
if (typeof a !== 'object' || typeof b !== 'object' || Array.isArray(a) || Array.isArray(b) || !hasIterator(a) || !hasIterator(b)) { | ||
return undefined; | ||
} | ||
if (a.constructor !== b.constructor) { | ||
return false; | ||
} | ||
let length = aStack.length; | ||
while (length--) { | ||
// Linear search. Performance is inversely proportional to the number of | ||
// unique nested structures. | ||
// circular references at same depth are equal | ||
// circular reference is not equal to non-circular one | ||
if (aStack[length] === a) { | ||
return bStack[length] === b; | ||
} | ||
} | ||
aStack.push(a); | ||
bStack.push(b); | ||
const iterableEqualityWithStack = (a, b) => iterableEquality(a, b, [...filteredCustomTesters], [...aStack], [...bStack]); | ||
// Replace any instance of iterableEquality with the new | ||
// iterableEqualityWithStack so we can do circular detection | ||
const filteredCustomTesters = [...customTesters.filter(t => t !== iterableEquality), iterableEqualityWithStack]; | ||
if (a.size !== undefined) { | ||
if (a.size !== b.size) { | ||
return false; | ||
} else if ((0, _jasmineUtils.isA)('Set', a) || (0, _immutableUtils.isImmutableUnorderedSet)(a)) { | ||
let allFound = true; | ||
for (const aValue of a) { | ||
if (!b.has(aValue)) { | ||
let has = false; | ||
for (const bValue of b) { | ||
const isEqual = (0, _jasmineUtils.equals)(aValue, bValue, filteredCustomTesters); | ||
if (isEqual === true) { | ||
has = true; | ||
} | ||
} | ||
if (has === false) { | ||
allFound = false; | ||
break; | ||
} | ||
} | ||
} | ||
// Remove the first value from the stack of traversed values. | ||
aStack.pop(); | ||
bStack.pop(); | ||
return allFound; | ||
} else if ((0, _jasmineUtils.isA)('Map', a) || (0, _immutableUtils.isImmutableUnorderedKeyed)(a)) { | ||
let allFound = true; | ||
for (const aEntry of a) { | ||
if (!b.has(aEntry[0]) || !(0, _jasmineUtils.equals)(aEntry[1], b.get(aEntry[0]), filteredCustomTesters)) { | ||
let has = false; | ||
for (const bEntry of b) { | ||
const matchedKey = (0, _jasmineUtils.equals)(aEntry[0], bEntry[0], filteredCustomTesters); | ||
let matchedValue = false; | ||
if (matchedKey === true) { | ||
matchedValue = (0, _jasmineUtils.equals)(aEntry[1], bEntry[1], filteredCustomTesters); | ||
} | ||
if (matchedValue === true) { | ||
has = true; | ||
} | ||
} | ||
if (has === false) { | ||
allFound = false; | ||
break; | ||
} | ||
} | ||
} | ||
// Remove the first value from the stack of traversed values. | ||
aStack.pop(); | ||
bStack.pop(); | ||
return allFound; | ||
} | ||
} | ||
const bIterator = b[IteratorSymbol](); | ||
for (const aValue of a) { | ||
const nextB = bIterator.next(); | ||
if (nextB.done || !(0, _jasmineUtils.equals)(aValue, nextB.value, filteredCustomTesters)) { | ||
return false; | ||
} | ||
} | ||
if (!bIterator.next().done) { | ||
return false; | ||
} | ||
if (!(0, _immutableUtils.isImmutableList)(a) && !(0, _immutableUtils.isImmutableOrderedKeyed)(a) && !(0, _immutableUtils.isImmutableOrderedSet)(a) && !(0, _immutableUtils.isImmutableRecord)(a)) { | ||
const aEntries = Object.entries(a); | ||
const bEntries = Object.entries(b); | ||
if (!(0, _jasmineUtils.equals)(aEntries, bEntries)) { | ||
return false; | ||
} | ||
} | ||
// Remove the first value from the stack of traversed values. | ||
aStack.pop(); | ||
bStack.pop(); | ||
return true; | ||
}; | ||
exports.iterableEquality = iterableEquality; | ||
const isObject = a => a !== null && typeof a === 'object'; | ||
const isObjectWithKeys = a => isObject(a) && !(a instanceof Error) && !(a instanceof Array) && !(a instanceof Date); | ||
const subsetEquality = (object, subset, customTesters = []) => { | ||
const filteredCustomTesters = customTesters.filter(t => t !== subsetEquality); | ||
// subsetEquality needs to keep track of the references | ||
// it has already visited to avoid infinite loops in case | ||
// there are circular references in the subset passed to it. | ||
const subsetEqualityWithContext = (seenReferences = new WeakMap()) => (object, subset) => { | ||
if (!isObjectWithKeys(subset)) { | ||
return undefined; | ||
} | ||
return getObjectKeys(subset).every(key => { | ||
if (isObjectWithKeys(subset[key])) { | ||
if (seenReferences.has(subset[key])) { | ||
return (0, _jasmineUtils.equals)(object[key], subset[key], filteredCustomTesters); | ||
} | ||
seenReferences.set(subset[key], true); | ||
} | ||
const result = object != null && hasPropertyInObject(object, key) && (0, _jasmineUtils.equals)(object[key], subset[key], [...filteredCustomTesters, subsetEqualityWithContext(seenReferences)]); | ||
// The main goal of using seenReference is to avoid circular node on tree. | ||
// It will only happen within a parent and its child, not a node and nodes next to it (same level) | ||
// We should keep the reference for a parent and its child only | ||
// Thus we should delete the reference immediately so that it doesn't interfere | ||
// other nodes within the same level on tree. | ||
seenReferences.delete(subset[key]); | ||
return result; | ||
}); | ||
}; | ||
return subsetEqualityWithContext()(object, subset); | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
exports.subsetEquality = subsetEquality; | ||
const typeEquality = (a, b) => { | ||
if (a == null || b == null || a.constructor === b.constructor || | ||
// Since Jest globals are different from Node globals, | ||
// constructors are different even between arrays when comparing properties of mock objects. | ||
// Both of them should be able to compare correctly when they are array-to-array. | ||
// https://github.com/jestjs/jest/issues/2549 | ||
Array.isArray(a) && Array.isArray(b)) { | ||
return undefined; | ||
} | ||
return false; | ||
}; | ||
exports.typeEquality = typeEquality; | ||
const arrayBufferEquality = (a, b) => { | ||
let dataViewA = a; | ||
let dataViewB = b; | ||
if (a instanceof ArrayBuffer && b instanceof ArrayBuffer) { | ||
dataViewA = new DataView(a); | ||
dataViewB = new DataView(b); | ||
} | ||
if (!(dataViewA instanceof DataView && dataViewB instanceof DataView)) { | ||
return undefined; | ||
} | ||
// Buffers are not equal when they do not have the same byte length | ||
if (dataViewA.byteLength !== dataViewB.byteLength) { | ||
return false; | ||
} | ||
// Check if every byte value is equal to each other | ||
for (let i = 0; i < dataViewA.byteLength; i++) { | ||
if (dataViewA.getUint8(i) !== dataViewB.getUint8(i)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
exports.arrayBufferEquality = arrayBufferEquality; | ||
const sparseArrayEquality = (a, b, customTesters = []) => { | ||
if (!Array.isArray(a) || !Array.isArray(b)) { | ||
return undefined; | ||
} | ||
// A sparse array [, , 1] will have keys ["2"] whereas [undefined, undefined, 1] will have keys ["0", "1", "2"] | ||
const aKeys = Object.keys(a); | ||
const bKeys = Object.keys(b); | ||
return (0, _jasmineUtils.equals)(a, b, customTesters.filter(t => t !== sparseArrayEquality), true) && (0, _jasmineUtils.equals)(aKeys, bKeys); | ||
}; | ||
exports.sparseArrayEquality = sparseArrayEquality; | ||
const partition = (items, predicate) => { | ||
const result = [[], []]; | ||
for (const item of items) result[predicate(item) ? 0 : 1].push(item); | ||
return result; | ||
}; | ||
exports.partition = partition; | ||
const pathAsArray = propertyPath => { | ||
const properties = []; | ||
if (propertyPath === '') { | ||
properties.push(''); | ||
return properties; | ||
} | ||
// will match everything that's not a dot or a bracket, and "" for consecutive dots. | ||
const pattern = RegExp('[^.[\\]]+|(?=(?:\\.)(?:\\.|$))', 'g'); | ||
// Because the regex won't match a dot in the beginning of the path, if present. | ||
if (propertyPath[0] === '.') { | ||
properties.push(''); | ||
} | ||
propertyPath.replace(pattern, match => { | ||
properties.push(match); | ||
return match; | ||
}); | ||
return properties; | ||
}; | ||
// Copied from https://github.com/graingert/angular.js/blob/a43574052e9775cbc1d7dd8a086752c979b0f020/src/Angular.js#L685-L693 | ||
exports.pathAsArray = pathAsArray; | ||
const isError = value => { | ||
switch (Object.prototype.toString.call(value)) { | ||
case '[object Error]': | ||
case '[object Exception]': | ||
case '[object DOMException]': | ||
return true; | ||
default: | ||
return value instanceof Error; | ||
} | ||
}; | ||
exports.isError = isError; | ||
function emptyObject(obj) { | ||
return obj && typeof obj === 'object' ? Object.keys(obj).length === 0 : false; | ||
} | ||
const MULTILINE_REGEXP = /[\r\n]/; | ||
const isOneline = (expected, received) => typeof expected === 'string' && typeof received === 'string' && (!MULTILINE_REGEXP.test(expected) || !MULTILINE_REGEXP.test(received)); | ||
exports.isOneline = isOneline; | ||
/***/ }) | ||
/******/ }); | ||
/************************************************************************/ | ||
/******/ // The module cache | ||
/******/ var __webpack_module_cache__ = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ var cachedModule = __webpack_module_cache__[moduleId]; | ||
/******/ if (cachedModule !== undefined) { | ||
/******/ return cachedModule.exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = __webpack_module_cache__[moduleId] = { | ||
/******/ // no module.id needed | ||
/******/ // no module.loaded needed | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/************************************************************************/ | ||
/******/ | ||
/******/ // startup | ||
/******/ // Load entry module and return exports | ||
/******/ // This entry module is referenced by other modules so it can't be inlined | ||
/******/ var __webpack_exports__ = __webpack_require__("./src/index.ts"); | ||
/******/ module.exports = __webpack_exports__; | ||
/******/ | ||
/******/ })() | ||
; |
{ | ||
"name": "@jest/expect-utils", | ||
"version": "29.7.0", | ||
"version": "30.0.0-alpha.1", | ||
"repository": { | ||
@@ -15,2 +15,4 @@ "type": "git", | ||
"types": "./build/index.d.ts", | ||
"require": "./build/index.js", | ||
"import": "./build/index.mjs", | ||
"default": "./build/index.js" | ||
@@ -21,3 +23,3 @@ }, | ||
"dependencies": { | ||
"jest-get-type": "^29.6.3" | ||
"jest-get-type": "30.0.0-alpha.1" | ||
}, | ||
@@ -27,7 +29,7 @@ "devDependencies": { | ||
"immutable": "^4.0.0", | ||
"jest-matcher-utils": "^29.7.0", | ||
"tsd-lite": "^0.7.0" | ||
"jest-matcher-utils": "30.0.0-alpha.1", | ||
"tsd-lite": "^0.8.0" | ||
}, | ||
"engines": { | ||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0" | ||
"node": "^16.10.0 || ^18.12.0 || >=20.0.0" | ||
}, | ||
@@ -37,3 +39,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "4e56991693da7cd4c3730dc3579a1dd1403ee630" | ||
"gitHead": "d005cb2505c041583e0c5636d006e08666a54b63" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30297
6
732
2
1
+ Addedjest-get-type@30.0.0-alpha.1(transitive)
- Removedjest-get-type@29.6.3(transitive)
Updatedjest-get-type@30.0.0-alpha.1