vest 4.2.0 → 4.2.1-dev-ee64be
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/vest.development.js +303 -303
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/vest.development.js +303 -303
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/vest.development.js +210 -210
- package/dist/umd/vest.production.js +1 -1
- package/package.json +3 -3
- package/types/classnames.d.ts +7 -7
- package/types/parser.d.ts +7 -7
- package/types/promisify.d.ts +7 -7
- package/types/vest.d.ts +64 -63
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export { enforce } from 'n4s';
|
|
2
2
|
import { createContext } from 'context';
|
|
3
3
|
|
|
4
|
-
var assign = Object.assign;
|
|
5
|
-
|
|
6
4
|
/**
|
|
7
5
|
* @returns a unique numeric id.
|
|
8
6
|
*/
|
|
@@ -10,206 +8,76 @@ var genId = (function (n) { return function () {
|
|
|
10
8
|
return "".concat(n++);
|
|
11
9
|
}; })(0);
|
|
12
10
|
|
|
13
|
-
function
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function optionalFunctionValue(value) {
|
|
18
|
-
var args = [];
|
|
19
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
20
|
-
args[_i - 1] = arguments[_i];
|
|
21
|
-
}
|
|
22
|
-
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function defaultTo(callback, defaultValue) {
|
|
26
|
-
var _a;
|
|
27
|
-
return (_a = optionalFunctionValue(callback)) !== null && _a !== void 0 ? _a : defaultValue;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Throws a timed out error.
|
|
32
|
-
*/
|
|
33
|
-
function throwError(devMessage, productionMessage) {
|
|
34
|
-
throw new Error(devMessage );
|
|
35
|
-
}
|
|
36
|
-
function throwErrorDeferred(devMessage, productionMessage) {
|
|
37
|
-
setTimeout(function () {
|
|
38
|
-
throwError(devMessage);
|
|
39
|
-
}, 0);
|
|
11
|
+
function isStringValue(v) {
|
|
12
|
+
return String(v) === v;
|
|
40
13
|
}
|
|
41
14
|
|
|
42
|
-
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var registrations = [];
|
|
48
|
-
return {
|
|
49
|
-
registerStateKey: registerStateKey,
|
|
50
|
-
reset: reset
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Registers a new key in the state, takes the initial value (may be a function that returns the initial value), returns a function.
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
*
|
|
57
|
-
* const useColor = state.registerStateKey("blue");
|
|
58
|
-
*
|
|
59
|
-
* let [color, setColor] = useColor(); // -> ["blue", Function]
|
|
60
|
-
*
|
|
61
|
-
* setColor("green");
|
|
62
|
-
*
|
|
63
|
-
* useColor()[0]; -> "green"
|
|
64
|
-
*/
|
|
65
|
-
function registerStateKey(initialState, onUpdate) {
|
|
66
|
-
var key = registrations.length;
|
|
67
|
-
registrations.push([initialState, onUpdate]);
|
|
68
|
-
return initKey(key, initialState);
|
|
69
|
-
}
|
|
70
|
-
function reset() {
|
|
71
|
-
var prev = current();
|
|
72
|
-
state.references = [];
|
|
73
|
-
registrations.forEach(function (_a, index) {
|
|
74
|
-
var initialValue = _a[0];
|
|
75
|
-
return initKey(index, initialValue, prev[index]);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
function initKey(key, initialState, prevState) {
|
|
79
|
-
current().push();
|
|
80
|
-
set(key, optionalFunctionValue(initialState, prevState));
|
|
81
|
-
return function useStateKey() {
|
|
82
|
-
return [
|
|
83
|
-
current()[key],
|
|
84
|
-
function (nextState) {
|
|
85
|
-
return set(key, optionalFunctionValue(nextState, current()[key]));
|
|
86
|
-
},
|
|
87
|
-
];
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function current() {
|
|
91
|
-
return state.references;
|
|
92
|
-
}
|
|
93
|
-
function set(index, value) {
|
|
94
|
-
var prevValue = state.references[index];
|
|
95
|
-
state.references[index] = value;
|
|
96
|
-
var _a = registrations[index], onUpdate = _a[1];
|
|
97
|
-
if (isFunction(onUpdate)) {
|
|
98
|
-
onUpdate(value, prevValue);
|
|
99
|
-
}
|
|
100
|
-
if (isFunction(onStateChange)) {
|
|
101
|
-
onStateChange();
|
|
15
|
+
function bindNot(fn) {
|
|
16
|
+
return function () {
|
|
17
|
+
var args = [];
|
|
18
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
19
|
+
args[_i] = arguments[_i];
|
|
102
20
|
}
|
|
103
|
-
|
|
21
|
+
return !fn.apply(void 0, args);
|
|
22
|
+
};
|
|
104
23
|
}
|
|
105
24
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
IsolateTypes[IsolateTypes["SUITE"] = 1] = "SUITE";
|
|
110
|
-
IsolateTypes[IsolateTypes["EACH"] = 2] = "EACH";
|
|
111
|
-
IsolateTypes[IsolateTypes["SKIP_WHEN"] = 3] = "SKIP_WHEN";
|
|
112
|
-
IsolateTypes[IsolateTypes["OMIT_WHEN"] = 4] = "OMIT_WHEN";
|
|
113
|
-
IsolateTypes[IsolateTypes["GROUP"] = 5] = "GROUP";
|
|
114
|
-
})(IsolateTypes || (IsolateTypes = {}));
|
|
25
|
+
function isUndefined(value) {
|
|
26
|
+
return value === undefined;
|
|
27
|
+
}
|
|
115
28
|
|
|
116
|
-
function
|
|
117
|
-
|
|
118
|
-
return
|
|
119
|
-
optionalFields: state.registerStateKey(function () { return ({}); }),
|
|
120
|
-
suiteId: state.registerStateKey(suiteId),
|
|
121
|
-
suiteName: state.registerStateKey(suiteName),
|
|
122
|
-
testCallbacks: state.registerStateKey(function () { return ({
|
|
123
|
-
fieldCallbacks: {},
|
|
124
|
-
doneCallbacks: []
|
|
125
|
-
}); }),
|
|
126
|
-
testObjects: state.registerStateKey(function (prev) {
|
|
127
|
-
return {
|
|
128
|
-
prev: prev ? prev.current : [],
|
|
129
|
-
current: []
|
|
130
|
-
};
|
|
131
|
-
})
|
|
132
|
-
};
|
|
29
|
+
function shouldUseErrorAsMessage(message, error) {
|
|
30
|
+
// kind of cheating with this safe guard, but it does the job
|
|
31
|
+
return isUndefined(message) && isStringValue(error);
|
|
133
32
|
}
|
|
134
33
|
|
|
135
34
|
function asArray(possibleArg) {
|
|
136
35
|
return [].concat(possibleArg);
|
|
137
36
|
}
|
|
138
37
|
|
|
139
|
-
function
|
|
140
|
-
|
|
141
|
-
return valuesArray[valuesArray.length - 1];
|
|
38
|
+
function lengthEquals(value, arg1) {
|
|
39
|
+
return value.length === Number(arg1);
|
|
142
40
|
}
|
|
143
41
|
|
|
144
|
-
function
|
|
145
|
-
|
|
146
|
-
cursor: []
|
|
147
|
-
};
|
|
148
|
-
function addLevel() {
|
|
149
|
-
storage.cursor.push(0);
|
|
150
|
-
}
|
|
151
|
-
function removeLevel() {
|
|
152
|
-
storage.cursor.pop();
|
|
153
|
-
}
|
|
154
|
-
function cursorAt() {
|
|
155
|
-
return last(storage.cursor);
|
|
156
|
-
}
|
|
157
|
-
function getCursor() {
|
|
158
|
-
return asArray(storage.cursor);
|
|
159
|
-
}
|
|
160
|
-
function next() {
|
|
161
|
-
storage.cursor[storage.cursor.length - 1]++;
|
|
162
|
-
return last(storage.cursor);
|
|
163
|
-
}
|
|
164
|
-
function reset() {
|
|
165
|
-
storage.cursor = [0];
|
|
166
|
-
}
|
|
167
|
-
reset();
|
|
168
|
-
return {
|
|
169
|
-
addLevel: addLevel,
|
|
170
|
-
cursorAt: cursorAt,
|
|
171
|
-
getCursor: getCursor,
|
|
172
|
-
next: next,
|
|
173
|
-
removeLevel: removeLevel,
|
|
174
|
-
reset: reset
|
|
175
|
-
};
|
|
42
|
+
function longerThan(value, arg1) {
|
|
43
|
+
return value.length > Number(arg1);
|
|
176
44
|
}
|
|
177
45
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
var
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
mode: [Modes.ALL],
|
|
201
|
-
testCursor: createCursor()
|
|
202
|
-
}, ctxRef);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
function bindNot(fn) {
|
|
206
|
-
return function () {
|
|
207
|
-
var args = [];
|
|
208
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
209
|
-
args[_i] = arguments[_i];
|
|
210
|
-
}
|
|
211
|
-
return !fn.apply(void 0, args);
|
|
46
|
+
/**
|
|
47
|
+
* Creates a cache function
|
|
48
|
+
*/
|
|
49
|
+
function createCache(maxSize) {
|
|
50
|
+
if (maxSize === void 0) { maxSize = 1; }
|
|
51
|
+
var cacheStorage = [];
|
|
52
|
+
var cache = function (deps, cacheAction) {
|
|
53
|
+
var cacheHit = cache.get(deps);
|
|
54
|
+
// cache hit is not null
|
|
55
|
+
if (cacheHit)
|
|
56
|
+
return cacheHit[1];
|
|
57
|
+
var result = cacheAction();
|
|
58
|
+
cacheStorage.unshift([deps.concat(), result]);
|
|
59
|
+
if (longerThan(cacheStorage, maxSize))
|
|
60
|
+
cacheStorage.length = maxSize;
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
// invalidate an item in the cache by its dependencies
|
|
64
|
+
cache.invalidate = function (deps) {
|
|
65
|
+
var index = findIndex(deps);
|
|
66
|
+
if (index > -1)
|
|
67
|
+
cacheStorage.splice(index, 1);
|
|
212
68
|
};
|
|
69
|
+
// Retrieves an item from the cache.
|
|
70
|
+
cache.get = function (deps) {
|
|
71
|
+
return cacheStorage[findIndex(deps)] || null;
|
|
72
|
+
};
|
|
73
|
+
return cache;
|
|
74
|
+
function findIndex(deps) {
|
|
75
|
+
return cacheStorage.findIndex(function (_a) {
|
|
76
|
+
var cachedDeps = _a[0];
|
|
77
|
+
return lengthEquals(deps, cachedDeps.length) &&
|
|
78
|
+
deps.every(function (dep, i) { return dep === cachedDeps[i]; });
|
|
79
|
+
});
|
|
80
|
+
}
|
|
213
81
|
}
|
|
214
82
|
|
|
215
83
|
// The module is named "isArrayValue" since it
|
|
@@ -224,6 +92,28 @@ function isNull(value) {
|
|
|
224
92
|
}
|
|
225
93
|
var isNotNull = bindNot(isNull);
|
|
226
94
|
|
|
95
|
+
function isFunction(value) {
|
|
96
|
+
return typeof value === 'function';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function optionalFunctionValue(value) {
|
|
100
|
+
var args = [];
|
|
101
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
102
|
+
args[_i - 1] = arguments[_i];
|
|
103
|
+
}
|
|
104
|
+
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function defaultTo(callback, defaultValue) {
|
|
108
|
+
var _a;
|
|
109
|
+
return (_a = optionalFunctionValue(callback)) !== null && _a !== void 0 ? _a : defaultValue;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function last(values) {
|
|
113
|
+
var valuesArray = asArray(values);
|
|
114
|
+
return valuesArray[valuesArray.length - 1];
|
|
115
|
+
}
|
|
116
|
+
|
|
227
117
|
// This is kind of a map/filter in one function.
|
|
228
118
|
// Normally, behaves like a nested-array map,
|
|
229
119
|
// but returning `null` will drop the element from the array
|
|
@@ -269,68 +159,79 @@ function getCurrent(array, path) {
|
|
|
269
159
|
return current;
|
|
270
160
|
}
|
|
271
161
|
|
|
272
|
-
|
|
273
|
-
return value === undefined;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
function isNullish(value) {
|
|
277
|
-
return isNull(value) || isUndefined(value);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
function isStringValue(v) {
|
|
281
|
-
return String(v) === v;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function shouldUseErrorAsMessage(message, error) {
|
|
285
|
-
// kind of cheating with this safe guard, but it does the job
|
|
286
|
-
return isUndefined(message) && isStringValue(error);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
function lengthEquals(value, arg1) {
|
|
290
|
-
return value.length === Number(arg1);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function longerThan(value, arg1) {
|
|
294
|
-
return value.length > Number(arg1);
|
|
295
|
-
}
|
|
162
|
+
var assign = Object.assign;
|
|
296
163
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
function createCache(maxSize) {
|
|
301
|
-
if (maxSize === void 0) { maxSize = 1; }
|
|
302
|
-
var cacheStorage = [];
|
|
303
|
-
var cache = function (deps, cacheAction) {
|
|
304
|
-
var cacheHit = cache.get(deps);
|
|
305
|
-
// cache hit is not null
|
|
306
|
-
if (cacheHit)
|
|
307
|
-
return cacheHit[1];
|
|
308
|
-
var result = cacheAction();
|
|
309
|
-
cacheStorage.unshift([deps.concat(), result]);
|
|
310
|
-
if (longerThan(cacheStorage, maxSize))
|
|
311
|
-
cacheStorage.length = maxSize;
|
|
312
|
-
return result;
|
|
313
|
-
};
|
|
314
|
-
// invalidate an item in the cache by its dependencies
|
|
315
|
-
cache.invalidate = function (deps) {
|
|
316
|
-
var index = findIndex(deps);
|
|
317
|
-
if (index > -1)
|
|
318
|
-
cacheStorage.splice(index, 1);
|
|
319
|
-
};
|
|
320
|
-
// Retrieves an item from the cache.
|
|
321
|
-
cache.get = function (deps) {
|
|
322
|
-
return cacheStorage[findIndex(deps)] || null;
|
|
164
|
+
function createCursor() {
|
|
165
|
+
var storage = {
|
|
166
|
+
cursor: []
|
|
323
167
|
};
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
168
|
+
function addLevel() {
|
|
169
|
+
storage.cursor.push(0);
|
|
170
|
+
}
|
|
171
|
+
function removeLevel() {
|
|
172
|
+
storage.cursor.pop();
|
|
173
|
+
}
|
|
174
|
+
function cursorAt() {
|
|
175
|
+
return last(storage.cursor);
|
|
176
|
+
}
|
|
177
|
+
function getCursor() {
|
|
178
|
+
return asArray(storage.cursor);
|
|
179
|
+
}
|
|
180
|
+
function next() {
|
|
181
|
+
storage.cursor[storage.cursor.length - 1]++;
|
|
182
|
+
return last(storage.cursor);
|
|
183
|
+
}
|
|
184
|
+
function reset() {
|
|
185
|
+
storage.cursor = [0];
|
|
331
186
|
}
|
|
187
|
+
reset();
|
|
188
|
+
return {
|
|
189
|
+
addLevel: addLevel,
|
|
190
|
+
cursorAt: cursorAt,
|
|
191
|
+
getCursor: getCursor,
|
|
192
|
+
next: next,
|
|
193
|
+
removeLevel: removeLevel,
|
|
194
|
+
reset: reset
|
|
195
|
+
};
|
|
332
196
|
}
|
|
333
197
|
|
|
198
|
+
var IsolateTypes;
|
|
199
|
+
(function (IsolateTypes) {
|
|
200
|
+
IsolateTypes[IsolateTypes["DEFAULT"] = 0] = "DEFAULT";
|
|
201
|
+
IsolateTypes[IsolateTypes["SUITE"] = 1] = "SUITE";
|
|
202
|
+
IsolateTypes[IsolateTypes["EACH"] = 2] = "EACH";
|
|
203
|
+
IsolateTypes[IsolateTypes["SKIP_WHEN"] = 3] = "SKIP_WHEN";
|
|
204
|
+
IsolateTypes[IsolateTypes["OMIT_WHEN"] = 4] = "OMIT_WHEN";
|
|
205
|
+
IsolateTypes[IsolateTypes["GROUP"] = 5] = "GROUP";
|
|
206
|
+
})(IsolateTypes || (IsolateTypes = {}));
|
|
207
|
+
|
|
208
|
+
var Modes;
|
|
209
|
+
(function (Modes) {
|
|
210
|
+
Modes[Modes["ALL"] = 0] = "ALL";
|
|
211
|
+
Modes[Modes["EAGER"] = 1] = "EAGER";
|
|
212
|
+
})(Modes || (Modes = {}));
|
|
213
|
+
|
|
214
|
+
var context = createContext(function (ctxRef, parentContext) {
|
|
215
|
+
return parentContext
|
|
216
|
+
? null
|
|
217
|
+
: assign({}, {
|
|
218
|
+
exclusion: {
|
|
219
|
+
tests: {},
|
|
220
|
+
groups: {}
|
|
221
|
+
},
|
|
222
|
+
inclusion: {},
|
|
223
|
+
isolate: {
|
|
224
|
+
type: IsolateTypes.DEFAULT,
|
|
225
|
+
keys: {
|
|
226
|
+
current: {},
|
|
227
|
+
prev: {}
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
mode: [Modes.ALL],
|
|
231
|
+
testCursor: createCursor()
|
|
232
|
+
}, ctxRef);
|
|
233
|
+
});
|
|
234
|
+
|
|
334
235
|
// STATE REF
|
|
335
236
|
function useStateRef() {
|
|
336
237
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -546,6 +447,105 @@ var STATUS_PENDING = 'PENDING';
|
|
|
546
447
|
var STATUS_CANCELED = 'CANCELED';
|
|
547
448
|
var STATUS_OMITTED = 'OMITTED';
|
|
548
449
|
|
|
450
|
+
/**
|
|
451
|
+
* Throws a timed out error.
|
|
452
|
+
*/
|
|
453
|
+
function throwError(devMessage, productionMessage) {
|
|
454
|
+
throw new Error(devMessage );
|
|
455
|
+
}
|
|
456
|
+
function throwErrorDeferred(devMessage, productionMessage) {
|
|
457
|
+
setTimeout(function () {
|
|
458
|
+
throwError(devMessage);
|
|
459
|
+
}, 0);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// eslint-disable-next-line max-lines-per-function
|
|
463
|
+
function createState(onStateChange) {
|
|
464
|
+
var state = {
|
|
465
|
+
references: []
|
|
466
|
+
};
|
|
467
|
+
var registrations = [];
|
|
468
|
+
return {
|
|
469
|
+
registerStateKey: registerStateKey,
|
|
470
|
+
reset: reset
|
|
471
|
+
};
|
|
472
|
+
/**
|
|
473
|
+
* Registers a new key in the state, takes the initial value (may be a function that returns the initial value), returns a function.
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
*
|
|
477
|
+
* const useColor = state.registerStateKey("blue");
|
|
478
|
+
*
|
|
479
|
+
* let [color, setColor] = useColor(); // -> ["blue", Function]
|
|
480
|
+
*
|
|
481
|
+
* setColor("green");
|
|
482
|
+
*
|
|
483
|
+
* useColor()[0]; -> "green"
|
|
484
|
+
*/
|
|
485
|
+
function registerStateKey(initialState, onUpdate) {
|
|
486
|
+
var key = registrations.length;
|
|
487
|
+
registrations.push([initialState, onUpdate]);
|
|
488
|
+
return initKey(key, initialState);
|
|
489
|
+
}
|
|
490
|
+
function reset() {
|
|
491
|
+
var prev = current();
|
|
492
|
+
state.references = [];
|
|
493
|
+
registrations.forEach(function (_a, index) {
|
|
494
|
+
var initialValue = _a[0];
|
|
495
|
+
return initKey(index, initialValue, prev[index]);
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
function initKey(key, initialState, prevState) {
|
|
499
|
+
current().push();
|
|
500
|
+
set(key, optionalFunctionValue(initialState, prevState));
|
|
501
|
+
return function useStateKey() {
|
|
502
|
+
return [
|
|
503
|
+
current()[key],
|
|
504
|
+
function (nextState) {
|
|
505
|
+
return set(key, optionalFunctionValue(nextState, current()[key]));
|
|
506
|
+
},
|
|
507
|
+
];
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
function current() {
|
|
511
|
+
return state.references;
|
|
512
|
+
}
|
|
513
|
+
function set(index, value) {
|
|
514
|
+
var prevValue = state.references[index];
|
|
515
|
+
state.references[index] = value;
|
|
516
|
+
var _a = registrations[index], onUpdate = _a[1];
|
|
517
|
+
if (isFunction(onUpdate)) {
|
|
518
|
+
onUpdate(value, prevValue);
|
|
519
|
+
}
|
|
520
|
+
if (isFunction(onStateChange)) {
|
|
521
|
+
onStateChange();
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function createStateRef(state, _a) {
|
|
527
|
+
var suiteId = _a.suiteId, suiteName = _a.suiteName;
|
|
528
|
+
return {
|
|
529
|
+
optionalFields: state.registerStateKey(function () { return ({}); }),
|
|
530
|
+
suiteId: state.registerStateKey(suiteId),
|
|
531
|
+
suiteName: state.registerStateKey(suiteName),
|
|
532
|
+
testCallbacks: state.registerStateKey(function () { return ({
|
|
533
|
+
fieldCallbacks: {},
|
|
534
|
+
doneCallbacks: []
|
|
535
|
+
}); }),
|
|
536
|
+
testObjects: state.registerStateKey(function (prev) {
|
|
537
|
+
return {
|
|
538
|
+
prev: prev ? prev.current : [],
|
|
539
|
+
current: []
|
|
540
|
+
};
|
|
541
|
+
})
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function isNullish(value) {
|
|
546
|
+
return isNull(value) || isUndefined(value);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
549
|
function usePath() {
|
|
550
550
|
var context$1 = context.useX();
|
|
551
551
|
return context$1.testCursor.getCursor();
|
|
@@ -619,57 +619,6 @@ function shouldAllowReorder() {
|
|
|
619
619
|
return context.useX().isolate.type === IsolateTypes.EACH;
|
|
620
620
|
}
|
|
621
621
|
|
|
622
|
-
/**
|
|
623
|
-
* A safe hasOwnProperty access
|
|
624
|
-
*/
|
|
625
|
-
function hasOwnProperty(obj, key) {
|
|
626
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
function isNumber(value) {
|
|
630
|
-
return Boolean(typeof value === 'number');
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
function isEmpty(value) {
|
|
634
|
-
if (!value) {
|
|
635
|
-
return true;
|
|
636
|
-
}
|
|
637
|
-
else if (isNumber(value)) {
|
|
638
|
-
return value === 0;
|
|
639
|
-
}
|
|
640
|
-
else if (hasOwnProperty(value, 'length')) {
|
|
641
|
-
return lengthEquals(value, 0);
|
|
642
|
-
}
|
|
643
|
-
else if (typeof value === 'object') {
|
|
644
|
-
return lengthEquals(Object.keys(value), 0);
|
|
645
|
-
}
|
|
646
|
-
return true;
|
|
647
|
-
}
|
|
648
|
-
var isNotEmpty = bindNot(isEmpty);
|
|
649
|
-
|
|
650
|
-
function nonMatchingFieldName(testObject, fieldName) {
|
|
651
|
-
return !!fieldName && !matchingFieldName(testObject, fieldName);
|
|
652
|
-
}
|
|
653
|
-
function matchingFieldName(testObject, fieldName) {
|
|
654
|
-
return !!(fieldName && testObject.fieldName === fieldName);
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
/**
|
|
658
|
-
* Checks if a given field, or the suite as a whole still have remaining tests.
|
|
659
|
-
*/
|
|
660
|
-
function hasRemainingTests(fieldName) {
|
|
661
|
-
var allIncomplete = useAllIncomplete();
|
|
662
|
-
if (isEmpty(allIncomplete)) {
|
|
663
|
-
return false;
|
|
664
|
-
}
|
|
665
|
-
if (fieldName) {
|
|
666
|
-
return allIncomplete.some(function (testObject) {
|
|
667
|
-
return matchingFieldName(testObject, fieldName);
|
|
668
|
-
});
|
|
669
|
-
}
|
|
670
|
-
return isNotEmpty(allIncomplete);
|
|
671
|
-
}
|
|
672
|
-
|
|
673
622
|
var Severity;
|
|
674
623
|
(function (Severity) {
|
|
675
624
|
Severity["WARNINGS"] = "warnings";
|
|
@@ -777,6 +726,13 @@ function __spreadArray(to, from, pack) {
|
|
|
777
726
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
778
727
|
}
|
|
779
728
|
|
|
729
|
+
function nonMatchingFieldName(testObject, fieldName) {
|
|
730
|
+
return !!fieldName && !matchingFieldName(testObject, fieldName);
|
|
731
|
+
}
|
|
732
|
+
function matchingFieldName(testObject, fieldName) {
|
|
733
|
+
return !!(fieldName && testObject.fieldName === fieldName);
|
|
734
|
+
}
|
|
735
|
+
|
|
780
736
|
function either(a, b) {
|
|
781
737
|
return !!a !== !!b;
|
|
782
738
|
}
|
|
@@ -912,6 +868,34 @@ function hasByGroup(severityKey, group, fieldName) {
|
|
|
912
868
|
});
|
|
913
869
|
}
|
|
914
870
|
|
|
871
|
+
/**
|
|
872
|
+
* A safe hasOwnProperty access
|
|
873
|
+
*/
|
|
874
|
+
function hasOwnProperty(obj, key) {
|
|
875
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
function isNumber(value) {
|
|
879
|
+
return Boolean(typeof value === 'number');
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
function isEmpty(value) {
|
|
883
|
+
if (!value) {
|
|
884
|
+
return true;
|
|
885
|
+
}
|
|
886
|
+
else if (isNumber(value)) {
|
|
887
|
+
return value === 0;
|
|
888
|
+
}
|
|
889
|
+
else if (hasOwnProperty(value, 'length')) {
|
|
890
|
+
return lengthEquals(value, 0);
|
|
891
|
+
}
|
|
892
|
+
else if (typeof value === 'object') {
|
|
893
|
+
return lengthEquals(Object.keys(value), 0);
|
|
894
|
+
}
|
|
895
|
+
return true;
|
|
896
|
+
}
|
|
897
|
+
var isNotEmpty = bindNot(isEmpty);
|
|
898
|
+
|
|
915
899
|
// eslint-disable-next-line max-statements, complexity
|
|
916
900
|
function isValid(result, fieldName) {
|
|
917
901
|
if (fieldIsOmitted(fieldName)) {
|
|
@@ -965,7 +949,7 @@ function noMissingTests(fieldName) {
|
|
|
965
949
|
}
|
|
966
950
|
|
|
967
951
|
var cache$1 = createCache(20);
|
|
968
|
-
function
|
|
952
|
+
function produceBase() {
|
|
969
953
|
var testObjects = useTestsFlat();
|
|
970
954
|
var ctxRef = { stateRef: useStateRef() };
|
|
971
955
|
return cache$1([testObjects], context.bind(ctxRef, function () {
|
|
@@ -980,19 +964,35 @@ function produceDraft() {
|
|
|
980
964
|
hasWarnings: context.bind(ctxRef, hasWarnings),
|
|
981
965
|
hasWarningsByGroup: context.bind(ctxRef, hasWarningsByGroup),
|
|
982
966
|
isValid: context.bind(ctxRef, function (fieldName) {
|
|
983
|
-
return isValid(
|
|
967
|
+
return isValid(produceBase(), fieldName);
|
|
984
968
|
}),
|
|
985
969
|
suiteName: suiteName
|
|
986
970
|
});
|
|
987
971
|
}));
|
|
988
972
|
}
|
|
989
973
|
|
|
974
|
+
/**
|
|
975
|
+
* Checks if a given field, or the suite as a whole still have remaining tests.
|
|
976
|
+
*/
|
|
977
|
+
function hasRemainingTests(fieldName) {
|
|
978
|
+
var allIncomplete = useAllIncomplete();
|
|
979
|
+
if (isEmpty(allIncomplete)) {
|
|
980
|
+
return false;
|
|
981
|
+
}
|
|
982
|
+
if (fieldName) {
|
|
983
|
+
return allIncomplete.some(function (testObject) {
|
|
984
|
+
return matchingFieldName(testObject, fieldName);
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
return isNotEmpty(allIncomplete);
|
|
988
|
+
}
|
|
989
|
+
|
|
990
990
|
var cache = createCache(20);
|
|
991
991
|
function produceFullResult() {
|
|
992
992
|
var testObjects = useTestsFlat();
|
|
993
993
|
var ctxRef = { stateRef: useStateRef() };
|
|
994
994
|
return cache([testObjects], context.bind(ctxRef, function () {
|
|
995
|
-
return assign({},
|
|
995
|
+
return assign({}, produceBase(), {
|
|
996
996
|
done: context.bind(ctxRef, done)
|
|
997
997
|
});
|
|
998
998
|
}));
|
|
@@ -1025,7 +1025,7 @@ var done = function done() {
|
|
|
1025
1025
|
if (shouldSkipDoneRegistration(callback, fieldName, output)) {
|
|
1026
1026
|
return output;
|
|
1027
1027
|
}
|
|
1028
|
-
var doneCallback = function () { return callback(
|
|
1028
|
+
var doneCallback = function () { return callback(produceBase()); };
|
|
1029
1029
|
if (shouldRunDoneCallback(fieldName)) {
|
|
1030
1030
|
doneCallback();
|
|
1031
1031
|
return output;
|
|
@@ -1226,7 +1226,7 @@ function create() {
|
|
|
1226
1226
|
// Return the result
|
|
1227
1227
|
return produceFullResult();
|
|
1228
1228
|
}), {
|
|
1229
|
-
get: context.bind(ctxRef,
|
|
1229
|
+
get: context.bind(ctxRef, produceBase),
|
|
1230
1230
|
remove: context.bind(ctxRef, function (fieldName) {
|
|
1231
1231
|
bus.emit(Events.REMOVE_FIELD, fieldName);
|
|
1232
1232
|
}),
|
|
@@ -1284,7 +1284,7 @@ function skipWhen(conditional, callback) {
|
|
|
1284
1284
|
// we should skip the test if the parent conditional is true.
|
|
1285
1285
|
isExcludedIndividually() ||
|
|
1286
1286
|
// Otherwise, we should skip the test if the conditional is true.
|
|
1287
|
-
optionalFunctionValue(conditional, optionalFunctionValue(
|
|
1287
|
+
optionalFunctionValue(conditional, optionalFunctionValue(produceBase))
|
|
1288
1288
|
}, function () { return callback(); });
|
|
1289
1289
|
});
|
|
1290
1290
|
}
|
|
@@ -1484,7 +1484,7 @@ function include(fieldName) {
|
|
|
1484
1484
|
if (isStringValue(condition)) {
|
|
1485
1485
|
return Boolean(exclusion.tests[condition]);
|
|
1486
1486
|
}
|
|
1487
|
-
return optionalFunctionValue(condition, optionalFunctionValue(
|
|
1487
|
+
return optionalFunctionValue(condition, optionalFunctionValue(produceBase));
|
|
1488
1488
|
};
|
|
1489
1489
|
}
|
|
1490
1490
|
}
|
|
@@ -1541,7 +1541,7 @@ function omitWhen(conditional, callback) {
|
|
|
1541
1541
|
isolate({ type: IsolateTypes.OMIT_WHEN }, function () {
|
|
1542
1542
|
context.run({
|
|
1543
1543
|
omitted: isOmitted() ||
|
|
1544
|
-
optionalFunctionValue(conditional, optionalFunctionValue(
|
|
1544
|
+
optionalFunctionValue(conditional, optionalFunctionValue(produceBase))
|
|
1545
1545
|
}, function () { return callback(); });
|
|
1546
1546
|
});
|
|
1547
1547
|
}
|
|
@@ -1674,7 +1674,7 @@ function registerTest(testObject) {
|
|
|
1674
1674
|
}
|
|
1675
1675
|
}
|
|
1676
1676
|
catch (e) {
|
|
1677
|
-
throwError("Unexpected error encountered during test registration.\n Test Object: ".concat(testObject, ".\n Error: ").concat(e, "."));
|
|
1677
|
+
throwError("Unexpected error encountered during test registration.\n Test Object: ".concat(JSON.stringify(testObject), ".\n Error: ").concat(e, "."));
|
|
1678
1678
|
}
|
|
1679
1679
|
}
|
|
1680
1680
|
|
|
@@ -1873,6 +1873,6 @@ function warn() {
|
|
|
1873
1873
|
ctx.currentTest.warn();
|
|
1874
1874
|
}
|
|
1875
1875
|
|
|
1876
|
-
var VERSION = "4.2.
|
|
1876
|
+
var VERSION = "4.2.1-dev-ee64be";
|
|
1877
1877
|
|
|
1878
1878
|
export { VERSION, context, create, each, eager, group, include, omitWhen, only, optional, skip, skipWhen, test, warn };
|