@jest/expect-utils 29.7.0 → 30.0.0-alpha.1
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/index.js +664 -10
- package/build/index.mjs +17 -0
- package/package.json +8 -6
- package/build/immutableUtils.js +0 -66
- package/build/jasmineUtils.js +0 -218
- package/build/types.js +0 -1
- package/build/utils.js +0 -462
package/build/index.mjs
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
import cjsModule from './index.js';
|
2
|
+
|
3
|
+
export const equals = cjsModule.equals;
|
4
|
+
export const isA = cjsModule.isA;
|
5
|
+
export const arrayBufferEquality = cjsModule.arrayBufferEquality;
|
6
|
+
export const emptyObject = cjsModule.emptyObject;
|
7
|
+
export const getObjectKeys = cjsModule.getObjectKeys;
|
8
|
+
export const getObjectSubset = cjsModule.getObjectSubset;
|
9
|
+
export const getPath = cjsModule.getPath;
|
10
|
+
export const isError = cjsModule.isError;
|
11
|
+
export const isOneline = cjsModule.isOneline;
|
12
|
+
export const iterableEquality = cjsModule.iterableEquality;
|
13
|
+
export const partition = cjsModule.partition;
|
14
|
+
export const pathAsArray = cjsModule.pathAsArray;
|
15
|
+
export const sparseArrayEquality = cjsModule.sparseArrayEquality;
|
16
|
+
export const subsetEquality = cjsModule.subsetEquality;
|
17
|
+
export const typeEquality = cjsModule.typeEquality;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jest/expect-utils",
|
3
|
-
"version": "
|
3
|
+
"version": "30.0.0-alpha.1",
|
4
4
|
"repository": {
|
5
5
|
"type": "git",
|
6
6
|
"url": "https://github.com/jestjs/jest.git",
|
@@ -12,24 +12,26 @@
|
|
12
12
|
"exports": {
|
13
13
|
".": {
|
14
14
|
"types": "./build/index.d.ts",
|
15
|
+
"require": "./build/index.js",
|
16
|
+
"import": "./build/index.mjs",
|
15
17
|
"default": "./build/index.js"
|
16
18
|
},
|
17
19
|
"./package.json": "./package.json"
|
18
20
|
},
|
19
21
|
"dependencies": {
|
20
|
-
"jest-get-type": "
|
22
|
+
"jest-get-type": "30.0.0-alpha.1"
|
21
23
|
},
|
22
24
|
"devDependencies": {
|
23
25
|
"@tsd/typescript": "^5.0.4",
|
24
26
|
"immutable": "^4.0.0",
|
25
|
-
"jest-matcher-utils": "
|
26
|
-
"tsd-lite": "^0.
|
27
|
+
"jest-matcher-utils": "30.0.0-alpha.1",
|
28
|
+
"tsd-lite": "^0.8.0"
|
27
29
|
},
|
28
30
|
"engines": {
|
29
|
-
"node": "^
|
31
|
+
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
|
30
32
|
},
|
31
33
|
"publishConfig": {
|
32
34
|
"access": "public"
|
33
35
|
},
|
34
|
-
"gitHead": "
|
36
|
+
"gitHead": "d005cb2505c041583e0c5636d006e08666a54b63"
|
35
37
|
}
|
package/build/immutableUtils.js
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.isImmutableList = isImmutableList;
|
7
|
-
exports.isImmutableOrderedKeyed = isImmutableOrderedKeyed;
|
8
|
-
exports.isImmutableOrderedSet = isImmutableOrderedSet;
|
9
|
-
exports.isImmutableRecord = isImmutableRecord;
|
10
|
-
exports.isImmutableUnorderedKeyed = isImmutableUnorderedKeyed;
|
11
|
-
exports.isImmutableUnorderedSet = isImmutableUnorderedSet;
|
12
|
-
/**
|
13
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
14
|
-
*
|
15
|
-
* This source code is licensed under the MIT license found in the
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
17
|
-
*
|
18
|
-
*/
|
19
|
-
|
20
|
-
// SENTINEL constants are from https://github.com/immutable-js/immutable-js/tree/main/src/predicates
|
21
|
-
const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
|
22
|
-
const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
|
23
|
-
const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
|
24
|
-
const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
|
25
|
-
const IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@';
|
26
|
-
function isObjectLiteral(source) {
|
27
|
-
return source != null && typeof source === 'object' && !Array.isArray(source);
|
28
|
-
}
|
29
|
-
function isImmutableUnorderedKeyed(source) {
|
30
|
-
return Boolean(
|
31
|
-
source &&
|
32
|
-
isObjectLiteral(source) &&
|
33
|
-
source[IS_KEYED_SENTINEL] &&
|
34
|
-
!source[IS_ORDERED_SENTINEL]
|
35
|
-
);
|
36
|
-
}
|
37
|
-
function isImmutableUnorderedSet(source) {
|
38
|
-
return Boolean(
|
39
|
-
source &&
|
40
|
-
isObjectLiteral(source) &&
|
41
|
-
source[IS_SET_SENTINEL] &&
|
42
|
-
!source[IS_ORDERED_SENTINEL]
|
43
|
-
);
|
44
|
-
}
|
45
|
-
function isImmutableList(source) {
|
46
|
-
return Boolean(source && isObjectLiteral(source) && source[IS_LIST_SENTINEL]);
|
47
|
-
}
|
48
|
-
function isImmutableOrderedKeyed(source) {
|
49
|
-
return Boolean(
|
50
|
-
source &&
|
51
|
-
isObjectLiteral(source) &&
|
52
|
-
source[IS_KEYED_SENTINEL] &&
|
53
|
-
source[IS_ORDERED_SENTINEL]
|
54
|
-
);
|
55
|
-
}
|
56
|
-
function isImmutableOrderedSet(source) {
|
57
|
-
return Boolean(
|
58
|
-
source &&
|
59
|
-
isObjectLiteral(source) &&
|
60
|
-
source[IS_SET_SENTINEL] &&
|
61
|
-
source[IS_ORDERED_SENTINEL]
|
62
|
-
);
|
63
|
-
}
|
64
|
-
function isImmutableRecord(source) {
|
65
|
-
return Boolean(source && isObjectLiteral(source) && source[IS_RECORD_SYMBOL]);
|
66
|
-
}
|
package/build/jasmineUtils.js
DELETED
@@ -1,218 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.equals = void 0;
|
7
|
-
exports.isA = isA;
|
8
|
-
/*
|
9
|
-
Copyright (c) 2008-2016 Pivotal Labs
|
10
|
-
|
11
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
12
|
-
a copy of this software and associated documentation files (the
|
13
|
-
"Software"), to deal in the Software without restriction, including
|
14
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
15
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
16
|
-
permit persons to whom the Software is furnished to do so, subject to
|
17
|
-
the following conditions:
|
18
|
-
|
19
|
-
The above copyright notice and this permission notice shall be
|
20
|
-
included in all copies or substantial portions of the Software.
|
21
|
-
|
22
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
23
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
24
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
25
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
26
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
27
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
28
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
29
|
-
|
30
|
-
*/
|
31
|
-
|
32
|
-
// Extracted out of jasmine 2.5.2
|
33
|
-
const equals = (a, b, customTesters, strictCheck) => {
|
34
|
-
customTesters = customTesters || [];
|
35
|
-
return eq(a, b, [], [], customTesters, strictCheck);
|
36
|
-
};
|
37
|
-
exports.equals = equals;
|
38
|
-
function isAsymmetric(obj) {
|
39
|
-
return !!obj && isA('Function', obj.asymmetricMatch);
|
40
|
-
}
|
41
|
-
function asymmetricMatch(a, b) {
|
42
|
-
const asymmetricA = isAsymmetric(a);
|
43
|
-
const asymmetricB = isAsymmetric(b);
|
44
|
-
if (asymmetricA && asymmetricB) {
|
45
|
-
return undefined;
|
46
|
-
}
|
47
|
-
if (asymmetricA) {
|
48
|
-
return a.asymmetricMatch(b);
|
49
|
-
}
|
50
|
-
if (asymmetricB) {
|
51
|
-
return b.asymmetricMatch(a);
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
// Equality function lovingly adapted from isEqual in
|
56
|
-
// [Underscore](http://underscorejs.org)
|
57
|
-
function eq(a, b, aStack, bStack, customTesters, strictCheck) {
|
58
|
-
let result = true;
|
59
|
-
const asymmetricResult = asymmetricMatch(a, b);
|
60
|
-
if (asymmetricResult !== undefined) {
|
61
|
-
return asymmetricResult;
|
62
|
-
}
|
63
|
-
const testerContext = {
|
64
|
-
equals
|
65
|
-
};
|
66
|
-
for (let i = 0; i < customTesters.length; i++) {
|
67
|
-
const customTesterResult = customTesters[i].call(
|
68
|
-
testerContext,
|
69
|
-
a,
|
70
|
-
b,
|
71
|
-
customTesters
|
72
|
-
);
|
73
|
-
if (customTesterResult !== undefined) {
|
74
|
-
return customTesterResult;
|
75
|
-
}
|
76
|
-
}
|
77
|
-
if (a instanceof Error && b instanceof Error) {
|
78
|
-
return a.message == b.message;
|
79
|
-
}
|
80
|
-
if (Object.is(a, b)) {
|
81
|
-
return true;
|
82
|
-
}
|
83
|
-
// A strict comparison is necessary because `null == undefined`.
|
84
|
-
if (a === null || b === null) {
|
85
|
-
return a === b;
|
86
|
-
}
|
87
|
-
const className = Object.prototype.toString.call(a);
|
88
|
-
if (className != Object.prototype.toString.call(b)) {
|
89
|
-
return false;
|
90
|
-
}
|
91
|
-
switch (className) {
|
92
|
-
case '[object Boolean]':
|
93
|
-
case '[object String]':
|
94
|
-
case '[object Number]':
|
95
|
-
if (typeof a !== typeof b) {
|
96
|
-
// One is a primitive, one a `new Primitive()`
|
97
|
-
return false;
|
98
|
-
} else if (typeof a !== 'object' && typeof b !== 'object') {
|
99
|
-
// both are proper primitives
|
100
|
-
return Object.is(a, b);
|
101
|
-
} else {
|
102
|
-
// both are `new Primitive()`s
|
103
|
-
return Object.is(a.valueOf(), b.valueOf());
|
104
|
-
}
|
105
|
-
case '[object Date]':
|
106
|
-
// Coerce dates to numeric primitive values. Dates are compared by their
|
107
|
-
// millisecond representations. Note that invalid dates with millisecond representations
|
108
|
-
// of `NaN` are not equivalent.
|
109
|
-
return +a == +b;
|
110
|
-
// RegExps are compared by their source patterns and flags.
|
111
|
-
case '[object RegExp]':
|
112
|
-
return a.source === b.source && a.flags === b.flags;
|
113
|
-
}
|
114
|
-
if (typeof a !== 'object' || typeof b !== 'object') {
|
115
|
-
return false;
|
116
|
-
}
|
117
|
-
|
118
|
-
// Use DOM3 method isEqualNode (IE>=9)
|
119
|
-
if (isDomNode(a) && isDomNode(b)) {
|
120
|
-
return a.isEqualNode(b);
|
121
|
-
}
|
122
|
-
|
123
|
-
// Used to detect circular references.
|
124
|
-
let length = aStack.length;
|
125
|
-
while (length--) {
|
126
|
-
// Linear search. Performance is inversely proportional to the number of
|
127
|
-
// unique nested structures.
|
128
|
-
// circular references at same depth are equal
|
129
|
-
// circular reference is not equal to non-circular one
|
130
|
-
if (aStack[length] === a) {
|
131
|
-
return bStack[length] === b;
|
132
|
-
} else if (bStack[length] === b) {
|
133
|
-
return false;
|
134
|
-
}
|
135
|
-
}
|
136
|
-
// Add the first object to the stack of traversed objects.
|
137
|
-
aStack.push(a);
|
138
|
-
bStack.push(b);
|
139
|
-
// Recursively compare objects and arrays.
|
140
|
-
// Compare array lengths to determine if a deep comparison is necessary.
|
141
|
-
if (strictCheck && className == '[object Array]' && a.length !== b.length) {
|
142
|
-
return false;
|
143
|
-
}
|
144
|
-
|
145
|
-
// Deep compare objects.
|
146
|
-
const aKeys = keys(a, hasKey);
|
147
|
-
let key;
|
148
|
-
const bKeys = keys(b, hasKey);
|
149
|
-
// Add keys corresponding to asymmetric matchers if they miss in non strict check mode
|
150
|
-
if (!strictCheck) {
|
151
|
-
for (let index = 0; index !== bKeys.length; ++index) {
|
152
|
-
key = bKeys[index];
|
153
|
-
if ((isAsymmetric(b[key]) || b[key] === undefined) && !hasKey(a, key)) {
|
154
|
-
aKeys.push(key);
|
155
|
-
}
|
156
|
-
}
|
157
|
-
for (let index = 0; index !== aKeys.length; ++index) {
|
158
|
-
key = aKeys[index];
|
159
|
-
if ((isAsymmetric(a[key]) || a[key] === undefined) && !hasKey(b, key)) {
|
160
|
-
bKeys.push(key);
|
161
|
-
}
|
162
|
-
}
|
163
|
-
}
|
164
|
-
|
165
|
-
// Ensure that both objects contain the same number of properties before comparing deep equality.
|
166
|
-
let size = aKeys.length;
|
167
|
-
if (bKeys.length !== size) {
|
168
|
-
return false;
|
169
|
-
}
|
170
|
-
while (size--) {
|
171
|
-
key = aKeys[size];
|
172
|
-
|
173
|
-
// Deep compare each member
|
174
|
-
if (strictCheck)
|
175
|
-
result =
|
176
|
-
hasKey(b, key) &&
|
177
|
-
eq(a[key], b[key], aStack, bStack, customTesters, strictCheck);
|
178
|
-
else
|
179
|
-
result =
|
180
|
-
(hasKey(b, key) || isAsymmetric(a[key]) || a[key] === undefined) &&
|
181
|
-
eq(a[key], b[key], aStack, bStack, customTesters, strictCheck);
|
182
|
-
if (!result) {
|
183
|
-
return false;
|
184
|
-
}
|
185
|
-
}
|
186
|
-
// Remove the first object from the stack of traversed objects.
|
187
|
-
aStack.pop();
|
188
|
-
bStack.pop();
|
189
|
-
return result;
|
190
|
-
}
|
191
|
-
function keys(obj, hasKey) {
|
192
|
-
const keys = [];
|
193
|
-
for (const key in obj) {
|
194
|
-
if (hasKey(obj, key)) {
|
195
|
-
keys.push(key);
|
196
|
-
}
|
197
|
-
}
|
198
|
-
return keys.concat(
|
199
|
-
Object.getOwnPropertySymbols(obj).filter(
|
200
|
-
symbol => Object.getOwnPropertyDescriptor(obj, symbol).enumerable
|
201
|
-
)
|
202
|
-
);
|
203
|
-
}
|
204
|
-
function hasKey(obj, key) {
|
205
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
206
|
-
}
|
207
|
-
function isA(typeName, value) {
|
208
|
-
return Object.prototype.toString.apply(value) === `[object ${typeName}]`;
|
209
|
-
}
|
210
|
-
function isDomNode(obj) {
|
211
|
-
return (
|
212
|
-
obj !== null &&
|
213
|
-
typeof obj === 'object' &&
|
214
|
-
typeof obj.nodeType === 'number' &&
|
215
|
-
typeof obj.nodeName === 'string' &&
|
216
|
-
typeof obj.isEqualNode === 'function'
|
217
|
-
);
|
218
|
-
}
|
package/build/types.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
'use strict';
|