vest 4.4.1 → 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 +94 -293
- 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 +19 -218
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/classnames.development.js +13 -13
- package/dist/umd/classnames.production.js +1 -1
- package/dist/umd/enforce/compose.development.js +121 -121
- package/dist/umd/enforce/compose.production.js +1 -1
- package/dist/umd/enforce/compounds.development.js +180 -184
- package/dist/umd/enforce/compounds.production.js +1 -1
- package/dist/umd/enforce/schema.development.js +132 -132
- package/dist/umd/enforce/schema.production.js +1 -1
- package/dist/umd/parser.development.js +13 -13
- package/dist/umd/parser.production.js +1 -1
- package/dist/umd/vest.development.js +277 -277
- 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 +0 -8
- package/types/enforce/compose.d.ts +14 -30
- package/types/enforce/compounds.d.ts +14 -30
- package/types/enforce/schema.d.ts +14 -30
- package/types/vest.d.ts +4 -3
- package/testUtils/itWithContext.ts +0 -23
|
@@ -3,44 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var n4s = require('n4s');
|
|
6
|
+
var vestUtils = require('vest-utils');
|
|
6
7
|
var context$1 = require('context');
|
|
7
8
|
|
|
8
|
-
/**
|
|
9
|
-
* @returns a unique numeric id.
|
|
10
|
-
*/
|
|
11
|
-
var genId = (function (n) { return function () {
|
|
12
|
-
return "".concat(n++);
|
|
13
|
-
}; })(0);
|
|
14
|
-
|
|
15
|
-
function isStringValue(v) {
|
|
16
|
-
return String(v) === v;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function bindNot(fn) {
|
|
20
|
-
return function () {
|
|
21
|
-
var args = [];
|
|
22
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
23
|
-
args[_i] = arguments[_i];
|
|
24
|
-
}
|
|
25
|
-
return !fn.apply(void 0, args);
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function isUndefined(value) {
|
|
30
|
-
return value === undefined;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
9
|
function shouldUseErrorAsMessage(message, error) {
|
|
34
10
|
// kind of cheating with this safe guard, but it does the job
|
|
35
|
-
return isUndefined(message) && isStringValue(error);
|
|
11
|
+
return vestUtils.isUndefined(message) && vestUtils.isStringValue(error);
|
|
36
12
|
}
|
|
37
13
|
|
|
38
|
-
function asArray(possibleArg) {
|
|
39
|
-
return [].concat(possibleArg);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var assign = Object.assign;
|
|
43
|
-
|
|
44
14
|
function isNumeric(value) {
|
|
45
15
|
var str = String(value);
|
|
46
16
|
var num = Number(value);
|
|
@@ -101,85 +71,6 @@ function createCache(maxSize) {
|
|
|
101
71
|
}
|
|
102
72
|
}
|
|
103
73
|
|
|
104
|
-
// The module is named "isArrayValue" since it
|
|
105
|
-
// is conflicting with a nested npm dependency.
|
|
106
|
-
// We may need to revisit this in the future.
|
|
107
|
-
function isArray(value) {
|
|
108
|
-
return Boolean(Array.isArray(value));
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function isNull(value) {
|
|
112
|
-
return value === null;
|
|
113
|
-
}
|
|
114
|
-
var isNotNull = bindNot(isNull);
|
|
115
|
-
|
|
116
|
-
function isFunction(value) {
|
|
117
|
-
return typeof value === 'function';
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function optionalFunctionValue(value) {
|
|
121
|
-
var args = [];
|
|
122
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
123
|
-
args[_i - 1] = arguments[_i];
|
|
124
|
-
}
|
|
125
|
-
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function defaultTo(callback, defaultValue) {
|
|
129
|
-
var _a;
|
|
130
|
-
return (_a = optionalFunctionValue(callback)) !== null && _a !== void 0 ? _a : defaultValue;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function last(values) {
|
|
134
|
-
var valuesArray = asArray(values);
|
|
135
|
-
return valuesArray[valuesArray.length - 1];
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// This is kind of a map/filter in one function.
|
|
139
|
-
// Normally, behaves like a nested-array map,
|
|
140
|
-
// but returning `null` will drop the element from the array
|
|
141
|
-
function transform(array, cb) {
|
|
142
|
-
var res = [];
|
|
143
|
-
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
|
|
144
|
-
var v = array_1[_i];
|
|
145
|
-
if (isArray(v)) {
|
|
146
|
-
res.push(transform(v, cb));
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
var output = cb(v);
|
|
150
|
-
if (isNotNull(output)) {
|
|
151
|
-
res.push(output);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return res;
|
|
156
|
-
}
|
|
157
|
-
function valueAtPath(array, path) {
|
|
158
|
-
return getCurrent(array, path)[last(path)];
|
|
159
|
-
}
|
|
160
|
-
function setValueAtPath(array, path, value) {
|
|
161
|
-
var current = getCurrent(array, path);
|
|
162
|
-
current[last(path)] = value;
|
|
163
|
-
return array;
|
|
164
|
-
}
|
|
165
|
-
function flatten(values) {
|
|
166
|
-
return asArray(values).reduce(function (acc, value) {
|
|
167
|
-
if (isArray(value)) {
|
|
168
|
-
return acc.concat(flatten(value));
|
|
169
|
-
}
|
|
170
|
-
return asArray(acc).concat(value);
|
|
171
|
-
}, []);
|
|
172
|
-
}
|
|
173
|
-
function getCurrent(array, path) {
|
|
174
|
-
var current = array;
|
|
175
|
-
for (var _i = 0, _a = path.slice(0, -1); _i < _a.length; _i++) {
|
|
176
|
-
var p = _a[_i];
|
|
177
|
-
current[p] = defaultTo(current[p], []);
|
|
178
|
-
current = current[p];
|
|
179
|
-
}
|
|
180
|
-
return current;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
74
|
var IsolateTypes;
|
|
184
75
|
(function (IsolateTypes) {
|
|
185
76
|
IsolateTypes[IsolateTypes["DEFAULT"] = 0] = "DEFAULT";
|
|
@@ -234,7 +125,7 @@ function generateIsolate(type, path) {
|
|
|
234
125
|
var context = context$1.createContext(function (ctxRef, parentContext) {
|
|
235
126
|
return parentContext
|
|
236
127
|
? null
|
|
237
|
-
: assign({}, {
|
|
128
|
+
: vestUtils.assign({}, {
|
|
238
129
|
exclusion: {
|
|
239
130
|
tests: {},
|
|
240
131
|
groups: {}
|
|
@@ -272,8 +163,8 @@ function useSetOptionalField(fieldName, setter) {
|
|
|
272
163
|
var _a = useOptionalFields(), setOptionalFields = _a[1];
|
|
273
164
|
setOptionalFields(function (optionalFields) {
|
|
274
165
|
var _a;
|
|
275
|
-
return assign(optionalFields, (_a = {},
|
|
276
|
-
_a[fieldName] = optionalFunctionValue(setter, optionalFields[fieldName]),
|
|
166
|
+
return vestUtils.assign(optionalFields, (_a = {},
|
|
167
|
+
_a[fieldName] = vestUtils.optionalFunctionValue(setter, optionalFields[fieldName]),
|
|
277
168
|
_a));
|
|
278
169
|
});
|
|
279
170
|
}
|
|
@@ -298,7 +189,7 @@ function useSetTests(handler) {
|
|
|
298
189
|
var current = _a.current, prev = _a.prev;
|
|
299
190
|
return ({
|
|
300
191
|
prev: prev,
|
|
301
|
-
current: asArray(handler(current))
|
|
192
|
+
current: vestUtils.asArray(handler(current))
|
|
302
193
|
});
|
|
303
194
|
});
|
|
304
195
|
}
|
|
@@ -309,7 +200,7 @@ function useAllIncomplete() {
|
|
|
309
200
|
var flatCache = createCache();
|
|
310
201
|
function useTestsFlat() {
|
|
311
202
|
var current = useTestObjects()[0].current;
|
|
312
|
-
return flatCache([current], function () { return flatten(current); });
|
|
203
|
+
return flatCache([current], function () { return vestUtils.nestedArray.flatten(current); });
|
|
313
204
|
}
|
|
314
205
|
function useEachTestObject(handler) {
|
|
315
206
|
var testObjects = useTestsFlat();
|
|
@@ -325,7 +216,7 @@ var VestTest = /** @class */ (function () {
|
|
|
325
216
|
function VestTest(fieldName, testFn, _a) {
|
|
326
217
|
var _b = _a === void 0 ? {} : _a, message = _b.message, groupName = _b.groupName, key = _b.key;
|
|
327
218
|
this.key = null;
|
|
328
|
-
this.id = genId();
|
|
219
|
+
this.id = vestUtils.genId();
|
|
329
220
|
this.severity = TestSeverity.Error;
|
|
330
221
|
this.status = STATUS_UNTESTED;
|
|
331
222
|
this.fieldName = fieldName;
|
|
@@ -460,20 +351,6 @@ var STATUS_PENDING = 'PENDING';
|
|
|
460
351
|
var STATUS_CANCELED = 'CANCELED';
|
|
461
352
|
var STATUS_OMITTED = 'OMITTED';
|
|
462
353
|
|
|
463
|
-
function invariant(condition,
|
|
464
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
465
|
-
message) {
|
|
466
|
-
if (condition) {
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
469
|
-
// If message is a string object (rather than string literal)
|
|
470
|
-
// Throw the value directly as a string
|
|
471
|
-
// Alternatively, throw an error with the message
|
|
472
|
-
throw message instanceof String
|
|
473
|
-
? message.valueOf()
|
|
474
|
-
: new Error(message ? optionalFunctionValue(message) : message);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
354
|
// eslint-disable-next-line max-lines-per-function
|
|
478
355
|
function createState(onStateChange) {
|
|
479
356
|
var state = {
|
|
@@ -512,12 +389,12 @@ function createState(onStateChange) {
|
|
|
512
389
|
}
|
|
513
390
|
function initKey(key, initialState, prevState) {
|
|
514
391
|
current().push();
|
|
515
|
-
set(key, optionalFunctionValue(initialState, prevState));
|
|
392
|
+
set(key, vestUtils.optionalFunctionValue(initialState, prevState));
|
|
516
393
|
return function useStateKey() {
|
|
517
394
|
return [
|
|
518
395
|
current()[key],
|
|
519
396
|
function (nextState) {
|
|
520
|
-
return set(key, optionalFunctionValue(nextState, current()[key]));
|
|
397
|
+
return set(key, vestUtils.optionalFunctionValue(nextState, current()[key]));
|
|
521
398
|
},
|
|
522
399
|
];
|
|
523
400
|
};
|
|
@@ -529,10 +406,10 @@ function createState(onStateChange) {
|
|
|
529
406
|
var prevValue = state.references[index];
|
|
530
407
|
state.references[index] = value;
|
|
531
408
|
var _a = registrations[index], onUpdate = _a[1];
|
|
532
|
-
if (isFunction(onUpdate)) {
|
|
409
|
+
if (vestUtils.isFunction(onUpdate)) {
|
|
533
410
|
onUpdate(value, prevValue);
|
|
534
411
|
}
|
|
535
|
-
if (isFunction(onStateChange)) {
|
|
412
|
+
if (vestUtils.isFunction(onStateChange)) {
|
|
536
413
|
onStateChange();
|
|
537
414
|
}
|
|
538
415
|
}
|
|
@@ -557,23 +434,13 @@ function createStateRef(state, _a) {
|
|
|
557
434
|
};
|
|
558
435
|
}
|
|
559
436
|
|
|
560
|
-
function isNullish(value) {
|
|
561
|
-
return isNull(value) || isUndefined(value);
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
function deferThrow(message) {
|
|
565
|
-
setTimeout(function () {
|
|
566
|
-
throw new Error(message);
|
|
567
|
-
}, 0);
|
|
568
|
-
}
|
|
569
|
-
|
|
570
437
|
function usePrevKeys() {
|
|
571
438
|
var prev = useTestObjects()[0].prev;
|
|
572
|
-
return asArray(getCurrent(prev, useCurrentPath())).reduce(function (prevKeys, testObject) {
|
|
439
|
+
return vestUtils.asArray(vestUtils.nestedArray.getCurrent(prev, useCurrentPath())).reduce(function (prevKeys, testObject) {
|
|
573
440
|
if (!(testObject instanceof VestTest)) {
|
|
574
441
|
return prevKeys;
|
|
575
442
|
}
|
|
576
|
-
if (isNullish(testObject.key)) {
|
|
443
|
+
if (vestUtils.isNullish(testObject.key)) {
|
|
577
444
|
return prevKeys;
|
|
578
445
|
}
|
|
579
446
|
prevKeys[testObject.key] = testObject;
|
|
@@ -586,22 +453,22 @@ function usePrevTestByKey(key) {
|
|
|
586
453
|
}
|
|
587
454
|
function useRetainTestKey(key, testObject) {
|
|
588
455
|
var current = useIsolate().keys.current;
|
|
589
|
-
if (isNullish(current[key])) {
|
|
456
|
+
if (vestUtils.isNullish(current[key])) {
|
|
590
457
|
current[key] = testObject;
|
|
591
458
|
}
|
|
592
459
|
else {
|
|
593
|
-
deferThrow("Encountered the same test key \"".concat(key, "\" twice. This may lead to tests overriding each other's results, or to tests being unexpectedly omitted."));
|
|
460
|
+
vestUtils.deferThrow("Encountered the same test key \"".concat(key, "\" twice. This may lead to tests overriding each other's results, or to tests being unexpectedly omitted."));
|
|
594
461
|
}
|
|
595
462
|
}
|
|
596
463
|
|
|
597
464
|
function isolate(_a, callback) {
|
|
598
465
|
var _b = _a.type, type = _b === void 0 ? IsolateTypes.DEFAULT : _b;
|
|
599
|
-
invariant(isFunction(callback));
|
|
466
|
+
vestUtils.invariant(vestUtils.isFunction(callback));
|
|
600
467
|
// Generate a new Isolate layer, with its own cursor
|
|
601
468
|
var isolate = generateIsolate(type, useCurrentPath());
|
|
602
469
|
var output = context.run({ isolate: isolate }, function () {
|
|
603
470
|
isolate.keys.prev = usePrevKeys();
|
|
604
|
-
useSetTests(function (tests) { return setValueAtPath(tests, isolate.path, []); });
|
|
471
|
+
useSetTests(function (tests) { return vestUtils.nestedArray.setValueAtPath(tests, isolate.path, []); });
|
|
605
472
|
var res = callback();
|
|
606
473
|
return res;
|
|
607
474
|
});
|
|
@@ -651,34 +518,6 @@ function countKeyBySeverity(severity) {
|
|
|
651
518
|
: SeverityCount.WARN_COUNT;
|
|
652
519
|
}
|
|
653
520
|
|
|
654
|
-
/**
|
|
655
|
-
* A safe hasOwnProperty access
|
|
656
|
-
*/
|
|
657
|
-
function hasOwnProperty(obj, key) {
|
|
658
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
function isNumber(value) {
|
|
662
|
-
return Boolean(typeof value === 'number');
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
function isEmpty(value) {
|
|
666
|
-
if (!value) {
|
|
667
|
-
return true;
|
|
668
|
-
}
|
|
669
|
-
else if (isNumber(value)) {
|
|
670
|
-
return value === 0;
|
|
671
|
-
}
|
|
672
|
-
else if (hasOwnProperty(value, 'length')) {
|
|
673
|
-
return lengthEquals(value, 0);
|
|
674
|
-
}
|
|
675
|
-
else if (typeof value === 'object') {
|
|
676
|
-
return lengthEquals(Object.keys(value), 0);
|
|
677
|
-
}
|
|
678
|
-
return false;
|
|
679
|
-
}
|
|
680
|
-
var isNotEmpty = bindNot(isEmpty);
|
|
681
|
-
|
|
682
521
|
function nonMatchingFieldName(testObject, fieldName) {
|
|
683
522
|
return !!fieldName && !matchingFieldName(testObject, fieldName);
|
|
684
523
|
}
|
|
@@ -686,20 +525,16 @@ function matchingFieldName(testObject, fieldName) {
|
|
|
686
525
|
return !!(fieldName && testObject.fieldName === fieldName);
|
|
687
526
|
}
|
|
688
527
|
|
|
689
|
-
var nonMatchingGroupName = bindNot(matchingGroupName);
|
|
528
|
+
var nonMatchingGroupName = vestUtils.bindNot(matchingGroupName);
|
|
690
529
|
function matchingGroupName(testObject, groupName) {
|
|
691
530
|
return testObject.groupName === groupName;
|
|
692
531
|
}
|
|
693
532
|
|
|
694
|
-
function either(a, b) {
|
|
695
|
-
return !!a !== !!b;
|
|
696
|
-
}
|
|
697
|
-
|
|
698
533
|
/**
|
|
699
534
|
* Checks that a given test object matches the currently specified severity level
|
|
700
535
|
*/
|
|
701
536
|
function nonMatchingSeverityProfile(severity, testObject) {
|
|
702
|
-
return either(severity === Severity.WARNINGS, testObject.warns());
|
|
537
|
+
return vestUtils.either(severity === Severity.WARNINGS, testObject.warns());
|
|
703
538
|
}
|
|
704
539
|
|
|
705
540
|
/**
|
|
@@ -749,7 +584,7 @@ function shouldAddValidProperty(fieldName) {
|
|
|
749
584
|
return false;
|
|
750
585
|
}
|
|
751
586
|
var testObjects = useTestsFlat();
|
|
752
|
-
if (isEmpty(testObjects)) {
|
|
587
|
+
if (vestUtils.isEmpty(testObjects)) {
|
|
753
588
|
return false;
|
|
754
589
|
}
|
|
755
590
|
// Does the given field have any pending tests that are not optional?
|
|
@@ -779,13 +614,13 @@ function fieldIsOmitted(fieldName) {
|
|
|
779
614
|
}
|
|
780
615
|
// Does the given field have any pending tests that are not optional?
|
|
781
616
|
function hasNonOptionalIncomplete(fieldName) {
|
|
782
|
-
return isNotEmpty(useAllIncomplete().filter(function (testObject) {
|
|
617
|
+
return vestUtils.isNotEmpty(useAllIncomplete().filter(function (testObject) {
|
|
783
618
|
return isOptionalFieldIncomplete(testObject, fieldName);
|
|
784
619
|
}));
|
|
785
620
|
}
|
|
786
621
|
// Do the given group/field have any pending tests that are not optional?
|
|
787
622
|
function hasNonOptionalIncompleteByGroup(groupName, fieldName) {
|
|
788
|
-
return isNotEmpty(useAllIncomplete().filter(function (testObject) {
|
|
623
|
+
return vestUtils.isNotEmpty(useAllIncomplete().filter(function (testObject) {
|
|
789
624
|
if (nonMatchingGroupName(testObject, groupName)) {
|
|
790
625
|
return false;
|
|
791
626
|
}
|
|
@@ -827,7 +662,7 @@ function missingTestsLogic(testObject, fieldName) {
|
|
|
827
662
|
|
|
828
663
|
function useSummary() {
|
|
829
664
|
var summary = context.useX().summary;
|
|
830
|
-
invariant(summary);
|
|
665
|
+
vestUtils.invariant(summary);
|
|
831
666
|
return summary;
|
|
832
667
|
}
|
|
833
668
|
/**
|
|
@@ -835,7 +670,7 @@ function useSummary() {
|
|
|
835
670
|
*/
|
|
836
671
|
function genTestsSummary() {
|
|
837
672
|
var testObjects = useTestsFlat();
|
|
838
|
-
var summary = assign(baseStats(), {
|
|
673
|
+
var summary = vestUtils.assign(baseStats(), {
|
|
839
674
|
groups: {},
|
|
840
675
|
tests: {},
|
|
841
676
|
valid: false
|
|
@@ -912,16 +747,12 @@ function baseStats() {
|
|
|
912
747
|
};
|
|
913
748
|
}
|
|
914
749
|
function baseTestStats() {
|
|
915
|
-
return assign(baseStats(), {
|
|
750
|
+
return vestUtils.assign(baseStats(), {
|
|
916
751
|
errors: [],
|
|
917
752
|
warnings: []
|
|
918
753
|
});
|
|
919
754
|
}
|
|
920
755
|
|
|
921
|
-
function isPositive(value) {
|
|
922
|
-
return greaterThan(value, 0);
|
|
923
|
-
}
|
|
924
|
-
|
|
925
756
|
// calls collectAll or getByFieldName depending on whether fieldName is provided
|
|
926
757
|
function gatherFailures(testGroup, severityKey, fieldName) {
|
|
927
758
|
return fieldName
|
|
@@ -936,7 +767,7 @@ function collectAll(testGroup, severityKey) {
|
|
|
936
767
|
var output = {};
|
|
937
768
|
var countKey = countKeyBySeverity(severityKey);
|
|
938
769
|
for (var field in testGroup) {
|
|
939
|
-
if (isPositive(testGroup[field][countKey])) {
|
|
770
|
+
if (vestUtils.isPositive(testGroup[field][countKey])) {
|
|
940
771
|
// We will probably never get to the fallback array
|
|
941
772
|
// leaving it just in case the implementation changes
|
|
942
773
|
output[field] = testGroup[field][severityKey] || [];
|
|
@@ -980,9 +811,9 @@ function hasFailures(severityCount, fieldName) {
|
|
|
980
811
|
var _a;
|
|
981
812
|
var summary = useSummary();
|
|
982
813
|
if (fieldName) {
|
|
983
|
-
return isPositive((_a = summary.tests[fieldName]) === null || _a === void 0 ? void 0 : _a[severityCount]);
|
|
814
|
+
return vestUtils.isPositive((_a = summary.tests[fieldName]) === null || _a === void 0 ? void 0 : _a[severityCount]);
|
|
984
815
|
}
|
|
985
|
-
return isPositive(summary[severityCount]);
|
|
816
|
+
return vestUtils.isPositive(summary[severityCount]);
|
|
986
817
|
}
|
|
987
818
|
|
|
988
819
|
function hasErrorsByGroup(groupName, fieldName) {
|
|
@@ -1001,10 +832,10 @@ function hasFailuresByGroup(severityKey, groupName, fieldName) {
|
|
|
1001
832
|
return false;
|
|
1002
833
|
}
|
|
1003
834
|
if (fieldName) {
|
|
1004
|
-
return isPositive((_a = group[fieldName]) === null || _a === void 0 ? void 0 : _a[severityCount]);
|
|
835
|
+
return vestUtils.isPositive((_a = group[fieldName]) === null || _a === void 0 ? void 0 : _a[severityCount]);
|
|
1005
836
|
}
|
|
1006
837
|
for (var field in group) {
|
|
1007
|
-
if (isPositive((_b = group[field]) === null || _b === void 0 ? void 0 : _b[severityCount])) {
|
|
838
|
+
if (vestUtils.isPositive((_b = group[field]) === null || _b === void 0 ? void 0 : _b[severityCount])) {
|
|
1008
839
|
return true;
|
|
1009
840
|
}
|
|
1010
841
|
}
|
|
@@ -1046,7 +877,7 @@ function produceSuiteResult() {
|
|
|
1046
877
|
var summary = genTestsSummary();
|
|
1047
878
|
var suiteName = useSuiteName();
|
|
1048
879
|
var ref = { summary: summary };
|
|
1049
|
-
return assign(summary, {
|
|
880
|
+
return vestUtils.assign(summary, {
|
|
1050
881
|
getErrors: context.bind(ref, getErrors),
|
|
1051
882
|
getErrorsByGroup: context.bind(ref, getErrorsByGroup),
|
|
1052
883
|
getWarnings: context.bind(ref, getWarnings),
|
|
@@ -1067,7 +898,7 @@ function produceSuiteResult() {
|
|
|
1067
898
|
*/
|
|
1068
899
|
function hasRemainingTests(fieldName) {
|
|
1069
900
|
var allIncomplete = useAllIncomplete();
|
|
1070
|
-
if (isEmpty(allIncomplete)) {
|
|
901
|
+
if (vestUtils.isEmpty(allIncomplete)) {
|
|
1071
902
|
return false;
|
|
1072
903
|
}
|
|
1073
904
|
if (fieldName) {
|
|
@@ -1075,7 +906,7 @@ function hasRemainingTests(fieldName) {
|
|
|
1075
906
|
return matchingFieldName(testObject, fieldName);
|
|
1076
907
|
});
|
|
1077
908
|
}
|
|
1078
|
-
return isNotEmpty(allIncomplete);
|
|
909
|
+
return vestUtils.isNotEmpty(allIncomplete);
|
|
1079
910
|
}
|
|
1080
911
|
|
|
1081
912
|
var cache = createCache(20);
|
|
@@ -1083,7 +914,7 @@ function produceFullResult() {
|
|
|
1083
914
|
var testObjects = useTestsFlat();
|
|
1084
915
|
var ctxRef = { stateRef: useStateRef() };
|
|
1085
916
|
return cache([testObjects], context.bind(ctxRef, function () {
|
|
1086
|
-
return assign({}, produceSuiteResult(), {
|
|
917
|
+
return vestUtils.assign({}, produceSuiteResult(), {
|
|
1087
918
|
done: context.bind(ctxRef, done)
|
|
1088
919
|
});
|
|
1089
920
|
}));
|
|
@@ -1093,9 +924,9 @@ function produceFullResult() {
|
|
|
1093
924
|
*/
|
|
1094
925
|
function shouldSkipDoneRegistration(callback, fieldName, output) {
|
|
1095
926
|
// If we do not have any test runs for the current field
|
|
1096
|
-
return !!(!isFunction(callback) ||
|
|
927
|
+
return !!(!vestUtils.isFunction(callback) ||
|
|
1097
928
|
(fieldName &&
|
|
1098
|
-
(!output.tests[fieldName] || isEmpty(output.tests[fieldName].testCount))));
|
|
929
|
+
(!output.tests[fieldName] || vestUtils.isEmpty(output.tests[fieldName].testCount))));
|
|
1099
930
|
}
|
|
1100
931
|
function shouldRunDoneCallback(fieldName) {
|
|
1101
932
|
// is suite finished || field name exists, and test is finished;
|
|
@@ -1137,38 +968,16 @@ function deferDoneCallback(doneCallback, fieldName) {
|
|
|
1137
968
|
});
|
|
1138
969
|
}
|
|
1139
970
|
|
|
1140
|
-
function createBus() {
|
|
1141
|
-
var listeners = {};
|
|
1142
|
-
return {
|
|
1143
|
-
emit: function (event, data) {
|
|
1144
|
-
listener(event).forEach(function (handler) {
|
|
1145
|
-
handler(data);
|
|
1146
|
-
});
|
|
1147
|
-
},
|
|
1148
|
-
on: function (event, handler) {
|
|
1149
|
-
listeners[event] = listener(event).concat(handler);
|
|
1150
|
-
return {
|
|
1151
|
-
off: function () {
|
|
1152
|
-
listeners[event] = listener(event).filter(function (h) { return h !== handler; });
|
|
1153
|
-
}
|
|
1154
|
-
};
|
|
1155
|
-
}
|
|
1156
|
-
};
|
|
1157
|
-
function listener(event) {
|
|
1158
|
-
return listeners[event] || [];
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
971
|
function omitOptionalFields() {
|
|
1163
972
|
var optionalFields = useOptionalFields()[0];
|
|
1164
|
-
if (isEmpty(optionalFields)) {
|
|
973
|
+
if (vestUtils.isEmpty(optionalFields)) {
|
|
1165
974
|
return;
|
|
1166
975
|
}
|
|
1167
976
|
var shouldOmit = {};
|
|
1168
977
|
useSetTests(function (tests) {
|
|
1169
|
-
return transform(tests, function (testObject) {
|
|
978
|
+
return vestUtils.nestedArray.transform(tests, function (testObject) {
|
|
1170
979
|
var fieldName = testObject.fieldName;
|
|
1171
|
-
if (hasOwnProperty(shouldOmit, fieldName)) {
|
|
980
|
+
if (vestUtils.hasOwnProperty(shouldOmit, fieldName)) {
|
|
1172
981
|
verifyAndOmit(testObject);
|
|
1173
982
|
}
|
|
1174
983
|
else {
|
|
@@ -1185,7 +994,7 @@ function omitOptionalFields() {
|
|
|
1185
994
|
}
|
|
1186
995
|
function runOptionalConfig(testObject) {
|
|
1187
996
|
var optionalConfig = useOptionalFieldConfig(testObject.fieldName);
|
|
1188
|
-
if (isFunction(optionalConfig)) {
|
|
997
|
+
if (vestUtils.isFunction(optionalConfig)) {
|
|
1189
998
|
shouldOmit[testObject.fieldName] = optionalConfig();
|
|
1190
999
|
verifyAndOmit(testObject);
|
|
1191
1000
|
}
|
|
@@ -1197,14 +1006,10 @@ function omitOptionalFields() {
|
|
|
1197
1006
|
*/
|
|
1198
1007
|
function removeTestFromState (testObject) {
|
|
1199
1008
|
useSetTests(function (tests) {
|
|
1200
|
-
return transform(tests, function (test) { return (testObject !== test ? test : null); });
|
|
1009
|
+
return vestUtils.nestedArray.transform(tests, function (test) { return (testObject !== test ? test : null); });
|
|
1201
1010
|
});
|
|
1202
1011
|
}
|
|
1203
1012
|
|
|
1204
|
-
function callEach(arr) {
|
|
1205
|
-
return arr.forEach(function (fn) { return fn(); });
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
1013
|
/**
|
|
1209
1014
|
* Runs done callback per field when async tests are finished running.
|
|
1210
1015
|
*/
|
|
@@ -1212,8 +1017,8 @@ function runFieldCallbacks(fieldName) {
|
|
|
1212
1017
|
var fieldCallbacks = useTestCallbacks()[0].fieldCallbacks;
|
|
1213
1018
|
if (fieldName &&
|
|
1214
1019
|
!hasRemainingTests(fieldName) &&
|
|
1215
|
-
isArray(fieldCallbacks[fieldName])) {
|
|
1216
|
-
callEach(fieldCallbacks[fieldName]);
|
|
1020
|
+
vestUtils.isArray(fieldCallbacks[fieldName])) {
|
|
1021
|
+
vestUtils.callEach(fieldCallbacks[fieldName]);
|
|
1217
1022
|
}
|
|
1218
1023
|
}
|
|
1219
1024
|
/**
|
|
@@ -1221,15 +1026,15 @@ function runFieldCallbacks(fieldName) {
|
|
|
1221
1026
|
*/
|
|
1222
1027
|
function runDoneCallbacks() {
|
|
1223
1028
|
var doneCallbacks = useTestCallbacks()[0].doneCallbacks;
|
|
1224
|
-
callEach(doneCallbacks);
|
|
1029
|
+
vestUtils.callEach(doneCallbacks);
|
|
1225
1030
|
}
|
|
1226
1031
|
|
|
1227
1032
|
// eslint-disable-next-line max-lines-per-function
|
|
1228
1033
|
function initBus() {
|
|
1229
|
-
var
|
|
1034
|
+
var vestBus = vestUtils.bus.createBus();
|
|
1230
1035
|
// Report a the completion of a test. There may be other tests with the same
|
|
1231
1036
|
// name that are still running, or not yet started.
|
|
1232
|
-
|
|
1037
|
+
vestBus.on(Events.TEST_COMPLETED, function (testObject) {
|
|
1233
1038
|
if (testObject.isCanceled()) {
|
|
1234
1039
|
return;
|
|
1235
1040
|
}
|
|
@@ -1237,21 +1042,21 @@ function initBus() {
|
|
|
1237
1042
|
runFieldCallbacks(testObject.fieldName);
|
|
1238
1043
|
if (!hasRemainingTests()) {
|
|
1239
1044
|
// When no more tests are running, emit the done event
|
|
1240
|
-
|
|
1045
|
+
vestBus.emit(Events.ALL_RUNNING_TESTS_FINISHED);
|
|
1241
1046
|
}
|
|
1242
1047
|
});
|
|
1243
1048
|
// Report that the suite completed its synchronous test run.
|
|
1244
1049
|
// Async operations may still be running.
|
|
1245
|
-
|
|
1050
|
+
vestBus.on(Events.SUITE_CALLBACK_DONE_RUNNING, function () {
|
|
1246
1051
|
// Remove tests that are optional and need to be omitted
|
|
1247
1052
|
omitOptionalFields();
|
|
1248
1053
|
});
|
|
1249
1054
|
// Called when all the tests, including async, are done running
|
|
1250
|
-
|
|
1055
|
+
vestBus.on(Events.ALL_RUNNING_TESTS_FINISHED, function () {
|
|
1251
1056
|
runDoneCallbacks();
|
|
1252
1057
|
});
|
|
1253
1058
|
// Removes a certain field from the state.
|
|
1254
|
-
|
|
1059
|
+
vestBus.on(Events.REMOVE_FIELD, function (fieldName) {
|
|
1255
1060
|
useEachTestObject(function (testObject) {
|
|
1256
1061
|
if (matchingFieldName(testObject, fieldName)) {
|
|
1257
1062
|
testObject.cancel();
|
|
@@ -1260,18 +1065,18 @@ function initBus() {
|
|
|
1260
1065
|
});
|
|
1261
1066
|
});
|
|
1262
1067
|
// Resets a certain field in the state.
|
|
1263
|
-
|
|
1068
|
+
vestBus.on(Events.RESET_FIELD, function (fieldName) {
|
|
1264
1069
|
useEachTestObject(function (testObject) {
|
|
1265
1070
|
if (matchingFieldName(testObject, fieldName)) {
|
|
1266
1071
|
testObject.reset();
|
|
1267
1072
|
}
|
|
1268
1073
|
});
|
|
1269
1074
|
});
|
|
1270
|
-
return
|
|
1075
|
+
return vestBus;
|
|
1271
1076
|
}
|
|
1272
1077
|
function useBus() {
|
|
1273
1078
|
var context$1 = context.useX();
|
|
1274
|
-
invariant(context$1.bus);
|
|
1079
|
+
vestUtils.invariant(context$1.bus);
|
|
1275
1080
|
return context$1.bus;
|
|
1276
1081
|
}
|
|
1277
1082
|
var Events;
|
|
@@ -1290,16 +1095,16 @@ function create() {
|
|
|
1290
1095
|
args[_i] = arguments[_i];
|
|
1291
1096
|
}
|
|
1292
1097
|
var _a = args.reverse(), suiteCallback = _a[0], suiteName = _a[1];
|
|
1293
|
-
invariant(isFunction(suiteCallback), 'vest.create: Expected callback to be a function.');
|
|
1098
|
+
vestUtils.invariant(vestUtils.isFunction(suiteCallback), 'vest.create: Expected callback to be a function.');
|
|
1294
1099
|
// Event bus initialization
|
|
1295
1100
|
var bus = initBus();
|
|
1296
1101
|
// State initialization
|
|
1297
1102
|
var state = createState();
|
|
1298
1103
|
// State reference - this holds the actual state values
|
|
1299
|
-
var stateRef = createStateRef(state, { suiteId: genId(), suiteName: suiteName });
|
|
1104
|
+
var stateRef = createStateRef(state, { suiteId: vestUtils.genId(), suiteName: suiteName });
|
|
1300
1105
|
// Create base context reference. All hooks will derive their data from this
|
|
1301
1106
|
var ctxRef = { stateRef: stateRef, bus: bus };
|
|
1302
|
-
var suite = assign(
|
|
1107
|
+
var suite = vestUtils.assign(
|
|
1303
1108
|
// Bind the suite body to the context
|
|
1304
1109
|
context.bind(ctxRef, function () {
|
|
1305
1110
|
var args = [];
|
|
@@ -1345,7 +1150,7 @@ function create() {
|
|
|
1345
1150
|
* })
|
|
1346
1151
|
*/
|
|
1347
1152
|
function each(list, callback) {
|
|
1348
|
-
invariant(isFunction(callback), 'each callback must be a function');
|
|
1153
|
+
vestUtils.invariant(vestUtils.isFunction(callback), 'each callback must be a function');
|
|
1349
1154
|
isolate({ type: IsolateTypes.EACH }, function () {
|
|
1350
1155
|
list.forEach(function (arg, index) {
|
|
1351
1156
|
callback(arg, index);
|
|
@@ -1375,7 +1180,7 @@ function skipWhen(conditional, callback) {
|
|
|
1375
1180
|
// we should skip the test if the parent conditional is true.
|
|
1376
1181
|
isExcludedIndividually() ||
|
|
1377
1182
|
// Otherwise, we should skip the test if the conditional is true.
|
|
1378
|
-
optionalFunctionValue(conditional, optionalFunctionValue(produceSuiteResult))
|
|
1183
|
+
vestUtils.optionalFunctionValue(conditional, vestUtils.optionalFunctionValue(produceSuiteResult))
|
|
1379
1184
|
}, function () { return callback(); });
|
|
1380
1185
|
});
|
|
1381
1186
|
}
|
|
@@ -1451,7 +1256,7 @@ function isExcluded(testObject) {
|
|
|
1451
1256
|
// Check if inclusion rules for this field (`include` hook)
|
|
1452
1257
|
// TODO: Check if this may need to be moved outside of the condition.
|
|
1453
1258
|
// What if there are no included tests? This shouldn't run then?
|
|
1454
|
-
return !optionalFunctionValue(inclusion[fieldName]);
|
|
1259
|
+
return !vestUtils.optionalFunctionValue(inclusion[fieldName]);
|
|
1455
1260
|
}
|
|
1456
1261
|
// We're done here. This field is not excluded
|
|
1457
1262
|
return false;
|
|
@@ -1463,7 +1268,7 @@ function isGroupExcluded(groupName) {
|
|
|
1463
1268
|
var context$1 = context.useX();
|
|
1464
1269
|
var exclusion = context$1.exclusion;
|
|
1465
1270
|
var keyGroups = exclusion.groups;
|
|
1466
|
-
var groupPresent = hasOwnProperty(keyGroups, groupName);
|
|
1271
|
+
var groupPresent = vestUtils.hasOwnProperty(keyGroups, groupName);
|
|
1467
1272
|
// When group is either only'ed or skipped
|
|
1468
1273
|
if (groupPresent) {
|
|
1469
1274
|
// Return true if group is skipped and false if only'ed
|
|
@@ -1481,8 +1286,8 @@ function addTo(exclusionGroup, itemType, item) {
|
|
|
1481
1286
|
if (!item) {
|
|
1482
1287
|
return;
|
|
1483
1288
|
}
|
|
1484
|
-
asArray(item).forEach(function (itemName) {
|
|
1485
|
-
if (!isStringValue(itemName)) {
|
|
1289
|
+
vestUtils.asArray(item).forEach(function (itemName) {
|
|
1290
|
+
if (!vestUtils.isStringValue(itemName)) {
|
|
1486
1291
|
return;
|
|
1487
1292
|
}
|
|
1488
1293
|
context$1.exclusion[itemType][itemName] =
|
|
@@ -1529,8 +1334,8 @@ function hasIncludedGroups() {
|
|
|
1529
1334
|
* });
|
|
1530
1335
|
*/
|
|
1531
1336
|
function group(groupName, tests) {
|
|
1532
|
-
invariant(isStringValue(groupName), groupErrorMsg('name must be a string'));
|
|
1533
|
-
invariant(isFunction(tests), groupErrorMsg('callback must be a function'));
|
|
1337
|
+
vestUtils.invariant(vestUtils.isStringValue(groupName), groupErrorMsg('name must be a string'));
|
|
1338
|
+
vestUtils.invariant(vestUtils.isFunction(tests), groupErrorMsg('callback must be a function'));
|
|
1534
1339
|
// Running with the context applied
|
|
1535
1340
|
isolate({ type: IsolateTypes.GROUP }, function () {
|
|
1536
1341
|
context.run({ groupName: groupName }, tests);
|
|
@@ -1543,24 +1348,24 @@ function groupErrorMsg(error) {
|
|
|
1543
1348
|
function include(fieldName) {
|
|
1544
1349
|
var context$1 = context.useX();
|
|
1545
1350
|
var inclusion = context$1.inclusion, exclusion = context$1.exclusion;
|
|
1546
|
-
invariant(isStringValue(fieldName));
|
|
1547
|
-
inclusion[fieldName] = defaultTo(exclusion.tests[fieldName], true);
|
|
1351
|
+
vestUtils.invariant(vestUtils.isStringValue(fieldName));
|
|
1352
|
+
inclusion[fieldName] = vestUtils.defaultTo(exclusion.tests[fieldName], true);
|
|
1548
1353
|
return { when: when };
|
|
1549
1354
|
function when(condition) {
|
|
1550
1355
|
var context$1 = context.useX();
|
|
1551
1356
|
var inclusion = context$1.inclusion, exclusion = context$1.exclusion;
|
|
1552
1357
|
// This callback will run as part of the "isExcluded" series of checks
|
|
1553
1358
|
inclusion[fieldName] = function () {
|
|
1554
|
-
if (hasOwnProperty(exclusion.tests, fieldName)) {
|
|
1359
|
+
if (vestUtils.hasOwnProperty(exclusion.tests, fieldName)) {
|
|
1555
1360
|
// I suspect this code is technically unreachable because
|
|
1556
1361
|
// if there are any skip/only rules applied to the current
|
|
1557
1362
|
// field, the "isExcluded" function will have already bailed
|
|
1558
|
-
return defaultTo(exclusion.tests[fieldName], true);
|
|
1363
|
+
return vestUtils.defaultTo(exclusion.tests[fieldName], true);
|
|
1559
1364
|
}
|
|
1560
|
-
if (isStringValue(condition)) {
|
|
1365
|
+
if (vestUtils.isStringValue(condition)) {
|
|
1561
1366
|
return Boolean(exclusion.tests[condition]);
|
|
1562
1367
|
}
|
|
1563
|
-
return optionalFunctionValue(condition, optionalFunctionValue(produceSuiteResult));
|
|
1368
|
+
return vestUtils.optionalFunctionValue(condition, vestUtils.optionalFunctionValue(produceSuiteResult));
|
|
1564
1369
|
};
|
|
1565
1370
|
}
|
|
1566
1371
|
}
|
|
@@ -1588,9 +1393,7 @@ function eager() {
|
|
|
1588
1393
|
setMode(Modes.EAGER);
|
|
1589
1394
|
}
|
|
1590
1395
|
function shouldSkipBasedOnMode(testObject) {
|
|
1591
|
-
|
|
1592
|
-
return true;
|
|
1593
|
-
return false;
|
|
1396
|
+
return isEager() && hasErrorsByTestObjects(testObject.fieldName);
|
|
1594
1397
|
}
|
|
1595
1398
|
function isEager() {
|
|
1596
1399
|
return isMode(Modes.EAGER);
|
|
@@ -1617,7 +1420,7 @@ function omitWhen(conditional, callback) {
|
|
|
1617
1420
|
isolate({ type: IsolateTypes.OMIT_WHEN }, function () {
|
|
1618
1421
|
context.run({
|
|
1619
1422
|
omitted: isOmitted() ||
|
|
1620
|
-
optionalFunctionValue(conditional, optionalFunctionValue(produceSuiteResult))
|
|
1423
|
+
vestUtils.optionalFunctionValue(conditional, vestUtils.optionalFunctionValue(produceSuiteResult))
|
|
1621
1424
|
}, function () { return callback(); });
|
|
1622
1425
|
});
|
|
1623
1426
|
}
|
|
@@ -1639,8 +1442,8 @@ function isOmitted() {
|
|
|
1639
1442
|
function optional(optionals) {
|
|
1640
1443
|
// When the optional is given as a string or a list of strings
|
|
1641
1444
|
// we just add them to the list of optional fields.
|
|
1642
|
-
if (isArray(optionals) || isStringValue(optionals)) {
|
|
1643
|
-
asArray(optionals).forEach(function (optionalField) {
|
|
1445
|
+
if (vestUtils.isArray(optionals) || vestUtils.isStringValue(optionals)) {
|
|
1446
|
+
vestUtils.asArray(optionals).forEach(function (optionalField) {
|
|
1644
1447
|
useSetOptionalField(optionalField, [true, false]);
|
|
1645
1448
|
});
|
|
1646
1449
|
}
|
|
@@ -1679,9 +1482,7 @@ function __spreadArray(to, from, pack) {
|
|
|
1679
1482
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1680
1483
|
}
|
|
1681
1484
|
|
|
1682
|
-
|
|
1683
|
-
return value && isFunction(value.then);
|
|
1684
|
-
}
|
|
1485
|
+
vestUtils.bindNot(vestUtils.isStringValue);
|
|
1685
1486
|
|
|
1686
1487
|
function isSameProfileTest(testObject1, testObject2) {
|
|
1687
1488
|
return (testObject1.fieldName === testObject2.fieldName &&
|
|
@@ -1701,7 +1502,7 @@ function cancelOverriddenPendingTest(prevRunTestObject, currentRunTestObject) {
|
|
|
1701
1502
|
*/
|
|
1702
1503
|
function runAsyncTest(testObject) {
|
|
1703
1504
|
var asyncTest = testObject.asyncTest, message = testObject.message;
|
|
1704
|
-
if (!isPromise(asyncTest))
|
|
1505
|
+
if (!vestUtils.isPromise(asyncTest))
|
|
1705
1506
|
return;
|
|
1706
1507
|
var emit = useBus().emit;
|
|
1707
1508
|
var stateRef = useStateRef();
|
|
@@ -1714,7 +1515,7 @@ function runAsyncTest(testObject) {
|
|
|
1714
1515
|
if (testObject.isCanceled()) {
|
|
1715
1516
|
return;
|
|
1716
1517
|
}
|
|
1717
|
-
testObject.message = isStringValue(rejectionMessage)
|
|
1518
|
+
testObject.message = vestUtils.isStringValue(rejectionMessage)
|
|
1718
1519
|
? rejectionMessage
|
|
1719
1520
|
: message;
|
|
1720
1521
|
testObject.fail();
|
|
@@ -1749,7 +1550,7 @@ function registerTest(testObject) {
|
|
|
1749
1550
|
try {
|
|
1750
1551
|
// try catch for safe property access
|
|
1751
1552
|
// in case object is an enforce chain
|
|
1752
|
-
if (isPromise(result)) {
|
|
1553
|
+
if (vestUtils.isPromise(result)) {
|
|
1753
1554
|
testObject.asyncTest = result;
|
|
1754
1555
|
testObject.setPending();
|
|
1755
1556
|
runAsyncTest(testObject);
|
|
@@ -1776,12 +1577,12 @@ function registerTest(testObject) {
|
|
|
1776
1577
|
function useTestAtCursor(newTestObject) {
|
|
1777
1578
|
var testObjects = useTestObjects()[0];
|
|
1778
1579
|
var prevTests = testObjects.prev;
|
|
1779
|
-
if (isEmpty(prevTests)) {
|
|
1580
|
+
if (vestUtils.isEmpty(prevTests)) {
|
|
1780
1581
|
useSetTestAtCursor(newTestObject);
|
|
1781
1582
|
return newTestObject;
|
|
1782
1583
|
}
|
|
1783
1584
|
var prevTest = useGetTestAtCursor(prevTests);
|
|
1784
|
-
if (!isNullish(newTestObject.key)) {
|
|
1585
|
+
if (!vestUtils.isNullish(newTestObject.key)) {
|
|
1785
1586
|
var nextTest_1 = handleKeyTest(newTestObject.key, newTestObject);
|
|
1786
1587
|
useSetTestAtCursor(nextTest_1);
|
|
1787
1588
|
return nextTest_1;
|
|
@@ -1792,7 +1593,7 @@ function useTestAtCursor(newTestObject) {
|
|
|
1792
1593
|
// Need to see if this has any effect at all.
|
|
1793
1594
|
prevTest = null;
|
|
1794
1595
|
}
|
|
1795
|
-
var nextTest = defaultTo(prevTest, newTestObject);
|
|
1596
|
+
var nextTest = vestUtils.defaultTo(prevTest, newTestObject);
|
|
1796
1597
|
useSetTestAtCursor(nextTest);
|
|
1797
1598
|
return nextTest;
|
|
1798
1599
|
}
|
|
@@ -1809,21 +1610,21 @@ function removeAllNextTestsInIsolate() {
|
|
|
1809
1610
|
function useSetTestAtCursor(testObject) {
|
|
1810
1611
|
var cursorPath = useCurrentPath();
|
|
1811
1612
|
useSetTests(function (tests) {
|
|
1812
|
-
return setValueAtPath(tests, cursorPath, testObject);
|
|
1613
|
+
return vestUtils.nestedArray.setValueAtPath(tests, cursorPath, testObject);
|
|
1813
1614
|
});
|
|
1814
1615
|
}
|
|
1815
1616
|
function useGetTestAtCursor(tests) {
|
|
1816
1617
|
var cursorPath = useCurrentPath();
|
|
1817
|
-
return valueAtPath(tests, cursorPath);
|
|
1618
|
+
return vestUtils.nestedArray.valueAtPath(tests, cursorPath);
|
|
1818
1619
|
}
|
|
1819
1620
|
function testReorderDetected(prevTest, newTest) {
|
|
1820
|
-
return isNotEmpty(prevTest) && !isSameProfileTest(prevTest, newTest);
|
|
1621
|
+
return vestUtils.isNotEmpty(prevTest) && !isSameProfileTest(prevTest, newTest);
|
|
1821
1622
|
}
|
|
1822
1623
|
function throwTestOrderError(prevTest, newTestObject) {
|
|
1823
1624
|
if (shouldAllowReorder()) {
|
|
1824
1625
|
return;
|
|
1825
1626
|
}
|
|
1826
|
-
deferThrow("Vest Critical Error: Tests called in different order than previous run.\n expected: ".concat(prevTest.fieldName, "\n received: ").concat(newTestObject.fieldName, "\n This can happen on one of two reasons:\n 1. You're using if/else statements to conditionally select tests. Instead, use \"skipWhen\".\n 2. You are iterating over a list of tests, and their order changed. Use \"each\" and a custom key prop so that Vest retains their state."));
|
|
1627
|
+
vestUtils.deferThrow("Vest Critical Error: Tests called in different order than previous run.\n expected: ".concat(prevTest.fieldName, "\n received: ").concat(newTestObject.fieldName, "\n This can happen on one of two reasons:\n 1. You're using if/else statements to conditionally select tests. Instead, use \"skipWhen\".\n 2. You are iterating over a list of tests, and their order changed. Use \"each\" and a custom key prop so that Vest retains their state."));
|
|
1827
1628
|
}
|
|
1828
1629
|
function handleKeyTest(key, newTestObject) {
|
|
1829
1630
|
var prevTestByKey = usePrevTestByKey(key);
|
|
@@ -1869,7 +1670,7 @@ function registerTestObjectByTier(testObject) {
|
|
|
1869
1670
|
if (testObject.isUntested()) {
|
|
1870
1671
|
registerTest(testObject);
|
|
1871
1672
|
}
|
|
1872
|
-
else if (isPromise(testObject.asyncTest)) {
|
|
1673
|
+
else if (vestUtils.isPromise(testObject.asyncTest)) {
|
|
1873
1674
|
testObject.setPending();
|
|
1874
1675
|
runAsyncTest(testObject);
|
|
1875
1676
|
}
|
|
@@ -1890,7 +1691,7 @@ function bindTestMemo(test) {
|
|
|
1890
1691
|
// Implicit dependency for more specificity
|
|
1891
1692
|
var dependencies = [useSuiteId(), fieldName, cursorAt].concat(deps);
|
|
1892
1693
|
var cached = cache.get(dependencies);
|
|
1893
|
-
if (isNull(cached)) {
|
|
1694
|
+
if (vestUtils.isNull(cached)) {
|
|
1894
1695
|
// cache miss
|
|
1895
1696
|
return cache(dependencies, function () { return test(fieldName, msg, testFn); });
|
|
1896
1697
|
}
|
|
@@ -1909,9 +1710,9 @@ function testBase(fieldName) {
|
|
|
1909
1710
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1910
1711
|
args[_i - 1] = arguments[_i];
|
|
1911
1712
|
}
|
|
1912
|
-
var _a = (isFunction(args[1]) ? args : __spreadArray([undefined], args, true)), message = _a[0], testFn = _a[1], key = _a[2];
|
|
1913
|
-
invariant(isStringValue(fieldName), incompatibleParamsError('fieldName', 'string'));
|
|
1914
|
-
invariant(isFunction(testFn), incompatibleParamsError('Test callback', 'function'));
|
|
1713
|
+
var _a = (vestUtils.isFunction(args[1]) ? args : __spreadArray([undefined], args, true)), message = _a[0], testFn = _a[1], key = _a[2];
|
|
1714
|
+
vestUtils.invariant(vestUtils.isStringValue(fieldName), incompatibleParamsError('fieldName', 'string'));
|
|
1715
|
+
vestUtils.invariant(vestUtils.isFunction(testFn), incompatibleParamsError('Test callback', 'function'));
|
|
1915
1716
|
var context$1 = context.useX();
|
|
1916
1717
|
var testObject = new VestTest(fieldName, testFn, {
|
|
1917
1718
|
message: message,
|
|
@@ -1929,7 +1730,7 @@ function testBase(fieldName) {
|
|
|
1929
1730
|
* enforce(data.username).isNotBlank();
|
|
1930
1731
|
* });
|
|
1931
1732
|
*/
|
|
1932
|
-
var test = assign(testBase, {
|
|
1733
|
+
var test = vestUtils.assign(testBase, {
|
|
1933
1734
|
memo: bindTestMemo(testBase)
|
|
1934
1735
|
});
|
|
1935
1736
|
function incompatibleParamsError(name, expected) {
|
|
@@ -1943,11 +1744,11 @@ var ERROR_OUTSIDE_OF_TEST = "warn hook called outside of a test callback. It won
|
|
|
1943
1744
|
*/
|
|
1944
1745
|
function warn() {
|
|
1945
1746
|
var ctx = context.useX('warn ' + ERROR_HOOK_CALLED_OUTSIDE);
|
|
1946
|
-
invariant(ctx.currentTest, ERROR_OUTSIDE_OF_TEST);
|
|
1747
|
+
vestUtils.invariant(ctx.currentTest, ERROR_OUTSIDE_OF_TEST);
|
|
1947
1748
|
ctx.currentTest.warn();
|
|
1948
1749
|
}
|
|
1949
1750
|
|
|
1950
|
-
var VERSION = "4.4.
|
|
1751
|
+
var VERSION = "4.4.2-dev-afe5de";
|
|
1951
1752
|
|
|
1952
1753
|
Object.defineProperty(exports, 'enforce', {
|
|
1953
1754
|
enumerable: true,
|