vest 4.4.0 → 4.4.2-dev-d13b14
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/dist/cjs/classnames.development.js +9 -60
- package/dist/cjs/classnames.production.js +1 -1
- package/dist/cjs/enforce/compose.development.js +6 -53
- package/dist/cjs/enforce/compose.production.js +1 -1
- package/dist/cjs/enforce/compounds.development.js +16 -71
- package/dist/cjs/enforce/compounds.production.js +1 -1
- package/dist/cjs/enforce/schema.development.js +6 -58
- package/dist/cjs/enforce/schema.production.js +1 -1
- package/dist/cjs/parser.development.js +8 -59
- package/dist/cjs/parser.production.js +1 -1
- package/dist/cjs/promisify.development.js +2 -26
- package/dist/cjs/promisify.production.js +1 -1
- package/dist/cjs/vest.development.js +163 -429
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/classnames.development.js +1 -52
- package/dist/es/classnames.production.js +1 -1
- package/dist/es/enforce/compose.development.js +4 -51
- package/dist/es/enforce/compose.production.js +1 -1
- package/dist/es/enforce/compounds.development.js +11 -66
- package/dist/es/enforce/compounds.production.js +1 -1
- package/dist/es/enforce/schema.development.js +2 -54
- package/dist/es/enforce/schema.production.js +1 -1
- package/dist/es/parser.development.js +1 -52
- package/dist/es/parser.production.js +1 -1
- package/dist/es/promisify.development.js +1 -25
- package/dist/es/promisify.production.js +1 -1
- package/dist/es/vest.development.js +92 -358
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/classnames.development.js +13 -13
- package/dist/umd/classnames.production.js +1 -1
- package/dist/umd/enforce/compose.development.js +121 -121
- package/dist/umd/enforce/compose.production.js +1 -1
- package/dist/umd/enforce/compounds.development.js +180 -184
- package/dist/umd/enforce/compounds.production.js +1 -1
- package/dist/umd/enforce/schema.development.js +132 -132
- package/dist/umd/enforce/schema.production.js +1 -1
- package/dist/umd/parser.development.js +13 -13
- package/dist/umd/parser.production.js +1 -1
- package/dist/umd/vest.development.js +399 -406
- package/dist/umd/vest.production.js +1 -1
- package/package.json +4 -3
- package/testUtils/mockThrowError.ts +2 -1
- package/testUtils/suiteDummy.ts +1 -1
- package/testUtils/testObjects.ts +2 -17
- package/types/enforce/compose.d.ts +14 -30
- package/types/enforce/compounds.d.ts +14 -30
- package/types/enforce/schema.d.ts +14 -30
- package/types/vest.d.ts +4 -3
- package/testUtils/itWithContext.ts +0 -23
|
@@ -1,181 +1,12 @@
|
|
|
1
1
|
export { enforce } from 'n4s';
|
|
2
|
+
import { isUndefined, isStringValue, assign, cache as cache$2, optionalFunctionValue, nestedArray, asArray, genId, isFunction, isNullish, deferThrow, invariant, bindNot, either, isEmpty, isNotEmpty, isPositive, hasOwnProperty, isArray, callEach, bus, defaultTo, isPromise, isNull } from 'vest-utils';
|
|
2
3
|
import { createContext } from 'context';
|
|
3
4
|
|
|
4
|
-
/**
|
|
5
|
-
* @returns a unique numeric id.
|
|
6
|
-
*/
|
|
7
|
-
var genId = (function (n) { return function () {
|
|
8
|
-
return "".concat(n++);
|
|
9
|
-
}; })(0);
|
|
10
|
-
|
|
11
|
-
function isStringValue(v) {
|
|
12
|
-
return String(v) === v;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function bindNot(fn) {
|
|
16
|
-
return function () {
|
|
17
|
-
var args = [];
|
|
18
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
19
|
-
args[_i] = arguments[_i];
|
|
20
|
-
}
|
|
21
|
-
return !fn.apply(void 0, args);
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function isUndefined(value) {
|
|
26
|
-
return value === undefined;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
5
|
function shouldUseErrorAsMessage(message, error) {
|
|
30
6
|
// kind of cheating with this safe guard, but it does the job
|
|
31
7
|
return isUndefined(message) && isStringValue(error);
|
|
32
8
|
}
|
|
33
9
|
|
|
34
|
-
function asArray(possibleArg) {
|
|
35
|
-
return [].concat(possibleArg);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var assign = Object.assign;
|
|
39
|
-
|
|
40
|
-
function isNumeric(value) {
|
|
41
|
-
var str = String(value);
|
|
42
|
-
var num = Number(value);
|
|
43
|
-
var result = !isNaN(parseFloat(str)) && !isNaN(Number(value)) && isFinite(num);
|
|
44
|
-
return Boolean(result);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function numberEquals(value, eq) {
|
|
48
|
-
return isNumeric(value) && isNumeric(eq) && Number(value) === Number(eq);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function lengthEquals(value, arg1) {
|
|
52
|
-
return numberEquals(value.length, arg1);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function greaterThan(value, gt) {
|
|
56
|
-
return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function longerThan(value, arg1) {
|
|
60
|
-
return greaterThan(value.length, arg1);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Creates a cache function
|
|
65
|
-
*/
|
|
66
|
-
function createCache(maxSize) {
|
|
67
|
-
if (maxSize === void 0) { maxSize = 1; }
|
|
68
|
-
var cacheStorage = [];
|
|
69
|
-
var cache = function (deps, cacheAction) {
|
|
70
|
-
var cacheHit = cache.get(deps);
|
|
71
|
-
// cache hit is not null
|
|
72
|
-
if (cacheHit)
|
|
73
|
-
return cacheHit[1];
|
|
74
|
-
var result = cacheAction();
|
|
75
|
-
cacheStorage.unshift([deps.concat(), result]);
|
|
76
|
-
if (longerThan(cacheStorage, maxSize))
|
|
77
|
-
cacheStorage.length = maxSize;
|
|
78
|
-
return result;
|
|
79
|
-
};
|
|
80
|
-
// invalidate an item in the cache by its dependencies
|
|
81
|
-
cache.invalidate = function (deps) {
|
|
82
|
-
var index = findIndex(deps);
|
|
83
|
-
if (index > -1)
|
|
84
|
-
cacheStorage.splice(index, 1);
|
|
85
|
-
};
|
|
86
|
-
// Retrieves an item from the cache.
|
|
87
|
-
cache.get = function (deps) {
|
|
88
|
-
return cacheStorage[findIndex(deps)] || null;
|
|
89
|
-
};
|
|
90
|
-
return cache;
|
|
91
|
-
function findIndex(deps) {
|
|
92
|
-
return cacheStorage.findIndex(function (_a) {
|
|
93
|
-
var cachedDeps = _a[0];
|
|
94
|
-
return lengthEquals(deps, cachedDeps.length) &&
|
|
95
|
-
deps.every(function (dep, i) { return dep === cachedDeps[i]; });
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// The module is named "isArrayValue" since it
|
|
101
|
-
// is conflicting with a nested npm dependency.
|
|
102
|
-
// We may need to revisit this in the future.
|
|
103
|
-
function isArray(value) {
|
|
104
|
-
return Boolean(Array.isArray(value));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function isNull(value) {
|
|
108
|
-
return value === null;
|
|
109
|
-
}
|
|
110
|
-
var isNotNull = bindNot(isNull);
|
|
111
|
-
|
|
112
|
-
function isFunction(value) {
|
|
113
|
-
return typeof value === 'function';
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function optionalFunctionValue(value) {
|
|
117
|
-
var args = [];
|
|
118
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
119
|
-
args[_i - 1] = arguments[_i];
|
|
120
|
-
}
|
|
121
|
-
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function defaultTo(callback, defaultValue) {
|
|
125
|
-
var _a;
|
|
126
|
-
return (_a = optionalFunctionValue(callback)) !== null && _a !== void 0 ? _a : defaultValue;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function last(values) {
|
|
130
|
-
var valuesArray = asArray(values);
|
|
131
|
-
return valuesArray[valuesArray.length - 1];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// This is kind of a map/filter in one function.
|
|
135
|
-
// Normally, behaves like a nested-array map,
|
|
136
|
-
// but returning `null` will drop the element from the array
|
|
137
|
-
function transform(array, cb) {
|
|
138
|
-
var res = [];
|
|
139
|
-
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
|
|
140
|
-
var v = array_1[_i];
|
|
141
|
-
if (isArray(v)) {
|
|
142
|
-
res.push(transform(v, cb));
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
var output = cb(v);
|
|
146
|
-
if (isNotNull(output)) {
|
|
147
|
-
res.push(output);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return res;
|
|
152
|
-
}
|
|
153
|
-
function valueAtPath(array, path) {
|
|
154
|
-
return getCurrent(array, path)[last(path)];
|
|
155
|
-
}
|
|
156
|
-
function setValueAtPath(array, path, value) {
|
|
157
|
-
var current = getCurrent(array, path);
|
|
158
|
-
current[last(path)] = value;
|
|
159
|
-
return array;
|
|
160
|
-
}
|
|
161
|
-
function flatten(values) {
|
|
162
|
-
return asArray(values).reduce(function (acc, value) {
|
|
163
|
-
if (isArray(value)) {
|
|
164
|
-
return acc.concat(flatten(value));
|
|
165
|
-
}
|
|
166
|
-
return asArray(acc).concat(value);
|
|
167
|
-
}, []);
|
|
168
|
-
}
|
|
169
|
-
function getCurrent(array, path) {
|
|
170
|
-
var current = array;
|
|
171
|
-
for (var _i = 0, _a = path.slice(0, -1); _i < _a.length; _i++) {
|
|
172
|
-
var p = _a[_i];
|
|
173
|
-
current[p] = defaultTo(current[p], []);
|
|
174
|
-
current = current[p];
|
|
175
|
-
}
|
|
176
|
-
return current;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
10
|
var IsolateTypes;
|
|
180
11
|
(function (IsolateTypes) {
|
|
181
12
|
IsolateTypes[IsolateTypes["DEFAULT"] = 0] = "DEFAULT";
|
|
@@ -192,20 +23,6 @@ var Modes;
|
|
|
192
23
|
Modes[Modes["EAGER"] = 1] = "EAGER";
|
|
193
24
|
})(Modes || (Modes = {}));
|
|
194
25
|
|
|
195
|
-
function invariant(condition,
|
|
196
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
197
|
-
message) {
|
|
198
|
-
if (condition) {
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
// If message is a string object (rather than string literal)
|
|
202
|
-
// Throw the value directly as a string
|
|
203
|
-
// Alternatively, throw an error with the message
|
|
204
|
-
throw message instanceof String
|
|
205
|
-
? message.valueOf()
|
|
206
|
-
: new Error(message ? optionalFunctionValue(message) : message);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
26
|
function createIsolateCursor() {
|
|
210
27
|
var cursor = {
|
|
211
28
|
value: 0
|
|
@@ -228,84 +45,6 @@ function createIsolateCursor() {
|
|
|
228
45
|
}
|
|
229
46
|
}
|
|
230
47
|
|
|
231
|
-
function isNullish(value) {
|
|
232
|
-
return isNull(value) || isUndefined(value);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function deferThrow(message) {
|
|
236
|
-
setTimeout(function () {
|
|
237
|
-
throw new Error(message);
|
|
238
|
-
}, 0);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
function usePrevKeys() {
|
|
242
|
-
var prev = useTestObjects()[0].prev;
|
|
243
|
-
return asArray(getCurrent(prev, useCurrentPath())).reduce(function (prevKeys, testObject) {
|
|
244
|
-
if (!(testObject instanceof VestTest)) {
|
|
245
|
-
return prevKeys;
|
|
246
|
-
}
|
|
247
|
-
if (isNullish(testObject.key)) {
|
|
248
|
-
return prevKeys;
|
|
249
|
-
}
|
|
250
|
-
prevKeys[testObject.key] = testObject;
|
|
251
|
-
return prevKeys;
|
|
252
|
-
}, {});
|
|
253
|
-
}
|
|
254
|
-
function usePrevTestByKey(key) {
|
|
255
|
-
var prev = context.useX().isolate.keys.prev;
|
|
256
|
-
return prev[key];
|
|
257
|
-
}
|
|
258
|
-
function useRetainTestKey(key, testObject) {
|
|
259
|
-
var context$1 = context.useX();
|
|
260
|
-
var current = context$1.isolate.keys.current;
|
|
261
|
-
if (isNullish(current[key])) {
|
|
262
|
-
current[key] = testObject;
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
deferThrow("Encountered the same test key \"".concat(key, "\" twice. This may lead to tests overriding each other's results, or to tests being unexpectedly omitted."));
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function isolate(_a, callback) {
|
|
270
|
-
var _b = _a.type, type = _b === void 0 ? IsolateTypes.DEFAULT : _b;
|
|
271
|
-
invariant(isFunction(callback));
|
|
272
|
-
// Generate a new Isolate layer, with its own cursor
|
|
273
|
-
var isolate = generateIsolate(type, useCurrentPath());
|
|
274
|
-
var output = context.run({ isolate: isolate }, function () {
|
|
275
|
-
isolate.keys.prev = usePrevKeys();
|
|
276
|
-
useSetTests(function (tests) { return setValueAtPath(tests, isolate.path, []); });
|
|
277
|
-
var res = callback();
|
|
278
|
-
return res;
|
|
279
|
-
});
|
|
280
|
-
// Move the parent cursor forward once we're done
|
|
281
|
-
useCursor().next();
|
|
282
|
-
return output;
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* @returns {Isolate} The current isolate layer
|
|
286
|
-
*/
|
|
287
|
-
function useIsolate() {
|
|
288
|
-
return context.useX().isolate;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* @returns {boolean} Whether or not the current isolate allows tests to be reordered
|
|
292
|
-
*/
|
|
293
|
-
function shouldAllowReorder() {
|
|
294
|
-
return context.useX().isolate.type === IsolateTypes.EACH;
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* @returns {number[]} The current cursor path of the isolate tree
|
|
298
|
-
*/
|
|
299
|
-
function useCurrentPath() {
|
|
300
|
-
var isolate = useIsolate();
|
|
301
|
-
return isolate.path.concat(isolate.cursor.current());
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* @returns {IsolateCursor} The cursor object for the current isolate
|
|
305
|
-
*/
|
|
306
|
-
function useCursor() {
|
|
307
|
-
return useIsolate().cursor;
|
|
308
|
-
}
|
|
309
48
|
function generateIsolate(type, path) {
|
|
310
49
|
if (path === void 0) { path = []; }
|
|
311
50
|
return {
|
|
@@ -394,10 +133,10 @@ function useSetTests(handler) {
|
|
|
394
133
|
function useAllIncomplete() {
|
|
395
134
|
return useTestsFlat().filter(function (test) { return test.isPending(); });
|
|
396
135
|
}
|
|
397
|
-
var flatCache =
|
|
136
|
+
var flatCache = cache$2();
|
|
398
137
|
function useTestsFlat() {
|
|
399
138
|
var current = useTestObjects()[0].current;
|
|
400
|
-
return flatCache([current], function () { return flatten(current); });
|
|
139
|
+
return flatCache([current], function () { return nestedArray.flatten(current); });
|
|
401
140
|
}
|
|
402
141
|
function useEachTestObject(handler) {
|
|
403
142
|
var testObjects = useTestsFlat();
|
|
@@ -631,6 +370,74 @@ function createStateRef(state, _a) {
|
|
|
631
370
|
};
|
|
632
371
|
}
|
|
633
372
|
|
|
373
|
+
function usePrevKeys() {
|
|
374
|
+
var prev = useTestObjects()[0].prev;
|
|
375
|
+
return asArray(nestedArray.getCurrent(prev, useCurrentPath())).reduce(function (prevKeys, testObject) {
|
|
376
|
+
if (!(testObject instanceof VestTest)) {
|
|
377
|
+
return prevKeys;
|
|
378
|
+
}
|
|
379
|
+
if (isNullish(testObject.key)) {
|
|
380
|
+
return prevKeys;
|
|
381
|
+
}
|
|
382
|
+
prevKeys[testObject.key] = testObject;
|
|
383
|
+
return prevKeys;
|
|
384
|
+
}, {});
|
|
385
|
+
}
|
|
386
|
+
function usePrevTestByKey(key) {
|
|
387
|
+
var prev = useIsolate().keys.prev;
|
|
388
|
+
return prev[key];
|
|
389
|
+
}
|
|
390
|
+
function useRetainTestKey(key, testObject) {
|
|
391
|
+
var current = useIsolate().keys.current;
|
|
392
|
+
if (isNullish(current[key])) {
|
|
393
|
+
current[key] = testObject;
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
deferThrow("Encountered the same test key \"".concat(key, "\" twice. This may lead to tests overriding each other's results, or to tests being unexpectedly omitted."));
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function isolate(_a, callback) {
|
|
401
|
+
var _b = _a.type, type = _b === void 0 ? IsolateTypes.DEFAULT : _b;
|
|
402
|
+
invariant(isFunction(callback));
|
|
403
|
+
// Generate a new Isolate layer, with its own cursor
|
|
404
|
+
var isolate = generateIsolate(type, useCurrentPath());
|
|
405
|
+
var output = context.run({ isolate: isolate }, function () {
|
|
406
|
+
isolate.keys.prev = usePrevKeys();
|
|
407
|
+
useSetTests(function (tests) { return nestedArray.setValueAtPath(tests, isolate.path, []); });
|
|
408
|
+
var res = callback();
|
|
409
|
+
return res;
|
|
410
|
+
});
|
|
411
|
+
// Move the parent cursor forward once we're done
|
|
412
|
+
useCursor().next();
|
|
413
|
+
return output;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* @returns {Isolate} The current isolate layer
|
|
417
|
+
*/
|
|
418
|
+
function useIsolate() {
|
|
419
|
+
return context.useX().isolate;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* @returns {boolean} Whether or not the current isolate allows tests to be reordered
|
|
423
|
+
*/
|
|
424
|
+
function shouldAllowReorder() {
|
|
425
|
+
return useIsolate().type === IsolateTypes.EACH;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* @returns {number[]} The current cursor path of the isolate tree
|
|
429
|
+
*/
|
|
430
|
+
function useCurrentPath() {
|
|
431
|
+
var isolate = useIsolate();
|
|
432
|
+
return isolate.path.concat(isolate.cursor.current());
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* @returns {IsolateCursor} The cursor object for the current isolate
|
|
436
|
+
*/
|
|
437
|
+
function useCursor() {
|
|
438
|
+
return useIsolate().cursor;
|
|
439
|
+
}
|
|
440
|
+
|
|
634
441
|
var Severity;
|
|
635
442
|
(function (Severity) {
|
|
636
443
|
Severity["WARNINGS"] = "warnings";
|
|
@@ -647,34 +454,6 @@ function countKeyBySeverity(severity) {
|
|
|
647
454
|
: SeverityCount.WARN_COUNT;
|
|
648
455
|
}
|
|
649
456
|
|
|
650
|
-
/**
|
|
651
|
-
* A safe hasOwnProperty access
|
|
652
|
-
*/
|
|
653
|
-
function hasOwnProperty(obj, key) {
|
|
654
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
function isNumber(value) {
|
|
658
|
-
return Boolean(typeof value === 'number');
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
function isEmpty(value) {
|
|
662
|
-
if (!value) {
|
|
663
|
-
return true;
|
|
664
|
-
}
|
|
665
|
-
else if (isNumber(value)) {
|
|
666
|
-
return value === 0;
|
|
667
|
-
}
|
|
668
|
-
else if (hasOwnProperty(value, 'length')) {
|
|
669
|
-
return lengthEquals(value, 0);
|
|
670
|
-
}
|
|
671
|
-
else if (typeof value === 'object') {
|
|
672
|
-
return lengthEquals(Object.keys(value), 0);
|
|
673
|
-
}
|
|
674
|
-
return false;
|
|
675
|
-
}
|
|
676
|
-
var isNotEmpty = bindNot(isEmpty);
|
|
677
|
-
|
|
678
457
|
function nonMatchingFieldName(testObject, fieldName) {
|
|
679
458
|
return !!fieldName && !matchingFieldName(testObject, fieldName);
|
|
680
459
|
}
|
|
@@ -687,10 +466,6 @@ function matchingGroupName(testObject, groupName) {
|
|
|
687
466
|
return testObject.groupName === groupName;
|
|
688
467
|
}
|
|
689
468
|
|
|
690
|
-
function either(a, b) {
|
|
691
|
-
return !!a !== !!b;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
469
|
/**
|
|
695
470
|
* Checks that a given test object matches the currently specified severity level
|
|
696
471
|
*/
|
|
@@ -914,10 +689,6 @@ function baseTestStats() {
|
|
|
914
689
|
});
|
|
915
690
|
}
|
|
916
691
|
|
|
917
|
-
function isPositive(value) {
|
|
918
|
-
return greaterThan(value, 0);
|
|
919
|
-
}
|
|
920
|
-
|
|
921
692
|
// calls collectAll or getByFieldName depending on whether fieldName is provided
|
|
922
693
|
function gatherFailures(testGroup, severityKey, fieldName) {
|
|
923
694
|
return fieldName
|
|
@@ -1034,7 +805,7 @@ function isFieldValid(testContainer, fieldName) {
|
|
|
1034
805
|
return !!((_a = testContainer[fieldName]) === null || _a === void 0 ? void 0 : _a.valid);
|
|
1035
806
|
}
|
|
1036
807
|
|
|
1037
|
-
var cache$1 =
|
|
808
|
+
var cache$1 = cache$2(1);
|
|
1038
809
|
function produceSuiteResult() {
|
|
1039
810
|
var testObjects = useTestsFlat();
|
|
1040
811
|
var ctxRef = { stateRef: useStateRef() };
|
|
@@ -1074,7 +845,7 @@ function hasRemainingTests(fieldName) {
|
|
|
1074
845
|
return isNotEmpty(allIncomplete);
|
|
1075
846
|
}
|
|
1076
847
|
|
|
1077
|
-
var cache =
|
|
848
|
+
var cache = cache$2(20);
|
|
1078
849
|
function produceFullResult() {
|
|
1079
850
|
var testObjects = useTestsFlat();
|
|
1080
851
|
var ctxRef = { stateRef: useStateRef() };
|
|
@@ -1133,28 +904,6 @@ function deferDoneCallback(doneCallback, fieldName) {
|
|
|
1133
904
|
});
|
|
1134
905
|
}
|
|
1135
906
|
|
|
1136
|
-
function createBus() {
|
|
1137
|
-
var listeners = {};
|
|
1138
|
-
return {
|
|
1139
|
-
emit: function (event, data) {
|
|
1140
|
-
listener(event).forEach(function (handler) {
|
|
1141
|
-
handler(data);
|
|
1142
|
-
});
|
|
1143
|
-
},
|
|
1144
|
-
on: function (event, handler) {
|
|
1145
|
-
listeners[event] = listener(event).concat(handler);
|
|
1146
|
-
return {
|
|
1147
|
-
off: function () {
|
|
1148
|
-
listeners[event] = listener(event).filter(function (h) { return h !== handler; });
|
|
1149
|
-
}
|
|
1150
|
-
};
|
|
1151
|
-
}
|
|
1152
|
-
};
|
|
1153
|
-
function listener(event) {
|
|
1154
|
-
return listeners[event] || [];
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
907
|
function omitOptionalFields() {
|
|
1159
908
|
var optionalFields = useOptionalFields()[0];
|
|
1160
909
|
if (isEmpty(optionalFields)) {
|
|
@@ -1162,7 +911,7 @@ function omitOptionalFields() {
|
|
|
1162
911
|
}
|
|
1163
912
|
var shouldOmit = {};
|
|
1164
913
|
useSetTests(function (tests) {
|
|
1165
|
-
return transform(tests, function (testObject) {
|
|
914
|
+
return nestedArray.transform(tests, function (testObject) {
|
|
1166
915
|
var fieldName = testObject.fieldName;
|
|
1167
916
|
if (hasOwnProperty(shouldOmit, fieldName)) {
|
|
1168
917
|
verifyAndOmit(testObject);
|
|
@@ -1193,14 +942,10 @@ function omitOptionalFields() {
|
|
|
1193
942
|
*/
|
|
1194
943
|
function removeTestFromState (testObject) {
|
|
1195
944
|
useSetTests(function (tests) {
|
|
1196
|
-
return transform(tests, function (test) { return (testObject !== test ? test : null); });
|
|
945
|
+
return nestedArray.transform(tests, function (test) { return (testObject !== test ? test : null); });
|
|
1197
946
|
});
|
|
1198
947
|
}
|
|
1199
948
|
|
|
1200
|
-
function callEach(arr) {
|
|
1201
|
-
return arr.forEach(function (fn) { return fn(); });
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
949
|
/**
|
|
1205
950
|
* Runs done callback per field when async tests are finished running.
|
|
1206
951
|
*/
|
|
@@ -1222,10 +967,10 @@ function runDoneCallbacks() {
|
|
|
1222
967
|
|
|
1223
968
|
// eslint-disable-next-line max-lines-per-function
|
|
1224
969
|
function initBus() {
|
|
1225
|
-
var
|
|
970
|
+
var vestBus = bus.createBus();
|
|
1226
971
|
// Report a the completion of a test. There may be other tests with the same
|
|
1227
972
|
// name that are still running, or not yet started.
|
|
1228
|
-
|
|
973
|
+
vestBus.on(Events.TEST_COMPLETED, function (testObject) {
|
|
1229
974
|
if (testObject.isCanceled()) {
|
|
1230
975
|
return;
|
|
1231
976
|
}
|
|
@@ -1233,21 +978,21 @@ function initBus() {
|
|
|
1233
978
|
runFieldCallbacks(testObject.fieldName);
|
|
1234
979
|
if (!hasRemainingTests()) {
|
|
1235
980
|
// When no more tests are running, emit the done event
|
|
1236
|
-
|
|
981
|
+
vestBus.emit(Events.ALL_RUNNING_TESTS_FINISHED);
|
|
1237
982
|
}
|
|
1238
983
|
});
|
|
1239
984
|
// Report that the suite completed its synchronous test run.
|
|
1240
985
|
// Async operations may still be running.
|
|
1241
|
-
|
|
986
|
+
vestBus.on(Events.SUITE_CALLBACK_DONE_RUNNING, function () {
|
|
1242
987
|
// Remove tests that are optional and need to be omitted
|
|
1243
988
|
omitOptionalFields();
|
|
1244
989
|
});
|
|
1245
990
|
// Called when all the tests, including async, are done running
|
|
1246
|
-
|
|
991
|
+
vestBus.on(Events.ALL_RUNNING_TESTS_FINISHED, function () {
|
|
1247
992
|
runDoneCallbacks();
|
|
1248
993
|
});
|
|
1249
994
|
// Removes a certain field from the state.
|
|
1250
|
-
|
|
995
|
+
vestBus.on(Events.REMOVE_FIELD, function (fieldName) {
|
|
1251
996
|
useEachTestObject(function (testObject) {
|
|
1252
997
|
if (matchingFieldName(testObject, fieldName)) {
|
|
1253
998
|
testObject.cancel();
|
|
@@ -1256,14 +1001,14 @@ function initBus() {
|
|
|
1256
1001
|
});
|
|
1257
1002
|
});
|
|
1258
1003
|
// Resets a certain field in the state.
|
|
1259
|
-
|
|
1004
|
+
vestBus.on(Events.RESET_FIELD, function (fieldName) {
|
|
1260
1005
|
useEachTestObject(function (testObject) {
|
|
1261
1006
|
if (matchingFieldName(testObject, fieldName)) {
|
|
1262
1007
|
testObject.reset();
|
|
1263
1008
|
}
|
|
1264
1009
|
});
|
|
1265
1010
|
});
|
|
1266
|
-
return
|
|
1011
|
+
return vestBus;
|
|
1267
1012
|
}
|
|
1268
1013
|
function useBus() {
|
|
1269
1014
|
var context$1 = context.useX();
|
|
@@ -1584,9 +1329,7 @@ function eager() {
|
|
|
1584
1329
|
setMode(Modes.EAGER);
|
|
1585
1330
|
}
|
|
1586
1331
|
function shouldSkipBasedOnMode(testObject) {
|
|
1587
|
-
|
|
1588
|
-
return true;
|
|
1589
|
-
return false;
|
|
1332
|
+
return isEager() && hasErrorsByTestObjects(testObject.fieldName);
|
|
1590
1333
|
}
|
|
1591
1334
|
function isEager() {
|
|
1592
1335
|
return isMode(Modes.EAGER);
|
|
@@ -1675,9 +1418,7 @@ function __spreadArray(to, from, pack) {
|
|
|
1675
1418
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1676
1419
|
}
|
|
1677
1420
|
|
|
1678
|
-
|
|
1679
|
-
return value && isFunction(value.then);
|
|
1680
|
-
}
|
|
1421
|
+
bindNot(isStringValue);
|
|
1681
1422
|
|
|
1682
1423
|
function isSameProfileTest(testObject1, testObject2) {
|
|
1683
1424
|
return (testObject1.fieldName === testObject2.fieldName &&
|
|
@@ -1793,31 +1534,24 @@ function useTestAtCursor(newTestObject) {
|
|
|
1793
1534
|
return nextTest;
|
|
1794
1535
|
}
|
|
1795
1536
|
function removeAllNextTestsInIsolate() {
|
|
1796
|
-
var _a = useTestObjects(), testObjects = _a[0], setTestObjects = _a[1];
|
|
1797
|
-
var prevTests = testObjects.prev;
|
|
1798
|
-
var current = getCurrent(prevTests, useCurrentPath());
|
|
1799
1537
|
var cursorAt = useCursor().current();
|
|
1800
|
-
current.splice(cursorAt);
|
|
1801
1538
|
// We actually don't mind mutating the state directly (as can be seen above). There is no harm in it
|
|
1802
1539
|
// since we're only touching the "prev" state. The reason we still use the setter function is
|
|
1803
1540
|
// to prevent future headaches if we ever do need to rely on prev-state immutability.
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
return
|
|
1807
|
-
prev: prevTests,
|
|
1808
|
-
current: current
|
|
1809
|
-
});
|
|
1541
|
+
useSetTests(function (current) {
|
|
1542
|
+
current.splice(cursorAt);
|
|
1543
|
+
return current;
|
|
1810
1544
|
});
|
|
1811
1545
|
}
|
|
1812
1546
|
function useSetTestAtCursor(testObject) {
|
|
1813
1547
|
var cursorPath = useCurrentPath();
|
|
1814
1548
|
useSetTests(function (tests) {
|
|
1815
|
-
return setValueAtPath(tests, cursorPath, testObject);
|
|
1549
|
+
return nestedArray.setValueAtPath(tests, cursorPath, testObject);
|
|
1816
1550
|
});
|
|
1817
1551
|
}
|
|
1818
1552
|
function useGetTestAtCursor(tests) {
|
|
1819
1553
|
var cursorPath = useCurrentPath();
|
|
1820
|
-
return valueAtPath(tests, cursorPath);
|
|
1554
|
+
return nestedArray.valueAtPath(tests, cursorPath);
|
|
1821
1555
|
}
|
|
1822
1556
|
function testReorderDetected(prevTest, newTest) {
|
|
1823
1557
|
return isNotEmpty(prevTest) && !isSameProfileTest(prevTest, newTest);
|
|
@@ -1881,7 +1615,7 @@ function registerTestObjectByTier(testObject) {
|
|
|
1881
1615
|
/* eslint-disable jest/valid-title */
|
|
1882
1616
|
// eslint-disable-next-line max-lines-per-function
|
|
1883
1617
|
function bindTestMemo(test) {
|
|
1884
|
-
var cache =
|
|
1618
|
+
var cache = cache$2(10); // arbitrary cache size
|
|
1885
1619
|
// eslint-disable-next-line max-statements
|
|
1886
1620
|
function memo(fieldName) {
|
|
1887
1621
|
var args = [];
|
|
@@ -1950,6 +1684,6 @@ function warn() {
|
|
|
1950
1684
|
ctx.currentTest.warn();
|
|
1951
1685
|
}
|
|
1952
1686
|
|
|
1953
|
-
var VERSION = "4.4.
|
|
1687
|
+
var VERSION = "4.4.2-dev-d13b14";
|
|
1954
1688
|
|
|
1955
1689
|
export { VERSION, context, create, each, eager, group, include, omitWhen, only, optional, skip, skipWhen, test, warn };
|