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
|
@@ -1,42 +1,12 @@
|
|
|
1
1
|
export { enforce } from 'n4s';
|
|
2
|
+
import { isUndefined, isStringValue, assign, 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
10
|
function isNumeric(value) {
|
|
41
11
|
var str = String(value);
|
|
42
12
|
var num = Number(value);
|
|
@@ -97,119 +67,6 @@ function createCache(maxSize) {
|
|
|
97
67
|
}
|
|
98
68
|
}
|
|
99
69
|
|
|
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
|
-
function createCursor() {
|
|
180
|
-
var storage = {
|
|
181
|
-
cursor: []
|
|
182
|
-
};
|
|
183
|
-
function addLevel() {
|
|
184
|
-
storage.cursor.push(0);
|
|
185
|
-
}
|
|
186
|
-
function removeLevel() {
|
|
187
|
-
storage.cursor.pop();
|
|
188
|
-
}
|
|
189
|
-
function cursorAt() {
|
|
190
|
-
return last(storage.cursor);
|
|
191
|
-
}
|
|
192
|
-
function getCursor() {
|
|
193
|
-
return asArray(storage.cursor);
|
|
194
|
-
}
|
|
195
|
-
function next() {
|
|
196
|
-
storage.cursor[storage.cursor.length - 1]++;
|
|
197
|
-
return last(storage.cursor);
|
|
198
|
-
}
|
|
199
|
-
function reset() {
|
|
200
|
-
storage.cursor = [0];
|
|
201
|
-
}
|
|
202
|
-
reset();
|
|
203
|
-
return {
|
|
204
|
-
addLevel: addLevel,
|
|
205
|
-
cursorAt: cursorAt,
|
|
206
|
-
getCursor: getCursor,
|
|
207
|
-
next: next,
|
|
208
|
-
removeLevel: removeLevel,
|
|
209
|
-
reset: reset
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
|
|
213
70
|
var IsolateTypes;
|
|
214
71
|
(function (IsolateTypes) {
|
|
215
72
|
IsolateTypes[IsolateTypes["DEFAULT"] = 0] = "DEFAULT";
|
|
@@ -226,6 +83,41 @@ var Modes;
|
|
|
226
83
|
Modes[Modes["EAGER"] = 1] = "EAGER";
|
|
227
84
|
})(Modes || (Modes = {}));
|
|
228
85
|
|
|
86
|
+
function createIsolateCursor() {
|
|
87
|
+
var cursor = {
|
|
88
|
+
value: 0
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
current: current,
|
|
92
|
+
next: next
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* @returns {number} The current value of the cursor
|
|
96
|
+
*/
|
|
97
|
+
function current() {
|
|
98
|
+
return cursor.value;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Moves the isolate cursor forward by 1
|
|
102
|
+
*/
|
|
103
|
+
function next() {
|
|
104
|
+
cursor.value++;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function generateIsolate(type, path) {
|
|
109
|
+
if (path === void 0) { path = []; }
|
|
110
|
+
return {
|
|
111
|
+
cursor: createIsolateCursor(),
|
|
112
|
+
keys: {
|
|
113
|
+
current: {},
|
|
114
|
+
prev: {}
|
|
115
|
+
},
|
|
116
|
+
path: path,
|
|
117
|
+
type: type
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
229
121
|
var context = createContext(function (ctxRef, parentContext) {
|
|
230
122
|
return parentContext
|
|
231
123
|
? null
|
|
@@ -235,15 +127,8 @@ var context = createContext(function (ctxRef, parentContext) {
|
|
|
235
127
|
groups: {}
|
|
236
128
|
},
|
|
237
129
|
inclusion: {},
|
|
238
|
-
isolate:
|
|
239
|
-
|
|
240
|
-
keys: {
|
|
241
|
-
current: {},
|
|
242
|
-
prev: {}
|
|
243
|
-
}
|
|
244
|
-
},
|
|
245
|
-
mode: [Modes.ALL],
|
|
246
|
-
testCursor: createCursor()
|
|
130
|
+
isolate: generateIsolate(IsolateTypes.DEFAULT),
|
|
131
|
+
mode: [Modes.ALL]
|
|
247
132
|
}, ctxRef);
|
|
248
133
|
});
|
|
249
134
|
|
|
@@ -311,7 +196,7 @@ function useAllIncomplete() {
|
|
|
311
196
|
var flatCache = createCache();
|
|
312
197
|
function useTestsFlat() {
|
|
313
198
|
var current = useTestObjects()[0].current;
|
|
314
|
-
return flatCache([current], function () { return flatten(current); });
|
|
199
|
+
return flatCache([current], function () { return nestedArray.flatten(current); });
|
|
315
200
|
}
|
|
316
201
|
function useEachTestObject(handler) {
|
|
317
202
|
var testObjects = useTestsFlat();
|
|
@@ -462,20 +347,6 @@ var STATUS_PENDING = 'PENDING';
|
|
|
462
347
|
var STATUS_CANCELED = 'CANCELED';
|
|
463
348
|
var STATUS_OMITTED = 'OMITTED';
|
|
464
349
|
|
|
465
|
-
function invariant(condition,
|
|
466
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
467
|
-
message) {
|
|
468
|
-
if (condition) {
|
|
469
|
-
return;
|
|
470
|
-
}
|
|
471
|
-
// If message is a string object (rather than string literal)
|
|
472
|
-
// Throw the value directly as a string
|
|
473
|
-
// Alternatively, throw an error with the message
|
|
474
|
-
throw message instanceof String
|
|
475
|
-
? message.valueOf()
|
|
476
|
-
: new Error(message ? optionalFunctionValue(message) : message);
|
|
477
|
-
}
|
|
478
|
-
|
|
479
350
|
// eslint-disable-next-line max-lines-per-function
|
|
480
351
|
function createState(onStateChange) {
|
|
481
352
|
var state = {
|
|
@@ -559,40 +430,9 @@ function createStateRef(state, _a) {
|
|
|
559
430
|
};
|
|
560
431
|
}
|
|
561
432
|
|
|
562
|
-
function isNullish(value) {
|
|
563
|
-
return isNull(value) || isUndefined(value);
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
function deferThrow(message) {
|
|
567
|
-
setTimeout(function () {
|
|
568
|
-
throw new Error(message);
|
|
569
|
-
}, 0);
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
function usePath() {
|
|
573
|
-
var context$1 = context.useX();
|
|
574
|
-
return context$1.testCursor.getCursor();
|
|
575
|
-
}
|
|
576
|
-
function useCursorAt() {
|
|
577
|
-
var context$1 = context.useX();
|
|
578
|
-
return context$1.testCursor.cursorAt();
|
|
579
|
-
}
|
|
580
|
-
function moveForward() {
|
|
581
|
-
var context$1 = context.useX();
|
|
582
|
-
return context$1.testCursor.next();
|
|
583
|
-
}
|
|
584
|
-
function addLevel() {
|
|
585
|
-
var context$1 = context.useX();
|
|
586
|
-
context$1.testCursor.addLevel();
|
|
587
|
-
}
|
|
588
|
-
function removeLevel() {
|
|
589
|
-
var context$1 = context.useX();
|
|
590
|
-
context$1.testCursor.removeLevel();
|
|
591
|
-
}
|
|
592
|
-
|
|
593
433
|
function usePrevKeys() {
|
|
594
434
|
var prev = useTestObjects()[0].prev;
|
|
595
|
-
return asArray(getCurrent(prev,
|
|
435
|
+
return asArray(nestedArray.getCurrent(prev, useCurrentPath())).reduce(function (prevKeys, testObject) {
|
|
596
436
|
if (!(testObject instanceof VestTest)) {
|
|
597
437
|
return prevKeys;
|
|
598
438
|
}
|
|
@@ -604,12 +444,11 @@ function usePrevKeys() {
|
|
|
604
444
|
}, {});
|
|
605
445
|
}
|
|
606
446
|
function usePrevTestByKey(key) {
|
|
607
|
-
var prev =
|
|
447
|
+
var prev = useIsolate().keys.prev;
|
|
608
448
|
return prev[key];
|
|
609
449
|
}
|
|
610
450
|
function useRetainTestKey(key, testObject) {
|
|
611
|
-
var
|
|
612
|
-
var current = context$1.isolate.keys.current;
|
|
451
|
+
var current = useIsolate().keys.current;
|
|
613
452
|
if (isNullish(current[key])) {
|
|
614
453
|
current[key] = testObject;
|
|
615
454
|
}
|
|
@@ -621,23 +460,42 @@ function useRetainTestKey(key, testObject) {
|
|
|
621
460
|
function isolate(_a, callback) {
|
|
622
461
|
var _b = _a.type, type = _b === void 0 ? IsolateTypes.DEFAULT : _b;
|
|
623
462
|
invariant(isFunction(callback));
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
return context.run({ isolate: { type: type, keys: keys } }, function () {
|
|
630
|
-
addLevel();
|
|
631
|
-
keys.prev = usePrevKeys();
|
|
632
|
-
useSetTests(function (tests) { return setValueAtPath(tests, path, []); });
|
|
463
|
+
// Generate a new Isolate layer, with its own cursor
|
|
464
|
+
var isolate = generateIsolate(type, useCurrentPath());
|
|
465
|
+
var output = context.run({ isolate: isolate }, function () {
|
|
466
|
+
isolate.keys.prev = usePrevKeys();
|
|
467
|
+
useSetTests(function (tests) { return nestedArray.setValueAtPath(tests, isolate.path, []); });
|
|
633
468
|
var res = callback();
|
|
634
|
-
removeLevel();
|
|
635
|
-
moveForward();
|
|
636
469
|
return res;
|
|
637
470
|
});
|
|
471
|
+
// Move the parent cursor forward once we're done
|
|
472
|
+
useCursor().next();
|
|
473
|
+
return output;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* @returns {Isolate} The current isolate layer
|
|
477
|
+
*/
|
|
478
|
+
function useIsolate() {
|
|
479
|
+
return context.useX().isolate;
|
|
638
480
|
}
|
|
481
|
+
/**
|
|
482
|
+
* @returns {boolean} Whether or not the current isolate allows tests to be reordered
|
|
483
|
+
*/
|
|
639
484
|
function shouldAllowReorder() {
|
|
640
|
-
return
|
|
485
|
+
return useIsolate().type === IsolateTypes.EACH;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* @returns {number[]} The current cursor path of the isolate tree
|
|
489
|
+
*/
|
|
490
|
+
function useCurrentPath() {
|
|
491
|
+
var isolate = useIsolate();
|
|
492
|
+
return isolate.path.concat(isolate.cursor.current());
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* @returns {IsolateCursor} The cursor object for the current isolate
|
|
496
|
+
*/
|
|
497
|
+
function useCursor() {
|
|
498
|
+
return useIsolate().cursor;
|
|
641
499
|
}
|
|
642
500
|
|
|
643
501
|
var Severity;
|
|
@@ -656,34 +514,6 @@ function countKeyBySeverity(severity) {
|
|
|
656
514
|
: SeverityCount.WARN_COUNT;
|
|
657
515
|
}
|
|
658
516
|
|
|
659
|
-
/**
|
|
660
|
-
* A safe hasOwnProperty access
|
|
661
|
-
*/
|
|
662
|
-
function hasOwnProperty(obj, key) {
|
|
663
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
function isNumber(value) {
|
|
667
|
-
return Boolean(typeof value === 'number');
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
function isEmpty(value) {
|
|
671
|
-
if (!value) {
|
|
672
|
-
return true;
|
|
673
|
-
}
|
|
674
|
-
else if (isNumber(value)) {
|
|
675
|
-
return value === 0;
|
|
676
|
-
}
|
|
677
|
-
else if (hasOwnProperty(value, 'length')) {
|
|
678
|
-
return lengthEquals(value, 0);
|
|
679
|
-
}
|
|
680
|
-
else if (typeof value === 'object') {
|
|
681
|
-
return lengthEquals(Object.keys(value), 0);
|
|
682
|
-
}
|
|
683
|
-
return false;
|
|
684
|
-
}
|
|
685
|
-
var isNotEmpty = bindNot(isEmpty);
|
|
686
|
-
|
|
687
517
|
function nonMatchingFieldName(testObject, fieldName) {
|
|
688
518
|
return !!fieldName && !matchingFieldName(testObject, fieldName);
|
|
689
519
|
}
|
|
@@ -696,10 +526,6 @@ function matchingGroupName(testObject, groupName) {
|
|
|
696
526
|
return testObject.groupName === groupName;
|
|
697
527
|
}
|
|
698
528
|
|
|
699
|
-
function either(a, b) {
|
|
700
|
-
return !!a !== !!b;
|
|
701
|
-
}
|
|
702
|
-
|
|
703
529
|
/**
|
|
704
530
|
* Checks that a given test object matches the currently specified severity level
|
|
705
531
|
*/
|
|
@@ -923,10 +749,6 @@ function baseTestStats() {
|
|
|
923
749
|
});
|
|
924
750
|
}
|
|
925
751
|
|
|
926
|
-
function isPositive(value) {
|
|
927
|
-
return greaterThan(value, 0);
|
|
928
|
-
}
|
|
929
|
-
|
|
930
752
|
// calls collectAll or getByFieldName depending on whether fieldName is provided
|
|
931
753
|
function gatherFailures(testGroup, severityKey, fieldName) {
|
|
932
754
|
return fieldName
|
|
@@ -1142,28 +964,6 @@ function deferDoneCallback(doneCallback, fieldName) {
|
|
|
1142
964
|
});
|
|
1143
965
|
}
|
|
1144
966
|
|
|
1145
|
-
function createBus() {
|
|
1146
|
-
var listeners = {};
|
|
1147
|
-
return {
|
|
1148
|
-
emit: function (event, data) {
|
|
1149
|
-
listener(event).forEach(function (handler) {
|
|
1150
|
-
handler(data);
|
|
1151
|
-
});
|
|
1152
|
-
},
|
|
1153
|
-
on: function (event, handler) {
|
|
1154
|
-
listeners[event] = listener(event).concat(handler);
|
|
1155
|
-
return {
|
|
1156
|
-
off: function () {
|
|
1157
|
-
listeners[event] = listener(event).filter(function (h) { return h !== handler; });
|
|
1158
|
-
}
|
|
1159
|
-
};
|
|
1160
|
-
}
|
|
1161
|
-
};
|
|
1162
|
-
function listener(event) {
|
|
1163
|
-
return listeners[event] || [];
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
967
|
function omitOptionalFields() {
|
|
1168
968
|
var optionalFields = useOptionalFields()[0];
|
|
1169
969
|
if (isEmpty(optionalFields)) {
|
|
@@ -1171,7 +971,7 @@ function omitOptionalFields() {
|
|
|
1171
971
|
}
|
|
1172
972
|
var shouldOmit = {};
|
|
1173
973
|
useSetTests(function (tests) {
|
|
1174
|
-
return transform(tests, function (testObject) {
|
|
974
|
+
return nestedArray.transform(tests, function (testObject) {
|
|
1175
975
|
var fieldName = testObject.fieldName;
|
|
1176
976
|
if (hasOwnProperty(shouldOmit, fieldName)) {
|
|
1177
977
|
verifyAndOmit(testObject);
|
|
@@ -1202,14 +1002,10 @@ function omitOptionalFields() {
|
|
|
1202
1002
|
*/
|
|
1203
1003
|
function removeTestFromState (testObject) {
|
|
1204
1004
|
useSetTests(function (tests) {
|
|
1205
|
-
return transform(tests, function (test) { return (testObject !== test ? test : null); });
|
|
1005
|
+
return nestedArray.transform(tests, function (test) { return (testObject !== test ? test : null); });
|
|
1206
1006
|
});
|
|
1207
1007
|
}
|
|
1208
1008
|
|
|
1209
|
-
function callEach(arr) {
|
|
1210
|
-
return arr.forEach(function (fn) { return fn(); });
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
1009
|
/**
|
|
1214
1010
|
* Runs done callback per field when async tests are finished running.
|
|
1215
1011
|
*/
|
|
@@ -1231,10 +1027,10 @@ function runDoneCallbacks() {
|
|
|
1231
1027
|
|
|
1232
1028
|
// eslint-disable-next-line max-lines-per-function
|
|
1233
1029
|
function initBus() {
|
|
1234
|
-
var
|
|
1030
|
+
var vestBus = bus.createBus();
|
|
1235
1031
|
// Report a the completion of a test. There may be other tests with the same
|
|
1236
1032
|
// name that are still running, or not yet started.
|
|
1237
|
-
|
|
1033
|
+
vestBus.on(Events.TEST_COMPLETED, function (testObject) {
|
|
1238
1034
|
if (testObject.isCanceled()) {
|
|
1239
1035
|
return;
|
|
1240
1036
|
}
|
|
@@ -1242,21 +1038,21 @@ function initBus() {
|
|
|
1242
1038
|
runFieldCallbacks(testObject.fieldName);
|
|
1243
1039
|
if (!hasRemainingTests()) {
|
|
1244
1040
|
// When no more tests are running, emit the done event
|
|
1245
|
-
|
|
1041
|
+
vestBus.emit(Events.ALL_RUNNING_TESTS_FINISHED);
|
|
1246
1042
|
}
|
|
1247
1043
|
});
|
|
1248
1044
|
// Report that the suite completed its synchronous test run.
|
|
1249
1045
|
// Async operations may still be running.
|
|
1250
|
-
|
|
1046
|
+
vestBus.on(Events.SUITE_CALLBACK_DONE_RUNNING, function () {
|
|
1251
1047
|
// Remove tests that are optional and need to be omitted
|
|
1252
1048
|
omitOptionalFields();
|
|
1253
1049
|
});
|
|
1254
1050
|
// Called when all the tests, including async, are done running
|
|
1255
|
-
|
|
1051
|
+
vestBus.on(Events.ALL_RUNNING_TESTS_FINISHED, function () {
|
|
1256
1052
|
runDoneCallbacks();
|
|
1257
1053
|
});
|
|
1258
1054
|
// Removes a certain field from the state.
|
|
1259
|
-
|
|
1055
|
+
vestBus.on(Events.REMOVE_FIELD, function (fieldName) {
|
|
1260
1056
|
useEachTestObject(function (testObject) {
|
|
1261
1057
|
if (matchingFieldName(testObject, fieldName)) {
|
|
1262
1058
|
testObject.cancel();
|
|
@@ -1265,14 +1061,14 @@ function initBus() {
|
|
|
1265
1061
|
});
|
|
1266
1062
|
});
|
|
1267
1063
|
// Resets a certain field in the state.
|
|
1268
|
-
|
|
1064
|
+
vestBus.on(Events.RESET_FIELD, function (fieldName) {
|
|
1269
1065
|
useEachTestObject(function (testObject) {
|
|
1270
1066
|
if (matchingFieldName(testObject, fieldName)) {
|
|
1271
1067
|
testObject.reset();
|
|
1272
1068
|
}
|
|
1273
1069
|
});
|
|
1274
1070
|
});
|
|
1275
|
-
return
|
|
1071
|
+
return vestBus;
|
|
1276
1072
|
}
|
|
1277
1073
|
function useBus() {
|
|
1278
1074
|
var context$1 = context.useX();
|
|
@@ -1593,9 +1389,7 @@ function eager() {
|
|
|
1593
1389
|
setMode(Modes.EAGER);
|
|
1594
1390
|
}
|
|
1595
1391
|
function shouldSkipBasedOnMode(testObject) {
|
|
1596
|
-
|
|
1597
|
-
return true;
|
|
1598
|
-
return false;
|
|
1392
|
+
return isEager() && hasErrorsByTestObjects(testObject.fieldName);
|
|
1599
1393
|
}
|
|
1600
1394
|
function isEager() {
|
|
1601
1395
|
return isMode(Modes.EAGER);
|
|
@@ -1659,7 +1453,7 @@ function optional(optionals) {
|
|
|
1659
1453
|
}
|
|
1660
1454
|
}
|
|
1661
1455
|
|
|
1662
|
-
|
|
1456
|
+
/******************************************************************************
|
|
1663
1457
|
Copyright (c) Microsoft Corporation.
|
|
1664
1458
|
|
|
1665
1459
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -1684,9 +1478,7 @@ function __spreadArray(to, from, pack) {
|
|
|
1684
1478
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1685
1479
|
}
|
|
1686
1480
|
|
|
1687
|
-
|
|
1688
|
-
return value && isFunction(value.then);
|
|
1689
|
-
}
|
|
1481
|
+
bindNot(isStringValue);
|
|
1690
1482
|
|
|
1691
1483
|
function isSameProfileTest(testObject1, testObject2) {
|
|
1692
1484
|
return (testObject1.fieldName === testObject2.fieldName &&
|
|
@@ -1802,31 +1594,24 @@ function useTestAtCursor(newTestObject) {
|
|
|
1802
1594
|
return nextTest;
|
|
1803
1595
|
}
|
|
1804
1596
|
function removeAllNextTestsInIsolate() {
|
|
1805
|
-
var
|
|
1806
|
-
var prevTests = testObjects.prev;
|
|
1807
|
-
var current = getCurrent(prevTests, usePath());
|
|
1808
|
-
var cursorAt = useCursorAt();
|
|
1809
|
-
current.splice(cursorAt);
|
|
1597
|
+
var cursorAt = useCursor().current();
|
|
1810
1598
|
// We actually don't mind mutating the state directly (as can be seen above). There is no harm in it
|
|
1811
1599
|
// since we're only touching the "prev" state. The reason we still use the setter function is
|
|
1812
1600
|
// to prevent future headaches if we ever do need to rely on prev-state immutability.
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
return
|
|
1816
|
-
prev: prevTests,
|
|
1817
|
-
current: current
|
|
1818
|
-
});
|
|
1601
|
+
useSetTests(function (current) {
|
|
1602
|
+
current.splice(cursorAt);
|
|
1603
|
+
return current;
|
|
1819
1604
|
});
|
|
1820
1605
|
}
|
|
1821
1606
|
function useSetTestAtCursor(testObject) {
|
|
1822
|
-
var cursorPath =
|
|
1607
|
+
var cursorPath = useCurrentPath();
|
|
1823
1608
|
useSetTests(function (tests) {
|
|
1824
|
-
return setValueAtPath(tests, cursorPath, testObject);
|
|
1609
|
+
return nestedArray.setValueAtPath(tests, cursorPath, testObject);
|
|
1825
1610
|
});
|
|
1826
1611
|
}
|
|
1827
1612
|
function useGetTestAtCursor(tests) {
|
|
1828
|
-
var cursorPath =
|
|
1829
|
-
return valueAtPath(tests, cursorPath);
|
|
1613
|
+
var cursorPath = useCurrentPath();
|
|
1614
|
+
return nestedArray.valueAtPath(tests, cursorPath);
|
|
1830
1615
|
}
|
|
1831
1616
|
function testReorderDetected(prevTest, newTest) {
|
|
1832
1617
|
return isNotEmpty(prevTest) && !isSameProfileTest(prevTest, newTest);
|
|
@@ -1849,16 +1634,17 @@ function handleKeyTest(key, newTestObject) {
|
|
|
1849
1634
|
|
|
1850
1635
|
// eslint-disable-next-line max-statements
|
|
1851
1636
|
function registerPrevRunTest(testObject) {
|
|
1637
|
+
var cursor = useCursor();
|
|
1852
1638
|
if (shouldSkipBasedOnMode(testObject)) {
|
|
1853
1639
|
testObject.skip();
|
|
1854
1640
|
useTestAtCursor(testObject);
|
|
1855
|
-
|
|
1641
|
+
cursor.next();
|
|
1856
1642
|
return testObject;
|
|
1857
1643
|
}
|
|
1858
1644
|
var prevRunTest = useTestAtCursor(testObject);
|
|
1859
1645
|
if (isOmitted()) {
|
|
1860
1646
|
prevRunTest.omit();
|
|
1861
|
-
|
|
1647
|
+
cursor.next();
|
|
1862
1648
|
return prevRunTest;
|
|
1863
1649
|
}
|
|
1864
1650
|
if (isExcluded(testObject)) {
|
|
@@ -1867,13 +1653,13 @@ function registerPrevRunTest(testObject) {
|
|
|
1867
1653
|
// This mostly means that we're probably giving
|
|
1868
1654
|
// up on this async test intentionally.
|
|
1869
1655
|
prevRunTest.skip(isExcludedIndividually());
|
|
1870
|
-
|
|
1656
|
+
cursor.next();
|
|
1871
1657
|
return prevRunTest;
|
|
1872
1658
|
}
|
|
1873
1659
|
cancelOverriddenPendingTest(prevRunTest, testObject);
|
|
1874
1660
|
useSetTestAtCursor(testObject);
|
|
1875
|
-
moveForward();
|
|
1876
1661
|
registerTestObjectByTier(testObject);
|
|
1662
|
+
cursor.next();
|
|
1877
1663
|
return testObject;
|
|
1878
1664
|
}
|
|
1879
1665
|
function registerTestObjectByTier(testObject) {
|
|
@@ -1896,7 +1682,7 @@ function bindTestMemo(test) {
|
|
|
1896
1682
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1897
1683
|
args[_i - 1] = arguments[_i];
|
|
1898
1684
|
}
|
|
1899
|
-
var cursorAt =
|
|
1685
|
+
var cursorAt = useCursor().current();
|
|
1900
1686
|
var _a = args.reverse(), deps = _a[0], testFn = _a[1], msg = _a[2];
|
|
1901
1687
|
// Implicit dependency for more specificity
|
|
1902
1688
|
var dependencies = [useSuiteId(), fieldName, cursorAt].concat(deps);
|
|
@@ -1958,6 +1744,6 @@ function warn() {
|
|
|
1958
1744
|
ctx.currentTest.warn();
|
|
1959
1745
|
}
|
|
1960
1746
|
|
|
1961
|
-
var VERSION = "4.4.
|
|
1747
|
+
var VERSION = "4.4.2-dev-afe5de";
|
|
1962
1748
|
|
|
1963
1749
|
export { VERSION, context, create, each, eager, group, include, omitWhen, only, optional, skip, skipWhen, test, warn };
|