@jest/expect-utils
Advanced tools
Comparing version 28.0.0-alpha.7 to 28.0.0-alpha.8
@@ -39,3 +39,3 @@ 'use strict'; | ||
customTesters = customTesters || []; | ||
return eq(a, b, [], [], customTesters, strictCheck ? hasKey : hasDefinedKey); | ||
return eq(a, b, [], [], customTesters, strictCheck); | ||
}; | ||
@@ -67,3 +67,3 @@ | ||
function eq(a, b, aStack, bStack, customTesters, hasKey) { | ||
function eq(a, b, aStack, bStack, customTesters, strictCheck) { | ||
var result = true; | ||
@@ -154,3 +154,3 @@ var asymmetricResult = asymmetricMatch(a, b); | ||
if (className == '[object Array]' && a.length !== b.length) { | ||
if (strictCheck && className == '[object Array]' && a.length !== b.length) { | ||
return false; | ||
@@ -161,5 +161,25 @@ } // Deep compare objects. | ||
key; | ||
var size = aKeys.length; // Ensure that both objects contain the same number of properties before comparing deep equality. | ||
var bKeys = keys(b, hasKey); // Add keys corresponding to asymmetric matchers if they miss in non strict check mode | ||
if (keys(b, hasKey).length !== size) { | ||
if (!strictCheck) { | ||
for (var index = 0; index !== bKeys.length; ++index) { | ||
key = bKeys[index]; | ||
if ((isAsymmetric(b[key]) || b[key] === undefined) && !hasKey(a, key)) { | ||
aKeys.push(key); | ||
} | ||
} | ||
for (var 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. | ||
var size = aKeys.length; | ||
if (bKeys.length !== size) { | ||
return false; | ||
@@ -171,5 +191,10 @@ } | ||
result = | ||
hasKey(b, key) && | ||
eq(a[key], b[key], aStack, bStack, customTesters, hasKey); | ||
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); | ||
@@ -202,6 +227,2 @@ if (!result) { | ||
function hasDefinedKey(obj, key) { | ||
return hasKey(obj, key) && obj[key] !== undefined; | ||
} | ||
function hasKey(obj, key) { | ||
@@ -208,0 +229,0 @@ return Object.prototype.hasOwnProperty.call(obj, key); |
{ | ||
"name": "@jest/expect-utils", | ||
"version": "28.0.0-alpha.7", | ||
"version": "28.0.0-alpha.8", | ||
"repository": { | ||
@@ -23,3 +23,3 @@ "type": "git", | ||
"devDependencies": { | ||
"jest-matcher-utils": "^28.0.0-alpha.7" | ||
"jest-matcher-utils": "^28.0.0-alpha.8" | ||
}, | ||
@@ -32,3 +32,3 @@ "engines": { | ||
}, | ||
"gitHead": "06f58f8ca70abc9c09d554967935b58ce85c48d6" | ||
"gitHead": "d915e7df92b220dbe6e124585ba6459838a6c41c" | ||
} |
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
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
24903
681