@alanszp/express 10.0.0 → 10.0.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/node_modules/@jest/expect-utils/LICENSE +21 -0
- package/node_modules/@jest/expect-utils/README.md +5 -0
- package/node_modules/@jest/expect-utils/build/index.d.ts +93 -0
- package/node_modules/@jest/expect-utils/build/index.js +37 -0
- package/node_modules/@jest/expect-utils/build/jasmineUtils.js +282 -0
- package/node_modules/@jest/expect-utils/build/types.js +1 -0
- package/node_modules/@jest/expect-utils/build/utils.js +457 -0
- package/node_modules/@jest/expect-utils/package.json +33 -0
- package/node_modules/@jest/types/LICENSE +21 -0
- package/node_modules/@jest/types/README.md +30 -0
- package/node_modules/@jest/types/build/Circus.js +1 -0
- package/node_modules/@jest/types/build/Config.js +1 -0
- package/node_modules/@jest/types/build/Global.js +1 -0
- package/node_modules/@jest/types/build/TestResult.js +1 -0
- package/node_modules/@jest/types/build/Transform.js +1 -0
- package/node_modules/@jest/types/build/index.d.ts +1166 -0
- package/node_modules/@jest/types/build/index.js +1 -0
- package/node_modules/@jest/types/package.json +38 -0
- package/node_modules/@types/jest/LICENSE +21 -0
- package/node_modules/@types/jest/README.md +17 -0
- package/node_modules/@types/jest/index.d.ts +1608 -0
- package/node_modules/@types/jest/package.json +159 -0
- package/node_modules/@types/node/LICENSE +21 -0
- package/node_modules/@types/node/README.md +15 -0
- package/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/node_modules/@types/node/assert.d.ts +996 -0
- package/node_modules/@types/node/async_hooks.d.ts +539 -0
- package/node_modules/@types/node/buffer.d.ts +2362 -0
- package/node_modules/@types/node/child_process.d.ts +1540 -0
- package/node_modules/@types/node/cluster.d.ts +432 -0
- package/node_modules/@types/node/console.d.ts +415 -0
- package/node_modules/@types/node/constants.d.ts +19 -0
- package/node_modules/@types/node/crypto.d.ts +4487 -0
- package/node_modules/@types/node/dgram.d.ts +596 -0
- package/node_modules/@types/node/diagnostics_channel.d.ts +545 -0
- package/node_modules/@types/node/dns/promises.d.ts +425 -0
- package/node_modules/@types/node/dns.d.ts +809 -0
- package/node_modules/@types/node/dom-events.d.ts +122 -0
- package/node_modules/@types/node/domain.d.ts +170 -0
- package/node_modules/@types/node/events.d.ts +879 -0
- package/node_modules/@types/node/fs/promises.d.ts +1239 -0
- package/node_modules/@types/node/fs.d.ts +4311 -0
- package/node_modules/@types/node/globals.d.ts +411 -0
- package/node_modules/@types/node/globals.global.d.ts +1 -0
- package/node_modules/@types/node/http.d.ts +1887 -0
- package/node_modules/@types/node/http2.d.ts +2382 -0
- package/node_modules/@types/node/https.d.ts +550 -0
- package/node_modules/@types/node/index.d.ts +88 -0
- package/node_modules/@types/node/inspector.d.ts +2747 -0
- package/node_modules/@types/node/module.d.ts +315 -0
- package/node_modules/@types/node/net.d.ts +949 -0
- package/node_modules/@types/node/os.d.ts +478 -0
- package/node_modules/@types/node/package.json +229 -0
- package/node_modules/@types/node/path.d.ts +191 -0
- package/node_modules/@types/node/perf_hooks.d.ts +645 -0
- package/node_modules/@types/node/process.d.ts +1561 -0
- package/node_modules/@types/node/punycode.d.ts +117 -0
- package/node_modules/@types/node/querystring.d.ts +141 -0
- package/node_modules/@types/node/readline/promises.d.ts +150 -0
- package/node_modules/@types/node/readline.d.ts +539 -0
- package/node_modules/@types/node/repl.d.ts +430 -0
- package/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/node_modules/@types/node/stream/promises.d.ts +83 -0
- package/node_modules/@types/node/stream/web.d.ts +366 -0
- package/node_modules/@types/node/stream.d.ts +1701 -0
- package/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/node_modules/@types/node/test.d.ts +1465 -0
- package/node_modules/@types/node/timers/promises.d.ts +93 -0
- package/node_modules/@types/node/timers.d.ts +240 -0
- package/node_modules/@types/node/tls.d.ts +1210 -0
- package/node_modules/@types/node/trace_events.d.ts +182 -0
- package/node_modules/@types/node/ts4.8/assert/strict.d.ts +8 -0
- package/node_modules/@types/node/ts4.8/assert.d.ts +996 -0
- package/node_modules/@types/node/ts4.8/async_hooks.d.ts +539 -0
- package/node_modules/@types/node/ts4.8/buffer.d.ts +2362 -0
- package/node_modules/@types/node/ts4.8/child_process.d.ts +1540 -0
- package/node_modules/@types/node/ts4.8/cluster.d.ts +432 -0
- package/node_modules/@types/node/ts4.8/console.d.ts +415 -0
- package/node_modules/@types/node/ts4.8/constants.d.ts +19 -0
- package/node_modules/@types/node/ts4.8/crypto.d.ts +4487 -0
- package/node_modules/@types/node/ts4.8/dgram.d.ts +596 -0
- package/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +545 -0
- package/node_modules/@types/node/ts4.8/dns/promises.d.ts +425 -0
- package/node_modules/@types/node/ts4.8/dns.d.ts +809 -0
- package/node_modules/@types/node/ts4.8/dom-events.d.ts +122 -0
- package/node_modules/@types/node/ts4.8/domain.d.ts +170 -0
- package/node_modules/@types/node/ts4.8/events.d.ts +879 -0
- package/node_modules/@types/node/ts4.8/fs/promises.d.ts +1239 -0
- package/node_modules/@types/node/ts4.8/fs.d.ts +4311 -0
- package/node_modules/@types/node/ts4.8/globals.d.ts +411 -0
- package/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
- package/node_modules/@types/node/ts4.8/http.d.ts +1887 -0
- package/node_modules/@types/node/ts4.8/http2.d.ts +2382 -0
- package/node_modules/@types/node/ts4.8/https.d.ts +550 -0
- package/node_modules/@types/node/ts4.8/index.d.ts +88 -0
- package/node_modules/@types/node/ts4.8/inspector.d.ts +2747 -0
- package/node_modules/@types/node/ts4.8/module.d.ts +315 -0
- package/node_modules/@types/node/ts4.8/net.d.ts +949 -0
- package/node_modules/@types/node/ts4.8/os.d.ts +478 -0
- package/node_modules/@types/node/ts4.8/path.d.ts +191 -0
- package/node_modules/@types/node/ts4.8/perf_hooks.d.ts +645 -0
- package/node_modules/@types/node/ts4.8/process.d.ts +1561 -0
- package/node_modules/@types/node/ts4.8/punycode.d.ts +117 -0
- package/node_modules/@types/node/ts4.8/querystring.d.ts +141 -0
- package/node_modules/@types/node/ts4.8/readline/promises.d.ts +150 -0
- package/node_modules/@types/node/ts4.8/readline.d.ts +539 -0
- package/node_modules/@types/node/ts4.8/repl.d.ts +430 -0
- package/node_modules/@types/node/ts4.8/stream/consumers.d.ts +12 -0
- package/node_modules/@types/node/ts4.8/stream/promises.d.ts +83 -0
- package/node_modules/@types/node/ts4.8/stream/web.d.ts +366 -0
- package/node_modules/@types/node/ts4.8/stream.d.ts +1701 -0
- package/node_modules/@types/node/ts4.8/string_decoder.d.ts +67 -0
- package/node_modules/@types/node/ts4.8/test.d.ts +1465 -0
- package/node_modules/@types/node/ts4.8/timers/promises.d.ts +93 -0
- package/node_modules/@types/node/ts4.8/timers.d.ts +240 -0
- package/node_modules/@types/node/ts4.8/tls.d.ts +1210 -0
- package/node_modules/@types/node/ts4.8/trace_events.d.ts +182 -0
- package/node_modules/@types/node/ts4.8/tty.d.ts +208 -0
- package/node_modules/@types/node/ts4.8/url.d.ts +927 -0
- package/node_modules/@types/node/ts4.8/util.d.ts +2183 -0
- package/node_modules/@types/node/ts4.8/v8.d.ts +764 -0
- package/node_modules/@types/node/ts4.8/vm.d.ts +903 -0
- package/node_modules/@types/node/ts4.8/wasi.d.ts +179 -0
- package/node_modules/@types/node/ts4.8/worker_threads.d.ts +691 -0
- package/node_modules/@types/node/ts4.8/zlib.d.ts +517 -0
- package/node_modules/@types/node/tty.d.ts +208 -0
- package/node_modules/@types/node/url.d.ts +927 -0
- package/node_modules/@types/node/util.d.ts +2183 -0
- package/node_modules/@types/node/v8.d.ts +764 -0
- package/node_modules/@types/node/vm.d.ts +903 -0
- package/node_modules/@types/node/wasi.d.ts +179 -0
- package/node_modules/@types/node/worker_threads.d.ts +691 -0
- package/node_modules/@types/node/zlib.d.ts +517 -0
- package/package.json +8 -8
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.arrayBufferEquality = void 0;
|
|
7
|
+
exports.emptyObject = emptyObject;
|
|
8
|
+
exports.typeEquality =
|
|
9
|
+
exports.subsetEquality =
|
|
10
|
+
exports.sparseArrayEquality =
|
|
11
|
+
exports.pathAsArray =
|
|
12
|
+
exports.partition =
|
|
13
|
+
exports.iterableEquality =
|
|
14
|
+
exports.isOneline =
|
|
15
|
+
exports.isError =
|
|
16
|
+
exports.getPath =
|
|
17
|
+
exports.getObjectSubset =
|
|
18
|
+
void 0;
|
|
19
|
+
|
|
20
|
+
var _jestGetType = require('jest-get-type');
|
|
21
|
+
|
|
22
|
+
var _jasmineUtils = require('./jasmineUtils');
|
|
23
|
+
|
|
24
|
+
var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Checks if `hasOwnProperty(object, key)` up the prototype chain, stopping at `Object.prototype`.
|
|
28
|
+
*/
|
|
29
|
+
const hasPropertyInObject = (object, key) => {
|
|
30
|
+
const shouldTerminate =
|
|
31
|
+
!object || typeof object !== 'object' || object === Object.prototype;
|
|
32
|
+
|
|
33
|
+
if (shouldTerminate) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
Object.prototype.hasOwnProperty.call(object, key) ||
|
|
39
|
+
hasPropertyInObject(Object.getPrototypeOf(object), key)
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const getPath = (object, propertyPath) => {
|
|
44
|
+
if (!Array.isArray(propertyPath)) {
|
|
45
|
+
propertyPath = pathAsArray(propertyPath);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (propertyPath.length) {
|
|
49
|
+
const lastProp = propertyPath.length === 1;
|
|
50
|
+
const prop = propertyPath[0];
|
|
51
|
+
const newObject = object[prop];
|
|
52
|
+
|
|
53
|
+
if (!lastProp && (newObject === null || newObject === undefined)) {
|
|
54
|
+
// This is not the last prop in the chain. If we keep recursing it will
|
|
55
|
+
// hit a `can't access property X of undefined | null`. At this point we
|
|
56
|
+
// know that the chain has broken and we can return right away.
|
|
57
|
+
return {
|
|
58
|
+
hasEndProp: false,
|
|
59
|
+
lastTraversedObject: object,
|
|
60
|
+
traversedPath: []
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const result = getPath(newObject, propertyPath.slice(1));
|
|
65
|
+
|
|
66
|
+
if (result.lastTraversedObject === null) {
|
|
67
|
+
result.lastTraversedObject = object;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
result.traversedPath.unshift(prop);
|
|
71
|
+
|
|
72
|
+
if (lastProp) {
|
|
73
|
+
// Does object have the property with an undefined value?
|
|
74
|
+
// Although primitive values support bracket notation (above)
|
|
75
|
+
// they would throw TypeError for in operator (below).
|
|
76
|
+
result.endPropIsDefined =
|
|
77
|
+
!(0, _jestGetType.isPrimitive)(object) && prop in object;
|
|
78
|
+
result.hasEndProp = newObject !== undefined || result.endPropIsDefined;
|
|
79
|
+
|
|
80
|
+
if (!result.hasEndProp) {
|
|
81
|
+
result.traversedPath.shift();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
lastTraversedObject: null,
|
|
90
|
+
traversedPath: [],
|
|
91
|
+
value: object
|
|
92
|
+
};
|
|
93
|
+
}; // Strip properties from object that are not present in the subset. Useful for
|
|
94
|
+
// printing the diff for toMatchObject() without adding unrelated noise.
|
|
95
|
+
|
|
96
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
97
|
+
|
|
98
|
+
exports.getPath = getPath;
|
|
99
|
+
|
|
100
|
+
const getObjectSubset = (object, subset, seenReferences = new WeakMap()) => {
|
|
101
|
+
/* eslint-enable @typescript-eslint/explicit-module-boundary-types */
|
|
102
|
+
if (Array.isArray(object)) {
|
|
103
|
+
if (Array.isArray(subset) && subset.length === object.length) {
|
|
104
|
+
// The map method returns correct subclass of subset.
|
|
105
|
+
return subset.map((sub, i) => getObjectSubset(object[i], sub));
|
|
106
|
+
}
|
|
107
|
+
} else if (object instanceof Date) {
|
|
108
|
+
return object;
|
|
109
|
+
} else if (isObject(object) && isObject(subset)) {
|
|
110
|
+
if (
|
|
111
|
+
(0, _jasmineUtils.equals)(object, subset, [
|
|
112
|
+
iterableEquality,
|
|
113
|
+
subsetEquality
|
|
114
|
+
])
|
|
115
|
+
) {
|
|
116
|
+
// Avoid unnecessary copy which might return Object instead of subclass.
|
|
117
|
+
return subset;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const trimmed = {};
|
|
121
|
+
seenReferences.set(object, trimmed);
|
|
122
|
+
Object.keys(object)
|
|
123
|
+
.filter(key => hasPropertyInObject(subset, key))
|
|
124
|
+
.forEach(key => {
|
|
125
|
+
trimmed[key] = seenReferences.has(object[key])
|
|
126
|
+
? seenReferences.get(object[key])
|
|
127
|
+
: getObjectSubset(object[key], subset[key], seenReferences);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
if (Object.keys(trimmed).length > 0) {
|
|
131
|
+
return trimmed;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return object;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
exports.getObjectSubset = getObjectSubset;
|
|
139
|
+
const IteratorSymbol = Symbol.iterator;
|
|
140
|
+
|
|
141
|
+
const hasIterator = object => !!(object != null && object[IteratorSymbol]);
|
|
142
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
143
|
+
|
|
144
|
+
const iterableEquality = (
|
|
145
|
+
a,
|
|
146
|
+
b,
|
|
147
|
+
/* eslint-enable @typescript-eslint/explicit-module-boundary-types */
|
|
148
|
+
aStack = [],
|
|
149
|
+
bStack = []
|
|
150
|
+
) => {
|
|
151
|
+
if (
|
|
152
|
+
typeof a !== 'object' ||
|
|
153
|
+
typeof b !== 'object' ||
|
|
154
|
+
Array.isArray(a) ||
|
|
155
|
+
Array.isArray(b) ||
|
|
156
|
+
!hasIterator(a) ||
|
|
157
|
+
!hasIterator(b)
|
|
158
|
+
) {
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (a.constructor !== b.constructor) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
let length = aStack.length;
|
|
167
|
+
|
|
168
|
+
while (length--) {
|
|
169
|
+
// Linear search. Performance is inversely proportional to the number of
|
|
170
|
+
// unique nested structures.
|
|
171
|
+
// circular references at same depth are equal
|
|
172
|
+
// circular reference is not equal to non-circular one
|
|
173
|
+
if (aStack[length] === a) {
|
|
174
|
+
return bStack[length] === b;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
aStack.push(a);
|
|
179
|
+
bStack.push(b);
|
|
180
|
+
|
|
181
|
+
const iterableEqualityWithStack = (a, b) =>
|
|
182
|
+
iterableEquality(a, b, [...aStack], [...bStack]);
|
|
183
|
+
|
|
184
|
+
if (a.size !== undefined) {
|
|
185
|
+
if (a.size !== b.size) {
|
|
186
|
+
return false;
|
|
187
|
+
} else if (
|
|
188
|
+
(0, _jasmineUtils.isA)('Set', a) ||
|
|
189
|
+
(0, _jasmineUtils.isImmutableUnorderedSet)(a)
|
|
190
|
+
) {
|
|
191
|
+
let allFound = true;
|
|
192
|
+
|
|
193
|
+
for (const aValue of a) {
|
|
194
|
+
if (!b.has(aValue)) {
|
|
195
|
+
let has = false;
|
|
196
|
+
|
|
197
|
+
for (const bValue of b) {
|
|
198
|
+
const isEqual = (0, _jasmineUtils.equals)(aValue, bValue, [
|
|
199
|
+
iterableEqualityWithStack
|
|
200
|
+
]);
|
|
201
|
+
|
|
202
|
+
if (isEqual === true) {
|
|
203
|
+
has = true;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (has === false) {
|
|
208
|
+
allFound = false;
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
} // Remove the first value from the stack of traversed values.
|
|
213
|
+
|
|
214
|
+
aStack.pop();
|
|
215
|
+
bStack.pop();
|
|
216
|
+
return allFound;
|
|
217
|
+
} else if (
|
|
218
|
+
(0, _jasmineUtils.isA)('Map', a) ||
|
|
219
|
+
(0, _jasmineUtils.isImmutableUnorderedKeyed)(a)
|
|
220
|
+
) {
|
|
221
|
+
let allFound = true;
|
|
222
|
+
|
|
223
|
+
for (const aEntry of a) {
|
|
224
|
+
if (
|
|
225
|
+
!b.has(aEntry[0]) ||
|
|
226
|
+
!(0, _jasmineUtils.equals)(aEntry[1], b.get(aEntry[0]), [
|
|
227
|
+
iterableEqualityWithStack
|
|
228
|
+
])
|
|
229
|
+
) {
|
|
230
|
+
let has = false;
|
|
231
|
+
|
|
232
|
+
for (const bEntry of b) {
|
|
233
|
+
const matchedKey = (0, _jasmineUtils.equals)(aEntry[0], bEntry[0], [
|
|
234
|
+
iterableEqualityWithStack
|
|
235
|
+
]);
|
|
236
|
+
let matchedValue = false;
|
|
237
|
+
|
|
238
|
+
if (matchedKey === true) {
|
|
239
|
+
matchedValue = (0, _jasmineUtils.equals)(aEntry[1], bEntry[1], [
|
|
240
|
+
iterableEqualityWithStack
|
|
241
|
+
]);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (matchedValue === true) {
|
|
245
|
+
has = true;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (has === false) {
|
|
250
|
+
allFound = false;
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
} // Remove the first value from the stack of traversed values.
|
|
255
|
+
|
|
256
|
+
aStack.pop();
|
|
257
|
+
bStack.pop();
|
|
258
|
+
return allFound;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const bIterator = b[IteratorSymbol]();
|
|
263
|
+
|
|
264
|
+
for (const aValue of a) {
|
|
265
|
+
const nextB = bIterator.next();
|
|
266
|
+
|
|
267
|
+
if (
|
|
268
|
+
nextB.done ||
|
|
269
|
+
!(0, _jasmineUtils.equals)(aValue, nextB.value, [
|
|
270
|
+
iterableEqualityWithStack
|
|
271
|
+
])
|
|
272
|
+
) {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (!bIterator.next().done) {
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (
|
|
282
|
+
!(0, _jasmineUtils.isImmutableList)(a) &&
|
|
283
|
+
!(0, _jasmineUtils.isImmutableOrderedKeyed)(a) &&
|
|
284
|
+
!(0, _jasmineUtils.isImmutableOrderedSet)(a)
|
|
285
|
+
) {
|
|
286
|
+
const aEntries = Object.entries(a);
|
|
287
|
+
const bEntries = Object.entries(b);
|
|
288
|
+
|
|
289
|
+
if (!(0, _jasmineUtils.equals)(aEntries, bEntries)) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
} // Remove the first value from the stack of traversed values.
|
|
293
|
+
|
|
294
|
+
aStack.pop();
|
|
295
|
+
bStack.pop();
|
|
296
|
+
return true;
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
exports.iterableEquality = iterableEquality;
|
|
300
|
+
|
|
301
|
+
const isObject = a => a !== null && typeof a === 'object';
|
|
302
|
+
|
|
303
|
+
const isObjectWithKeys = a =>
|
|
304
|
+
isObject(a) &&
|
|
305
|
+
!(a instanceof Error) &&
|
|
306
|
+
!(a instanceof Array) &&
|
|
307
|
+
!(a instanceof Date);
|
|
308
|
+
|
|
309
|
+
const subsetEquality = (object, subset) => {
|
|
310
|
+
// subsetEquality needs to keep track of the references
|
|
311
|
+
// it has already visited to avoid infinite loops in case
|
|
312
|
+
// there are circular references in the subset passed to it.
|
|
313
|
+
const subsetEqualityWithContext =
|
|
314
|
+
(seenReferences = new WeakMap()) =>
|
|
315
|
+
(object, subset) => {
|
|
316
|
+
if (!isObjectWithKeys(subset)) {
|
|
317
|
+
return undefined;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
return Object.keys(subset).every(key => {
|
|
321
|
+
if (isObjectWithKeys(subset[key])) {
|
|
322
|
+
if (seenReferences.has(subset[key])) {
|
|
323
|
+
return (0, _jasmineUtils.equals)(object[key], subset[key], [
|
|
324
|
+
iterableEquality
|
|
325
|
+
]);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
seenReferences.set(subset[key], true);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const result =
|
|
332
|
+
object != null &&
|
|
333
|
+
hasPropertyInObject(object, key) &&
|
|
334
|
+
(0, _jasmineUtils.equals)(object[key], subset[key], [
|
|
335
|
+
iterableEquality,
|
|
336
|
+
subsetEqualityWithContext(seenReferences)
|
|
337
|
+
]); // The main goal of using seenReference is to avoid circular node on tree.
|
|
338
|
+
// It will only happen within a parent and its child, not a node and nodes next to it (same level)
|
|
339
|
+
// We should keep the reference for a parent and its child only
|
|
340
|
+
// Thus we should delete the reference immediately so that it doesn't interfere
|
|
341
|
+
// other nodes within the same level on tree.
|
|
342
|
+
|
|
343
|
+
seenReferences.delete(subset[key]);
|
|
344
|
+
return result;
|
|
345
|
+
});
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
return subsetEqualityWithContext()(object, subset);
|
|
349
|
+
}; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
350
|
+
|
|
351
|
+
exports.subsetEquality = subsetEquality;
|
|
352
|
+
|
|
353
|
+
const typeEquality = (a, b) => {
|
|
354
|
+
if (a == null || b == null || a.constructor === b.constructor) {
|
|
355
|
+
return undefined;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
return false;
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
exports.typeEquality = typeEquality;
|
|
362
|
+
|
|
363
|
+
const arrayBufferEquality = (a, b) => {
|
|
364
|
+
if (!(a instanceof ArrayBuffer) || !(b instanceof ArrayBuffer)) {
|
|
365
|
+
return undefined;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const dataViewA = new DataView(a);
|
|
369
|
+
const dataViewB = new DataView(b); // Buffers are not equal when they do not have the same byte length
|
|
370
|
+
|
|
371
|
+
if (dataViewA.byteLength !== dataViewB.byteLength) {
|
|
372
|
+
return false;
|
|
373
|
+
} // Check if every byte value is equal to each other
|
|
374
|
+
|
|
375
|
+
for (let i = 0; i < dataViewA.byteLength; i++) {
|
|
376
|
+
if (dataViewA.getUint8(i) !== dataViewB.getUint8(i)) {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return true;
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
exports.arrayBufferEquality = arrayBufferEquality;
|
|
385
|
+
|
|
386
|
+
const sparseArrayEquality = (a, b) => {
|
|
387
|
+
if (!Array.isArray(a) || !Array.isArray(b)) {
|
|
388
|
+
return undefined;
|
|
389
|
+
} // A sparse array [, , 1] will have keys ["2"] whereas [undefined, undefined, 1] will have keys ["0", "1", "2"]
|
|
390
|
+
|
|
391
|
+
const aKeys = Object.keys(a);
|
|
392
|
+
const bKeys = Object.keys(b);
|
|
393
|
+
return (
|
|
394
|
+
(0, _jasmineUtils.equals)(a, b, [iterableEquality, typeEquality], true) &&
|
|
395
|
+
(0, _jasmineUtils.equals)(aKeys, bKeys)
|
|
396
|
+
);
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
exports.sparseArrayEquality = sparseArrayEquality;
|
|
400
|
+
|
|
401
|
+
const partition = (items, predicate) => {
|
|
402
|
+
const result = [[], []];
|
|
403
|
+
items.forEach(item => result[predicate(item) ? 0 : 1].push(item));
|
|
404
|
+
return result;
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
exports.partition = partition;
|
|
408
|
+
|
|
409
|
+
const pathAsArray = propertyPath => {
|
|
410
|
+
const properties = [];
|
|
411
|
+
|
|
412
|
+
if (propertyPath === '') {
|
|
413
|
+
properties.push('');
|
|
414
|
+
return properties;
|
|
415
|
+
} // will match everything that's not a dot or a bracket, and "" for consecutive dots.
|
|
416
|
+
|
|
417
|
+
const pattern = RegExp('[^.[\\]]+|(?=(?:\\.)(?:\\.|$))', 'g'); // Because the regex won't match a dot in the beginning of the path, if present.
|
|
418
|
+
|
|
419
|
+
if (propertyPath[0] === '.') {
|
|
420
|
+
properties.push('');
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
propertyPath.replace(pattern, match => {
|
|
424
|
+
properties.push(match);
|
|
425
|
+
return match;
|
|
426
|
+
});
|
|
427
|
+
return properties;
|
|
428
|
+
}; // Copied from https://github.com/graingert/angular.js/blob/a43574052e9775cbc1d7dd8a086752c979b0f020/src/Angular.js#L685-L693
|
|
429
|
+
|
|
430
|
+
exports.pathAsArray = pathAsArray;
|
|
431
|
+
|
|
432
|
+
const isError = value => {
|
|
433
|
+
switch (Object.prototype.toString.call(value)) {
|
|
434
|
+
case '[object Error]':
|
|
435
|
+
case '[object Exception]':
|
|
436
|
+
case '[object DOMException]':
|
|
437
|
+
return true;
|
|
438
|
+
|
|
439
|
+
default:
|
|
440
|
+
return value instanceof Error;
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
exports.isError = isError;
|
|
445
|
+
|
|
446
|
+
function emptyObject(obj) {
|
|
447
|
+
return obj && typeof obj === 'object' ? !Object.keys(obj).length : false;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
const MULTILINE_REGEXP = /[\r\n]/;
|
|
451
|
+
|
|
452
|
+
const isOneline = (expected, received) =>
|
|
453
|
+
typeof expected === 'string' &&
|
|
454
|
+
typeof received === 'string' &&
|
|
455
|
+
(!MULTILINE_REGEXP.test(expected) || !MULTILINE_REGEXP.test(received));
|
|
456
|
+
|
|
457
|
+
exports.isOneline = isOneline;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jest/expect-utils",
|
|
3
|
+
"version": "28.1.3",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/facebook/jest.git",
|
|
7
|
+
"directory": "packages/expect-utils"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"main": "./build/index.js",
|
|
11
|
+
"types": "./build/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./build/index.d.ts",
|
|
15
|
+
"default": "./build/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"jest-get-type": "^28.0.2"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"immutable": "^4.0.0",
|
|
24
|
+
"jest-matcher-utils": "^28.1.3"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"gitHead": "2cce069800dab3fc8ca7c469b32d2e2b2f7e2bb1"
|
|
33
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @jest/types
|
|
2
|
+
|
|
3
|
+
This package contains shared types of Jest's packages.
|
|
4
|
+
|
|
5
|
+
If you are looking for types of [Jest globals](https://jestjs.io/docs/api), you can import them from `@jest/globals` package:
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import {describe, expect, it} from '@jest/globals';
|
|
9
|
+
|
|
10
|
+
describe('my tests', () => {
|
|
11
|
+
it('works', () => {
|
|
12
|
+
expect(1).toBe(1);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
If you prefer to omit imports, a similar result can be achieved installing the [@types/jest](https://npmjs.com/package/@types/jest) package. Note that this is a third party library maintained at [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest) and may not cover the latest Jest features.
|
|
18
|
+
|
|
19
|
+
Another use-case for `@types/jest` is a typed Jest config as those types are not provided by Jest out of the box:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
// jest.config.ts
|
|
23
|
+
import {Config} from '@jest/types';
|
|
24
|
+
|
|
25
|
+
const config: Config.InitialOptions = {
|
|
26
|
+
// some typed config
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default config;
|
|
30
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';
|