vest 4.4.2 → 4.5.0

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.
Files changed (51) hide show
  1. package/dist/cjs/classnames.development.js +16 -90
  2. package/dist/cjs/classnames.production.js +1 -1
  3. package/dist/cjs/enforce/compose.development.js +5 -58
  4. package/dist/cjs/enforce/compose.production.js +1 -1
  5. package/dist/cjs/enforce/compounds.development.js +8 -51
  6. package/dist/cjs/enforce/compounds.production.js +1 -1
  7. package/dist/cjs/enforce/schema.development.js +5 -57
  8. package/dist/cjs/enforce/schema.production.js +1 -1
  9. package/dist/cjs/parser.development.js +15 -89
  10. package/dist/cjs/parser.production.js +1 -1
  11. package/dist/cjs/promisify.development.js +2 -26
  12. package/dist/cjs/promisify.production.js +1 -1
  13. package/dist/cjs/vest.development.js +197 -452
  14. package/dist/cjs/vest.production.js +1 -1
  15. package/dist/es/classnames.development.js +14 -88
  16. package/dist/es/classnames.production.js +1 -1
  17. package/dist/es/enforce/compose.development.js +1 -54
  18. package/dist/es/enforce/compose.production.js +1 -1
  19. package/dist/es/enforce/compounds.development.js +2 -45
  20. package/dist/es/enforce/compounds.production.js +1 -1
  21. package/dist/es/enforce/schema.development.js +1 -53
  22. package/dist/es/enforce/schema.production.js +1 -1
  23. package/dist/es/parser.development.js +14 -88
  24. package/dist/es/parser.production.js +1 -1
  25. package/dist/es/promisify.development.js +1 -25
  26. package/dist/es/promisify.production.js +1 -1
  27. package/dist/es/vest.development.js +131 -387
  28. package/dist/es/vest.production.js +1 -1
  29. package/dist/umd/classnames.development.js +27 -56
  30. package/dist/umd/classnames.production.js +1 -1
  31. package/dist/umd/enforce/compose.development.js +111 -94
  32. package/dist/umd/enforce/compose.production.js +1 -1
  33. package/dist/umd/enforce/compounds.development.js +185 -168
  34. package/dist/umd/enforce/compounds.production.js +1 -1
  35. package/dist/umd/enforce/schema.development.js +134 -117
  36. package/dist/umd/enforce/schema.production.js +1 -1
  37. package/dist/umd/parser.development.js +27 -56
  38. package/dist/umd/parser.production.js +1 -1
  39. package/dist/umd/vest.development.js +398 -386
  40. package/dist/umd/vest.production.js +1 -1
  41. package/package.json +4 -3
  42. package/testUtils/__tests__/partition.test.ts +21 -0
  43. package/testUtils/mockThrowError.ts +2 -1
  44. package/testUtils/partition.ts +13 -0
  45. package/testUtils/suiteDummy.ts +1 -1
  46. package/types/enforce/compose.d.ts +17 -32
  47. package/types/enforce/compounds.d.ts +17 -32
  48. package/types/enforce/schema.d.ts +17 -32
  49. package/types/parser.d.ts +8 -7
  50. package/types/promisify.d.ts +20 -35
  51. package/types/vest.d.ts +45 -60
