vest 4.4.0-dev-08ec91 → 4.4.2-dev-afe5de
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 +176 -390
- 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 +101 -315
- 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 +122 -122
- package/dist/umd/enforce/compose.production.js +1 -1
- package/dist/umd/enforce/compounds.development.js +181 -185
- package/dist/umd/enforce/compounds.production.js +1 -1
- package/dist/umd/enforce/schema.development.js +133 -133
- 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 +361 -376
- 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 +14 -15
- package/testUtils/itWithContext.ts +0 -23
|
@@ -4,12 +4,6 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.vest = {}));
|
|
5
5
|
}(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
var assign = Object.assign;
|
|
8
|
-
|
|
9
|
-
function isFunction(value) {
|
|
10
|
-
return typeof value === 'function';
|
|
11
|
-
}
|
|
12
|
-
|
|
13
7
|
function bindNot(fn) {
|
|
14
8
|
return function () {
|
|
15
9
|
var args = [];
|
|
@@ -20,6 +14,69 @@
|
|
|
20
14
|
};
|
|
21
15
|
}
|
|
22
16
|
|
|
17
|
+
function isNumeric(value) {
|
|
18
|
+
var str = String(value);
|
|
19
|
+
var num = Number(value);
|
|
20
|
+
var result = !isNaN(parseFloat(str)) && !isNaN(Number(value)) && isFinite(num);
|
|
21
|
+
return Boolean(result);
|
|
22
|
+
}
|
|
23
|
+
var isNotNumeric = bindNot(isNumeric);
|
|
24
|
+
|
|
25
|
+
function numberEquals(value, eq) {
|
|
26
|
+
return isNumeric(value) && isNumeric(eq) && Number(value) === Number(eq);
|
|
27
|
+
}
|
|
28
|
+
var numberNotEquals = bindNot(numberEquals);
|
|
29
|
+
|
|
30
|
+
function lengthEquals(value, arg1) {
|
|
31
|
+
return numberEquals(value.length, arg1);
|
|
32
|
+
}
|
|
33
|
+
var lengthNotEquals = bindNot(lengthEquals);
|
|
34
|
+
|
|
35
|
+
function greaterThan(value, gt) {
|
|
36
|
+
return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function longerThan(value, arg1) {
|
|
40
|
+
return greaterThan(value.length, arg1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Creates a cache function
|
|
45
|
+
*/
|
|
46
|
+
function createCache(maxSize) {
|
|
47
|
+
if (maxSize === void 0) { maxSize = 1; }
|
|
48
|
+
var cacheStorage = [];
|
|
49
|
+
var cache = function (deps, cacheAction) {
|
|
50
|
+
var cacheHit = cache.get(deps);
|
|
51
|
+
// cache hit is not null
|
|
52
|
+
if (cacheHit)
|
|
53
|
+
return cacheHit[1];
|
|
54
|
+
var result = cacheAction();
|
|
55
|
+
cacheStorage.unshift([deps.concat(), result]);
|
|
56
|
+
if (longerThan(cacheStorage, maxSize))
|
|
57
|
+
cacheStorage.length = maxSize;
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
// invalidate an item in the cache by its dependencies
|
|
61
|
+
cache.invalidate = function (deps) {
|
|
62
|
+
var index = findIndex(deps);
|
|
63
|
+
if (index > -1)
|
|
64
|
+
cacheStorage.splice(index, 1);
|
|
65
|
+
};
|
|
66
|
+
// Retrieves an item from the cache.
|
|
67
|
+
cache.get = function (deps) {
|
|
68
|
+
return cacheStorage[findIndex(deps)] || null;
|
|
69
|
+
};
|
|
70
|
+
return cache;
|
|
71
|
+
function findIndex(deps) {
|
|
72
|
+
return cacheStorage.findIndex(function (_a) {
|
|
73
|
+
var cachedDeps = _a[0];
|
|
74
|
+
return lengthEquals(deps, cachedDeps.length) &&
|
|
75
|
+
deps.every(function (dep, i) { return dep === cachedDeps[i]; });
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
23
80
|
function isNull(value) {
|
|
24
81
|
return value === null;
|
|
25
82
|
}
|
|
@@ -35,39 +92,25 @@
|
|
|
35
92
|
}
|
|
36
93
|
var isNotNullish = bindNot(isNullish);
|
|
37
94
|
|
|
38
|
-
function
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function endsWith(value, arg1) {
|
|
43
|
-
return isStringValue(value) && isStringValue(arg1) && value.endsWith(arg1);
|
|
44
|
-
}
|
|
45
|
-
var doesNotEndWith = bindNot(endsWith);
|
|
46
|
-
|
|
47
|
-
function equals(value, arg1) {
|
|
48
|
-
return value === arg1;
|
|
49
|
-
}
|
|
50
|
-
var notEquals = bindNot(equals);
|
|
51
|
-
|
|
52
|
-
function isNumeric(value) {
|
|
53
|
-
var str = String(value);
|
|
54
|
-
var num = Number(value);
|
|
55
|
-
var result = !isNaN(parseFloat(str)) && !isNaN(Number(value)) && isFinite(num);
|
|
56
|
-
return Boolean(result);
|
|
95
|
+
function asArray(possibleArg) {
|
|
96
|
+
return [].concat(possibleArg);
|
|
57
97
|
}
|
|
58
|
-
var isNotNumeric = bindNot(isNumeric);
|
|
59
98
|
|
|
60
|
-
function
|
|
61
|
-
return
|
|
99
|
+
function isFunction(value) {
|
|
100
|
+
return typeof value === 'function';
|
|
62
101
|
}
|
|
63
102
|
|
|
64
|
-
function
|
|
65
|
-
|
|
103
|
+
function optionalFunctionValue(value) {
|
|
104
|
+
var args = [];
|
|
105
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
106
|
+
args[_i - 1] = arguments[_i];
|
|
107
|
+
}
|
|
108
|
+
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
66
109
|
}
|
|
67
|
-
var numberNotEquals = bindNot(numberEquals);
|
|
68
110
|
|
|
69
|
-
function
|
|
70
|
-
|
|
111
|
+
function defaultTo(value, defaultValue) {
|
|
112
|
+
var _a;
|
|
113
|
+
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
71
114
|
}
|
|
72
115
|
|
|
73
116
|
// The module is named "isArrayValue" since it
|
|
@@ -78,66 +121,159 @@
|
|
|
78
121
|
}
|
|
79
122
|
var isNotArray = bindNot(isArray);
|
|
80
123
|
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
124
|
+
function last(values) {
|
|
125
|
+
var valuesArray = asArray(values);
|
|
126
|
+
return valuesArray[valuesArray.length - 1];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// This is kind of a map/filter in one function.
|
|
130
|
+
// Normally, behaves like a nested-array map,
|
|
131
|
+
// but returning `null` will drop the element from the array
|
|
132
|
+
function transform(array, cb) {
|
|
133
|
+
var res = [];
|
|
134
|
+
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
|
|
135
|
+
var v = array_1[_i];
|
|
136
|
+
if (isArray(v)) {
|
|
137
|
+
res.push(transform(v, cb));
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
var output = cb(v);
|
|
141
|
+
if (isNotNull(output)) {
|
|
142
|
+
res.push(output);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
84
145
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
146
|
+
return res;
|
|
147
|
+
}
|
|
148
|
+
function valueAtPath(array, path) {
|
|
149
|
+
return getCurrent(array, path)[last(path)];
|
|
150
|
+
}
|
|
151
|
+
function setValueAtPath(array, path, value) {
|
|
152
|
+
var current = getCurrent(array, path);
|
|
153
|
+
current[last(path)] = value;
|
|
154
|
+
return array;
|
|
155
|
+
}
|
|
156
|
+
function flatten(values) {
|
|
157
|
+
return asArray(values).reduce(function (acc, value) {
|
|
158
|
+
if (isArray(value)) {
|
|
159
|
+
return acc.concat(flatten(value));
|
|
160
|
+
}
|
|
161
|
+
return asArray(acc).concat(value);
|
|
162
|
+
}, []);
|
|
163
|
+
}
|
|
164
|
+
function getCurrent(array, path) {
|
|
165
|
+
var current = array;
|
|
166
|
+
for (var _i = 0, _a = path.slice(0, -1); _i < _a.length; _i++) {
|
|
167
|
+
var p = _a[_i];
|
|
168
|
+
current[p] = defaultTo(current[p], []);
|
|
169
|
+
current = current[p];
|
|
88
170
|
}
|
|
89
|
-
return
|
|
171
|
+
return current;
|
|
90
172
|
}
|
|
91
|
-
var notInside = bindNot(inside);
|
|
92
173
|
|
|
93
|
-
function
|
|
94
|
-
return
|
|
174
|
+
function callEach(arr) {
|
|
175
|
+
return arr.forEach(function (fn) { return fn(); });
|
|
95
176
|
}
|
|
96
177
|
|
|
97
|
-
|
|
98
|
-
|
|
178
|
+
/**
|
|
179
|
+
* A safe hasOwnProperty access
|
|
180
|
+
*/
|
|
181
|
+
function hasOwnProperty(obj, key) {
|
|
182
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
99
183
|
}
|
|
100
184
|
|
|
101
|
-
function
|
|
102
|
-
return
|
|
185
|
+
function isPromise(value) {
|
|
186
|
+
return value && isFunction(value.then);
|
|
103
187
|
}
|
|
104
|
-
var isNotBetween = bindNot(isBetween);
|
|
105
188
|
|
|
106
|
-
|
|
107
|
-
|
|
189
|
+
var assign = Object.assign;
|
|
190
|
+
|
|
191
|
+
function invariant(condition,
|
|
192
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
193
|
+
message) {
|
|
194
|
+
if (condition) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
// If message is a string object (rather than string literal)
|
|
198
|
+
// Throw the value directly as a string
|
|
199
|
+
// Alternatively, throw an error with the message
|
|
200
|
+
throw message instanceof String
|
|
201
|
+
? message.valueOf()
|
|
202
|
+
: new Error(message ? optionalFunctionValue(message) : message);
|
|
203
|
+
}
|
|
204
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
205
|
+
function StringObject(value) {
|
|
206
|
+
return new String(optionalFunctionValue(value));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function isStringValue(v) {
|
|
210
|
+
return String(v) === v;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function either(a, b) {
|
|
214
|
+
return !!a !== !!b;
|
|
108
215
|
}
|
|
109
|
-
var isNotBlank = bindNot(isBlank);
|
|
110
216
|
|
|
111
217
|
function isBoolean(value) {
|
|
112
218
|
return !!value === value;
|
|
113
219
|
}
|
|
114
220
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
*/
|
|
120
|
-
function hasOwnProperty(obj, key) {
|
|
121
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
221
|
+
function deferThrow(message) {
|
|
222
|
+
setTimeout(function () {
|
|
223
|
+
throw new Error(message);
|
|
224
|
+
}, 0);
|
|
122
225
|
}
|
|
123
226
|
|
|
124
|
-
function
|
|
125
|
-
|
|
227
|
+
function createBus() {
|
|
228
|
+
var listeners = {};
|
|
229
|
+
return {
|
|
230
|
+
emit: function (event, data) {
|
|
231
|
+
listener(event).forEach(function (handler) {
|
|
232
|
+
handler(data);
|
|
233
|
+
});
|
|
234
|
+
},
|
|
235
|
+
on: function (event, handler) {
|
|
236
|
+
listeners[event] = listener(event).concat(handler);
|
|
237
|
+
return {
|
|
238
|
+
off: function () {
|
|
239
|
+
listeners[event] = listener(event).filter(function (h) { return h !== handler; });
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
function listener(event) {
|
|
245
|
+
return listeners[event] || [];
|
|
246
|
+
}
|
|
126
247
|
}
|
|
127
|
-
var isNotNumber = bindNot(isNumber);
|
|
128
248
|
|
|
129
|
-
|
|
130
|
-
|
|
249
|
+
/**
|
|
250
|
+
* @returns a unique numeric id.
|
|
251
|
+
*/
|
|
252
|
+
var genId = (function (n) { return function () {
|
|
253
|
+
return "".concat(n++);
|
|
254
|
+
}; })(0);
|
|
255
|
+
|
|
256
|
+
function mapFirst(array, callback) {
|
|
257
|
+
var broke = false;
|
|
258
|
+
var breakoutValue = null;
|
|
259
|
+
for (var i = 0; i < array.length; i++) {
|
|
260
|
+
callback(array[i], breakout, i);
|
|
261
|
+
if (broke) {
|
|
262
|
+
return breakoutValue;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function breakout(conditional, value) {
|
|
266
|
+
if (conditional) {
|
|
267
|
+
broke = true;
|
|
268
|
+
breakoutValue = value;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
131
271
|
}
|
|
132
|
-
var lengthNotEquals = bindNot(lengthEquals);
|
|
133
272
|
|
|
134
273
|
function isEmpty(value) {
|
|
135
274
|
if (!value) {
|
|
136
275
|
return true;
|
|
137
276
|
}
|
|
138
|
-
else if (isNumber(value)) {
|
|
139
|
-
return value === 0;
|
|
140
|
-
}
|
|
141
277
|
else if (hasOwnProperty(value, 'length')) {
|
|
142
278
|
return lengthEquals(value, 0);
|
|
143
279
|
}
|
|
@@ -148,6 +284,56 @@
|
|
|
148
284
|
}
|
|
149
285
|
var isNotEmpty = bindNot(isEmpty);
|
|
150
286
|
|
|
287
|
+
function isPositive(value) {
|
|
288
|
+
return greaterThan(value, 0);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function endsWith(value, arg1) {
|
|
292
|
+
return isStringValue(value) && isStringValue(arg1) && value.endsWith(arg1);
|
|
293
|
+
}
|
|
294
|
+
var doesNotEndWith = bindNot(endsWith);
|
|
295
|
+
|
|
296
|
+
function equals(value, arg1) {
|
|
297
|
+
return value === arg1;
|
|
298
|
+
}
|
|
299
|
+
var notEquals = bindNot(equals);
|
|
300
|
+
|
|
301
|
+
function greaterThanOrEquals(value, gte) {
|
|
302
|
+
return numberEquals(value, gte) || greaterThan(value, gte);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function inside(value, arg1) {
|
|
306
|
+
if (isArray(arg1)) {
|
|
307
|
+
return arg1.indexOf(value) !== -1;
|
|
308
|
+
}
|
|
309
|
+
// both value and arg1 are strings
|
|
310
|
+
if (isStringValue(arg1) && isStringValue(value)) {
|
|
311
|
+
return arg1.indexOf(value) !== -1;
|
|
312
|
+
}
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
var notInside = bindNot(inside);
|
|
316
|
+
|
|
317
|
+
function lessThan(value, lt) {
|
|
318
|
+
return isNumeric(value) && isNumeric(lt) && Number(value) < Number(lt);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function lessThanOrEquals(value, lte) {
|
|
322
|
+
return numberEquals(value, lte) || lessThan(value, lte);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function isBetween(value, min, max) {
|
|
326
|
+
return greaterThanOrEquals(value, min) && lessThanOrEquals(value, max);
|
|
327
|
+
}
|
|
328
|
+
var isNotBetween = bindNot(isBetween);
|
|
329
|
+
|
|
330
|
+
function isBlank(value) {
|
|
331
|
+
return isNullish(value) || (isStringValue(value) && !value.trim());
|
|
332
|
+
}
|
|
333
|
+
var isNotBlank = bindNot(isBlank);
|
|
334
|
+
|
|
335
|
+
var isNotBoolean = bindNot(isBoolean);
|
|
336
|
+
|
|
151
337
|
/**
|
|
152
338
|
* Validates that a given value is an even number
|
|
153
339
|
*/
|
|
@@ -172,6 +358,11 @@
|
|
|
172
358
|
return lessThan(value, 0);
|
|
173
359
|
}
|
|
174
360
|
|
|
361
|
+
function isNumber(value) {
|
|
362
|
+
return Boolean(typeof value === 'number');
|
|
363
|
+
}
|
|
364
|
+
var isNotNumber = bindNot(isNumber);
|
|
365
|
+
|
|
175
366
|
/**
|
|
176
367
|
* Validates that a given value is an odd number
|
|
177
368
|
*/
|
|
@@ -182,10 +373,6 @@
|
|
|
182
373
|
return false;
|
|
183
374
|
};
|
|
184
375
|
|
|
185
|
-
function isPositive(value) {
|
|
186
|
-
return greaterThan(value, 0);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
376
|
var isNotString = bindNot(isStringValue);
|
|
190
377
|
|
|
191
378
|
function isTruthy(value) {
|
|
@@ -206,10 +393,6 @@
|
|
|
206
393
|
}
|
|
207
394
|
var isNotValueOf = bindNot(isValueOf);
|
|
208
395
|
|
|
209
|
-
function longerThan(value, arg1) {
|
|
210
|
-
return greaterThan(value.length, arg1);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
396
|
function longerThanOrEquals(value, arg1) {
|
|
214
397
|
return greaterThanOrEquals(value.length, arg1);
|
|
215
398
|
}
|
|
@@ -330,33 +513,6 @@
|
|
|
330
513
|
}
|
|
331
514
|
}
|
|
332
515
|
|
|
333
|
-
function optionalFunctionValue(value) {
|
|
334
|
-
var args = [];
|
|
335
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
336
|
-
args[_i - 1] = arguments[_i];
|
|
337
|
-
}
|
|
338
|
-
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
function defaultTo(callback, defaultValue) {
|
|
342
|
-
var _a;
|
|
343
|
-
return (_a = optionalFunctionValue(callback)) !== null && _a !== void 0 ? _a : defaultValue;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
function invariant(condition,
|
|
347
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
348
|
-
message) {
|
|
349
|
-
if (condition) {
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
// If message is a string object (rather than string literal)
|
|
353
|
-
// Throw the value directly as a string
|
|
354
|
-
// Alternatively, throw an error with the message
|
|
355
|
-
throw message instanceof String
|
|
356
|
-
? message.valueOf()
|
|
357
|
-
: new Error(message ? optionalFunctionValue(message) : message);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
516
|
// eslint-disable-next-line max-lines-per-function
|
|
361
517
|
function createContext(init) {
|
|
362
518
|
var storage = { ancestry: [] };
|
|
@@ -367,8 +523,9 @@
|
|
|
367
523
|
useX: useX
|
|
368
524
|
};
|
|
369
525
|
function useX(errorMessage) {
|
|
370
|
-
|
|
371
|
-
|
|
526
|
+
var ctx = use();
|
|
527
|
+
invariant(ctx, defaultTo(errorMessage, 'Context was used after it was closed'));
|
|
528
|
+
return ctx;
|
|
372
529
|
}
|
|
373
530
|
function run(ctxRef, fn) {
|
|
374
531
|
var _a;
|
|
@@ -438,7 +595,7 @@
|
|
|
438
595
|
return null;
|
|
439
596
|
}
|
|
440
597
|
|
|
441
|
-
|
|
598
|
+
/******************************************************************************
|
|
442
599
|
Copyright (c) Microsoft Corporation.
|
|
443
600
|
|
|
444
601
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -531,32 +688,17 @@
|
|
|
531
688
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
532
689
|
args[_i] = arguments[_i];
|
|
533
690
|
}
|
|
534
|
-
var transformedResult =
|
|
535
|
-
ruleName,
|
|
536
|
-
|
|
537
|
-
invariant(transformedResult.pass,
|
|
691
|
+
var transformedResult = ctx.run({ value: value }, function () {
|
|
692
|
+
return transformResult.apply(void 0, __spreadArray([rule.apply(void 0, __spreadArray([value], args, false)), ruleName, value], args, false));
|
|
693
|
+
});
|
|
694
|
+
invariant(transformedResult.pass, isNullish(transformedResult.message)
|
|
538
695
|
? "enforce/".concat(ruleName, " failed with ").concat(JSON.stringify(value))
|
|
539
|
-
:
|
|
696
|
+
: StringObject(transformedResult.message));
|
|
540
697
|
return target;
|
|
541
698
|
};
|
|
542
699
|
}
|
|
543
700
|
}
|
|
544
701
|
|
|
545
|
-
function mapFirst(array, callback) {
|
|
546
|
-
var broke = false;
|
|
547
|
-
var breakoutValue = null;
|
|
548
|
-
for (var i = 0; i < array.length; i++) {
|
|
549
|
-
callback(array[i], breakout, i);
|
|
550
|
-
if (broke) {
|
|
551
|
-
return breakoutValue;
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
function breakout(value) {
|
|
555
|
-
broke = true;
|
|
556
|
-
breakoutValue = value;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
|
|
560
702
|
// eslint-disable-next-line max-lines-per-function
|
|
561
703
|
function genEnforceLazy(key) {
|
|
562
704
|
var registeredRules = [];
|
|
@@ -579,9 +721,7 @@
|
|
|
579
721
|
return defaultToPassing(mapFirst(registeredRules, function (rule, breakout) {
|
|
580
722
|
var _a;
|
|
581
723
|
var res = ctx.run({ value: value }, function () { return rule(value); });
|
|
582
|
-
|
|
583
|
-
breakout(ruleReturn(!!res.pass, (_a = optionalFunctionValue(lazyMessage, value, res.message)) !== null && _a !== void 0 ? _a : res.message));
|
|
584
|
-
}
|
|
724
|
+
breakout(!res.pass, ruleReturn(!!res.pass, (_a = optionalFunctionValue(lazyMessage, value, res.message)) !== null && _a !== void 0 ? _a : res.message));
|
|
585
725
|
}));
|
|
586
726
|
},
|
|
587
727
|
test: function (value) { return proxy.run(value).pass; },
|
|
@@ -672,143 +812,11 @@
|
|
|
672
812
|
}
|
|
673
813
|
var enforce = genEnforce();
|
|
674
814
|
|
|
675
|
-
/**
|
|
676
|
-
* @returns a unique numeric id.
|
|
677
|
-
*/
|
|
678
|
-
var genId = (function (n) { return function () {
|
|
679
|
-
return "".concat(n++);
|
|
680
|
-
}; })(0);
|
|
681
|
-
|
|
682
815
|
function shouldUseErrorAsMessage(message, error) {
|
|
683
816
|
// kind of cheating with this safe guard, but it does the job
|
|
684
817
|
return isUndefined(message) && isStringValue(error);
|
|
685
818
|
}
|
|
686
819
|
|
|
687
|
-
function asArray(possibleArg) {
|
|
688
|
-
return [].concat(possibleArg);
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
/**
|
|
692
|
-
* Creates a cache function
|
|
693
|
-
*/
|
|
694
|
-
function createCache(maxSize) {
|
|
695
|
-
if (maxSize === void 0) { maxSize = 1; }
|
|
696
|
-
var cacheStorage = [];
|
|
697
|
-
var cache = function (deps, cacheAction) {
|
|
698
|
-
var cacheHit = cache.get(deps);
|
|
699
|
-
// cache hit is not null
|
|
700
|
-
if (cacheHit)
|
|
701
|
-
return cacheHit[1];
|
|
702
|
-
var result = cacheAction();
|
|
703
|
-
cacheStorage.unshift([deps.concat(), result]);
|
|
704
|
-
if (longerThan(cacheStorage, maxSize))
|
|
705
|
-
cacheStorage.length = maxSize;
|
|
706
|
-
return result;
|
|
707
|
-
};
|
|
708
|
-
// invalidate an item in the cache by its dependencies
|
|
709
|
-
cache.invalidate = function (deps) {
|
|
710
|
-
var index = findIndex(deps);
|
|
711
|
-
if (index > -1)
|
|
712
|
-
cacheStorage.splice(index, 1);
|
|
713
|
-
};
|
|
714
|
-
// Retrieves an item from the cache.
|
|
715
|
-
cache.get = function (deps) {
|
|
716
|
-
return cacheStorage[findIndex(deps)] || null;
|
|
717
|
-
};
|
|
718
|
-
return cache;
|
|
719
|
-
function findIndex(deps) {
|
|
720
|
-
return cacheStorage.findIndex(function (_a) {
|
|
721
|
-
var cachedDeps = _a[0];
|
|
722
|
-
return lengthEquals(deps, cachedDeps.length) &&
|
|
723
|
-
deps.every(function (dep, i) { return dep === cachedDeps[i]; });
|
|
724
|
-
});
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
function last(values) {
|
|
729
|
-
var valuesArray = asArray(values);
|
|
730
|
-
return valuesArray[valuesArray.length - 1];
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
// This is kind of a map/filter in one function.
|
|
734
|
-
// Normally, behaves like a nested-array map,
|
|
735
|
-
// but returning `null` will drop the element from the array
|
|
736
|
-
function transform(array, cb) {
|
|
737
|
-
var res = [];
|
|
738
|
-
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
|
|
739
|
-
var v = array_1[_i];
|
|
740
|
-
if (isArray(v)) {
|
|
741
|
-
res.push(transform(v, cb));
|
|
742
|
-
}
|
|
743
|
-
else {
|
|
744
|
-
var output = cb(v);
|
|
745
|
-
if (isNotNull(output)) {
|
|
746
|
-
res.push(output);
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
return res;
|
|
751
|
-
}
|
|
752
|
-
function valueAtPath(array, path) {
|
|
753
|
-
return getCurrent(array, path)[last(path)];
|
|
754
|
-
}
|
|
755
|
-
function setValueAtPath(array, path, value) {
|
|
756
|
-
var current = getCurrent(array, path);
|
|
757
|
-
current[last(path)] = value;
|
|
758
|
-
return array;
|
|
759
|
-
}
|
|
760
|
-
function flatten(values) {
|
|
761
|
-
return asArray(values).reduce(function (acc, value) {
|
|
762
|
-
if (isArray(value)) {
|
|
763
|
-
return acc.concat(flatten(value));
|
|
764
|
-
}
|
|
765
|
-
return asArray(acc).concat(value);
|
|
766
|
-
}, []);
|
|
767
|
-
}
|
|
768
|
-
function getCurrent(array, path) {
|
|
769
|
-
var current = array;
|
|
770
|
-
for (var _i = 0, _a = path.slice(0, -1); _i < _a.length; _i++) {
|
|
771
|
-
var p = _a[_i];
|
|
772
|
-
current[p] = defaultTo(current[p], []);
|
|
773
|
-
current = current[p];
|
|
774
|
-
}
|
|
775
|
-
return current;
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
function createCursor() {
|
|
779
|
-
var storage = {
|
|
780
|
-
cursor: []
|
|
781
|
-
};
|
|
782
|
-
function addLevel() {
|
|
783
|
-
storage.cursor.push(0);
|
|
784
|
-
}
|
|
785
|
-
function removeLevel() {
|
|
786
|
-
storage.cursor.pop();
|
|
787
|
-
}
|
|
788
|
-
function cursorAt() {
|
|
789
|
-
return last(storage.cursor);
|
|
790
|
-
}
|
|
791
|
-
function getCursor() {
|
|
792
|
-
return asArray(storage.cursor);
|
|
793
|
-
}
|
|
794
|
-
function next() {
|
|
795
|
-
storage.cursor[storage.cursor.length - 1]++;
|
|
796
|
-
return last(storage.cursor);
|
|
797
|
-
}
|
|
798
|
-
function reset() {
|
|
799
|
-
storage.cursor = [0];
|
|
800
|
-
}
|
|
801
|
-
reset();
|
|
802
|
-
return {
|
|
803
|
-
addLevel: addLevel,
|
|
804
|
-
cursorAt: cursorAt,
|
|
805
|
-
getCursor: getCursor,
|
|
806
|
-
next: next,
|
|
807
|
-
removeLevel: removeLevel,
|
|
808
|
-
reset: reset
|
|
809
|
-
};
|
|
810
|
-
}
|
|
811
|
-
|
|
812
820
|
var IsolateTypes;
|
|
813
821
|
(function (IsolateTypes) {
|
|
814
822
|
IsolateTypes[IsolateTypes["DEFAULT"] = 0] = "DEFAULT";
|
|
@@ -825,6 +833,41 @@
|
|
|
825
833
|
Modes[Modes["EAGER"] = 1] = "EAGER";
|
|
826
834
|
})(Modes || (Modes = {}));
|
|
827
835
|
|
|
836
|
+
function createIsolateCursor() {
|
|
837
|
+
var cursor = {
|
|
838
|
+
value: 0
|
|
839
|
+
};
|
|
840
|
+
return {
|
|
841
|
+
current: current,
|
|
842
|
+
next: next
|
|
843
|
+
};
|
|
844
|
+
/**
|
|
845
|
+
* @returns {number} The current value of the cursor
|
|
846
|
+
*/
|
|
847
|
+
function current() {
|
|
848
|
+
return cursor.value;
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Moves the isolate cursor forward by 1
|
|
852
|
+
*/
|
|
853
|
+
function next() {
|
|
854
|
+
cursor.value++;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
function generateIsolate(type, path) {
|
|
859
|
+
if (path === void 0) { path = []; }
|
|
860
|
+
return {
|
|
861
|
+
cursor: createIsolateCursor(),
|
|
862
|
+
keys: {
|
|
863
|
+
current: {},
|
|
864
|
+
prev: {}
|
|
865
|
+
},
|
|
866
|
+
path: path,
|
|
867
|
+
type: type
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
|
|
828
871
|
var context = createContext(function (ctxRef, parentContext) {
|
|
829
872
|
return parentContext
|
|
830
873
|
? null
|
|
@@ -834,15 +877,8 @@
|
|
|
834
877
|
groups: {}
|
|
835
878
|
},
|
|
836
879
|
inclusion: {},
|
|
837
|
-
isolate:
|
|
838
|
-
|
|
839
|
-
keys: {
|
|
840
|
-
current: {},
|
|
841
|
-
prev: {}
|
|
842
|
-
}
|
|
843
|
-
},
|
|
844
|
-
mode: [Modes.ALL],
|
|
845
|
-
testCursor: createCursor()
|
|
880
|
+
isolate: generateIsolate(IsolateTypes.DEFAULT),
|
|
881
|
+
mode: [Modes.ALL]
|
|
846
882
|
}, ctxRef);
|
|
847
883
|
});
|
|
848
884
|
|
|
@@ -1144,36 +1180,9 @@
|
|
|
1144
1180
|
};
|
|
1145
1181
|
}
|
|
1146
1182
|
|
|
1147
|
-
function deferThrow(message) {
|
|
1148
|
-
setTimeout(function () {
|
|
1149
|
-
throw new Error(message);
|
|
1150
|
-
}, 0);
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
function usePath() {
|
|
1154
|
-
var context$1 = context.useX();
|
|
1155
|
-
return context$1.testCursor.getCursor();
|
|
1156
|
-
}
|
|
1157
|
-
function useCursorAt() {
|
|
1158
|
-
var context$1 = context.useX();
|
|
1159
|
-
return context$1.testCursor.cursorAt();
|
|
1160
|
-
}
|
|
1161
|
-
function moveForward() {
|
|
1162
|
-
var context$1 = context.useX();
|
|
1163
|
-
return context$1.testCursor.next();
|
|
1164
|
-
}
|
|
1165
|
-
function addLevel() {
|
|
1166
|
-
var context$1 = context.useX();
|
|
1167
|
-
context$1.testCursor.addLevel();
|
|
1168
|
-
}
|
|
1169
|
-
function removeLevel() {
|
|
1170
|
-
var context$1 = context.useX();
|
|
1171
|
-
context$1.testCursor.removeLevel();
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
1183
|
function usePrevKeys() {
|
|
1175
1184
|
var prev = useTestObjects()[0].prev;
|
|
1176
|
-
return asArray(getCurrent(prev,
|
|
1185
|
+
return asArray(getCurrent(prev, useCurrentPath())).reduce(function (prevKeys, testObject) {
|
|
1177
1186
|
if (!(testObject instanceof VestTest)) {
|
|
1178
1187
|
return prevKeys;
|
|
1179
1188
|
}
|
|
@@ -1185,12 +1194,11 @@
|
|
|
1185
1194
|
}, {});
|
|
1186
1195
|
}
|
|
1187
1196
|
function usePrevTestByKey(key) {
|
|
1188
|
-
var prev =
|
|
1197
|
+
var prev = useIsolate().keys.prev;
|
|
1189
1198
|
return prev[key];
|
|
1190
1199
|
}
|
|
1191
1200
|
function useRetainTestKey(key, testObject) {
|
|
1192
|
-
var
|
|
1193
|
-
var current = context$1.isolate.keys.current;
|
|
1201
|
+
var current = useIsolate().keys.current;
|
|
1194
1202
|
if (isNullish(current[key])) {
|
|
1195
1203
|
current[key] = testObject;
|
|
1196
1204
|
}
|
|
@@ -1202,23 +1210,42 @@
|
|
|
1202
1210
|
function isolate(_a, callback) {
|
|
1203
1211
|
var _b = _a.type, type = _b === void 0 ? IsolateTypes.DEFAULT : _b;
|
|
1204
1212
|
invariant(isFunction(callback));
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
return context.run({ isolate: { type: type, keys: keys } }, function () {
|
|
1211
|
-
addLevel();
|
|
1212
|
-
keys.prev = usePrevKeys();
|
|
1213
|
-
useSetTests(function (tests) { return setValueAtPath(tests, path, []); });
|
|
1213
|
+
// Generate a new Isolate layer, with its own cursor
|
|
1214
|
+
var isolate = generateIsolate(type, useCurrentPath());
|
|
1215
|
+
var output = context.run({ isolate: isolate }, function () {
|
|
1216
|
+
isolate.keys.prev = usePrevKeys();
|
|
1217
|
+
useSetTests(function (tests) { return setValueAtPath(tests, isolate.path, []); });
|
|
1214
1218
|
var res = callback();
|
|
1215
|
-
removeLevel();
|
|
1216
|
-
moveForward();
|
|
1217
1219
|
return res;
|
|
1218
1220
|
});
|
|
1221
|
+
// Move the parent cursor forward once we're done
|
|
1222
|
+
useCursor().next();
|
|
1223
|
+
return output;
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* @returns {Isolate} The current isolate layer
|
|
1227
|
+
*/
|
|
1228
|
+
function useIsolate() {
|
|
1229
|
+
return context.useX().isolate;
|
|
1219
1230
|
}
|
|
1231
|
+
/**
|
|
1232
|
+
* @returns {boolean} Whether or not the current isolate allows tests to be reordered
|
|
1233
|
+
*/
|
|
1220
1234
|
function shouldAllowReorder() {
|
|
1221
|
-
return
|
|
1235
|
+
return useIsolate().type === IsolateTypes.EACH;
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* @returns {number[]} The current cursor path of the isolate tree
|
|
1239
|
+
*/
|
|
1240
|
+
function useCurrentPath() {
|
|
1241
|
+
var isolate = useIsolate();
|
|
1242
|
+
return isolate.path.concat(isolate.cursor.current());
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* @returns {IsolateCursor} The cursor object for the current isolate
|
|
1246
|
+
*/
|
|
1247
|
+
function useCursor() {
|
|
1248
|
+
return useIsolate().cursor;
|
|
1222
1249
|
}
|
|
1223
1250
|
|
|
1224
1251
|
var Severity;
|
|
@@ -1249,10 +1276,6 @@
|
|
|
1249
1276
|
return testObject.groupName === groupName;
|
|
1250
1277
|
}
|
|
1251
1278
|
|
|
1252
|
-
function either(a, b) {
|
|
1253
|
-
return !!a !== !!b;
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
1279
|
/**
|
|
1257
1280
|
* Checks that a given test object matches the currently specified severity level
|
|
1258
1281
|
*/
|
|
@@ -1691,28 +1714,6 @@
|
|
|
1691
1714
|
});
|
|
1692
1715
|
}
|
|
1693
1716
|
|
|
1694
|
-
function createBus() {
|
|
1695
|
-
var listeners = {};
|
|
1696
|
-
return {
|
|
1697
|
-
emit: function (event, data) {
|
|
1698
|
-
listener(event).forEach(function (handler) {
|
|
1699
|
-
handler(data);
|
|
1700
|
-
});
|
|
1701
|
-
},
|
|
1702
|
-
on: function (event, handler) {
|
|
1703
|
-
listeners[event] = listener(event).concat(handler);
|
|
1704
|
-
return {
|
|
1705
|
-
off: function () {
|
|
1706
|
-
listeners[event] = listener(event).filter(function (h) { return h !== handler; });
|
|
1707
|
-
}
|
|
1708
|
-
};
|
|
1709
|
-
}
|
|
1710
|
-
};
|
|
1711
|
-
function listener(event) {
|
|
1712
|
-
return listeners[event] || [];
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
1717
|
function omitOptionalFields() {
|
|
1717
1718
|
var optionalFields = useOptionalFields()[0];
|
|
1718
1719
|
if (isEmpty(optionalFields)) {
|
|
@@ -1755,10 +1756,6 @@
|
|
|
1755
1756
|
});
|
|
1756
1757
|
}
|
|
1757
1758
|
|
|
1758
|
-
function callEach(arr) {
|
|
1759
|
-
return arr.forEach(function (fn) { return fn(); });
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
1759
|
/**
|
|
1763
1760
|
* Runs done callback per field when async tests are finished running.
|
|
1764
1761
|
*/
|
|
@@ -1780,10 +1777,10 @@
|
|
|
1780
1777
|
|
|
1781
1778
|
// eslint-disable-next-line max-lines-per-function
|
|
1782
1779
|
function initBus() {
|
|
1783
|
-
var
|
|
1780
|
+
var vestBus = createBus();
|
|
1784
1781
|
// Report a the completion of a test. There may be other tests with the same
|
|
1785
1782
|
// name that are still running, or not yet started.
|
|
1786
|
-
|
|
1783
|
+
vestBus.on(Events.TEST_COMPLETED, function (testObject) {
|
|
1787
1784
|
if (testObject.isCanceled()) {
|
|
1788
1785
|
return;
|
|
1789
1786
|
}
|
|
@@ -1791,21 +1788,21 @@
|
|
|
1791
1788
|
runFieldCallbacks(testObject.fieldName);
|
|
1792
1789
|
if (!hasRemainingTests()) {
|
|
1793
1790
|
// When no more tests are running, emit the done event
|
|
1794
|
-
|
|
1791
|
+
vestBus.emit(Events.ALL_RUNNING_TESTS_FINISHED);
|
|
1795
1792
|
}
|
|
1796
1793
|
});
|
|
1797
1794
|
// Report that the suite completed its synchronous test run.
|
|
1798
1795
|
// Async operations may still be running.
|
|
1799
|
-
|
|
1796
|
+
vestBus.on(Events.SUITE_CALLBACK_DONE_RUNNING, function () {
|
|
1800
1797
|
// Remove tests that are optional and need to be omitted
|
|
1801
1798
|
omitOptionalFields();
|
|
1802
1799
|
});
|
|
1803
1800
|
// Called when all the tests, including async, are done running
|
|
1804
|
-
|
|
1801
|
+
vestBus.on(Events.ALL_RUNNING_TESTS_FINISHED, function () {
|
|
1805
1802
|
runDoneCallbacks();
|
|
1806
1803
|
});
|
|
1807
1804
|
// Removes a certain field from the state.
|
|
1808
|
-
|
|
1805
|
+
vestBus.on(Events.REMOVE_FIELD, function (fieldName) {
|
|
1809
1806
|
useEachTestObject(function (testObject) {
|
|
1810
1807
|
if (matchingFieldName(testObject, fieldName)) {
|
|
1811
1808
|
testObject.cancel();
|
|
@@ -1814,14 +1811,14 @@
|
|
|
1814
1811
|
});
|
|
1815
1812
|
});
|
|
1816
1813
|
// Resets a certain field in the state.
|
|
1817
|
-
|
|
1814
|
+
vestBus.on(Events.RESET_FIELD, function (fieldName) {
|
|
1818
1815
|
useEachTestObject(function (testObject) {
|
|
1819
1816
|
if (matchingFieldName(testObject, fieldName)) {
|
|
1820
1817
|
testObject.reset();
|
|
1821
1818
|
}
|
|
1822
1819
|
});
|
|
1823
1820
|
});
|
|
1824
|
-
return
|
|
1821
|
+
return vestBus;
|
|
1825
1822
|
}
|
|
1826
1823
|
function useBus() {
|
|
1827
1824
|
var context$1 = context.useX();
|
|
@@ -2142,9 +2139,7 @@
|
|
|
2142
2139
|
setMode(Modes.EAGER);
|
|
2143
2140
|
}
|
|
2144
2141
|
function shouldSkipBasedOnMode(testObject) {
|
|
2145
|
-
|
|
2146
|
-
return true;
|
|
2147
|
-
return false;
|
|
2142
|
+
return isEager() && hasErrorsByTestObjects(testObject.fieldName);
|
|
2148
2143
|
}
|
|
2149
2144
|
function isEager() {
|
|
2150
2145
|
return isMode(Modes.EAGER);
|
|
@@ -2208,10 +2203,6 @@
|
|
|
2208
2203
|
}
|
|
2209
2204
|
}
|
|
2210
2205
|
|
|
2211
|
-
function isPromise(value) {
|
|
2212
|
-
return value && isFunction(value.then);
|
|
2213
|
-
}
|
|
2214
|
-
|
|
2215
2206
|
function isSameProfileTest(testObject1, testObject2) {
|
|
2216
2207
|
return (testObject1.fieldName === testObject2.fieldName &&
|
|
2217
2208
|
testObject1.groupName === testObject2.groupName);
|
|
@@ -2326,30 +2317,23 @@
|
|
|
2326
2317
|
return nextTest;
|
|
2327
2318
|
}
|
|
2328
2319
|
function removeAllNextTestsInIsolate() {
|
|
2329
|
-
var
|
|
2330
|
-
var prevTests = testObjects.prev;
|
|
2331
|
-
var current = getCurrent(prevTests, usePath());
|
|
2332
|
-
var cursorAt = useCursorAt();
|
|
2333
|
-
current.splice(cursorAt);
|
|
2320
|
+
var cursorAt = useCursor().current();
|
|
2334
2321
|
// We actually don't mind mutating the state directly (as can be seen above). There is no harm in it
|
|
2335
2322
|
// since we're only touching the "prev" state. The reason we still use the setter function is
|
|
2336
2323
|
// to prevent future headaches if we ever do need to rely on prev-state immutability.
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
return
|
|
2340
|
-
prev: prevTests,
|
|
2341
|
-
current: current
|
|
2342
|
-
});
|
|
2324
|
+
useSetTests(function (current) {
|
|
2325
|
+
current.splice(cursorAt);
|
|
2326
|
+
return current;
|
|
2343
2327
|
});
|
|
2344
2328
|
}
|
|
2345
2329
|
function useSetTestAtCursor(testObject) {
|
|
2346
|
-
var cursorPath =
|
|
2330
|
+
var cursorPath = useCurrentPath();
|
|
2347
2331
|
useSetTests(function (tests) {
|
|
2348
2332
|
return setValueAtPath(tests, cursorPath, testObject);
|
|
2349
2333
|
});
|
|
2350
2334
|
}
|
|
2351
2335
|
function useGetTestAtCursor(tests) {
|
|
2352
|
-
var cursorPath =
|
|
2336
|
+
var cursorPath = useCurrentPath();
|
|
2353
2337
|
return valueAtPath(tests, cursorPath);
|
|
2354
2338
|
}
|
|
2355
2339
|
function testReorderDetected(prevTest, newTest) {
|
|
@@ -2373,16 +2357,17 @@
|
|
|
2373
2357
|
|
|
2374
2358
|
// eslint-disable-next-line max-statements
|
|
2375
2359
|
function registerPrevRunTest(testObject) {
|
|
2360
|
+
var cursor = useCursor();
|
|
2376
2361
|
if (shouldSkipBasedOnMode(testObject)) {
|
|
2377
2362
|
testObject.skip();
|
|
2378
2363
|
useTestAtCursor(testObject);
|
|
2379
|
-
|
|
2364
|
+
cursor.next();
|
|
2380
2365
|
return testObject;
|
|
2381
2366
|
}
|
|
2382
2367
|
var prevRunTest = useTestAtCursor(testObject);
|
|
2383
2368
|
if (isOmitted()) {
|
|
2384
2369
|
prevRunTest.omit();
|
|
2385
|
-
|
|
2370
|
+
cursor.next();
|
|
2386
2371
|
return prevRunTest;
|
|
2387
2372
|
}
|
|
2388
2373
|
if (isExcluded(testObject)) {
|
|
@@ -2391,13 +2376,13 @@
|
|
|
2391
2376
|
// This mostly means that we're probably giving
|
|
2392
2377
|
// up on this async test intentionally.
|
|
2393
2378
|
prevRunTest.skip(isExcludedIndividually());
|
|
2394
|
-
|
|
2379
|
+
cursor.next();
|
|
2395
2380
|
return prevRunTest;
|
|
2396
2381
|
}
|
|
2397
2382
|
cancelOverriddenPendingTest(prevRunTest, testObject);
|
|
2398
2383
|
useSetTestAtCursor(testObject);
|
|
2399
|
-
moveForward();
|
|
2400
2384
|
registerTestObjectByTier(testObject);
|
|
2385
|
+
cursor.next();
|
|
2401
2386
|
return testObject;
|
|
2402
2387
|
}
|
|
2403
2388
|
function registerTestObjectByTier(testObject) {
|
|
@@ -2420,7 +2405,7 @@
|
|
|
2420
2405
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2421
2406
|
args[_i - 1] = arguments[_i];
|
|
2422
2407
|
}
|
|
2423
|
-
var cursorAt =
|
|
2408
|
+
var cursorAt = useCursor().current();
|
|
2424
2409
|
var _a = args.reverse(), deps = _a[0], testFn = _a[1], msg = _a[2];
|
|
2425
2410
|
// Implicit dependency for more specificity
|
|
2426
2411
|
var dependencies = [useSuiteId(), fieldName, cursorAt].concat(deps);
|
|
@@ -2482,7 +2467,7 @@
|
|
|
2482
2467
|
ctx.currentTest.warn();
|
|
2483
2468
|
}
|
|
2484
2469
|
|
|
2485
|
-
var VERSION = "4.4.
|
|
2470
|
+
var VERSION = "4.4.2-dev-afe5de";
|
|
2486
2471
|
|
|
2487
2472
|
exports.VERSION = VERSION;
|
|
2488
2473
|
exports.context = context;
|