Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jest/expect-utils

Package Overview
Dependencies
Maintainers
6
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jest/expect-utils - npm Package Compare versions

Comparing version 29.1.2 to 29.2.0

build/immutableUtils.js

2

build/index.d.ts

@@ -49,3 +49,3 @@ /**

export declare function isA(typeName: string, value: unknown): boolean;
export declare function isA<T>(typeName: string, value: unknown): value is T;

@@ -52,0 +52,0 @@ export declare const isError: (value: unknown) => value is Error;

@@ -22,7 +22,4 @@ 'use strict';

});
var _jasmineUtils = require('./jasmineUtils');
var _utils = require('./utils');
Object.keys(_utils).forEach(function (key) {

@@ -29,0 +26,0 @@ if (key === 'default' || key === '__esModule') return;

@@ -8,9 +8,2 @@ 'use strict';

exports.isA = isA;
exports.isImmutableList = isImmutableList;
exports.isImmutableOrderedKeyed = isImmutableOrderedKeyed;
exports.isImmutableOrderedSet = isImmutableOrderedSet;
exports.isImmutableRecord = isImmutableRecord;
exports.isImmutableUnorderedKeyed = isImmutableUnorderedKeyed;
exports.isImmutableUnorderedSet = isImmutableUnorderedSet;
/*

@@ -40,3 +33,2 @@ Copyright (c) 2008-2016 Pivotal Labs

/* eslint-disable */
// Extracted out of jasmine 2.5.2