@@ -3,181 +3,12 @@
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);
36
- }
37
-
38
- function asArray(possibleArg) {
39
- return [].concat(possibleArg);
40
- }
41
-
42
- var assign = Object.assign;
43
-
44
- function isNumeric(value) {
45
- var str = String(value);
46
- var num = Number(value);
47
- var result = !isNaN(parseFloat(str)) && !isNaN(Number(value)) && isFinite(num);
48
- return Boolean(result);
49
- }
50
-
51
- function numberEquals(value, eq) {
52
- return isNumeric(value) && isNumeric(eq) && Number(value) === Number(eq);
53
- }
54
-
55
- function lengthEquals(value, arg1) {
56
- return numberEquals(value.length, arg1);
57
- }
58
-
59
- function greaterThan(value, gt) {
60
- return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
61
- }
62
-
63
- function longerThan(value, arg1) {
64
- return greaterThan(value.length, arg1);
65
- }
66
-
67
- /**
68
- * Creates a cache function
69
- */
70
- function createCache(maxSize) {
71
- if (maxSize === void 0) { maxSize = 1; }
72
- var cacheStorage = [];
73
- var cache = function (deps, cacheAction) {
74
- var cacheHit = cache.get(deps);
75
- // cache hit is not null
76
- if (cacheHit)
77
- return cacheHit[1];
78
- var result = cacheAction();
79
- cacheStorage.unshift([deps.concat(), result]);
80
- if (longerThan(cacheStorage, maxSize))
81
- cacheStorage.length = maxSize;
82
- return result;
83
- };
84
- // invalidate an item in the cache by its dependencies
85
- cache.invalidate = function (deps) {
86
- var index = findIndex(deps);
87
- if (index > -1)
88
- cacheStorage.splice(index, 1);
89
- };
90
- // Retrieves an item from the cache.
91
- cache.get = function (deps) {
92
- return cacheStorage[findIndex(deps)] || null;
93
- };
94
- return cache;
95
- function findIndex(deps) {
96
- return cacheStorage.findIndex(function (_a) {
97
- var cachedDeps = _a[0];
98
- return lengthEquals(deps, cachedDeps.length) &&
99
- deps.every(function (dep, i) { return dep === cachedDeps[i]; });
100
- });
101
- }
102
- }
103
-
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(value, defaultValue) {
129
- var _a;
130
- return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(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;
11
+ return vestUtils.isUndefined(message) && vestUtils.isStringValue(error);
181
12
  }
182
13
 
183
14
  var IsolateTypes;
@@ -234,7 +65,7 @@ function generateIsolate(type, path) {
234
65
  var context = context$1.createContext(function (ctxRef, parentContext) {
235
66
  return parentContext
236
67
  ? null
237
- : assign({}, {
68
+ : vestUtils.assign({
238
69
  exclusion: {
239
70
  tests: {},
240
71
  groups: {}
@@ -272,8 +103,8 @@ function useSetOptionalField(fieldName, setter) {
272
103
  var _a = useOptionalFields(), setOptionalFields = _a[1];
273
104
  setOptionalFields(function (optionalFields) {
274
105
  var _a;
275
- return assign(optionalFields, (_a = {},
276
- _a[fieldName] = optionalFunctionValue(setter, optionalFields[fieldName]),
106
+ return vestUtils.assign(optionalFields, (_a = {},
107
+ _a[fieldName] = vestUtils.optionalFunctionValue(setter, optionalFields[fieldName]),
277
108
  _a));
278
109
  });
279
110
  }
@@ -298,7 +129,7 @@ function useSetTests(handler) {
298
129
  var current = _a.current, prev = _a.prev;
299
130
  return ({
300
131
  prev: prev,
301
- current: asArray(handler(current))
132
+ current: vestUtils.asArray(handler(current))
302
133
  });
303
134
  });
304
135
  }
@@ -306,10 +137,10 @@ function useSetTests(handler) {
306
137
  function useAllIncomplete() {
307
138
  return useTestsFlat().filter(function (test) { return test.isPending(); });
308
139
  }
309
- var flatCache = createCache();
140
+ var flatCache = vestUtils.cache();
310
141
  function useTestsFlat() {
311
142
  var current = useTestObjects()[0].current;
312
- return flatCache([current], function () { return flatten(current); });
143
+ return flatCache([current], function () { return vestUtils.nestedArray.flatten(current); });
313
144
  }
314
145
  function useEachTestObject(handler) {
315
146
  var testObjects = useTestsFlat();
@@ -325,7 +156,7 @@ var VestTest = /** @class */ (function () {
325
156
  function VestTest(fieldName, testFn, _a) {
326
157
  var _b = _a === void 0 ? {} : _a, message = _b.message, groupName = _b.groupName, key = _b.key;
327
158
  this.key = null;
328
- this.id = genId();
159
+ this.id = vestUtils.seq();
329
160
  this.severity = TestSeverity.Error;
330
161
  this.status = STATUS_UNTESTED;
331
162
  this.fieldName = fieldName;
@@ -460,20 +291,6 @@ var STATUS_PENDING = 'PENDING';
460
291
  var STATUS_CANCELED = 'CANCELED';
461
292
  var STATUS_OMITTED = 'OMITTED';
462
293
 
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
294
  // eslint-disable-next-line max-lines-per-function
478
295
  function createState(onStateChange) {
479
296
  var state = {
@@ -512,12 +329,12 @@ function createState(onStateChange) {
512
329
  }
513
330
  function initKey(key, initialState, prevState) {
514
331
  current().push();
515
- set(key, optionalFunctionValue(initialState, prevState));
332
+ set(key, vestUtils.optionalFunctionValue(initialState, prevState));
516
333
  return function useStateKey() {
517
334
  return [
518
335
  current()[key],
519
336
  function (nextState) {
520
- return set(key, optionalFunctionValue(nextState, current()[key]));
337
+ return set(key, vestUtils.optionalFunctionValue(nextState, current()[key]));
521
338
  },
522
339
  ];
523
340
  };
@@ -529,10 +346,10 @@ function createState(onStateChange) {
529
346
  var prevValue = state.references[index];
530
347
  state.references[index] = value;
531
348
  var _a = registrations[index], onUpdate = _a[1];
532
- if (isFunction(onUpdate)) {
349
+ if (vestUtils.isFunction(onUpdate)) {
533
350
  onUpdate(value, prevValue);
534
351
  }
535
- if (isFunction(onStateChange)) {
352
+ if (vestUtils.isFunction(onStateChange)) {
536
353
  onStateChange();
537
354
  }
538
355
  }
@@ -557,23 +374,33 @@ function createStateRef(state, _a) {
557
374
  };
558
375
  }
559
376
 
560
- function isNullish(value) {
561
- return isNull(value) || isUndefined(value);
377
+ /**
378
+ * @returns {Isolate} The current isolate layer
379
+ */
380
+ function useIsolate() {
381
+ return context.useX().isolate;
562
382
  }
563
-
564
- function deferThrow(message) {
565
- setTimeout(function () {
566
- throw new Error(message);
567
- }, 0);
383
+ /**
384
+ * @returns {number[]} The current cursor path of the isolate tree
385
+ */
386
+ function useCurrentPath() {
387
+ var isolate = useIsolate();
388
+ return isolate.path.concat(isolate.cursor.current());
389
+ }
390
+ /**
391
+ * @returns {IsolateCursor} The cursor object for the current isolate
392
+ */
393
+ function useCursor() {
394
+ return useIsolate().cursor;
568
395
  }
569
396
 
570
397
  function usePrevKeys() {
571
398
  var prev = useTestObjects()[0].prev;
572
- return asArray(getCurrent(prev, useCurrentPath())).reduce(function (prevKeys, testObject) {
399
+ return vestUtils.asArray(vestUtils.nestedArray.getCurrent(prev, useCurrentPath())).reduce(function (prevKeys, testObject) {
573
400
  if (!(testObject instanceof VestTest)) {
574
401
  return prevKeys;
575
402
  }
576
- if (isNullish(testObject.key)) {
403
+ if (vestUtils.isNullish(testObject.key)) {
577
404
  return prevKeys;
578
405
  }
579
406
  prevKeys[testObject.key] = testObject;
@@ -586,22 +413,22 @@ function usePrevTestByKey(key) {
586
413
  }
587
414
  function useRetainTestKey(key, testObject) {
588
415
  var current = useIsolate().keys.current;
589
- if (isNullish(current[key])) {
416
+ if (vestUtils.isNullish(current[key])) {
590
417
  current[key] = testObject;
591
418
  }
592
419
  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."));
420
+ 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
421
  }
595
422
  }
596
423
 
597
424
  function isolate(_a, callback) {
598
425
  var _b = _a.type, type = _b === void 0 ? IsolateTypes.DEFAULT : _b;
599
- invariant(isFunction(callback));
426
+ vestUtils.invariant(vestUtils.isFunction(callback));
600
427
  // Generate a new Isolate layer, with its own cursor
601
428
  var isolate = generateIsolate(type, useCurrentPath());
602
429
  var output = context.run({ isolate: isolate }, function () {
603
430
  isolate.keys.prev = usePrevKeys();
604
- useSetTests(function (tests) { return setValueAtPath(tests, isolate.path, []); });
431
+ useSetTests(function (tests) { return vestUtils.nestedArray.setValueAtPath(tests, isolate.path, []); });
605
432
  var res = callback();
606
433
  return res;
607
434
  });
@@ -609,31 +436,12 @@ function isolate(_a, callback) {
609
436
  useCursor().next();
610
437
  return output;
611
438
  }
612
- /**
613
- * @returns {Isolate} The current isolate layer
614
- */
615
- function useIsolate() {
616
- return context.useX().isolate;
617
- }
618
439
  /**
619
440
  * @returns {boolean} Whether or not the current isolate allows tests to be reordered
620
441
  */
621
442
  function shouldAllowReorder() {
622
443
  return useIsolate().type === IsolateTypes.EACH;
623
444
  }
624
- /**
625
- * @returns {number[]} The current cursor path of the isolate tree
626
- */
627
- function useCurrentPath() {
628
- var isolate = useIsolate();
629
- return isolate.path.concat(isolate.cursor.current());
630
- }
631
- /**
632
- * @returns {IsolateCursor} The cursor object for the current isolate
633
- */
634
- function useCursor() {
635
- return useIsolate().cursor;
636
- }
637
445
 
638
446
  var Severity;
639
447
  (function (Severity) {
@@ -651,27 +459,6 @@ function countKeyBySeverity(severity) {
651
459
  : SeverityCount.WARN_COUNT;
652
460
  }
653
461
 
654
- /**
655
- * A safe hasOwnProperty access
656
- */
657
- function hasOwnProperty(obj, key) {
658
- return Object.prototype.hasOwnProperty.call(obj, key);
659
- }
660
-
661
- function isEmpty(value) {
662
- if (!value) {
663
- return true;
664
- }
665
- else if (hasOwnProperty(value, 'length')) {
666
- return lengthEquals(value, 0);
667
- }
668
- else if (typeof value === 'object') {
669
- return lengthEquals(Object.keys(value), 0);
670
- }
671
- return false;
672
- }
673
- var isNotEmpty = bindNot(isEmpty);
674
-
675
462
  function nonMatchingFieldName(testObject, fieldName) {
676
463
  return !!fieldName && !matchingFieldName(testObject, fieldName);
677
464
  }
@@ -679,20 +466,16 @@ function matchingFieldName(testObject, fieldName) {
679
466
  return !!(fieldName && testObject.fieldName === fieldName);
680
467
  }
681
468
 
682
- var nonMatchingGroupName = bindNot(matchingGroupName);
469
+ var nonMatchingGroupName = vestUtils.bindNot(matchingGroupName);
683
470
  function matchingGroupName(testObject, groupName) {
684
471
  return testObject.groupName === groupName;
685
472
  }
686
473
 
687
- function either(a, b) {
688
- return !!a !== !!b;
689
- }
690
-
691
474
  /**
692
475
  * Checks that a given test object matches the currently specified severity level
693
476
  */
694
477
  function nonMatchingSeverityProfile(severity, testObject) {
695
- return either(severity === Severity.WARNINGS, testObject.warns());
478
+ return vestUtils.either(severity === Severity.WARNINGS, testObject.warns());
696
479
  }
697
480
 
698
481
  /**
@@ -742,7 +525,7 @@ function shouldAddValidProperty(fieldName) {
742
525
  return false;
743
526
  }
744
527
  var testObjects = useTestsFlat();
745
- if (isEmpty(testObjects)) {
528
+ if (vestUtils.isEmpty(testObjects)) {
746
529
  return false;
747
530
  }
748
531
  // Does the given field have any pending tests that are not optional?
@@ -772,13 +555,13 @@ function fieldIsOmitted(fieldName) {
772
555
  }
773
556
  // Does the given field have any pending tests that are not optional?
774
557
  function hasNonOptionalIncomplete(fieldName) {
775
- return isNotEmpty(useAllIncomplete().filter(function (testObject) {
558
+ return vestUtils.isNotEmpty(useAllIncomplete().filter(function (testObject) {
776
559
  return isOptionalFieldIncomplete(testObject, fieldName);
777
560
  }));
778
561
  }
779
562
  // Do the given group/field have any pending tests that are not optional?
780
563
  function hasNonOptionalIncompleteByGroup(groupName, fieldName) {
781
- return isNotEmpty(useAllIncomplete().filter(function (testObject) {
564
+ return vestUtils.isNotEmpty(useAllIncomplete().filter(function (testObject) {
782
565
  if (nonMatchingGroupName(testObject, groupName)) {
783
566
  return false;
784
567
  }
@@ -818,17 +601,12 @@ function missingTestsLogic(testObject, fieldName) {
818
601
  testObject.isOmitted());
819
602
  }
820
603
 
821
- function useSummary() {
822
- var summary = context.useX().summary;
823
- invariant(summary);
824
- return summary;
825
- }
826
604
  /**
827
605
  * Reads the testObjects list and gets full validation result from it.
828
606
  */
829
607
  function genTestsSummary() {
830
608
  var testObjects = useTestsFlat();
831
- var summary = assign(baseStats(), {
609
+ var summary = vestUtils.assign(baseStats(), {
832
610
  groups: {},
833
611
  tests: {},
834
612
  valid: false
@@ -905,16 +683,12 @@ function baseStats() {
905
683
  };
906
684
  }
907
685
  function baseTestStats() {
908
- return assign(baseStats(), {
686
+ return vestUtils.assign(baseStats(), {
909
687
  errors: [],
910
688
  warnings: []
911
689
  });
912
690
  }
913
691
 
914
- function isPositive(value) {
915
- return greaterThan(value, 0);
916
- }
917
-
918
692
  // calls collectAll or getByFieldName depending on whether fieldName is provided
919
693
  function gatherFailures(testGroup, severityKey, fieldName) {
920
694
  return fieldName
@@ -929,7 +703,7 @@ function collectAll(testGroup, severityKey) {
929
703
  var output = {};
930
704
  var countKey = countKeyBySeverity(severityKey);
931
705
  for (var field in testGroup) {
932
- if (isPositive(testGroup[field][countKey])) {
706
+ if (vestUtils.isPositive(testGroup[field][countKey])) {
933
707
  // We will probably never get to the fallback array
934
708
  // leaving it just in case the implementation changes
935
709
  output[field] = testGroup[field][severityKey] || [];
@@ -938,118 +712,117 @@ function collectAll(testGroup, severityKey) {
938
712
  return output;
939
713
  }
940
714
 
941
- function getErrors(fieldName) {
942
- return getFailures(Severity.ERRORS, fieldName);
943
- }
944
- function getWarnings(fieldName) {
945
- return getFailures(Severity.WARNINGS, fieldName);
715
+ // eslint-disable-next-line max-lines-per-function, max-statements
716
+ function suiteSelectors(summary) {
717
+ var selectors = {
718
+ getErrors: getErrors,
719
+ getErrorsByGroup: getErrorsByGroup,
720
+ getWarnings: getWarnings,
721
+ getWarningsByGroup: getWarningsByGroup,
722
+ hasErrors: hasErrors,
723
+ hasErrorsByGroup: hasErrorsByGroup,
724
+ hasWarnings: hasWarnings,
725
+ hasWarningsByGroup: hasWarningsByGroup,
726
+ isValid: isValid,
727
+ isValidByGroup: isValidByGroup
728
+ };
729
+ return selectors;
730
+ // Booleans
731
+ function isValid(fieldName) {
732
+ var _a;
733
+ return fieldName ? Boolean((_a = summary.tests[fieldName]) === null || _a === void 0 ? void 0 : _a.valid) : summary.valid;
734
+ }
735
+ function isValidByGroup(groupName, fieldName) {
736
+ var group = summary.groups[groupName];
737
+ if (!group) {
738
+ return false;
739
+ }
740
+ if (fieldName) {
741
+ return isFieldValid(group, fieldName);
742
+ }
743
+ for (var fieldName_1 in group) {
744
+ if (!isFieldValid(group, fieldName_1)) {
745
+ return false;
746
+ }
747
+ }
748
+ return true;
749
+ }
750
+ function hasWarnings(fieldName) {
751
+ return hasFailures(summary, SeverityCount.WARN_COUNT, fieldName);
752
+ }
753
+ function hasErrors(fieldName) {
754
+ return hasFailures(summary, SeverityCount.ERROR_COUNT, fieldName);
755
+ }
756
+ function hasWarningsByGroup(groupName, fieldName) {
757
+ return hasFailuresByGroup(summary, SeverityCount.WARN_COUNT, groupName, fieldName);
758
+ }
759
+ function hasErrorsByGroup(groupName, fieldName) {
760
+ return hasFailuresByGroup(summary, SeverityCount.ERROR_COUNT, groupName, fieldName);
761
+ }
762
+ function getWarnings(fieldName) {
763
+ return getFailures(summary, Severity.WARNINGS, fieldName);
764
+ }
765
+ function getErrors(fieldName) {
766
+ return getFailures(summary, Severity.ERRORS, fieldName);
767
+ }
768
+ function getErrorsByGroup(groupName, fieldName) {
769
+ return getFailuresByGroup(summary, Severity.ERRORS, groupName, fieldName);
770
+ }
771
+ function getWarningsByGroup(groupName, fieldName) {
772
+ return getFailuresByGroup(summary, Severity.WARNINGS, groupName, fieldName);
773
+ }
946
774
  }
947
- /**
948
- * @returns suite or field's errors or warnings.
949
- */
950
- function getFailures(severityKey, fieldName) {
951
- var summary = useSummary();
775
+ // Gathers all failures of a given severity
776
+ // With a fieldName, it will only gather failures for that field
777
+ function getFailures(summary, severityKey, fieldName) {
952
778
  return gatherFailures(summary.tests, severityKey, fieldName);
953
779
  }
954
-
955
- function getErrorsByGroup(groupName, fieldName) {
956
- return getFailuresByGroup(groupName, Severity.ERRORS, fieldName);
957
- }
958
- function getWarningsByGroup(groupName, fieldName) {
959
- return getFailuresByGroup(groupName, Severity.WARNINGS, fieldName);
960
- }
961
- function getFailuresByGroup(groupName, severityKey, fieldName) {
962
- var summary = useSummary();
780
+ // Gathers all failures of a given severity within a group
781
+ // With a fieldName, it will only gather failures for that field
782
+ function getFailuresByGroup(summary, severityKey, groupName, fieldName) {
963
783
  return gatherFailures(summary.groups[groupName], severityKey, fieldName);
964
784
  }
965
-
966
- function hasErrors(fieldName) {
967
- return hasFailures(SeverityCount.ERROR_COUNT, fieldName);
968
- }
969
- function hasWarnings(fieldName) {
970
- return hasFailures(SeverityCount.WARN_COUNT, fieldName);
971
- }
972
- function hasFailures(severityCount, fieldName) {
785
+ // Checks if a field is valid within a container object - can be within a group or top level
786
+ function isFieldValid(testContainer, fieldName) {
973
787
  var _a;
974
- var summary = useSummary();
975
- if (fieldName) {
976
- return isPositive((_a = summary.tests[fieldName]) === null || _a === void 0 ? void 0 : _a[severityCount]);
977
- }
978
- return isPositive(summary[severityCount]);
979
- }
980
-
981
- function hasErrorsByGroup(groupName, fieldName) {
982
- return hasFailuresByGroup(Severity.ERRORS, groupName, fieldName);
983
- }
984
- function hasWarningsByGroup(groupName, fieldName) {
985
- return hasFailuresByGroup(Severity.WARNINGS, groupName, fieldName);
788
+ return !!((_a = testContainer[fieldName]) === null || _a === void 0 ? void 0 : _a.valid);
986
789
  }
987
- // eslint-disable-next-line max-statements
988
- function hasFailuresByGroup(severityKey, groupName, fieldName) {
790
+ // Checks if a there are any failures of a given severity within a group
791
+ // If a fieldName is provided, it will only check for failures within that field
792
+ function hasFailuresByGroup(summary, severityCount, groupName, fieldName) {
989
793
  var _a, _b;
990
- var summary = useSummary();
991
- var severityCount = countKeyBySeverity(severityKey);
992
794
  var group = summary.groups[groupName];
993
795
  if (!group) {
994
796
  return false;
995
797
  }
996
798
  if (fieldName) {
997
- return isPositive((_a = group[fieldName]) === null || _a === void 0 ? void 0 : _a[severityCount]);
799
+ return vestUtils.isPositive((_a = group[fieldName]) === null || _a === void 0 ? void 0 : _a[severityCount]);
998
800
  }
999
801
  for (var field in group) {
1000
- if (isPositive((_b = group[field]) === null || _b === void 0 ? void 0 : _b[severityCount])) {
802
+ if (vestUtils.isPositive((_b = group[field]) === null || _b === void 0 ? void 0 : _b[severityCount])) {
1001
803
  return true;
1002
804
  }
1003
805
  }
1004
806
  return false;
1005
807
  }
1006
-
1007
- function isValid(fieldName) {
1008
- var summary = useSummary();
1009
- return fieldName
1010
- ? Boolean(isFieldValid(summary.tests, fieldName))
1011
- : summary.valid;
1012
- }
1013
- function isValidByGroup(groupName, fieldName) {
1014
- var summary = useSummary();
1015
- var group = summary.groups[groupName];
1016
- if (!group) {
1017
- return false;
1018
- }
1019
- if (fieldName) {
1020
- return isFieldValid(group, fieldName);
1021
- }
1022
- for (var fieldName_1 in group) {
1023
- if (!isFieldValid(group, fieldName_1)) {
1024
- return false;
1025
- }
1026
- }
1027
- return true;
1028
- }
1029
- function isFieldValid(testContainer, fieldName) {
808
+ // Checks if there are any failures of a given severity
809
+ // If a fieldName is provided, it will only check for failures within that field
810
+ function hasFailures(summary, countKey, fieldName) {
1030
811
  var _a;
1031
- return !!((_a = testContainer[fieldName]) === null || _a === void 0 ? void 0 : _a.valid);
812
+ var failureCount = fieldName
813
+ ? (_a = summary.tests[fieldName]) === null || _a === void 0 ? void 0 : _a[countKey]
814
+ : summary[countKey] || 0;
815
+ return vestUtils.isPositive(failureCount);
1032
816
  }
1033
817
 
1034
- var cache$1 = createCache(1);
818
+ var cache$1 = vestUtils.cache(1);
1035
819
  function produceSuiteResult() {
1036
820
  var testObjects = useTestsFlat();
1037
821
  var ctxRef = { stateRef: useStateRef() };
1038
822
  return cache$1([testObjects], context.bind(ctxRef, function () {
1039
823
  var summary = genTestsSummary();
1040
824
  var suiteName = useSuiteName();
1041
- var ref = { summary: summary };
1042
- return assign(summary, {
1043
- getErrors: context.bind(ref, getErrors),
1044
- getErrorsByGroup: context.bind(ref, getErrorsByGroup),
1045
- getWarnings: context.bind(ref, getWarnings),
1046
- getWarningsByGroup: context.bind(ref, getWarningsByGroup),
1047
- hasErrors: context.bind(ref, hasErrors),
1048
- hasErrorsByGroup: context.bind(ref, hasErrorsByGroup),
1049
- hasWarnings: context.bind(ref, hasWarnings),
1050
- hasWarningsByGroup: context.bind(ref, hasWarningsByGroup),
1051
- isValid: context.bind(ref, isValid),
1052
- isValidByGroup: context.bind(ref, isValidByGroup),
825
+ return vestUtils.assign(summary, suiteSelectors(summary), {
1053
826
  suiteName: suiteName
1054
827
  });
1055
828
  }));
@@ -1060,7 +833,7 @@ function produceSuiteResult() {
1060
833
  */
1061
834
  function hasRemainingTests(fieldName) {
1062
835
  var allIncomplete = useAllIncomplete();
1063
- if (isEmpty(allIncomplete)) {
836
+ if (vestUtils.isEmpty(allIncomplete)) {
1064
837
  return false;
1065
838
  }
1066
839
  if (fieldName) {
@@ -1068,15 +841,15 @@ function hasRemainingTests(fieldName) {
1068
841
  return matchingFieldName(testObject, fieldName);
1069
842
  });
1070
843
  }
1071
- return isNotEmpty(allIncomplete);
844
+ return true;
1072
845
  }
1073
846
 
1074
- var cache = createCache(20);
847
+ var cache = vestUtils.cache(20);
1075
848
  function produceFullResult() {
1076
849
  var testObjects = useTestsFlat();
1077
850
  var ctxRef = { stateRef: useStateRef() };
1078
851
  return cache([testObjects], context.bind(ctxRef, function () {
1079
- return assign({}, produceSuiteResult(), {
852
+ return vestUtils.assign({}, produceSuiteResult(), {
1080
853
  done: context.bind(ctxRef, done)
1081
854
  });
1082
855
  }));
@@ -1085,10 +858,10 @@ function produceFullResult() {
1085
858
  * DONE is here and not in its own module to prevent circular dependency issues.
1086
859
  */
1087
860
  function shouldSkipDoneRegistration(callback, fieldName, output) {
861
+ var _a;
1088
862
  // If we do not have any test runs for the current field
1089
- return !!(!isFunction(callback) ||
1090
- (fieldName &&
1091
- (!output.tests[fieldName] || isEmpty(output.tests[fieldName].testCount))));
863
+ return !!(!vestUtils.isFunction(callback) ||
864
+ (fieldName && vestUtils.numberEquals((_a = output.tests[fieldName]) === null || _a === void 0 ? void 0 : _a.testCount, 0)));
1092
865
  }
1093
866
  function shouldRunDoneCallback(fieldName) {
1094
867
  // is suite finished || field name exists, and test is finished;
@@ -1130,38 +903,16 @@ function deferDoneCallback(doneCallback, fieldName) {
1130
903
  });
1131
904
  }
1132
905
 
1133
- function createBus() {
1134
- var listeners = {};
1135
- return {
1136
- emit: function (event, data) {
1137
- listener(event).forEach(function (handler) {
1138
- handler(data);
1139
- });
1140
- },
1141
- on: function (event, handler) {
1142
- listeners[event] = listener(event).concat(handler);
1143
- return {
1144
- off: function () {
1145
- listeners[event] = listener(event).filter(function (h) { return h !== handler; });
1146
- }
1147
- };
1148
- }
1149
- };
1150
- function listener(event) {
1151
- return listeners[event] || [];
1152
- }
1153
- }
1154
-
1155
906
  function omitOptionalFields() {
1156
907
  var optionalFields = useOptionalFields()[0];
1157
- if (isEmpty(optionalFields)) {
908
+ if (vestUtils.isEmpty(optionalFields)) {
1158
909
  return;
1159
910
  }
1160
911
  var shouldOmit = {};
1161
912
  useSetTests(function (tests) {
1162
- return transform(tests, function (testObject) {
913
+ return vestUtils.nestedArray.transform(tests, function (testObject) {
1163
914
  var fieldName = testObject.fieldName;
1164
- if (hasOwnProperty(shouldOmit, fieldName)) {
915
+ if (vestUtils.hasOwnProperty(shouldOmit, fieldName)) {
1165
916
  verifyAndOmit(testObject);
1166
917
  }
1167
918
  else {
@@ -1178,7 +929,7 @@ function omitOptionalFields() {
1178
929
  }
1179
930
  function runOptionalConfig(testObject) {
1180
931
  var optionalConfig = useOptionalFieldConfig(testObject.fieldName);
1181
- if (isFunction(optionalConfig)) {
932
+ if (vestUtils.isFunction(optionalConfig)) {
1182
933
  shouldOmit[testObject.fieldName] = optionalConfig();
1183
934
  verifyAndOmit(testObject);
1184
935
  }
@@ -1190,14 +941,10 @@ function omitOptionalFields() {
1190
941
  */
1191
942
  function removeTestFromState (testObject) {
1192
943
  useSetTests(function (tests) {
1193
- return transform(tests, function (test) { return (testObject !== test ? test : null); });
944
+ return vestUtils.nestedArray.transform(tests, function (test) { return (testObject !== test ? test : null); });
1194
945
  });
1195
946
  }
1196
947
 
1197
- function callEach(arr) {
1198
- return arr.forEach(function (fn) { return fn(); });
1199
- }
1200
-
1201
948
  /**
1202
949
  * Runs done callback per field when async tests are finished running.
1203
950
  */
@@ -1205,8 +952,8 @@ function runFieldCallbacks(fieldName) {
1205
952
  var fieldCallbacks = useTestCallbacks()[0].fieldCallbacks;
1206
953
  if (fieldName &&
1207
954
  !hasRemainingTests(fieldName) &&
1208
- isArray(fieldCallbacks[fieldName])) {
1209
- callEach(fieldCallbacks[fieldName]);
955
+ vestUtils.isArray(fieldCallbacks[fieldName])) {
956
+ vestUtils.callEach(fieldCallbacks[fieldName]);
1210
957
  }
1211
958
  }
1212
959
  /**
@@ -1214,15 +961,15 @@ function runFieldCallbacks(fieldName) {
1214
961
  */
1215
962
  function runDoneCallbacks() {
1216
963
  var doneCallbacks = useTestCallbacks()[0].doneCallbacks;
1217
- callEach(doneCallbacks);
964
+ vestUtils.callEach(doneCallbacks);
1218
965
  }
1219
966
 
1220
967
  // eslint-disable-next-line max-lines-per-function
1221
968
  function initBus() {
1222
- var bus = createBus();
969
+ var vestBus = vestUtils.bus.createBus();
1223
970
  // Report a the completion of a test. There may be other tests with the same
1224
971
  // name that are still running, or not yet started.
1225
- bus.on(Events.TEST_COMPLETED, function (testObject) {
972
+ vestBus.on(Events.TEST_COMPLETED, function (testObject) {
1226
973
  if (testObject.isCanceled()) {
1227
974
  return;
1228
975
  }
@@ -1230,21 +977,21 @@ function initBus() {
1230
977
  runFieldCallbacks(testObject.fieldName);
1231
978
  if (!hasRemainingTests()) {
1232
979
  // When no more tests are running, emit the done event
1233
- bus.emit(Events.ALL_RUNNING_TESTS_FINISHED);
980
+ vestBus.emit(Events.ALL_RUNNING_TESTS_FINISHED);
1234
981
  }
1235
982
  });
1236
983
  // Report that the suite completed its synchronous test run.
1237
984
  // Async operations may still be running.
1238
- bus.on(Events.SUITE_CALLBACK_DONE_RUNNING, function () {
985
+ vestBus.on(Events.SUITE_CALLBACK_DONE_RUNNING, function () {
1239
986
  // Remove tests that are optional and need to be omitted
1240
987
  omitOptionalFields();
1241
988
  });
1242
989
  // Called when all the tests, including async, are done running
1243
- bus.on(Events.ALL_RUNNING_TESTS_FINISHED, function () {
990
+ vestBus.on(Events.ALL_RUNNING_TESTS_FINISHED, function () {
1244
991
  runDoneCallbacks();
1245
992
  });
1246
993
  // Removes a certain field from the state.
1247
- bus.on(Events.REMOVE_FIELD, function (fieldName) {
994
+ vestBus.on(Events.REMOVE_FIELD, function (fieldName) {
1248
995
  useEachTestObject(function (testObject) {
1249
996
  if (matchingFieldName(testObject, fieldName)) {
1250
997
  testObject.cancel();
@@ -1253,18 +1000,18 @@ function initBus() {
1253
1000
  });
1254
1001
  });
1255
1002
  // Resets a certain field in the state.
1256
- bus.on(Events.RESET_FIELD, function (fieldName) {
1003
+ vestBus.on(Events.RESET_FIELD, function (fieldName) {
1257
1004
  useEachTestObject(function (testObject) {
1258
1005
  if (matchingFieldName(testObject, fieldName)) {
1259
1006
  testObject.reset();
1260
1007
  }
1261
1008
  });
1262
1009
  });
1263
- return bus;
1010
+ return vestBus;
1264
1011
  }
1265
1012
  function useBus() {
1266
1013
  var context$1 = context.useX();
1267
- invariant(context$1.bus);
1014
+ vestUtils.invariant(context$1.bus);
1268
1015
  return context$1.bus;
1269
1016
  }
1270
1017
  var Events;
@@ -1283,16 +1030,16 @@ function create() {
1283
1030
  args[_i] = arguments[_i];
1284
1031
  }
1285
1032
  var _a = args.reverse(), suiteCallback = _a[0], suiteName = _a[1];
1286
- invariant(isFunction(suiteCallback), 'vest.create: Expected callback to be a function.');
1033
+ vestUtils.invariant(vestUtils.isFunction(suiteCallback), 'vest.create: Expected callback to be a function.');
1287
1034
  // Event bus initialization
1288
1035
  var bus = initBus();
1289
1036
  // State initialization
1290
1037
  var state = createState();
1291
1038
  // State reference - this holds the actual state values
1292
- var stateRef = createStateRef(state, { suiteId: genId(), suiteName: suiteName });
1039
+ var stateRef = createStateRef(state, { suiteId: vestUtils.seq(), suiteName: suiteName });
1293
1040
  // Create base context reference. All hooks will derive their data from this
1294
1041
  var ctxRef = { stateRef: stateRef, bus: bus };
1295
- var suite = assign(
1042
+ var suite = vestUtils.assign(
1296
1043
  // Bind the suite body to the context
1297
1044
  context.bind(ctxRef, function () {
1298
1045
  var args = [];
@@ -1338,7 +1085,7 @@ function create() {
1338
1085
  * })
1339
1086
  */
1340
1087
  function each(list, callback) {
1341
- invariant(isFunction(callback), 'each callback must be a function');
1088
+ vestUtils.invariant(vestUtils.isFunction(callback), 'each callback must be a function');
1342
1089
  isolate({ type: IsolateTypes.EACH }, function () {
1343
1090
  list.forEach(function (arg, index) {
1344
1091
  callback(arg, index);
@@ -1368,7 +1115,7 @@ function skipWhen(conditional, callback) {
1368
1115
  // we should skip the test if the parent conditional is true.
1369
1116
  isExcludedIndividually() ||
1370
1117
  // Otherwise, we should skip the test if the conditional is true.
1371
- optionalFunctionValue(conditional, optionalFunctionValue(produceSuiteResult))
1118
+ vestUtils.optionalFunctionValue(conditional, vestUtils.optionalFunctionValue(produceSuiteResult))
1372
1119
  }, function () { return callback(); });
1373
1120
  });
1374
1121
  }
@@ -1384,10 +1131,10 @@ function isExcludedIndividually() {
1384
1131
  * only('username');
1385
1132
  */
1386
1133
  function only(item) {
1387
- return addTo(0 /* ONLY */, 'tests', item);
1134
+ return addTo(0 /* ExclusionGroup.ONLY */, 'tests', item);
1388
1135
  }
1389
1136
  only.group = function (item) {
1390
- return addTo(0 /* ONLY */, 'groups', item);
1137
+ return addTo(0 /* ExclusionGroup.ONLY */, 'groups', item);
1391
1138
  };
1392
1139
  /**
1393
1140
  * Adds a field or a list of fields into the exclusion list
@@ -1397,13 +1144,13 @@ only.group = function (item) {
1397
1144
  * skip('username');
1398
1145
  */
1399
1146
  function skip(item) {
1400
- return addTo(1 /* SKIP */, 'tests', item);
1147
+ return addTo(1 /* ExclusionGroup.SKIP */, 'tests', item);
1401
1148
  }
1402
1149
  skip.group = function (item) {
1403
- return addTo(1 /* SKIP */, 'groups', item);
1150
+ return addTo(1 /* ExclusionGroup.SKIP */, 'groups', item);
1404
1151
  };
1405
1152
  //Checks whether a certain test profile excluded by any of the exclusion groups.
1406
- // eslint-disable-next-line complexity, max-statements, max-lines-per-function
1153
+ // eslint-disable-next-line complexity, max-statements
1407
1154
  function isExcluded(testObject) {
1408
1155
  var fieldName = testObject.fieldName, groupName = testObject.groupName;
1409
1156
  if (isExcludedIndividually())
@@ -1444,7 +1191,7 @@ function isExcluded(testObject) {
1444
1191
  // Check if inclusion rules for this field (`include` hook)
1445
1192
  // TODO: Check if this may need to be moved outside of the condition.
1446
1193
  // What if there are no included tests? This shouldn't run then?
1447
- return !optionalFunctionValue(inclusion[fieldName]);
1194
+ return !vestUtils.optionalFunctionValue(inclusion[fieldName]);
1448
1195
  }
1449
1196
  // We're done here. This field is not excluded
1450
1197
  return false;
@@ -1456,7 +1203,7 @@ function isGroupExcluded(groupName) {
1456
1203
  var context$1 = context.useX();
1457
1204
  var exclusion = context$1.exclusion;
1458
1205
  var keyGroups = exclusion.groups;
1459
- var groupPresent = hasOwnProperty(keyGroups, groupName);
1206
+ var groupPresent = vestUtils.hasOwnProperty(keyGroups, groupName);
1460
1207
  // When group is either only'ed or skipped
1461
1208
  if (groupPresent) {
1462
1209
  // Return true if group is skipped and false if only'ed
@@ -1474,12 +1221,12 @@ function addTo(exclusionGroup, itemType, item) {
1474
1221
  if (!item) {
1475
1222
  return;
1476
1223
  }
1477
- asArray(item).forEach(function (itemName) {
1478
- if (!isStringValue(itemName)) {
1224
+ vestUtils.asArray(item).forEach(function (itemName) {
1225
+ if (!vestUtils.isStringValue(itemName)) {
1479
1226
  return;
1480
1227
  }
1481
1228
  context$1.exclusion[itemType][itemName] =
1482
- exclusionGroup === 0 /* ONLY */;
1229
+ exclusionGroup === 0 /* ExclusionGroup.ONLY */;
1483
1230
  });
1484
1231
  }
1485
1232
  /**
@@ -1522,8 +1269,8 @@ function hasIncludedGroups() {
1522
1269
  * });
1523
1270
  */
1524
1271
  function group(groupName, tests) {
1525
- invariant(isStringValue(groupName), groupErrorMsg('name must be a string'));
1526
- invariant(isFunction(tests), groupErrorMsg('callback must be a function'));
1272
+ vestUtils.invariant(vestUtils.isStringValue(groupName), groupErrorMsg('name must be a string'));
1273
+ vestUtils.invariant(vestUtils.isFunction(tests), groupErrorMsg('callback must be a function'));
1527
1274
  // Running with the context applied
1528
1275
  isolate({ type: IsolateTypes.GROUP }, function () {
1529
1276
  context.run({ groupName: groupName }, tests);
@@ -1536,24 +1283,24 @@ function groupErrorMsg(error) {
1536
1283
  function include(fieldName) {
1537
1284
  var context$1 = context.useX();
1538
1285
  var inclusion = context$1.inclusion, exclusion = context$1.exclusion;
1539
- invariant(isStringValue(fieldName));
1540
- inclusion[fieldName] = defaultTo(exclusion.tests[fieldName], true);
1286
+ vestUtils.invariant(vestUtils.isStringValue(fieldName));
1287
+ inclusion[fieldName] = vestUtils.defaultTo(exclusion.tests[fieldName], true);
1541
1288
  return { when: when };
1542
1289
  function when(condition) {
1543
1290
  var context$1 = context.useX();
1544
1291
  var inclusion = context$1.inclusion, exclusion = context$1.exclusion;
1545
1292
  // This callback will run as part of the "isExcluded" series of checks
1546
1293
  inclusion[fieldName] = function () {
1547
- if (hasOwnProperty(exclusion.tests, fieldName)) {
1294
+ if (vestUtils.hasOwnProperty(exclusion.tests, fieldName)) {
1548
1295
  // I suspect this code is technically unreachable because
1549
1296
  // if there are any skip/only rules applied to the current
1550
1297
  // field, the "isExcluded" function will have already bailed
1551
- return defaultTo(exclusion.tests[fieldName], true);
1298
+ return vestUtils.defaultTo(exclusion.tests[fieldName], true);
1552
1299
  }
1553
- if (isStringValue(condition)) {
1300
+ if (vestUtils.isStringValue(condition)) {
1554
1301
  return Boolean(exclusion.tests[condition]);
1555
1302
  }
1556
- return optionalFunctionValue(condition, optionalFunctionValue(produceSuiteResult));
1303
+ return vestUtils.optionalFunctionValue(condition, vestUtils.optionalFunctionValue(produceSuiteResult));
1557
1304
  };
1558
1305
  }
1559
1306
  }
@@ -1608,7 +1355,7 @@ function omitWhen(conditional, callback) {
1608
1355
  isolate({ type: IsolateTypes.OMIT_WHEN }, function () {
1609
1356
  context.run({
1610
1357
  omitted: isOmitted() ||
1611
- optionalFunctionValue(conditional, optionalFunctionValue(produceSuiteResult))
1358
+ vestUtils.optionalFunctionValue(conditional, vestUtils.optionalFunctionValue(produceSuiteResult))
1612
1359
  }, function () { return callback(); });
1613
1360
  });
1614
1361
  }
@@ -1630,8 +1377,8 @@ function isOmitted() {
1630
1377
  function optional(optionals) {
1631
1378
  // When the optional is given as a string or a list of strings
1632
1379
  // we just add them to the list of optional fields.
1633
- if (isArray(optionals) || isStringValue(optionals)) {
1634
- asArray(optionals).forEach(function (optionalField) {
1380
+ if (vestUtils.isArray(optionals) || vestUtils.isStringValue(optionals)) {
1381
+ vestUtils.asArray(optionals).forEach(function (optionalField) {
1635
1382
  useSetOptionalField(optionalField, [true, false]);
1636
1383
  });
1637
1384
  }
@@ -1670,9 +1417,7 @@ function __spreadArray(to, from, pack) {
1670
1417
  return to.concat(ar || Array.prototype.slice.call(from));
1671
1418
  }
1672
1419
 
1673
- function isPromise(value) {
1674
- return value && isFunction(value.then);
1675
- }
1420
+ vestUtils.bindNot(vestUtils.isStringValue);
1676
1421
 
1677
1422
  function isSameProfileTest(testObject1, testObject2) {
1678
1423
  return (testObject1.fieldName === testObject2.fieldName &&
@@ -1692,7 +1437,7 @@ function cancelOverriddenPendingTest(prevRunTestObject, currentRunTestObject) {
1692
1437
  */
1693
1438
  function runAsyncTest(testObject) {
1694
1439
  var asyncTest = testObject.asyncTest, message = testObject.message;
1695
- if (!isPromise(asyncTest))
1440
+ if (!vestUtils.isPromise(asyncTest))
1696
1441
  return;
1697
1442
  var emit = useBus().emit;
1698
1443
  var stateRef = useStateRef();
@@ -1705,7 +1450,7 @@ function runAsyncTest(testObject) {
1705
1450
  if (testObject.isCanceled()) {
1706
1451
  return;
1707
1452
  }
1708
- testObject.message = isStringValue(rejectionMessage)
1453
+ testObject.message = vestUtils.isStringValue(rejectionMessage)
1709
1454
  ? rejectionMessage
1710
1455
  : message;
1711
1456
  testObject.fail();
@@ -1740,7 +1485,7 @@ function registerTest(testObject) {
1740
1485
  try {
1741
1486
  // try catch for safe property access
1742
1487
  // in case object is an enforce chain
1743
- if (isPromise(result)) {
1488
+ if (vestUtils.isPromise(result)) {
1744
1489
  testObject.asyncTest = result;
1745
1490
  testObject.setPending();
1746
1491
  runAsyncTest(testObject);
@@ -1767,12 +1512,12 @@ function registerTest(testObject) {
1767
1512
  function useTestAtCursor(newTestObject) {
1768
1513
  var testObjects = useTestObjects()[0];
1769
1514
  var prevTests = testObjects.prev;
1770
- if (isEmpty(prevTests)) {
1515
+ if (vestUtils.isEmpty(prevTests)) {
1771
1516
  useSetTestAtCursor(newTestObject);
1772
1517
  return newTestObject;
1773
1518
  }
1774
1519
  var prevTest = useGetTestAtCursor(prevTests);
1775
- if (!isNullish(newTestObject.key)) {
1520
+ if (!vestUtils.isNullish(newTestObject.key)) {
1776
1521
  var nextTest_1 = handleKeyTest(newTestObject.key, newTestObject);
1777
1522
  useSetTestAtCursor(nextTest_1);
1778
1523
  return nextTest_1;
@@ -1783,7 +1528,7 @@ function useTestAtCursor(newTestObject) {
1783
1528
  // Need to see if this has any effect at all.
1784
1529
  prevTest = null;
1785
1530
  }
1786
- var nextTest = defaultTo(prevTest, newTestObject);
1531
+ var nextTest = vestUtils.defaultTo(prevTest, newTestObject);
1787
1532
  useSetTestAtCursor(nextTest);
1788
1533
  return nextTest;
1789
1534
  }
@@ -1800,21 +1545,21 @@ function removeAllNextTestsInIsolate() {
1800
1545
  function useSetTestAtCursor(testObject) {
1801
1546
  var cursorPath = useCurrentPath();
1802
1547
  useSetTests(function (tests) {
1803
- return setValueAtPath(tests, cursorPath, testObject);
1548
+ return vestUtils.nestedArray.setValueAtPath(tests, cursorPath, testObject);
1804
1549
  });
1805
1550
  }
1806
1551
  function useGetTestAtCursor(tests) {
1807
1552
  var cursorPath = useCurrentPath();
1808
- return valueAtPath(tests, cursorPath);
1553
+ return vestUtils.nestedArray.valueAtPath(tests, cursorPath);
1809
1554
  }
1810
1555
  function testReorderDetected(prevTest, newTest) {
1811
- return isNotEmpty(prevTest) && !isSameProfileTest(prevTest, newTest);
1556
+ return vestUtils.isNotEmpty(prevTest) && !isSameProfileTest(prevTest, newTest);
1812
1557
  }
1813
1558
  function throwTestOrderError(prevTest, newTestObject) {
1814
1559
  if (shouldAllowReorder()) {
1815
1560
  return;
1816
1561
  }
1817
- 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."));
1562
+ 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."));
1818
1563
  }
1819
1564
  function handleKeyTest(key, newTestObject) {
1820
1565
  var prevTestByKey = usePrevTestByKey(key);
@@ -1860,16 +1605,15 @@ function registerTestObjectByTier(testObject) {
1860
1605
  if (testObject.isUntested()) {
1861
1606
  registerTest(testObject);
1862
1607
  }
1863
- else if (isPromise(testObject.asyncTest)) {
1608
+ else if (vestUtils.isPromise(testObject.asyncTest)) {
1864
1609
  testObject.setPending();
1865
1610
  runAsyncTest(testObject);
1866
1611
  }
1867
1612
  }
1868
1613
 
1869
1614
  /* eslint-disable jest/valid-title */
1870
- // eslint-disable-next-line max-lines-per-function
1871
1615
  function bindTestMemo(test) {
1872
- var cache = createCache(10); // arbitrary cache size
1616
+ var cache = vestUtils.cache(10); // arbitrary cache size
1873
1617
  // eslint-disable-next-line max-statements
1874
1618
  function memo(fieldName) {
1875
1619
  var args = [];
@@ -1881,7 +1625,7 @@ function bindTestMemo(test) {
1881
1625
  // Implicit dependency for more specificity
1882
1626
  var dependencies = [useSuiteId(), fieldName, cursorAt].concat(deps);
1883
1627
  var cached = cache.get(dependencies);
1884
- if (isNull(cached)) {
1628
+ if (vestUtils.isNull(cached)) {
1885
1629
  // cache miss
1886
1630
  return cache(dependencies, function () { return test(fieldName, msg, testFn); });
1887
1631
  }
@@ -1900,9 +1644,9 @@ function testBase(fieldName) {
1900
1644
  for (var _i = 1; _i < arguments.length; _i++) {
1901
1645
  args[_i - 1] = arguments[_i];
1902
1646
  }
1903
- var _a = (isFunction(args[1]) ? args : __spreadArray([undefined], args, true)), message = _a[0], testFn = _a[1], key = _a[2];
1904
- invariant(isStringValue(fieldName), incompatibleParamsError('fieldName', 'string'));
1905
- invariant(isFunction(testFn), incompatibleParamsError('Test callback', 'function'));
1647
+ var _a = (vestUtils.isFunction(args[1]) ? args : __spreadArray([undefined], args, true)), message = _a[0], testFn = _a[1], key = _a[2];
1648
+ vestUtils.invariant(vestUtils.isStringValue(fieldName), incompatibleParamsError('fieldName', 'string'));
1649
+ vestUtils.invariant(vestUtils.isFunction(testFn), incompatibleParamsError('Test callback', 'function'));
1906
1650
  var context$1 = context.useX();
1907
1651
  var testObject = new VestTest(fieldName, testFn, {
1908
1652
  message: message,
@@ -1920,7 +1664,7 @@ function testBase(fieldName) {
1920
1664
  * enforce(data.username).isNotBlank();
1921
1665
  * });
1922
1666
  */
1923
- var test = assign(testBase, {
1667
+ var test = vestUtils.assign(testBase, {
1924
1668
  memo: bindTestMemo(testBase)
1925
1669
  });
1926
1670
  function incompatibleParamsError(name, expected) {
@@ -1934,11 +1678,11 @@ var ERROR_OUTSIDE_OF_TEST = "warn hook called outside of a test callback. It won
1934
1678
  */
1935
1679
  function warn() {
1936
1680
  var ctx = context.useX('warn ' + ERROR_HOOK_CALLED_OUTSIDE);
1937
- invariant(ctx.currentTest, ERROR_OUTSIDE_OF_TEST);
1681
+ vestUtils.invariant(ctx.currentTest, ERROR_OUTSIDE_OF_TEST);
1938
1682
  ctx.currentTest.warn();
1939
1683
  }
1940
1684
 
1941
- var VERSION = "4.4.2";
1685
+ var VERSION = "4.5.0";
1942
1686
 
1943
1687
  Object.defineProperty(exports, 'enforce', {
1944
1688
  enumerable: true,
@@ -1958,5 +1702,6 @@ exports.only = only;
1958
1702
  exports.optional = optional;
1959
1703
  exports.skip = skip;
1960
1704
  exports.skipWhen = skipWhen;
1705
+ exports.suiteSelectors = suiteSelectors;
1961
1706
  exports.test = test;
1962
1707
  exports.warn = warn;