Updating NPM dependencies
This commit is contained in:
292
node_modules/expect/build/utils.js
generated
vendored
292
node_modules/expect/build/utils.js
generated
vendored
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.emptyObject = emptyObject;
|
||||
exports.isOneline = exports.isError = exports.partition = exports.sparseArrayEquality = exports.typeEquality = exports.subsetEquality = exports.iterableEquality = exports.getObjectSubset = exports.getPath = exports.hasOwnProperty = void 0;
|
||||
exports.isOneline = exports.isError = exports.partition = exports.sparseArrayEquality = exports.typeEquality = exports.subsetEquality = exports.iterableEquality = exports.getObjectSubset = exports.getPath = void 0;
|
||||
|
||||
var _jestGetType = require('jest-get-type');
|
||||
|
||||
@@ -12,37 +12,23 @@ var _jasmineUtils = require('./jasmineUtils');
|
||||
|
||||
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
|
||||
|
||||
// Return whether object instance inherits getter from its class.
|
||||
const hasGetterFromConstructor = (object, key) => {
|
||||
const constructor = object.constructor;
|
||||
/**
|
||||
* 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 (constructor === Object) {
|
||||
// A literal object has Object as constructor.
|
||||
// Therefore, it cannot inherit application-specific getters.
|
||||
// Furthermore, Object has __proto__ getter which is not relevant.
|
||||
// Array, Boolean, Number, String constructors don’t have any getters.
|
||||
if (shouldTerminate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof constructor !== 'function') {
|
||||
// Object.create(null) constructs object with no constructor nor prototype.
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create#Custom_and_Null_objects
|
||||
return false;
|
||||
}
|
||||
|
||||
const descriptor = Object.getOwnPropertyDescriptor(
|
||||
constructor.prototype,
|
||||
key
|
||||
return (
|
||||
Object.prototype.hasOwnProperty.call(object, key) ||
|
||||
hasPropertyInObject(Object.getPrototypeOf(object), key)
|
||||
);
|
||||
return descriptor !== undefined && typeof descriptor.get === 'function';
|
||||
};
|
||||
|
||||
const hasOwnProperty = (object, key) =>
|
||||
Object.prototype.hasOwnProperty.call(object, key) ||
|
||||
hasGetterFromConstructor(object, key);
|
||||
|
||||
exports.hasOwnProperty = hasOwnProperty;
|
||||
|
||||
const getPath = (object, propertyPath) => {
|
||||
if (!Array.isArray(propertyPath)) {
|
||||
propertyPath = propertyPath.split('.');
|
||||
@@ -96,20 +82,34 @@ const getPath = (object, propertyPath) => {
|
||||
}; // 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()) => {
|
||||
/* 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));
|
||||
}
|
||||
} else if (object instanceof Date) {
|
||||
return object;
|
||||
} else if (isObject(object) && isObject(subset)) {
|
||||
if (
|
||||
(0, _jasmineUtils.equals)(object, subset, [
|
||||
iterableEquality,
|
||||
subsetEquality
|
||||
])
|
||||
) {
|
||||
// Avoid unnecessary copy which might return Object instead of subclass.
|
||||
return subset;
|
||||
}
|
||||
|
||||
const trimmed = {};
|
||||
seenReferences.set(object, trimmed);
|
||||
Object.keys(object)
|
||||
.filter(key => hasOwnProperty(subset, key))
|
||||
.filter(key => hasPropertyInObject(subset, key))
|
||||
.forEach(key => {
|
||||
trimmed[key] = seenReferences.has(object[key])
|
||||
? seenReferences.get(object[key])
|
||||
@@ -128,8 +128,15 @@ 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, aStack = [], bStack = []) => {
|
||||
const iterableEquality = (
|
||||
a,
|
||||
b,
|
||||
/* eslint-enable @typescript-eslint/explicit-module-boundary-types */
|
||||
aStack = [],
|
||||
bStack = []
|
||||
) => {
|
||||
if (
|
||||
typeof a !== 'object' ||
|
||||
typeof b !== 'object' ||
|
||||
@@ -171,75 +178,27 @@ const iterableEquality = (a, b, aStack = [], bStack = []) => {
|
||||
(0, _jasmineUtils.isImmutableUnorderedSet)(a)
|
||||
) {
|
||||
let allFound = true;
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator = a[Symbol.iterator](), _step;
|
||||
!(_iteratorNormalCompletion = (_step = _iterator.next()).done);
|
||||
_iteratorNormalCompletion = true
|
||||
) {
|
||||
const aValue = _step.value;
|
||||
for (const aValue of a) {
|
||||
if (!b.has(aValue)) {
|
||||
let has = false;
|
||||
|
||||
if (!b.has(aValue)) {
|
||||
let has = false;
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
for (const bValue of b) {
|
||||
const isEqual = (0, _jasmineUtils.equals)(aValue, bValue, [
|
||||
iterableEqualityWithStack
|
||||
]);
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator2 = b[Symbol.iterator](), _step2;
|
||||
!(_iteratorNormalCompletion2 = (_step2 = _iterator2.next())
|
||||
.done);
|
||||
_iteratorNormalCompletion2 = true
|
||||
) {
|
||||
const bValue = _step2.value;
|
||||
const isEqual = (0, _jasmineUtils.equals)(aValue, bValue, [
|
||||
iterableEqualityWithStack
|
||||
]);
|
||||
|
||||
if (isEqual === true) {
|
||||
has = true;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (has === false) {
|
||||
allFound = false;
|
||||
break;
|
||||
if (isEqual === true) {
|
||||
has = true;
|
||||
}
|
||||
}
|
||||
} // Remove the first value from the stack of traversed values.
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
|
||||
if (has === false) {
|
||||
allFound = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // Remove the first value from the stack of traversed values.
|
||||
|
||||
aStack.pop();
|
||||
bStack.pop();
|
||||
@@ -249,91 +208,39 @@ const iterableEquality = (a, b, aStack = [], bStack = []) => {
|
||||
(0, _jasmineUtils.isImmutableUnorderedKeyed)(a)
|
||||
) {
|
||||
let allFound = true;
|
||||
var _iteratorNormalCompletion3 = true;
|
||||
var _didIteratorError3 = false;
|
||||
var _iteratorError3 = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator3 = a[Symbol.iterator](), _step3;
|
||||
!(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done);
|
||||
_iteratorNormalCompletion3 = true
|
||||
for (const aEntry of a) {
|
||||
if (
|
||||
!b.has(aEntry[0]) ||
|
||||
!(0, _jasmineUtils.equals)(aEntry[1], b.get(aEntry[0]), [
|
||||
iterableEqualityWithStack
|
||||
])
|
||||
) {
|
||||
const aEntry = _step3.value;
|
||||
let has = false;
|
||||
|
||||
if (
|
||||
!b.has(aEntry[0]) ||
|
||||
!(0, _jasmineUtils.equals)(aEntry[1], b.get(aEntry[0]), [
|
||||
for (const bEntry of b) {
|
||||
const matchedKey = (0, _jasmineUtils.equals)(aEntry[0], bEntry[0], [
|
||||
iterableEqualityWithStack
|
||||
])
|
||||
) {
|
||||
let has = false;
|
||||
var _iteratorNormalCompletion4 = true;
|
||||
var _didIteratorError4 = false;
|
||||
var _iteratorError4 = undefined;
|
||||
]);
|
||||
let matchedValue = false;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator4 = b[Symbol.iterator](), _step4;
|
||||
!(_iteratorNormalCompletion4 = (_step4 = _iterator4.next())
|
||||
.done);
|
||||
_iteratorNormalCompletion4 = true
|
||||
) {
|
||||
const bEntry = _step4.value;
|
||||
const matchedKey = (0, _jasmineUtils.equals)(
|
||||
aEntry[0],
|
||||
bEntry[0],
|
||||
[iterableEqualityWithStack]
|
||||
);
|
||||
let matchedValue = false;
|
||||
|
||||
if (matchedKey === true) {
|
||||
matchedValue = (0, _jasmineUtils.equals)(
|
||||
aEntry[1],
|
||||
bEntry[1],
|
||||
[iterableEqualityWithStack]
|
||||
);
|
||||
}
|
||||
|
||||
if (matchedValue === true) {
|
||||
has = true;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError4 = true;
|
||||
_iteratorError4 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
|
||||
_iterator4.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError4) {
|
||||
throw _iteratorError4;
|
||||
}
|
||||
}
|
||||
if (matchedKey === true) {
|
||||
matchedValue = (0, _jasmineUtils.equals)(aEntry[1], bEntry[1], [
|
||||
iterableEqualityWithStack
|
||||
]);
|
||||
}
|
||||
|
||||
if (has === false) {
|
||||
allFound = false;
|
||||
break;
|
||||
if (matchedValue === true) {
|
||||
has = true;
|
||||
}
|
||||
}
|
||||
} // Remove the first value from the stack of traversed values.
|
||||
} catch (err) {
|
||||
_didIteratorError3 = true;
|
||||
_iteratorError3 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
||||
_iterator3.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError3) {
|
||||
throw _iteratorError3;
|
||||
|
||||
if (has === false) {
|
||||
allFound = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // Remove the first value from the stack of traversed values.
|
||||
|
||||
aStack.pop();
|
||||
bStack.pop();
|
||||
@@ -342,40 +249,17 @@ const iterableEquality = (a, b, aStack = [], bStack = []) => {
|
||||
}
|
||||
|
||||
const bIterator = b[IteratorSymbol]();
|
||||
var _iteratorNormalCompletion5 = true;
|
||||
var _didIteratorError5 = false;
|
||||
var _iteratorError5 = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator5 = a[Symbol.iterator](), _step5;
|
||||
!(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done);
|
||||
_iteratorNormalCompletion5 = true
|
||||
for (const aValue of a) {
|
||||
const nextB = bIterator.next();
|
||||
|
||||
if (
|
||||
nextB.done ||
|
||||
!(0, _jasmineUtils.equals)(aValue, nextB.value, [
|
||||
iterableEqualityWithStack
|
||||
])
|
||||
) {
|
||||
const aValue = _step5.value;
|
||||
const nextB = bIterator.next();
|
||||
|
||||
if (
|
||||
nextB.done ||
|
||||
!(0, _jasmineUtils.equals)(aValue, nextB.value, [
|
||||
iterableEqualityWithStack
|
||||
])
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError5 = true;
|
||||
_iteratorError5 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
|
||||
_iterator5.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError5) {
|
||||
throw _iteratorError5;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,7 +296,7 @@ const subsetEquality = (object, subset) => {
|
||||
|
||||
return Object.keys(subset).every(key => {
|
||||
if (isObjectWithKeys(subset[key])) {
|
||||
if (seenReferences.get(subset[key])) {
|
||||
if (seenReferences.has(subset[key])) {
|
||||
return (0, _jasmineUtils.equals)(object[key], subset[key], [
|
||||
iterableEquality
|
||||
]);
|
||||
@@ -421,19 +305,25 @@ const subsetEquality = (object, subset) => {
|
||||
seenReferences.set(subset[key], true);
|
||||
}
|
||||
|
||||
return (
|
||||
const result =
|
||||
object != null &&
|
||||
hasOwnProperty(object, key) &&
|
||||
hasPropertyInObject(object, key) &&
|
||||
(0, _jasmineUtils.equals)(object[key], subset[key], [
|
||||
iterableEquality,
|
||||
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user