@@ -47,38 +39,30 @@ const equals = (a, b, customTesters, strictCheck) => {

};
exports.equals = equals;
function isAsymmetric(obj) {
return !!obj && isA('Function', obj.asymmetricMatch);
}
function asymmetricMatch(a, b) {
var asymmetricA = isAsymmetric(a),
asymmetricB = isAsymmetric(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
}
// Equality function lovingly adapted from isEqual in
// [Underscore](http://underscorejs.org)
function eq(a, b, aStack, bStack, customTesters, strictCheck) {
var result = true;
var asymmetricResult = asymmetricMatch(a, b);
let result = true;
const asymmetricResult = asymmetricMatch(a, b);
if (asymmetricResult !== undefined) {
return asymmetricResult;
}
for (var i = 0; i < customTesters.length; i++) {
var customTesterResult = customTesters[i](a, b);
for (let i = 0; i < customTesters.length; i++) {
const customTesterResult = customTesters[i](a, b);
if (customTesterResult !== undefined) {

@@ -88,21 +72,16 @@ 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`.
}
// A strict comparison is necessary because `null == undefined`.
if (a === null || b === null) {
return a === b;
}
var className = Object.prototype.toString.call(a);
const className = Object.prototype.toString.call(a);
if (className != Object.prototype.toString.call(b)) {
return false;
}
switch (className) {

@@ -122,3 +101,2 @@ case '[object Boolean]':

}
case '[object Date]':

@@ -130,17 +108,16 @@ // Coerce dates to numeric primitive values. Dates are compared by their

// 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)
}
// Use DOM3 method isEqualNode (IE>=9)
if (isDomNode(a) && isDomNode(b)) {
return a.isEqualNode(b);
} // Used to detect circular references.
}
var length = aStack.length;
// Used to detect circular references.
let length = aStack.length;
while (length--) {

@@ -156,20 +133,20 @@ // Linear search. Performance is inversely proportional to the number of

}
} // Add the first object to the stack of traversed objects.
}
// Add the first object to the stack of traversed objects.
aStack.push(a);
bStack.push(b); // Recursively compare objects and arrays.
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.
}
var aKeys = keys(a, hasKey),
key;
var bKeys = keys(b, hasKey); // Add keys corresponding to asymmetric matchers if they miss in non strict check mode
// 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 (var index = 0; index !== bKeys.length; ++index) {
for (let index = 0; index !== bKeys.length; ++index) {
key = bKeys[index];
if ((isAsymmetric(b[key]) || b[key] === undefined) && !hasKey(a, key)) {

@@ -179,6 +156,4 @@ aKeys.push(key);

}
for (var index = 0; index !== aKeys.length; ++index) {
for (let index = 0; index !== aKeys.length; ++index) {
key = aKeys[index];
if ((isAsymmetric(a[key]) || a[key] === undefined) && !hasKey(b, key)) {

@@ -188,13 +163,13 @@ bKeys.push(key);

}
} // Ensure that both objects contain the same number of properties before comparing deep equality.
}
var size = aKeys.length;
// 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
key = aKeys[size];
// Deep compare each member
if (strictCheck)

@@ -208,8 +183,7 @@ result =

eq(a[key], b[key], aStack, bStack, customTesters, strictCheck);
if (!result) {
return false;
}
} // Remove the first object from the stack of traversed objects.
}
// Remove the first object from the stack of traversed objects.
aStack.pop();

@@ -219,7 +193,5 @@ bStack.pop();

}
function keys(obj, hasKey) {
var keys = [];
for (var key in obj) {
const keys = [];
for (const key in obj) {
if (hasKey(obj, key)) {

@@ -229,3 +201,2 @@ keys.push(key);

}
return keys.concat(

@@ -237,11 +208,8 @@ Object.getOwnPropertySymbols(obj).filter(

}
function hasKey(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key);
}
function isA(typeName, value) {
return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
return Object.prototype.toString.apply(value) === `[object ${typeName}]`;
}
function isDomNode(obj) {

@@ -255,48 +223,2 @@ return (

);
} // 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 isImmutableUnorderedKeyed(maybeKeyed) {
return !!(
maybeKeyed &&
maybeKeyed[IS_KEYED_SENTINEL] &&
!maybeKeyed[IS_ORDERED_SENTINEL]
);
}
function isImmutableUnorderedSet(maybeSet) {
return !!(
maybeSet &&
maybeSet[IS_SET_SENTINEL] &&
!maybeSet[IS_ORDERED_SENTINEL]
);
}
function isImmutableList(maybeList) {
return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
}
function isImmutableOrderedKeyed(maybeKeyed) {
return !!(
maybeKeyed &&
maybeKeyed[IS_KEYED_SENTINEL] &&
maybeKeyed[IS_ORDERED_SENTINEL]
);
}
function isImmutableOrderedSet(maybeSet) {
return !!(
maybeSet &&
maybeSet[IS_SET_SENTINEL] &&
maybeSet[IS_ORDERED_SENTINEL]
);
}
function isImmutableRecord(maybeSet) {
return !!(maybeSet && maybeSet[IS_RECORD_SYMBOL]);
}

@@ -19,9 +19,6 @@ 'use strict';

void 0;
var _jestGetType = require('jest-get-type');
var _immutableUtils = require('./immutableUtils');
var _jasmineUtils = require('./jasmineUtils');
var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol;
/**

@@ -33,7 +30,5 @@ * Checks if `hasOwnProperty(object, key)` up the prototype chain, stopping at `Object.prototype`.

!object || typeof object !== 'object' || object === Object.prototype;
if (shouldTerminate) {
return false;
}
return (

@@ -44,3 +39,2 @@ Object.prototype.hasOwnProperty.call(object, key) ||

};
const getPath = (object, propertyPath) => {

@@ -50,3 +44,2 @@ if (!Array.isArray(propertyPath)) {

}
if (propertyPath.length) {

@@ -56,3 +49,2 @@ const lastProp = propertyPath.length === 1;

const newObject = object[prop];
if (!lastProp && (newObject === null || newObject === undefined)) {

@@ -68,11 +60,7 @@ // This is not the last prop in the chain. If we keep recursing it will

}
const result = getPath(newObject, propertyPath.slice(1));
if (result.lastTraversedObject === null) {
result.lastTraversedObject = object;
}
result.traversedPath.unshift(prop);
if (lastProp) {

@@ -85,3 +73,2 @@ // Does object have the property with an undefined value?

result.hasEndProp = newObject !== undefined || result.endPropIsDefined;
if (!result.hasEndProp) {

@@ -91,6 +78,4 @@ result.traversedPath.shift();

}
return result;
}
return {

@@ -101,9 +86,8 @@ lastTraversedObject: null,

};
}; // Strip properties from object that are not present in the subset. Useful for
};
// 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, seenReferences = new WeakMap()) => {

@@ -128,3 +112,2 @@ /* eslint-enable @typescript-eslint/explicit-module-boundary-types */

}
const trimmed = {};

@@ -139,3 +122,2 @@ seenReferences.set(object, trimmed);

});
if (Object.keys(trimmed).length > 0) {

@@ -145,16 +127,12 @@ return trimmed;

}
return object;
};
exports.getObjectSubset = getObjectSubset;
const IteratorSymbol = Symbol.iterator;
const hasIterator = object => !!(object != null && object[IteratorSymbol]);
const hasIterator = object => !!(object != null && object[IteratorSymbol]);
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
const iterableEquality = (
a,
b,
/* eslint-enable @typescript-eslint/explicit-module-boundary-types */
b /* eslint-enable @typescript-eslint/explicit-module-boundary-types */,
aStack = [],

@@ -173,9 +151,6 @@ bStack = []

}
if (a.constructor !== b.constructor) {
return false;
}
let length = aStack.length;
while (length--) {

@@ -190,9 +165,6 @@ // Linear search. Performance is inversely proportional to the number of

}
aStack.push(a);
bStack.push(b);
const iterableEqualityWithStack = (a, b) =>
iterableEquality(a, b, [...aStack], [...bStack]);
if (a.size !== undefined) {

@@ -203,10 +175,8 @@ if (a.size !== b.size) {

(0, _jasmineUtils.isA)('Set', a) ||
(0, _jasmineUtils.isImmutableUnorderedSet)(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) {

@@ -216,3 +186,2 @@ const isEqual = (0, _jasmineUtils.equals)(aValue, bValue, [

]);
if (isEqual === true) {

@@ -222,3 +191,2 @@ has = true;

}
if (has === false) {

@@ -229,4 +197,4 @@ allFound = false;

}
} // Remove the first value from the stack of traversed values.
}
// Remove the first value from the stack of traversed values.
aStack.pop();

@@ -237,6 +205,5 @@ bStack.pop();

(0, _jasmineUtils.isA)('Map', a) ||
(0, _jasmineUtils.isImmutableUnorderedKeyed)(a)
(0, _immutableUtils.isImmutableUnorderedKeyed)(a)
) {
let allFound = true;
for (const aEntry of a) {

@@ -250,3 +217,2 @@ if (

let has = false;
for (const bEntry of b) {

@@ -257,3 +223,2 @@ const matchedKey = (0, _jasmineUtils.equals)(aEntry[0], bEntry[0], [

let matchedValue = false;
if (matchedKey === true) {

@@ -264,3 +229,2 @@ matchedValue = (0, _jasmineUtils.equals)(aEntry[1], bEntry[1], [

}
if (matchedValue === true) {

@@ -270,3 +234,2 @@ has = true;

}
if (has === false) {

@@ -277,4 +240,4 @@ allFound = false;

}
} // Remove the first value from the stack of traversed values.
}
// Remove the first value from the stack of traversed values.
aStack.pop();

@@ -285,8 +248,5 @@ bStack.pop();

}
const bIterator = b[IteratorSymbol]();
for (const aValue of a) {
const nextB = bIterator.next();
if (

@@ -301,21 +261,19 @@ nextB.done ||

}
if (!bIterator.next().done) {
return false;
}
if (
!(0, _jasmineUtils.isImmutableList)(a) &&
!(0, _jasmineUtils.isImmutableOrderedKeyed)(a) &&
!(0, _jasmineUtils.isImmutableOrderedSet)(a) &&
!(0, _jasmineUtils.isImmutableRecord)(a)
!(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.
}
// Remove the first value from the stack of traversed values.
aStack.pop();

@@ -325,7 +283,4 @@ bStack.pop();

};
exports.iterableEquality = iterableEquality;
const isObject = a => a !== null && typeof a === 'object';
const isObjectWithKeys = a =>

@@ -336,3 +291,2 @@ isObject(a) &&

!(a instanceof Date);
const subsetEquality = (object, subset) => {

@@ -348,3 +302,2 @@ // subsetEquality needs to keep track of the references

}
return Object.keys(subset).every(key => {

@@ -357,6 +310,4 @@ if (isObjectWithKeys(subset[key])) {

}
seenReferences.set(subset[key], true);
}
const result =

@@ -368,3 +319,4 @@ object != null &&

subsetEqualityWithContext(seenReferences)
]); // The main goal of using seenReference is to avoid circular node on tree.
]);
// 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)

@@ -374,3 +326,2 @@ // We should keep the reference for a parent and its child only

// other nodes within the same level on tree.
seenReferences.delete(subset[key]);

@@ -380,8 +331,7 @@ return result;

};
return subsetEqualityWithContext()(object, subset);
}; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
};
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
exports.subsetEquality = subsetEquality;
const typeEquality = (a, b) => {

@@ -391,8 +341,5 @@ if (a == null || b == null || a.constructor === b.constructor) {

}
return false;
};
exports.typeEquality = typeEquality;
const arrayBufferEquality = (a, b) => {

@@ -402,10 +349,11 @@ if (!(a instanceof ArrayBuffer) || !(b instanceof ArrayBuffer)) {

}
const dataViewA = new DataView(a);
const dataViewB = new DataView(b); // Buffers are not equal when they do not have the same byte length
const dataViewB = new DataView(b);
// 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
}
// Check if every byte value is equal to each other
for (let i = 0; i < dataViewA.byteLength; i++) {

@@ -416,13 +364,11 @@ if (dataViewA.getUint8(i) !== dataViewB.getUint8(i)) {

}
return true;
};
exports.arrayBufferEquality = arrayBufferEquality;
const sparseArrayEquality = (a, b) => {
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"]
}
// A sparse array [, , 1] will have keys ["2"] whereas [undefined, undefined, 1] will have keys ["0", "1", "2"]
const aKeys = Object.keys(a);

@@ -435,5 +381,3 @@ const bKeys = Object.keys(b);

};
exports.sparseArrayEquality = sparseArrayEquality;
const partition = (items, predicate) => {

@@ -444,19 +388,17 @@ const 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.
// 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 => {

@@ -467,6 +409,6 @@ properties.push(match);

return properties;
}; // Copied from https://github.com/graingert/angular.js/blob/a43574052e9775cbc1d7dd8a086752c979b0f020/src/Angular.js#L685-L693
};
// Copied from https://github.com/graingert/angular.js/blob/a43574052e9775cbc1d7dd8a086752c979b0f020/src/Angular.js#L685-L693
exports.pathAsArray = pathAsArray;
const isError = value => {

@@ -478,3 +420,2 @@ switch (Object.prototype.toString.call(value)) {

return true;
default:

@@ -484,11 +425,7 @@ return value instanceof Error;

};
exports.isError = isError;
function emptyObject(obj) {
return obj && typeof obj === 'object' ? !Object.keys(obj).length : false;
}
const MULTILINE_REGEXP = /[\r\n]/;
const isOneline = (expected, received) =>

@@ -498,3 +435,2 @@ typeof expected === 'string' &&

(!MULTILINE_REGEXP.test(expected) || !MULTILINE_REGEXP.test(received));
exports.isOneline = isOneline;
{
"name": "@jest/expect-utils",
"version": "29.1.2",
"version": "29.2.0",
"repository": {

@@ -20,7 +20,9 @@ "type": "git",

"dependencies": {
"jest-get-type": "^29.0.0"
"jest-get-type": "^29.2.0"
},
"devDependencies": {
"@tsd/typescript": "~4.8.2",
"immutable": "^4.0.0",
"jest-matcher-utils": "^29.1.2"
"jest-matcher-utils": "^29.2.0",
"tsd-lite": "^0.6.0"
},

@@ -33,3 +35,3 @@ "engines": {

},
"gitHead": "3c31dd619e8c022cde53f40fa12ea2a67f4752ce"
"gitHead": "ee5b37a4f4433afcfffb0356cea47739d8092287"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc