@jest/expect-utils 28.0.0-alpha.7 → 28.0.0
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/jasmineUtils.js +33 -12
- package/package.json +4 -4
package/build/jasmineUtils.js
CHANGED
@@ -36,7 +36,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
36
36
|
// Extracted out of jasmine 2.5.2
|
37
37
|
const equals = (a, b, customTesters, strictCheck) => {
|
38
38
|
customTesters = customTesters || [];
|
39
|
-
return eq(a, b, [], [], customTesters, strictCheck
|
39
|
+
return eq(a, b, [], [], customTesters, strictCheck);
|
40
40
|
};
|
41
41
|
|
42
42
|
exports.equals = equals;
|
@@ -63,7 +63,7 @@ function asymmetricMatch(a, b) {
|
|
63
63
|
} // Equality function lovingly adapted from isEqual in
|
64
64
|
// [Underscore](http://underscorejs.org)
|
65
65
|
|
66
|
-
function eq(a, b, aStack, bStack, customTesters,
|
66
|
+
function eq(a, b, aStack, bStack, customTesters, strictCheck) {
|
67
67
|
var result = true;
|
68
68
|
var asymmetricResult = asymmetricMatch(a, b);
|
69
69
|
|
@@ -149,24 +149,49 @@ function eq(a, b, aStack, bStack, customTesters, hasKey) {
|
|
149
149
|
bStack.push(b); // Recursively compare objects and arrays.
|
150
150
|
// Compare array lengths to determine if a deep comparison is necessary.
|
151
151
|
|
152
|
-
if (className == '[object Array]' && a.length !== b.length) {
|
152
|
+
if (strictCheck && className == '[object Array]' && a.length !== b.length) {
|
153
153
|
return false;
|
154
154
|
} // Deep compare objects.
|
155
155
|
|
156
156
|
var aKeys = keys(a, hasKey),
|
157
157
|
key;
|
158
|
-
var
|
158
|
+
var bKeys = keys(b, hasKey); // Add keys corresponding to asymmetric matchers if they miss in non strict check mode
|
159
159
|
|
160
|
-
if (
|
160
|
+
if (!strictCheck) {
|
161
|
+
for (var index = 0; index !== bKeys.length; ++index) {
|
162
|
+
key = bKeys[index];
|
163
|
+
|
164
|
+
if ((isAsymmetric(b[key]) || b[key] === undefined) && !hasKey(a, key)) {
|
165
|
+
aKeys.push(key);
|
166
|
+
}
|
167
|
+
}
|
168
|
+
|
169
|
+
for (var index = 0; index !== aKeys.length; ++index) {
|
170
|
+
key = aKeys[index];
|
171
|
+
|
172
|
+
if ((isAsymmetric(a[key]) || a[key] === undefined) && !hasKey(b, key)) {
|
173
|
+
bKeys.push(key);
|
174
|
+
}
|
175
|
+
}
|
176
|
+
} // Ensure that both objects contain the same number of properties before comparing deep equality.
|
177
|
+
|
178
|
+
var size = aKeys.length;
|
179
|
+
|
180
|
+
if (bKeys.length !== size) {
|
161
181
|
return false;
|
162
182
|
}
|
163
183
|
|
164
184
|
while (size--) {
|
165
185
|
key = aKeys[size]; // Deep compare each member
|
166
186
|
|
167
|
-
|
168
|
-
|
169
|
-
|
187
|
+
if (strictCheck)
|
188
|
+
result =
|
189
|
+
hasKey(b, key) &&
|
190
|
+
eq(a[key], b[key], aStack, bStack, customTesters, strictCheck);
|
191
|
+
else
|
192
|
+
result =
|
193
|
+
(hasKey(b, key) || isAsymmetric(a[key]) || a[key] === undefined) &&
|
194
|
+
eq(a[key], b[key], aStack, bStack, customTesters, strictCheck);
|
170
195
|
|
171
196
|
if (!result) {
|
172
197
|
return false;
|
@@ -194,10 +219,6 @@ function keys(obj, hasKey) {
|
|
194
219
|
);
|
195
220
|
}
|
196
221
|
|
197
|
-
function hasDefinedKey(obj, key) {
|
198
|
-
return hasKey(obj, key) && obj[key] !== undefined;
|
199
|
-
}
|
200
|
-
|
201
222
|
function hasKey(obj, key) {
|
202
223
|
return Object.prototype.hasOwnProperty.call(obj, key);
|
203
224
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jest/expect-utils",
|
3
|
-
"version": "28.0.0
|
3
|
+
"version": "28.0.0",
|
4
4
|
"repository": {
|
5
5
|
"type": "git",
|
6
6
|
"url": "https://github.com/facebook/jest.git",
|
@@ -17,10 +17,10 @@
|
|
17
17
|
"./package.json": "./package.json"
|
18
18
|
},
|
19
19
|
"dependencies": {
|
20
|
-
"jest-get-type": "^28.0.0
|
20
|
+
"jest-get-type": "^28.0.0"
|
21
21
|
},
|
22
22
|
"devDependencies": {
|
23
|
-
"jest-matcher-utils": "^28.0.0
|
23
|
+
"jest-matcher-utils": "^28.0.0"
|
24
24
|
},
|
25
25
|
"engines": {
|
26
26
|
"node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0"
|
@@ -28,5 +28,5 @@
|
|
28
28
|
"publishConfig": {
|
29
29
|
"access": "public"
|
30
30
|
},
|
31
|
-
"gitHead": "
|
31
|
+
"gitHead": "8f9b812faf8e4d241d560a8574f0c6ed20a89365"
|
32
32
|
}
|