vest 4.5.0 → 4.6.2-dev-fcaa09
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/enforce_compose.development.js +2 -0
- package/dist/cjs/enforce_compose.js +7 -0
- package/dist/cjs/enforce_compose.production.js +1 -0
- package/dist/cjs/enforce_compounds.development.js +4 -0
- package/dist/cjs/enforce_compounds.js +7 -0
- package/dist/cjs/enforce_compounds.production.js +1 -0
- package/dist/cjs/enforce_schema.development.js +4 -0
- package/dist/cjs/enforce_schema.js +7 -0
- package/dist/cjs/enforce_schema.production.js +1 -0
- package/dist/cjs/vest.development.js +149 -168
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/enforce_compose.development.js +1 -0
- package/dist/es/enforce_compose.production.js +1 -0
- package/dist/es/enforce_compounds.development.js +1 -0
- package/dist/es/enforce_compounds.production.js +1 -0
- package/dist/es/enforce_schema.development.js +1 -0
- package/dist/es/enforce_schema.production.js +1 -0
- package/dist/es/vest.development.js +150 -169
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/classnames.development.js +11 -59
- package/dist/umd/classnames.production.js +1 -1
- package/dist/umd/enforce_compose.development.js +8 -0
- package/dist/umd/enforce_compose.production.js +1 -0
- package/dist/umd/enforce_compounds.development.js +8 -0
- package/dist/umd/enforce_compounds.production.js +1 -0
- package/dist/umd/enforce_schema.development.js +8 -0
- package/dist/umd/enforce_schema.production.js +1 -0
- package/dist/umd/parser.development.js +10 -58
- package/dist/umd/parser.production.js +1 -1
- package/dist/umd/promisify.development.js +5 -31
- package/dist/umd/promisify.production.js +1 -1
- package/dist/umd/vest.development.js +253 -1066
- package/dist/umd/vest.production.js +1 -1
- package/enforce_compose/package.json +9 -0
- package/enforce_compounds/package.json +9 -0
- package/enforce_schema/package.json +9 -0
- package/package.json +80 -79
- package/tsconfig.json +85 -1
- package/types/classnames.d.ts +1 -0
- package/types/classnames.d.ts.map +1 -0
- package/types/enforce_compose.d.ts +2 -0
- package/types/enforce_compose.d.ts.map +1 -0
- package/types/enforce_compounds.d.ts +2 -0
- package/types/enforce_compounds.d.ts.map +1 -0
- package/types/enforce_schema.d.ts +2 -0
- package/types/enforce_schema.d.ts.map +1 -0
- package/types/parser.d.ts +1 -0
- package/types/parser.d.ts.map +1 -0
- package/types/promisify.d.ts +1 -0
- package/types/promisify.d.ts.map +1 -0
- package/types/vest.d.ts +40 -37
- package/types/vest.d.ts.map +1 -0
- package/dist/cjs/compose.js +0 -7
- package/dist/cjs/compounds.js +0 -7
- package/dist/cjs/enforce/compose.development.js +0 -60
- package/dist/cjs/enforce/compose.production.js +0 -1
- package/dist/cjs/enforce/compounds.development.js +0 -92
- package/dist/cjs/enforce/compounds.production.js +0 -1
- package/dist/cjs/enforce/package.json +0 -1
- package/dist/cjs/enforce/schema.development.js +0 -92
- package/dist/cjs/enforce/schema.production.js +0 -1
- package/dist/cjs/schema.js +0 -7
- package/dist/es/enforce/compose.development.js +0 -58
- package/dist/es/enforce/compose.production.js +0 -1
- package/dist/es/enforce/compounds.development.js +0 -90
- package/dist/es/enforce/compounds.production.js +0 -1
- package/dist/es/enforce/package.json +0 -1
- package/dist/es/enforce/schema.development.js +0 -88
- package/dist/es/enforce/schema.production.js +0 -1
- package/dist/umd/enforce/compose.development.js +0 -736
- package/dist/umd/enforce/compose.production.js +0 -1
- package/dist/umd/enforce/compounds.development.js +0 -762
- package/dist/umd/enforce/compounds.production.js +0 -1
- package/dist/umd/enforce/schema.development.js +0 -768
- package/dist/umd/enforce/schema.production.js +0 -1
- package/enforce/compose/package.json +0 -9
- package/enforce/compounds/package.json +0 -9
- package/enforce/schema/package.json +0 -9
- package/types/enforce/compose.d.ts +0 -126
- package/types/enforce/compounds.d.ts +0 -138
- package/types/enforce/schema.d.ts +0 -143
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require("n4s/compounds");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require("n4s/schema");
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var n4s = require('n4s');
|
|
6
6
|
var vestUtils = require('vest-utils');
|
|
7
7
|
var context$1 = require('context');
|
|
8
|
+
var vast = require('vast');
|
|
8
9
|
|
|
9
10
|
function shouldUseErrorAsMessage(message, error) {
|
|
10
11
|
// kind of cheating with this safe guard, but it does the job
|
|
@@ -62,7 +63,7 @@ function generateIsolate(type, path) {
|
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
var context = context$1.
|
|
66
|
+
var context = context$1.createCascade(function (ctxRef, parentContext) {
|
|
66
67
|
return parentContext
|
|
67
68
|
? null
|
|
68
69
|
: vestUtils.assign({
|
|
@@ -92,29 +93,22 @@ function useTestCallbacks() {
|
|
|
92
93
|
return useStateRef().testCallbacks();
|
|
93
94
|
}
|
|
94
95
|
// OPTIONAL FIELDS
|
|
95
|
-
function useOptionalField(fieldName) {
|
|
96
|
-
var optionalFields = useOptionalFields()[0];
|
|
97
|
-
return optionalFields[fieldName];
|
|
98
|
-
}
|
|
99
96
|
function useOptionalFields() {
|
|
100
97
|
return useStateRef().optionalFields();
|
|
101
98
|
}
|
|
102
99
|
function useSetOptionalField(fieldName, setter) {
|
|
103
100
|
var _a = useOptionalFields(), setOptionalFields = _a[1];
|
|
104
|
-
setOptionalFields(function (
|
|
101
|
+
setOptionalFields(function (prev) {
|
|
105
102
|
var _a;
|
|
106
|
-
return vestUtils.assign(
|
|
107
|
-
_a[fieldName] = vestUtils.
|
|
103
|
+
return vestUtils.assign(prev, (_a = {},
|
|
104
|
+
_a[fieldName] = vestUtils.assign({}, prev[fieldName], setter(prev[fieldName])),
|
|
108
105
|
_a));
|
|
109
106
|
});
|
|
110
107
|
}
|
|
111
|
-
function
|
|
112
|
-
var _a;
|
|
113
|
-
return (_a = useOptionalField(fieldName)) === null || _a === void 0 ? void 0 : _a[1];
|
|
114
|
-
}
|
|
115
|
-
function useOptionalFieldConfig(fieldName) {
|
|
108
|
+
function useOptionalField(fieldName) {
|
|
116
109
|
var _a;
|
|
117
|
-
|
|
110
|
+
var optionalFields = useOptionalFields()[0];
|
|
111
|
+
return (_a = optionalFields[fieldName]) !== null && _a !== void 0 ? _a : {};
|
|
118
112
|
}
|
|
119
113
|
function useTestObjects() {
|
|
120
114
|
return useStateRef().testObjects();
|
|
@@ -244,18 +238,9 @@ var VestTest = /** @class */ (function () {
|
|
|
244
238
|
VestTest.prototype.valueOf = function () {
|
|
245
239
|
return !this.isFailing();
|
|
246
240
|
};
|
|
247
|
-
VestTest.prototype.hasFailures = function () {
|
|
248
|
-
return this.isFailing() || this.isWarning();
|
|
249
|
-
};
|
|
250
|
-
VestTest.prototype.isNonActionable = function () {
|
|
251
|
-
return this.isSkipped() || this.isOmitted() || this.isCanceled();
|
|
252
|
-
};
|
|
253
241
|
VestTest.prototype.isPending = function () {
|
|
254
242
|
return this.statusEquals(STATUS_PENDING);
|
|
255
243
|
};
|
|
256
|
-
VestTest.prototype.isTested = function () {
|
|
257
|
-
return this.hasFailures() || this.isPassing();
|
|
258
|
-
};
|
|
259
244
|
VestTest.prototype.isOmitted = function () {
|
|
260
245
|
return this.statusEquals(STATUS_OMITTED);
|
|
261
246
|
};
|
|
@@ -277,6 +262,20 @@ var VestTest = /** @class */ (function () {
|
|
|
277
262
|
VestTest.prototype.isWarning = function () {
|
|
278
263
|
return this.statusEquals(STATUS_WARNING);
|
|
279
264
|
};
|
|
265
|
+
VestTest.prototype.hasFailures = function () {
|
|
266
|
+
return this.isFailing() || this.isWarning();
|
|
267
|
+
};
|
|
268
|
+
VestTest.prototype.isNonActionable = function () {
|
|
269
|
+
return this.isSkipped() || this.isOmitted() || this.isCanceled();
|
|
270
|
+
};
|
|
271
|
+
VestTest.prototype.isTested = function () {
|
|
272
|
+
return this.hasFailures() || this.isPassing();
|
|
273
|
+
};
|
|
274
|
+
VestTest.prototype.awaitsResolution = function () {
|
|
275
|
+
// Is the test in a state where it can still be run, or complete running
|
|
276
|
+
// and its final status is indeterminate?
|
|
277
|
+
return this.isSkipped() || this.isUntested() || this.isPending();
|
|
278
|
+
};
|
|
280
279
|
VestTest.prototype.statusEquals = function (status) {
|
|
281
280
|
return this.status === status;
|
|
282
281
|
};
|
|
@@ -291,70 +290,6 @@ var STATUS_PENDING = 'PENDING';
|
|
|
291
290
|
var STATUS_CANCELED = 'CANCELED';
|
|
292
291
|
var STATUS_OMITTED = 'OMITTED';
|
|
293
292
|
|
|
294
|
-
// eslint-disable-next-line max-lines-per-function
|
|
295
|
-
function createState(onStateChange) {
|
|
296
|
-
var state = {
|
|
297
|
-
references: []
|
|
298
|
-
};
|
|
299
|
-
var registrations = [];
|
|
300
|
-
return {
|
|
301
|
-
registerStateKey: registerStateKey,
|
|
302
|
-
reset: reset
|
|
303
|
-
};
|
|
304
|
-
/**
|
|
305
|
-
* Registers a new key in the state, takes the initial value (may be a function that returns the initial value), returns a function.
|
|
306
|
-
*
|
|
307
|
-
* @example
|
|
308
|
-
*
|
|
309
|
-
* const useColor = state.registerStateKey("blue");
|
|
310
|
-
*
|
|
311
|
-
* let [color, setColor] = useColor(); // -> ["blue", Function]
|
|
312
|
-
*
|
|
313
|
-
* setColor("green");
|
|
314
|
-
*
|
|
315
|
-
* useColor()[0]; -> "green"
|
|
316
|
-
*/
|
|
317
|
-
function registerStateKey(initialState, onUpdate) {
|
|
318
|
-
var key = registrations.length;
|
|
319
|
-
registrations.push([initialState, onUpdate]);
|
|
320
|
-
return initKey(key, initialState);
|
|
321
|
-
}
|
|
322
|
-
function reset() {
|
|
323
|
-
var prev = current();
|
|
324
|
-
state.references = [];
|
|
325
|
-
registrations.forEach(function (_a, index) {
|
|
326
|
-
var initialValue = _a[0];
|
|
327
|
-
return initKey(index, initialValue, prev[index]);
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
function initKey(key, initialState, prevState) {
|
|
331
|
-
current().push();
|
|
332
|
-
set(key, vestUtils.optionalFunctionValue(initialState, prevState));
|
|
333
|
-
return function useStateKey() {
|
|
334
|
-
return [
|
|
335
|
-
current()[key],
|
|
336
|
-
function (nextState) {
|
|
337
|
-
return set(key, vestUtils.optionalFunctionValue(nextState, current()[key]));
|
|
338
|
-
},
|
|
339
|
-
];
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
function current() {
|
|
343
|
-
return state.references;
|
|
344
|
-
}
|
|
345
|
-
function set(index, value) {
|
|
346
|
-
var prevValue = state.references[index];
|
|
347
|
-
state.references[index] = value;
|
|
348
|
-
var _a = registrations[index], onUpdate = _a[1];
|
|
349
|
-
if (vestUtils.isFunction(onUpdate)) {
|
|
350
|
-
onUpdate(value, prevValue);
|
|
351
|
-
}
|
|
352
|
-
if (vestUtils.isFunction(onStateChange)) {
|
|
353
|
-
onStateChange();
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
293
|
function createStateRef(state, _a) {
|
|
359
294
|
var suiteId = _a.suiteId, suiteName = _a.suiteName;
|
|
360
295
|
return {
|
|
@@ -516,26 +451,85 @@ function hasFailuresByTestObject(testObject, severityKey, fieldName) {
|
|
|
516
451
|
return true;
|
|
517
452
|
}
|
|
518
453
|
|
|
454
|
+
/**
|
|
455
|
+
* Marks a field as optional, either just by name, or by a given condition.
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
*
|
|
459
|
+
* optional('field_name');
|
|
460
|
+
*
|
|
461
|
+
* optional({
|
|
462
|
+
* username: () => allowUsernameEmpty,
|
|
463
|
+
* });
|
|
464
|
+
*/
|
|
465
|
+
function optional(optionals) {
|
|
466
|
+
// There are two types of optional field declarations:
|
|
467
|
+
// 1. Delayed: A string, which is the name of the field to be optional.
|
|
468
|
+
// We will only determine whether to omit the test after the suite is done running
|
|
469
|
+
//
|
|
470
|
+
// 2. Immediate: Either a boolean or a function, which is used to determine
|
|
471
|
+
// if the field should be optional.
|
|
472
|
+
// Delayed case (field name)
|
|
473
|
+
if (vestUtils.isArray(optionals) || vestUtils.isStringValue(optionals)) {
|
|
474
|
+
vestUtils.asArray(optionals).forEach(function (optionalField) {
|
|
475
|
+
useSetOptionalField(optionalField, function () { return ({
|
|
476
|
+
type: OptionalFieldTypes.Delayed,
|
|
477
|
+
applied: false,
|
|
478
|
+
rule: null
|
|
479
|
+
}); });
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
var _loop_1 = function (field) {
|
|
484
|
+
var value = optionals[field];
|
|
485
|
+
useSetOptionalField(field, function () { return ({
|
|
486
|
+
type: OptionalFieldTypes.Immediate,
|
|
487
|
+
rule: value,
|
|
488
|
+
applied: vestUtils.optionalFunctionValue(value)
|
|
489
|
+
}); });
|
|
490
|
+
};
|
|
491
|
+
// Immediately case (function or boolean)
|
|
492
|
+
for (var field in optionals) {
|
|
493
|
+
_loop_1(field);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
function optionalFiedIsApplied(fieldName) {
|
|
498
|
+
if (!fieldName) {
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
return useOptionalField(fieldName).applied;
|
|
502
|
+
}
|
|
503
|
+
var OptionalFieldTypes;
|
|
504
|
+
(function (OptionalFieldTypes) {
|
|
505
|
+
OptionalFieldTypes[OptionalFieldTypes["Immediate"] = 0] = "Immediate";
|
|
506
|
+
OptionalFieldTypes[OptionalFieldTypes["Delayed"] = 1] = "Delayed";
|
|
507
|
+
})(OptionalFieldTypes || (OptionalFieldTypes = {}));
|
|
508
|
+
|
|
519
509
|
// eslint-disable-next-line max-statements, complexity
|
|
520
510
|
function shouldAddValidProperty(fieldName) {
|
|
521
|
-
|
|
511
|
+
// Is the field optional, and the optional condition is applied
|
|
512
|
+
if (optionalFiedIsApplied(fieldName)) {
|
|
522
513
|
return true;
|
|
523
514
|
}
|
|
524
|
-
if (hasErrorsByTestObjects(fieldName)) {
|
|
525
|
-
return false;
|
|
526
|
-
}
|
|
527
515
|
var testObjects = useTestsFlat();
|
|
516
|
+
// Are there no tests?
|
|
528
517
|
if (vestUtils.isEmpty(testObjects)) {
|
|
529
518
|
return false;
|
|
530
519
|
}
|
|
520
|
+
// Does the field have any tests with errors?
|
|
521
|
+
if (hasErrorsByTestObjects(fieldName)) {
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
531
524
|
// Does the given field have any pending tests that are not optional?
|
|
532
525
|
if (hasNonOptionalIncomplete(fieldName)) {
|
|
533
526
|
return false;
|
|
534
527
|
}
|
|
528
|
+
// Does the field have no missing tests?
|
|
535
529
|
return noMissingTests(fieldName);
|
|
536
530
|
}
|
|
537
531
|
function shouldAddValidPropertyInGroup(groupName, fieldName) {
|
|
538
|
-
if (
|
|
532
|
+
if (optionalFiedIsApplied(fieldName)) {
|
|
539
533
|
return true;
|
|
540
534
|
}
|
|
541
535
|
if (hasGroupFailuresByTestObjects(Severity.ERRORS, groupName, fieldName)) {
|
|
@@ -547,16 +541,10 @@ function shouldAddValidPropertyInGroup(groupName, fieldName) {
|
|
|
547
541
|
}
|
|
548
542
|
return noMissingTestsByGroup(groupName, fieldName);
|
|
549
543
|
}
|
|
550
|
-
function fieldIsOmitted(fieldName) {
|
|
551
|
-
if (!fieldName) {
|
|
552
|
-
return false;
|
|
553
|
-
}
|
|
554
|
-
return useOptionalFieldApplied(fieldName) === true;
|
|
555
|
-
}
|
|
556
544
|
// Does the given field have any pending tests that are not optional?
|
|
557
545
|
function hasNonOptionalIncomplete(fieldName) {
|
|
558
546
|
return vestUtils.isNotEmpty(useAllIncomplete().filter(function (testObject) {
|
|
559
|
-
return
|
|
547
|
+
return isTestObjectOptional(testObject, fieldName);
|
|
560
548
|
}));
|
|
561
549
|
}
|
|
562
550
|
// Do the given group/field have any pending tests that are not optional?
|
|
@@ -565,41 +553,57 @@ function hasNonOptionalIncompleteByGroup(groupName, fieldName) {
|
|
|
565
553
|
if (nonMatchingGroupName(testObject, groupName)) {
|
|
566
554
|
return false;
|
|
567
555
|
}
|
|
568
|
-
return
|
|
556
|
+
return isTestObjectOptional(testObject, fieldName);
|
|
569
557
|
}));
|
|
570
558
|
}
|
|
571
|
-
function
|
|
559
|
+
function isTestObjectOptional(testObject, fieldName) {
|
|
572
560
|
if (nonMatchingFieldName(testObject, fieldName)) {
|
|
573
561
|
return false;
|
|
574
562
|
}
|
|
575
|
-
return
|
|
563
|
+
return optionalFiedIsApplied(fieldName);
|
|
576
564
|
}
|
|
565
|
+
// Did all of the tests for the provided field run/omit?
|
|
566
|
+
// This makes sure that the fields are not skipped or pending.
|
|
577
567
|
function noMissingTests(fieldName) {
|
|
578
568
|
var testObjects = useTestsFlat();
|
|
579
569
|
return testObjects.every(function (testObject) {
|
|
580
|
-
|
|
581
|
-
return true;
|
|
582
|
-
}
|
|
583
|
-
return missingTestsLogic(testObject, fieldName);
|
|
570
|
+
return noMissingTestsLogic(testObject, fieldName);
|
|
584
571
|
});
|
|
585
572
|
}
|
|
573
|
+
// Does the group have no missing tests?
|
|
586
574
|
function noMissingTestsByGroup(groupName, fieldName) {
|
|
587
575
|
var testObjects = useTestsFlat();
|
|
588
576
|
return testObjects.every(function (testObject) {
|
|
589
577
|
if (nonMatchingGroupName(testObject, groupName)) {
|
|
590
578
|
return true;
|
|
591
579
|
}
|
|
592
|
-
return
|
|
580
|
+
return noMissingTestsLogic(testObject, fieldName);
|
|
593
581
|
});
|
|
594
582
|
}
|
|
595
|
-
|
|
583
|
+
// Does the object qualify as either tested or omitted (but not skipped!)
|
|
584
|
+
function noMissingTestsLogic(testObject, fieldName) {
|
|
596
585
|
if (nonMatchingFieldName(testObject, fieldName)) {
|
|
597
586
|
return true;
|
|
598
587
|
}
|
|
599
|
-
|
|
588
|
+
/**
|
|
589
|
+
* The reason we're checking for the optional field here and not in "omitOptionalFields"
|
|
590
|
+
* is because that unlike the bool/function check we do there, here it only depends on
|
|
591
|
+
* whether the field was tested alredy or not.
|
|
592
|
+
*
|
|
593
|
+
* We qualify the test as not missing only if it was already run, if it is omitted,
|
|
594
|
+
* or if it is marked as optional, even if the optional check did not apply yet -
|
|
595
|
+
* but the test did not reach its final state.
|
|
596
|
+
*/
|
|
597
|
+
return (optionalTestAwaitsResolution(testObject) ||
|
|
600
598
|
testObject.isTested() ||
|
|
601
599
|
testObject.isOmitted());
|
|
602
600
|
}
|
|
601
|
+
function optionalTestAwaitsResolution(testObject) {
|
|
602
|
+
// Does the test belong to an optional field,
|
|
603
|
+
// and the test itself is still in an indeterminate state?
|
|
604
|
+
return (useOptionalField(testObject.fieldName).type ===
|
|
605
|
+
OptionalFieldTypes.Delayed && testObject.awaitsResolution());
|
|
606
|
+
}
|
|
603
607
|
|
|
604
608
|
/**
|
|
605
609
|
* Reads the testObjects list and gets full validation result from it.
|
|
@@ -903,34 +907,48 @@ function deferDoneCallback(doneCallback, fieldName) {
|
|
|
903
907
|
});
|
|
904
908
|
}
|
|
905
909
|
|
|
910
|
+
/**
|
|
911
|
+
* This module gets triggered once the suite is done running its sync tests.
|
|
912
|
+
*
|
|
913
|
+
* It goes over all the tests in the state, and checks if they need to be omitted.
|
|
914
|
+
*/
|
|
906
915
|
function omitOptionalFields() {
|
|
907
916
|
var optionalFields = useOptionalFields()[0];
|
|
917
|
+
// If there are no optional fields, we don't need to do anything
|
|
908
918
|
if (vestUtils.isEmpty(optionalFields)) {
|
|
909
919
|
return;
|
|
910
920
|
}
|
|
921
|
+
// Create an object to store the fields that need to be omitted
|
|
911
922
|
var shouldOmit = {};
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
+
// iterate over each of the tests in the state
|
|
924
|
+
useTestsFlat().forEach(function (testObject) {
|
|
925
|
+
// If we already added the current field (not this test specifically)
|
|
926
|
+
// no need for further checks, go and omit the test
|
|
927
|
+
if (vestUtils.hasOwnProperty(shouldOmit, testObject.fieldName)) {
|
|
928
|
+
verifyAndOmit(testObject);
|
|
929
|
+
}
|
|
930
|
+
else {
|
|
931
|
+
// check if the field has an optional function
|
|
932
|
+
// if so, run it and verify/omit the test
|
|
933
|
+
runOptionalConfig(testObject);
|
|
934
|
+
}
|
|
923
935
|
});
|
|
936
|
+
// refresh the tests in the state so that the omitted fields are applied
|
|
937
|
+
useRefreshTestObjects();
|
|
924
938
|
function verifyAndOmit(testObject) {
|
|
925
939
|
if (shouldOmit[testObject.fieldName]) {
|
|
926
940
|
testObject.omit();
|
|
927
|
-
useSetOptionalField(testObject.fieldName, function (
|
|
941
|
+
useSetOptionalField(testObject.fieldName, function () { return ({
|
|
942
|
+
applied: true
|
|
943
|
+
}); });
|
|
928
944
|
}
|
|
929
945
|
}
|
|
930
946
|
function runOptionalConfig(testObject) {
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
947
|
+
// Ge the optional configuration for the given field
|
|
948
|
+
var optionalConfig = useOptionalField(testObject.fieldName);
|
|
949
|
+
// If the optional was set to a function or a boolean, run it and verify/omit the test
|
|
950
|
+
if (optionalConfig.type === OptionalFieldTypes.Immediate) {
|
|
951
|
+
shouldOmit[testObject.fieldName] = vestUtils.optionalFunctionValue(optionalConfig.rule);
|
|
934
952
|
verifyAndOmit(testObject);
|
|
935
953
|
}
|
|
936
954
|
}
|
|
@@ -1034,7 +1052,7 @@ function create() {
|
|
|
1034
1052
|
// Event bus initialization
|
|
1035
1053
|
var bus = initBus();
|
|
1036
1054
|
// State initialization
|
|
1037
|
-
var state = createState();
|
|
1055
|
+
var state = vast.createState();
|
|
1038
1056
|
// State reference - this holds the actual state values
|
|
1039
1057
|
var stateRef = createStateRef(state, { suiteId: vestUtils.seq(), suiteName: suiteName });
|
|
1040
1058
|
// Create base context reference. All hooks will derive their data from this
|
|
@@ -1354,44 +1372,16 @@ function setMode(nextMode) {
|
|
|
1354
1372
|
function omitWhen(conditional, callback) {
|
|
1355
1373
|
isolate({ type: IsolateTypes.OMIT_WHEN }, function () {
|
|
1356
1374
|
context.run({
|
|
1357
|
-
omitted:
|
|
1375
|
+
omitted: inActiveOmitWhen() ||
|
|
1358
1376
|
vestUtils.optionalFunctionValue(conditional, vestUtils.optionalFunctionValue(produceSuiteResult))
|
|
1359
1377
|
}, function () { return callback(); });
|
|
1360
1378
|
});
|
|
1361
1379
|
}
|
|
1362
|
-
|
|
1380
|
+
// Checks that we're currently in an active omitWhen block
|
|
1381
|
+
function inActiveOmitWhen() {
|
|
1363
1382
|
return !!context.useX().omitted;
|
|
1364
1383
|
}
|
|
1365
1384
|
|
|
1366
|
-
/**
|
|
1367
|
-
* Marks a field as optional, either just by name, or by a given condition.
|
|
1368
|
-
*
|
|
1369
|
-
* @example
|
|
1370
|
-
*
|
|
1371
|
-
* optional('field_name');
|
|
1372
|
-
*
|
|
1373
|
-
* optional({
|
|
1374
|
-
* username: () => allowUsernameEmpty,
|
|
1375
|
-
* });
|
|
1376
|
-
*/
|
|
1377
|
-
function optional(optionals) {
|
|
1378
|
-
// When the optional is given as a string or a list of strings
|
|
1379
|
-
// we just add them to the list of optional fields.
|
|
1380
|
-
if (vestUtils.isArray(optionals) || vestUtils.isStringValue(optionals)) {
|
|
1381
|
-
vestUtils.asArray(optionals).forEach(function (optionalField) {
|
|
1382
|
-
useSetOptionalField(optionalField, [true, false]);
|
|
1383
|
-
});
|
|
1384
|
-
}
|
|
1385
|
-
else {
|
|
1386
|
-
// if it's an object, we iterate over the keys and add them to the list
|
|
1387
|
-
var optionalFunctions = optionals;
|
|
1388
|
-
for (var field in optionalFunctions) {
|
|
1389
|
-
var predicate = optionalFunctions[field];
|
|
1390
|
-
useSetOptionalField(field, [predicate, false]);
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
}
|
|
1394
|
-
|
|
1395
1385
|
/******************************************************************************
|
|
1396
1386
|
Copyright (c) Microsoft Corporation.
|
|
1397
1387
|
|
|
@@ -1417,8 +1407,6 @@ function __spreadArray(to, from, pack) {
|
|
|
1417
1407
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1418
1408
|
}
|
|
1419
1409
|
|
|
1420
|
-
vestUtils.bindNot(vestUtils.isStringValue);
|
|
1421
|
-
|
|
1422
1410
|
function isSameProfileTest(testObject1, testObject2) {
|
|
1423
1411
|
return (testObject1.fieldName === testObject2.fieldName &&
|
|
1424
1412
|
testObject1.groupName === testObject2.groupName);
|
|
@@ -1456,14 +1444,7 @@ function runAsyncTest(testObject) {
|
|
|
1456
1444
|
testObject.fail();
|
|
1457
1445
|
done();
|
|
1458
1446
|
});
|
|
1459
|
-
|
|
1460
|
-
asyncTest.then(done, fail);
|
|
1461
|
-
}
|
|
1462
|
-
catch (e) {
|
|
1463
|
-
// We will probably never get here, unless the consumer uses a buggy custom Promise
|
|
1464
|
-
// implementation that behaves differently than the native one, or if they for some
|
|
1465
|
-
fail();
|
|
1466
|
-
}
|
|
1447
|
+
asyncTest.then(done, fail);
|
|
1467
1448
|
}
|
|
1468
1449
|
|
|
1469
1450
|
/**
|
|
@@ -1581,7 +1562,7 @@ function registerPrevRunTest(testObject) {
|
|
|
1581
1562
|
return testObject;
|
|
1582
1563
|
}
|
|
1583
1564
|
var prevRunTest = useTestAtCursor(testObject);
|
|
1584
|
-
if (
|
|
1565
|
+
if (inActiveOmitWhen() || optionalFiedIsApplied(testObject.fieldName)) {
|
|
1585
1566
|
prevRunTest.omit();
|
|
1586
1567
|
cursor.next();
|
|
1587
1568
|
return prevRunTest;
|
|
@@ -1682,7 +1663,7 @@ function warn() {
|
|
|
1682
1663
|
ctx.currentTest.warn();
|
|
1683
1664
|
}
|
|
1684
1665
|
|
|
1685
|
-
var VERSION = "4.
|
|
1666
|
+
var VERSION = "4.6.2-dev-fcaa09";
|
|
1686
1667
|
|
|
1687
1668
|
Object.defineProperty(exports, 'enforce', {
|
|
1688
1669
|
enumerable: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n,t,e,r=require("n4s"),i=require("vest-utils"),u=require("context");function o(){var n=0;return{current:function(){return n},next:function(){n++}}}function s(n,t){return void 0===t&&(t=[]),{cursor:o(),keys:{current:{},prev:{}},path:t,type:n}}(t=n||(n={}))[t.DEFAULT=0]="DEFAULT",t[t.SUITE=1]="SUITE",t[t.EACH=2]="EACH",t[t.SKIP_WHEN=3]="SKIP_WHEN",t[t.OMIT_WHEN=4]="OMIT_WHEN",t[t.GROUP=5]="GROUP",function(n){n[n.ALL=0]="ALL",n[n.EAGER=1]="EAGER"}(e||(e={}));var a=u.createContext((function(t,r){return r?null:i.assign({exclusion:{tests:{},groups:{}},inclusion:{},isolate:s(n.DEFAULT),mode:[e.ALL]},t)}));function c(){return a.useX().stateRef}function f(){return c().suiteId()[0]}function l(){return c().testCallbacks()}function p(n){return d()[0][n]}function d(){return c().optionalFields()}function v(n,t){(0,d()[1])((function(e){var r;return i.assign(e,((r={})[n]=i.optionalFunctionValue(t,e[n]),r))}))}function E(n){var t;return null===(t=p(n))||void 0===t?void 0:t[0]}function h(){return c().testObjects()}function g(){N((function(n){return n}))}function N(n){(0,h()[1])((function(t){return{prev:t.prev,current:i.asArray(n(t.current))}}))}function y(){return R().filter((function(n){return n.isPending()}))}var m,S=i.cache();function R(){var n=h()[0].current;return S([n],(function(){return i.nestedArray.flatten(n)}))}function T(n){R().forEach(n)}!function(n){n.Error="error",n.Warning="warning"}(m||(m={}));var C,A,_=function(){function n(n,t,e){var r=void 0===e?{}:e;e=r.message;var u=r.groupName;r=r.key,this.key=null,this.id=i.seq(),this.severity=m.Error,this.status=F,this.fieldName=n,this.testFn=t,u&&(this.groupName=u),e&&(this.message=e),r&&(this.key=r)}return n.prototype.run=function(){try{var n=this.testFn()}catch(t){(function(n,t){return i.isUndefined(n)&&i.isStringValue(t)})(this.message,t)&&(this.message=t),n=!1}return!1===n&&this.fail(),n},n.prototype.setStatus=function(n){this.isFinalStatus()&&n!==L||(this.status=n)},n.prototype.warns=function(){return this.severity===m.Warning},n.prototype.setPending=function(){this.setStatus(P)},n.prototype.fail=function(){this.setStatus(this.warns()?b:I)},n.prototype.done=function(){this.isFinalStatus()||this.setStatus(k)},n.prototype.warn=function(){this.severity=m.Warning},n.prototype.isFinalStatus=function(){return this.hasFailures()||this.isCanceled()||this.isPassing()},n.prototype.skip=function(n){this.isPending()&&!n||this.setStatus(O)},n.prototype.cancel=function(){this.setStatus(x),g()},n.prototype.reset=function(){this.status=F,g()},n.prototype.omit=function(){this.setStatus(L)},n.prototype.valueOf=function(){return!this.isFailing()},n.prototype.hasFailures=function(){return this.isFailing()||this.isWarning()},n.prototype.isNonActionable=function(){return this.isSkipped()||this.isOmitted()||this.isCanceled()},n.prototype.isPending=function(){return this.statusEquals(P)},n.prototype.isTested=function(){return this.hasFailures()||this.isPassing()},n.prototype.isOmitted=function(){return this.statusEquals(L)},n.prototype.isUntested=function(){return this.statusEquals(F)},n.prototype.isFailing=function(){return this.statusEquals(I)},n.prototype.isCanceled=function(){return this.statusEquals(x)},n.prototype.isSkipped=function(){return this.statusEquals(O)},n.prototype.isPassing=function(){return this.statusEquals(k)},n.prototype.isWarning=function(){return this.statusEquals(b)},n.prototype.statusEquals=function(n){return this.status===n},n}(),F="UNTESTED",O="SKIPPED",I="FAILED",b="WARNING",k="PASSING",P="PENDING",x="CANCELED",L="OMITTED";function U(n){function t(n,t,u){return r.references.push(),e(n,i.optionalFunctionValue(t,u)),function(){return[r.references[n],function(t){return e(n,i.optionalFunctionValue(t,r.references[n]))}]}}function e(t,e){var o=r.references[t];r.references[t]=e,t=u[t][1],i.isFunction(t)&&t(e,o),i.isFunction(n)&&n()}var r={references:[]},u=[];return{registerStateKey:function(n,e){var r=u.length;return u.push([n,e]),t(r,n)},reset:function(){var n=r.references;r.references=[],u.forEach((function(e,r){return t(r,e[0],n[r])}))}}}function W(n,t){var e=t.suiteId;return t=t.suiteName,{optionalFields:n.registerStateKey((function(){return{}})),suiteId:n.registerStateKey(e),suiteName:n.registerStateKey(t),testCallbacks:n.registerStateKey((function(){return{fieldCallbacks:{},doneCallbacks:[]}})),testObjects:n.registerStateKey((function(n){return{prev:n?n.current:[],current:[]}}))}}function V(){return a.useX().isolate}function G(){var n=V();return n.path.concat(n.cursor.current())}function w(){return V().cursor}function D(t,e){t=void 0===(t=t.type)?n.DEFAULT:t,i.invariant(i.isFunction(e));var r=s(t,G());return t=a.run({isolate:r},(function(){return r.keys.prev=function(){var n=h()[0].prev;return i.asArray(i.nestedArray.getCurrent(n,G())).reduce((function(n,t){return t instanceof _&&!i.isNullish(t.key)?(n[t.key]=t,n):n}),{})}(),N((function(n){return i.nestedArray.setValueAtPath(n,r.path,[])})),e()})),w().next(),t}function q(n){return n===C.ERRORS?A.ERROR_COUNT:A.WARN_COUNT}function X(n,t){return!!t&&!H(n,t)}function H(n,t){return!(!t||n.fieldName!==t)}!function(n){n.WARNINGS="warnings",n.ERRORS="errors"}(C||(C={})),function(n){n.ERROR_COUNT="errorCount",n.WARN_COUNT="warnCount"}(A||(A={}));var K=i.bindNot((function(n,t){return n.groupName===t}));function M(n){return function(n,t){return R().some((function(e){return B(e,n,t)}))}(C.ERRORS,n)}function B(n,t,e){return!(!n.hasFailures()||X(n,e)||function(n,t){return i.either(n===C.WARNINGS,t.warns())}(t,n))}function j(n){if(J(n))return!0;if(M(n))return!1;var t=R();return!i.isEmpty(t)&&!function(n){return i.isNotEmpty(y().filter((function(t){return z(t,n)})))}(n)&&function(n){return R().every((function(t){return!!X(t,n)||Q(t,n)}))}(n)}function Y(n,t){return!!J(t)||!function(n,t,e){return R().some((function(r){return!K(r,t)&&B(r,n,e)}))}(C.ERRORS,n,t)&&!function(n,t){return i.isNotEmpty(y().filter((function(e){return!K(e,n)&&z(e,t)})))}(n,t)&&function(n,t){return R().every((function(e){return!!K(e,n)||Q(e,t)}))}(n,t)}function J(n){return!!n&&!0===function(n){var t;return null===(t=p(n))||void 0===t?void 0:t[1]}(n)}function z(n,t){return!X(n,t)&&!0!==E(n.fieldName)}function Q(n,t){return!!X(n,t)||(!0===E(n.fieldName)||n.isTested()||n.isOmitted())}function Z(){var n=R(),t=i.assign({errorCount:0,warnCount:0,testCount:0},{groups:{},tests:{},valid:!1});return n.reduce((function(n,t){return function(n,t){n[t.fieldName]=$(n,t),n[t.fieldName].valid=!1!==n[t.fieldName].valid&&j(t.fieldName)}(n.tests,t),function(n,t){var e=t.groupName;e&&(n[e]=n[e]||{},n[e][t.fieldName]=$(n[e],t),n[e][t.fieldName].valid=!1!==n[e][t.fieldName].valid&&Y(e,t.fieldName))}(n.groups,t),n}),t),t.valid=j(),function(n){for(var t in n.tests)n.errorCount+=n.tests[t].errorCount,n.warnCount+=n.tests[t].warnCount,n.testCount+=n.tests[t].testCount;return n}(t)}function $(n,t){function e(n){var t=q(n);o[t]++,u&&(o[n]=(o[n]||[]).concat(u))}var r=t.fieldName,u=t.message;n[r]=n[r]||i.assign({errorCount:0,warnCount:0,testCount:0},{errors:[],warnings:[]});var o=n[r];return t.isNonActionable()||(n[r].testCount++,t.isFailing()?e(C.ERRORS):t.isWarning()&&e(C.WARNINGS)),o}function nn(n,t,e){return e?function(n,t,e){var r;return(null===(r=null==n?void 0:n[e])||void 0===r?void 0:r[t])||[]}(n,t,e):function(n,t){var e,r={},u=q(t);for(e in n)i.isPositive(n[e][u])&&(r[e]=n[e][t]||[]);return r}(n,t)}function tn(n){return{getErrors:function(t){return en(n,C.ERRORS,t)},getErrorsByGroup:function(t,e){return rn(n,C.ERRORS,t,e)},getWarnings:function(t){return en(n,C.WARNINGS,t)},getWarningsByGroup:function(t,e){return rn(n,C.WARNINGS,t,e)},hasErrors:function(t){return sn(n,A.ERROR_COUNT,t)},hasErrorsByGroup:function(t,e){return on(n,A.ERROR_COUNT,t,e)},hasWarnings:function(t){return sn(n,A.WARN_COUNT,t)},hasWarningsByGroup:function(t,e){return on(n,A.WARN_COUNT,t,e)},isValid:function(t){var e;return t?!(null===(e=n.tests[t])||void 0===e||!e.valid):n.valid},isValidByGroup:function(t,e){if(!(t=n.groups[t]))return!1;if(e)return un(t,e);for(var r in t)if(!un(t,r))return!1;return!0}}}function en(n,t,e){return nn(n.tests,t,e)}function rn(n,t,e,r){return nn(n.groups[e],t,r)}function un(n,t){var e;return!(null===(e=n[t])||void 0===e||!e.valid)}function on(n,t,e,r){var u,o;if(!(n=n.groups[e]))return!1;if(r)return i.isPositive(null===(u=n[r])||void 0===u?void 0:u[t]);for(var s in n)if(i.isPositive(null===(o=n[s])||void 0===o?void 0:o[t]))return!0;return!1}function sn(n,t,e){var r;return n=e?null===(r=n.tests[e])||void 0===r?void 0:r[t]:n[t]||0,i.isPositive(n)}var an=i.cache(1);function cn(){var n=R(),t={stateRef:c()};return an([n],a.bind(t,(function(){var n=Z(),t=c().suiteName()[0];return i.assign(n,tn(n),{suiteName:t})})))}function fn(n){var t=y();return!i.isEmpty(t)&&(!n||t.some((function(t){return H(t,n)})))}var ln=i.cache(20);function pn(){var n=R(),t={stateRef:c()};return ln([n],a.bind(t,(function(){return i.assign({},cn(),{done:a.bind(t,hn)})})))}function dn(n,t,e){var r;return!!(!i.isFunction(n)||t&&i.numberEquals(null===(r=e.tests[t])||void 0===r?void 0:r.testCount,0))}function vn(n){return!(fn()&&(!n||fn(n)))}var En,hn=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=(n=n.reverse())[0];if(n=n[1],t=pn(),dn(e,n,t))return t;var r=function(){return e(cn())};return vn(n)?(r(),t):(gn(r,n),t)};function gn(n,t){(0,l()[1])((function(e){return t?e.fieldCallbacks[t]=(e.fieldCallbacks[t]||[]).concat(n):e.doneCallbacks.push(n),e}))}function Nn(){var n=i.bus.createBus();return n.on(En.TEST_COMPLETED,(function(t){t.isCanceled()||(t.done(),function(n){var t=l()[0].fieldCallbacks;n&&!fn(n)&&i.isArray(t[n])&&i.callEach(t[n])}(t.fieldName),fn()||n.emit(En.ALL_RUNNING_TESTS_FINISHED))})),n.on(En.SUITE_CALLBACK_DONE_RUNNING,(function(){!function(){function n(n){e[n.fieldName]&&(n.omit(),v(n.fieldName,(function(n){return[n[0],!0]})))}var t=d()[0];if(!i.isEmpty(t)){var e={};N((function(t){return i.nestedArray.transform(t,(function(t){if(i.hasOwnProperty(e,t.fieldName))n(t);else{var r=E(t.fieldName);i.isFunction(r)&&(e[t.fieldName]=r(),n(t))}return t}))}))}}()})),n.on(En.ALL_RUNNING_TESTS_FINISHED,(function(){!function(){var n=l()[0].doneCallbacks;i.callEach(n)}()})),n.on(En.REMOVE_FIELD,(function(n){T((function(t){H(t,n)&&(t.cancel(),function(n){N((function(t){return i.nestedArray.transform(t,(function(t){return n!==t?t:null}))}))}(t))}))})),n.on(En.RESET_FIELD,(function(n){T((function(t){H(t,n)&&t.reset()}))})),n}function yn(){var n=a.useX();return i.invariant(n.bus),n.bus}!function(n){n.TEST_COMPLETED="test_completed",n.ALL_RUNNING_TESTS_FINISHED="all_running_tests_finished",n.REMOVE_FIELD="remove_field",n.RESET_FIELD="reset_field",n.SUITE_CALLBACK_DONE_RUNNING="suite_callback_done_running"}(En||(En={}));function mn(){return!!a.useX().skipped}function Sn(n){return Cn(0,"tests",n)}function Rn(n){return Cn(1,"tests",n)}function Tn(n){var t=n.fieldName;if(n=n.groupName,mn())return!0;var e=a.useX(),r=e.exclusion;e=e.inclusion;var u=r.tests,o=u[t];if(!1===o)return!0;if(o=!0===o,n){if(function(n){var t=a.useX().exclusion.groups;return i.hasOwnProperty(t,n)?!1===t[n]:_n()}(n))return!0;if(!0===r.groups[n])return!o&&(!!An(u)||!1===u[t])}return!!function(n){return!!_n()&&!n}(n)||!o&&(!!An(u)&&!i.optionalFunctionValue(e[t]))}function Cn(n,t,e){var r=a.useX("hook called outside of a running suite.");e&&i.asArray(e).forEach((function(e){i.isStringValue(e)&&(r.exclusion[t][e]=0===n)}))}function An(n){for(var t in n)if(!0===n[t])return!0;return!1}function _n(){var n,t=a.useX().exclusion;for(n in t.groups)if(t.groups[n])return!0;return!1}function Fn(n){return"Wrong arguments passed to group. Group ".concat(n,".")}function On(n){return function(n){return a.useX().mode[0]===n}(e.EAGER)&&M(n.fieldName)}function In(){return!!a.useX().omitted}function bn(n,t,e){if(e||2===arguments.length)for(var r,i=0,u=t.length;i<u;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return n.concat(r||Array.prototype.slice.call(t))}function kn(n,t){return n.fieldName===t.fieldName&&n.groupName===t.groupName}function Pn(n){var t=n.asyncTest,e=n.message;if(i.isPromise(t)){var r=yn().emit,u=c(),o=a.bind({stateRef:u},(function(){g(),r(En.TEST_COMPLETED,n)}));u=a.bind({stateRef:u},(function(t){n.isCanceled()||(n.message=i.isStringValue(t)?t:e,n.fail(),o())}));try{t.then(o,u)}catch(n){u()}}}function xn(n){var t=yn(),e=function(n){return a.run({currentTest:n},(function(){return n.run()}))}(n);try{i.isPromise(e)?(n.asyncTest=e,n.setPending(),Pn(n)):t.emit(En.TEST_COMPLETED,n)}catch(t){throw Error("Unexpected error encountered during test registration.\n Test Object: ".concat(JSON.stringify(n),".\n Error: ").concat(t,"."))}}function Ln(t){var e=h()[0].prev;return i.isEmpty(e)?(Un(t),t):(e=function(n){var t=G();return i.nestedArray.valueAtPath(n,t)}(e),i.isNullish(t.key)?(function(n,t){return i.isNotEmpty(n)&&!kn(n,t)}(e,t)&&(function(t,e){V().type===n.EACH||i.deferThrow("Vest Critical Error: Tests called in different order than previous run.\n expected: ".concat(t.fieldName,"\n received: ").concat(e.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.'))}(e,t),function(){var n=w().current();N((function(t){return t.splice(n),t}))}(),e=null),Un(t=i.defaultTo(e,t)),t):(Un(t=function(n,t){var e=function(n){return V().keys.prev[n]}(n);return e&&(t=e),function(n,t){var e=V().keys.current;i.isNullish(e[n])?e[n]=t:i.deferThrow('Encountered the same test key "'.concat(n,"\" twice. This may lead to tests overriding each other's results, or to tests being unexpectedly omitted."))}(n,t),t}(t.key,t)),t))}function Un(n){var t=G();N((function(e){return i.nestedArray.setValueAtPath(e,t,n)}))}function Wn(n){var t=w();if(On(n))return n.skip(),Ln(n),t.next(),n;var e=Ln(n);return In()?(e.omit(),t.next(),e):Tn(n)?(e.skip(mn()),t.next(),e):(function(n,t){t!==n&&kn(n,t)&&n.isPending()&&n.cancel()}(e,n),Un(n),function(n){n.isUntested()?xn(n):i.isPromise(n.asyncTest)&&(n.setPending(),Pn(n))}(n),t.next(),n)}function Vn(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];var r=i.isFunction(t[1])?t:bn([void 0],t,!0);t=r[0],e=r[1],r=r[2],i.invariant(i.isStringValue(n),wn("fieldName","string")),i.invariant(i.isFunction(e),wn("Test callback","function"));var u=a.useX();return Wn(t=new _(n,e,{message:t,groupName:u.groupName,key:r}))}Sn.group=function(n){return Cn(0,"groups",n)},Rn.group=function(n){return Cn(1,"groups",n)},i.bindNot(i.isStringValue);var Gn=i.assign(Vn,{memo:function(n){var t=i.cache(10);return function(e){for(var r=[],u=1;u<arguments.length;u++)r[u-1]=arguments[u];u=w().current();var o=(r=r.reverse())[0],s=r[1],a=r[2];return u=[f(),e,u].concat(o),r=t.get(u),i.isNull(r)?t(u,(function(){return n(e,a,s)})):r[1].isCanceled()?(t.invalidate(u),t(u,(function(){return n(e,a,s)}))):Wn(r[1])}}(Vn)});function wn(n,t){return"Incompatible params passed to test function. ".concat(n," must be a ").concat(t)}Object.defineProperty(exports,"enforce",{enumerable:!0,get:function(){return r.enforce}}),exports.VERSION="4.5.0",exports.context=a,exports.create=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(t=t.reverse())[0];t=t[1],i.invariant(i.isFunction(r),"vest.create: Expected callback to be a function.");var u=Nn(),o=U();return t={stateRef:W(o,{suiteId:i.seq(),suiteName:t}),bus:u},i.assign(a.bind(t,(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return o.reset(),D({type:n.SUITE},(function(){r.apply(void 0,t)})),u.emit(En.SUITE_CALLBACK_DONE_RUNNING),pn()})),{get:a.bind(t,cn),remove:a.bind(t,(function(n){u.emit(En.REMOVE_FIELD,n)})),reset:o.reset,resetField:a.bind(t,(function(n){u.emit(En.RESET_FIELD,n)}))})},exports.each=function(t,e){i.invariant(i.isFunction(e),"each callback must be a function"),D({type:n.EACH},(function(){t.forEach((function(n,t){e(n,t)}))}))},exports.eager=function(){!function(n){a.useX().mode[0]=n}(e.EAGER)},exports.group=function(t,e){i.invariant(i.isStringValue(t),Fn("name must be a string")),i.invariant(i.isFunction(e),Fn("callback must be a function")),D({type:n.GROUP},(function(){a.run({groupName:t},e)}))},exports.include=function(n){var t=a.useX(),e=t.inclusion;return t=t.exclusion,i.invariant(i.isStringValue(n)),e[n]=i.defaultTo(t.tests[n],!0),{when:function(t){var e=a.useX(),r=e.exclusion;e.inclusion[n]=function(){return i.hasOwnProperty(r.tests,n)?i.defaultTo(r.tests[n],!0):i.isStringValue(t)?!!r.tests[t]:i.optionalFunctionValue(t,i.optionalFunctionValue(cn))}}}},exports.omitWhen=function(t,e){D({type:n.OMIT_WHEN},(function(){a.run({omitted:In()||i.optionalFunctionValue(t,i.optionalFunctionValue(cn))},(function(){return e()}))}))},exports.only=Sn,exports.optional=function(n){if(i.isArray(n)||i.isStringValue(n))i.asArray(n).forEach((function(n){v(n,[!0,!1])}));else for(var t in n)v(t,[n[t],!1])},exports.skip=Rn,exports.skipWhen=function(t,e){D({type:n.SKIP_WHEN},(function(){a.run({skipped:mn()||i.optionalFunctionValue(t,i.optionalFunctionValue(cn))},(function(){return e()}))}))},exports.suiteSelectors=tn,exports.test=Gn,exports.warn=function(){var n=a.useX("warn hook called outside of a running suite.");i.invariant(n.currentTest,"warn called outside of a test."),n.currentTest.warn()};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,n,e,r=require("n4s"),i=require("vest-utils"),u=require("context"),o=require("vast");function s(){var t=0;return{current:function(){return t},next:function(){t++}}}function a(t,n){return void 0===n&&(n=[]),{cursor:s(),keys:{current:{},prev:{}},path:n,type:t}}(n=t||(t={}))[n.DEFAULT=0]="DEFAULT",n[n.SUITE=1]="SUITE",n[n.EACH=2]="EACH",n[n.SKIP_WHEN=3]="SKIP_WHEN",n[n.OMIT_WHEN=4]="OMIT_WHEN",n[n.GROUP=5]="GROUP",function(t){t[t.ALL=0]="ALL",t[t.EAGER=1]="EAGER"}(e||(e={}));var c=u.createCascade((function(n,r){return r?null:i.assign({exclusion:{tests:{},groups:{}},inclusion:{},isolate:a(t.DEFAULT),mode:[e.ALL]},n)}));function f(){return c.useX().stateRef}function l(){return f().suiteId()[0]}function p(){return f().testCallbacks()}function d(){return f().optionalFields()}function v(t,n){(0,d()[1])((function(e){var r;return i.assign(e,((r={})[t]=i.assign({},e[t],n(e[t])),r))}))}function E(t){var n;return null!==(n=d()[0][t])&&void 0!==n?n:{}}function h(){return f().testObjects()}function g(){N((function(t){return t}))}function N(t){(0,h()[1])((function(n){return{prev:n.prev,current:i.asArray(t(n.current))}}))}function y(){return S().filter((function(t){return t.isPending()}))}var m,R=i.cache();function S(){var t=h()[0].current;return R([t],(function(){return i.nestedArray.flatten(t)}))}function T(t){S().forEach(t)}!function(t){t.Error="error",t.Warning="warning"}(m||(m={}));var C,A,_=function(){function t(t,n,e){var r=void 0===e?{}:e;e=r.message;var u=r.groupName;r=r.key,this.key=null,this.id=i.seq(),this.severity=m.Error,this.status=I,this.fieldName=t,this.testFn=n,u&&(this.groupName=u),e&&(this.message=e),r&&(this.key=r)}return t.prototype.run=function(){try{var t=this.testFn()}catch(n){(function(t,n){return i.isUndefined(t)&&i.isStringValue(n)})(this.message,n)&&(this.message=n),t=!1}return!1===t&&this.fail(),t},t.prototype.setStatus=function(t){this.isFinalStatus()&&t!==L||(this.status=t)},t.prototype.warns=function(){return this.severity===m.Warning},t.prototype.setPending=function(){this.setStatus(P)},t.prototype.fail=function(){this.setStatus(this.warns()?b:F)},t.prototype.done=function(){this.isFinalStatus()||this.setStatus(k)},t.prototype.warn=function(){this.severity=m.Warning},t.prototype.isFinalStatus=function(){return this.hasFailures()||this.isCanceled()||this.isPassing()},t.prototype.skip=function(t){this.isPending()&&!t||this.setStatus(O)},t.prototype.cancel=function(){this.setStatus(x),g()},t.prototype.reset=function(){this.status=I,g()},t.prototype.omit=function(){this.setStatus(L)},t.prototype.valueOf=function(){return!this.isFailing()},t.prototype.isPending=function(){return this.statusEquals(P)},t.prototype.isOmitted=function(){return this.statusEquals(L)},t.prototype.isUntested=function(){return this.statusEquals(I)},t.prototype.isFailing=function(){return this.statusEquals(F)},t.prototype.isCanceled=function(){return this.statusEquals(x)},t.prototype.isSkipped=function(){return this.statusEquals(O)},t.prototype.isPassing=function(){return this.statusEquals(k)},t.prototype.isWarning=function(){return this.statusEquals(b)},t.prototype.hasFailures=function(){return this.isFailing()||this.isWarning()},t.prototype.isNonActionable=function(){return this.isSkipped()||this.isOmitted()||this.isCanceled()},t.prototype.isTested=function(){return this.hasFailures()||this.isPassing()},t.prototype.awaitsResolution=function(){return this.isSkipped()||this.isUntested()||this.isPending()},t.prototype.statusEquals=function(t){return this.status===t},t}(),I="UNTESTED",O="SKIPPED",F="FAILED",b="WARNING",k="PASSING",P="PENDING",x="CANCELED",L="OMITTED";function U(t,n){var e=n.suiteId;return n=n.suiteName,{optionalFields:t.registerStateKey((function(){return{}})),suiteId:t.registerStateKey(e),suiteName:t.registerStateKey(n),testCallbacks:t.registerStateKey((function(){return{fieldCallbacks:{},doneCallbacks:[]}})),testObjects:t.registerStateKey((function(t){return{prev:t?t.current:[],current:[]}}))}}function D(){return c.useX().isolate}function W(){var t=D();return t.path.concat(t.cursor.current())}function w(){return D().cursor}function G(n,e){n=void 0===(n=n.type)?t.DEFAULT:n,i.invariant(i.isFunction(e));var r=a(n,W());return n=c.run({isolate:r},(function(){return r.keys.prev=function(){var t=h()[0].prev;return i.asArray(i.nestedArray.getCurrent(t,W())).reduce((function(t,n){return n instanceof _&&!i.isNullish(n.key)?(t[n.key]=n,t):t}),{})}(),N((function(t){return i.nestedArray.setValueAtPath(t,r.path,[])})),e()})),w().next(),n}function V(t){return t===C.ERRORS?A.ERROR_COUNT:A.WARN_COUNT}function q(t,n){return!!n&&!X(t,n)}function X(t,n){return!(!n||t.fieldName!==n)}!function(t){t.WARNINGS="warnings",t.ERRORS="errors"}(C||(C={})),function(t){t.ERROR_COUNT="errorCount",t.WARN_COUNT="warnCount"}(A||(A={}));var H,K=i.bindNot((function(t,n){return t.groupName===n}));function M(t){return function(t,n){return S().some((function(e){return B(e,t,n)}))}(C.ERRORS,t)}function B(t,n,e){return!(!t.hasFailures()||q(t,e)||function(t,n){return i.either(t===C.WARNINGS,n.warns())}(n,t))}function j(t){return!!t&&E(t).applied}function Y(t){if(j(t))return!0;var n=S();return!(i.isEmpty(n)||M(t)||function(t){return i.isNotEmpty(y().filter((function(n){return z(n,t)})))}(t))&&function(t){return S().every((function(n){return Q(n,t)}))}(t)}function J(t,n){return!!j(n)||!function(t,n,e){return S().some((function(r){return!K(r,n)&&B(r,t,e)}))}(C.ERRORS,t,n)&&!function(t,n){return i.isNotEmpty(y().filter((function(e){return!K(e,t)&&z(e,n)})))}(t,n)&&function(t,n){return S().every((function(e){return!!K(e,t)||Q(e,n)}))}(t,n)}function z(t,n){return!q(t,n)&&j(n)}function Q(t,n){return!!q(t,n)||(function(t){return E(t.fieldName).type===H.Delayed&&t.awaitsResolution()}(t)||t.isTested()||t.isOmitted())}function Z(){var t=S(),n=i.assign({errorCount:0,warnCount:0,testCount:0},{groups:{},tests:{},valid:!1});return t.reduce((function(t,n){return function(t,n){t[n.fieldName]=$(t,n),t[n.fieldName].valid=!1!==t[n.fieldName].valid&&Y(n.fieldName)}(t.tests,n),function(t,n){var e=n.groupName;e&&(t[e]=t[e]||{},t[e][n.fieldName]=$(t[e],n),t[e][n.fieldName].valid=!1!==t[e][n.fieldName].valid&&J(e,n.fieldName))}(t.groups,n),t}),n),n.valid=Y(),function(t){for(var n in t.tests)t.errorCount+=t.tests[n].errorCount,t.warnCount+=t.tests[n].warnCount,t.testCount+=t.tests[n].testCount;return t}(n)}function $(t,n){function e(t){var n=V(t);o[n]++,u&&(o[t]=(o[t]||[]).concat(u))}var r=n.fieldName,u=n.message;t[r]=t[r]||i.assign({errorCount:0,warnCount:0,testCount:0},{errors:[],warnings:[]});var o=t[r];return n.isNonActionable()||(t[r].testCount++,n.isFailing()?e(C.ERRORS):n.isWarning()&&e(C.WARNINGS)),o}function tt(t,n,e){return e?function(t,n,e){var r;return(null===(r=null==t?void 0:t[e])||void 0===r?void 0:r[n])||[]}(t,n,e):function(t,n){var e,r={},u=V(n);for(e in t)i.isPositive(t[e][u])&&(r[e]=t[e][n]||[]);return r}(t,n)}function nt(t){return{getErrors:function(n){return et(t,C.ERRORS,n)},getErrorsByGroup:function(n,e){return rt(t,C.ERRORS,n,e)},getWarnings:function(n){return et(t,C.WARNINGS,n)},getWarningsByGroup:function(n,e){return rt(t,C.WARNINGS,n,e)},hasErrors:function(n){return ot(t,A.ERROR_COUNT,n)},hasErrorsByGroup:function(n,e){return ut(t,A.ERROR_COUNT,n,e)},hasWarnings:function(n){return ot(t,A.WARN_COUNT,n)},hasWarningsByGroup:function(n,e){return ut(t,A.WARN_COUNT,n,e)},isValid:function(n){var e;return n?!(null===(e=t.tests[n])||void 0===e||!e.valid):t.valid},isValidByGroup:function(n,e){if(!(n=t.groups[n]))return!1;if(e)return it(n,e);for(var r in n)if(!it(n,r))return!1;return!0}}}function et(t,n,e){return tt(t.tests,n,e)}function rt(t,n,e,r){return tt(t.groups[e],n,r)}function it(t,n){var e;return!(null===(e=t[n])||void 0===e||!e.valid)}function ut(t,n,e,r){var u,o;if(!(t=t.groups[e]))return!1;if(r)return i.isPositive(null===(u=t[r])||void 0===u?void 0:u[n]);for(var s in t)if(i.isPositive(null===(o=t[s])||void 0===o?void 0:o[n]))return!0;return!1}function ot(t,n,e){var r;return t=e?null===(r=t.tests[e])||void 0===r?void 0:r[n]:t[n]||0,i.isPositive(t)}!function(t){t[t.Immediate=0]="Immediate",t[t.Delayed=1]="Delayed"}(H||(H={}));var st=i.cache(1);function at(){var t=S(),n={stateRef:f()};return st([t],c.bind(n,(function(){var t=Z(),n=f().suiteName()[0];return i.assign(t,nt(t),{suiteName:n})})))}function ct(t){var n=y();return!i.isEmpty(n)&&(!t||n.some((function(n){return X(n,t)})))}var ft=i.cache(20);function lt(){var t=S(),n={stateRef:f()};return ft([t],c.bind(n,(function(){return i.assign({},at(),{done:c.bind(n,Et)})})))}function pt(t,n,e){var r;return!!(!i.isFunction(t)||n&&i.numberEquals(null===(r=e.tests[n])||void 0===r?void 0:r.testCount,0))}function dt(t){return!(ct()&&(!t||ct(t)))}var vt,Et=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=(t=t.reverse())[0];if(t=t[1],n=lt(),pt(e,t,n))return n;var r=function(){return e(at())};return dt(t)?(r(),n):(ht(r,t),n)};function ht(t,n){(0,p()[1])((function(e){return n?e.fieldCallbacks[n]=(e.fieldCallbacks[n]||[]).concat(t):e.doneCallbacks.push(t),e}))}function gt(){var t=i.bus.createBus();return t.on(vt.TEST_COMPLETED,(function(n){n.isCanceled()||(n.done(),function(t){var n=p()[0].fieldCallbacks;t&&!ct(t)&&i.isArray(n[t])&&i.callEach(n[t])}(n.fieldName),ct()||t.emit(vt.ALL_RUNNING_TESTS_FINISHED))})),t.on(vt.SUITE_CALLBACK_DONE_RUNNING,(function(){!function(){function t(t){e[t.fieldName]&&(t.omit(),v(t.fieldName,(function(){return{applied:!0}})))}var n=d()[0];if(!i.isEmpty(n)){var e={};S().forEach((function(n){if(i.hasOwnProperty(e,n.fieldName))t(n);else{var r=E(n.fieldName);r.type===H.Immediate&&(e[n.fieldName]=i.optionalFunctionValue(r.rule),t(n))}})),g()}}()})),t.on(vt.ALL_RUNNING_TESTS_FINISHED,(function(){!function(){var t=p()[0].doneCallbacks;i.callEach(t)}()})),t.on(vt.REMOVE_FIELD,(function(t){T((function(n){X(n,t)&&(n.cancel(),function(t){N((function(n){return i.nestedArray.transform(n,(function(n){return t!==n?n:null}))}))}(n))}))})),t.on(vt.RESET_FIELD,(function(t){T((function(n){X(n,t)&&n.reset()}))})),t}function Nt(){var t=c.useX();return i.invariant(t.bus),t.bus}!function(t){t.TEST_COMPLETED="test_completed",t.ALL_RUNNING_TESTS_FINISHED="all_running_tests_finished",t.REMOVE_FIELD="remove_field",t.RESET_FIELD="reset_field",t.SUITE_CALLBACK_DONE_RUNNING="suite_callback_done_running"}(vt||(vt={}));function yt(){return!!c.useX().skipped}function mt(t){return Tt(0,"tests",t)}function Rt(t){return Tt(1,"tests",t)}function St(t){var n=t.fieldName;if(t=t.groupName,yt())return!0;var e=c.useX(),r=e.exclusion;e=e.inclusion;var u=r.tests,o=u[n];if(!1===o)return!0;if(o=!0===o,t){if(function(t){var n=c.useX().exclusion.groups;return i.hasOwnProperty(n,t)?!1===n[t]:At()}(t))return!0;if(!0===r.groups[t])return!o&&(!!Ct(u)||!1===u[n])}return!!function(t){return!!At()&&!t}(t)||!o&&(!!Ct(u)&&!i.optionalFunctionValue(e[n]))}function Tt(t,n,e){var r=c.useX("hook called outside of a running suite.");e&&i.asArray(e).forEach((function(e){i.isStringValue(e)&&(r.exclusion[n][e]=0===t)}))}function Ct(t){for(var n in t)if(!0===t[n])return!0;return!1}function At(){var t,n=c.useX().exclusion;for(t in n.groups)if(n.groups[t])return!0;return!1}function _t(t){return"Wrong arguments passed to group. Group ".concat(t,".")}function It(t){return function(t){return c.useX().mode[0]===t}(e.EAGER)&&M(t.fieldName)}function Ot(){return!!c.useX().omitted}function Ft(t,n,e){if(e||2===arguments.length)for(var r,i=0,u=n.length;i<u;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return t.concat(r||Array.prototype.slice.call(n))}function bt(t,n){return t.fieldName===n.fieldName&&t.groupName===n.groupName}function kt(t){var n=t.asyncTest,e=t.message;if(i.isPromise(n)){var r=Nt().emit,u=f(),o=c.bind({stateRef:u},(function(){g(),r(vt.TEST_COMPLETED,t)}));u=c.bind({stateRef:u},(function(n){t.isCanceled()||(t.message=i.isStringValue(n)?n:e,t.fail(),o())})),n.then(o,u)}}function Pt(t){var n=Nt(),e=function(t){return c.run({currentTest:t},(function(){return t.run()}))}(t);try{i.isPromise(e)?(t.asyncTest=e,t.setPending(),kt(t)):n.emit(vt.TEST_COMPLETED,t)}catch(n){throw Error("Unexpected error encountered during test registration.\n Test Object: ".concat(JSON.stringify(t),".\n Error: ").concat(n,"."))}}function xt(n){var e=h()[0].prev;return i.isEmpty(e)?(Lt(n),n):(e=function(t){var n=W();return i.nestedArray.valueAtPath(t,n)}(e),i.isNullish(n.key)?(function(t,n){return i.isNotEmpty(t)&&!bt(t,n)}(e,n)&&(function(n,e){D().type===t.EACH||i.deferThrow("Vest Critical Error: Tests called in different order than previous run.\n expected: ".concat(n.fieldName,"\n received: ").concat(e.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.'))}(e,n),function(){var t=w().current();N((function(n){return n.splice(t),n}))}(),e=null),Lt(n=i.defaultTo(e,n)),n):(n=function(t,n){var e=function(t){return D().keys.prev[t]}(t);return e&&(n=e),function(t,n){var e=D().keys.current;i.isNullish(e[t])?e[t]=n:i.deferThrow('Encountered the same test key "'.concat(t,"\" twice. This may lead to tests overriding each other's results, or to tests being unexpectedly omitted."))}(t,n),n}(n.key,n),Lt(n),n))}function Lt(t){var n=W();N((function(e){return i.nestedArray.setValueAtPath(e,n,t)}))}function Ut(t){var n=w();if(It(t))return t.skip(),xt(t),n.next(),t;var e=xt(t);return Ot()||j(t.fieldName)?(e.omit(),n.next(),e):St(t)?(e.skip(yt()),n.next(),e):(function(t,n){n!==t&&bt(t,n)&&t.isPending()&&t.cancel()}(e,t),Lt(t),function(t){t.isUntested()?Pt(t):i.isPromise(t.asyncTest)&&(t.setPending(),kt(t))}(t),n.next(),t)}function Dt(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var r=i.isFunction(n[1])?n:Ft([void 0],n,!0);n=r[0],e=r[1],r=r[2],i.invariant(i.isStringValue(t),wt("fieldName","string")),i.invariant(i.isFunction(e),wt("Test callback","function"));var u=c.useX();return Ut(n=new _(t,e,{message:n,groupName:u.groupName,key:r}))}mt.group=function(t){return Tt(0,"groups",t)},Rt.group=function(t){return Tt(1,"groups",t)};var Wt=i.assign(Dt,{memo:function(t){var n=i.cache(10);return function(e){for(var r=[],u=1;u<arguments.length;u++)r[u-1]=arguments[u];u=w().current();var o=(r=r.reverse())[0],s=r[1],a=r[2];return u=[l(),e,u].concat(o),r=n.get(u),i.isNull(r)?n(u,(function(){return t(e,a,s)})):r[1].isCanceled()?(n.invalidate(u),n(u,(function(){return t(e,a,s)}))):Ut(r[1])}}(Dt)});function wt(t,n){return"Incompatible params passed to test function. ".concat(t," must be a ").concat(n)}Object.defineProperty(exports,"enforce",{enumerable:!0,get:function(){return r.enforce}}),exports.VERSION="4.6.2-dev-fcaa09",exports.context=c,exports.create=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var r=(n=n.reverse())[0];n=n[1],i.invariant(i.isFunction(r),"vest.create: Expected callback to be a function.");var u=gt(),s=o.createState();return n={stateRef:U(s,{suiteId:i.seq(),suiteName:n}),bus:u},i.assign(c.bind(n,(function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return s.reset(),G({type:t.SUITE},(function(){r.apply(void 0,n)})),u.emit(vt.SUITE_CALLBACK_DONE_RUNNING),lt()})),{get:c.bind(n,at),remove:c.bind(n,(function(t){u.emit(vt.REMOVE_FIELD,t)})),reset:s.reset,resetField:c.bind(n,(function(t){u.emit(vt.RESET_FIELD,t)}))})},exports.each=function(n,e){i.invariant(i.isFunction(e),"each callback must be a function"),G({type:t.EACH},(function(){n.forEach((function(t,n){e(t,n)}))}))},exports.eager=function(){!function(t){c.useX().mode[0]=t}(e.EAGER)},exports.group=function(n,e){i.invariant(i.isStringValue(n),_t("name must be a string")),i.invariant(i.isFunction(e),_t("callback must be a function")),G({type:t.GROUP},(function(){c.run({groupName:n},e)}))},exports.include=function(t){var n=c.useX(),e=n.inclusion;return n=n.exclusion,i.invariant(i.isStringValue(t)),e[t]=i.defaultTo(n.tests[t],!0),{when:function(n){var e=c.useX(),r=e.exclusion;e.inclusion[t]=function(){return i.hasOwnProperty(r.tests,t)?i.defaultTo(r.tests[t],!0):i.isStringValue(n)?!!r.tests[n]:i.optionalFunctionValue(n,i.optionalFunctionValue(at))}}}},exports.omitWhen=function(n,e){G({type:t.OMIT_WHEN},(function(){c.run({omitted:Ot()||i.optionalFunctionValue(n,i.optionalFunctionValue(at))},(function(){return e()}))}))},exports.only=mt,exports.optional=function(t){if(i.isArray(t)||i.isStringValue(t))i.asArray(t).forEach((function(t){v(t,(function(){return{type:H.Delayed,applied:!1,rule:null}}))}));else{var n,e=function(n){var e=t[n];v(n,(function(){return{type:H.Immediate,rule:e,applied:i.optionalFunctionValue(e)}}))};for(n in t)e(n)}},exports.skip=Rt,exports.skipWhen=function(n,e){G({type:t.SKIP_WHEN},(function(){c.run({skipped:yt()||i.optionalFunctionValue(n,i.optionalFunctionValue(at))},(function(){return e()}))}))},exports.suiteSelectors=nt,exports.test=Wt,exports.warn=function(){var t=c.useX("warn hook called outside of a running suite.");i.invariant(t.currentTest,"warn called outside of a test."),t.currentTest.warn()};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'n4s/compounds';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"n4s/compounds";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'n4s/schema';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"n4s/schema";
|