vest 4.2.3-dev-87ebfa → 4.3.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 (33) hide show
  1. package/dist/cjs/classnames.development.js +58 -23
  2. package/dist/cjs/classnames.production.js +1 -1
  3. package/dist/cjs/parser.development.js +84 -22
  4. package/dist/cjs/parser.production.js +1 -1
  5. package/dist/cjs/vest.development.js +447 -440
  6. package/dist/cjs/vest.production.js +1 -1
  7. package/dist/es/classnames.development.js +58 -23
  8. package/dist/es/classnames.production.js +1 -1
  9. package/dist/es/parser.development.js +84 -22
  10. package/dist/es/parser.production.js +1 -1
  11. package/dist/es/vest.development.js +447 -440
  12. package/dist/es/vest.production.js +1 -1
  13. package/dist/umd/classnames.development.js +58 -23
  14. package/dist/umd/classnames.production.js +1 -1
  15. package/dist/umd/enforce/compose.development.js +16 -16
  16. package/dist/umd/enforce/compose.production.js +1 -1
  17. package/dist/umd/enforce/compounds.development.js +16 -16
  18. package/dist/umd/enforce/compounds.production.js +1 -1
  19. package/dist/umd/enforce/schema.development.js +16 -16
  20. package/dist/umd/enforce/schema.production.js +1 -1
  21. package/dist/umd/parser.development.js +84 -22
  22. package/dist/umd/parser.production.js +1 -1
  23. package/dist/umd/vest.development.js +320 -313
  24. package/dist/umd/vest.production.js +1 -1
  25. package/package.json +3 -3
  26. package/testUtils/suiteDummy.ts +5 -1
  27. package/types/classnames.d.ts +13 -55
  28. package/types/enforce/compose.d.ts +2 -1
  29. package/types/enforce/compounds.d.ts +2 -1
  30. package/types/enforce/schema.d.ts +2 -1
  31. package/types/parser.d.ts +12 -54
  32. package/types/promisify.d.ts +12 -10
  33. package/types/vest.d.ts +63 -61
@@ -61,8 +61,13 @@
61
61
  return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
62
62
  }
63
63
 
64
+ function numberEquals(value, eq) {
65
+ return isNumeric(value) && isNumeric(eq) && Number(value) === Number(eq);
66
+ }
67
+ var numberNotEquals = bindNot(numberEquals);
68
+
64
69
  function greaterThanOrEquals(value, gte) {
65
- return isNumeric(value) && isNumeric(gte) && Number(value) >= Number(gte);
70
+ return numberEquals(value, gte) || greaterThan(value, gte);
66
71
  }
67
72
 
68
73
  // The module is named "isArrayValue" since it
@@ -85,8 +90,12 @@
85
90
  }
86
91
  var notInside = bindNot(inside);
87
92
 
93
+ function lessThan(value, lt) {
94
+ return isNumeric(value) && isNumeric(lt) && Number(value) < Number(lt);
95
+ }
96
+
88
97
  function lessThanOrEquals(value, lte) {
89
- return isNumeric(value) && isNumeric(lte) && Number(value) <= Number(lte);
98
+ return numberEquals(value, lte) || lessThan(value, lte);
90
99
  }
91
100
 
92
101
  function isBetween(value, min, max) {
@@ -160,12 +169,8 @@
160
169
  var isNotNaN = bindNot(isNaN$1);
161
170
 
162
171
  function isNegative(value) {
163
- if (isNumeric(value)) {
164
- return Number(value) < 0;
165
- }
166
- return false;
172
+ return lessThan(value, 0);
167
173
  }
168
- var isPositive = bindNot(isNegative);
169
174
 
170
175
  /**
171
176
  * Validates that a given value is an odd number
@@ -177,6 +182,10 @@
177
182
  return false;
178
183
  };
179
184
 
185
+ function isPositive(value) {
186
+ return greaterThan(value, 0);
187
+ }
188
+
180
189
  var isNotString = bindNot(isStringValue);
181
190
 
182
191
  function isTruthy(value) {
@@ -197,10 +206,6 @@
197
206
  }
198
207
  var isNotValueOf = bindNot(isValueOf);
199
208
 
200
- function lessThan(value, lt) {
201
- return isNumeric(value) && isNumeric(lt) && Number(value) < Number(lt);
202
- }
203
-
204
209
  function longerThan(value, arg1) {
205
210
  return value.length > Number(arg1);
206
211
  }
@@ -222,11 +227,6 @@
222
227
  }
223
228
  var notMatches = bindNot(matches);
224
229
 
225
- function numberEquals(value, eq) {
226
- return isNumeric(value) && isNumeric(eq) && Number(value) === Number(eq);
227
- }
228
- var numberNotEquals = bindNot(numberEquals);
229
-
230
230
  function condition(value, callback) {
231
231
  try {
232
232
  return callback(value);
@@ -686,106 +686,100 @@
686
686
  return "".concat(n++);
687
687
  }; })(0);
688
688
 
689
- // eslint-disable-next-line max-lines-per-function
690
- function createState(onStateChange) {
691
- var state = {
692
- references: []
689
+ function shouldUseErrorAsMessage(message, error) {
690
+ // kind of cheating with this safe guard, but it does the job
691
+ return isUndefined(message) && isStringValue(error);
692
+ }
693
+
694
+ function asArray(possibleArg) {
695
+ return [].concat(possibleArg);
696
+ }
697
+
698
+ /**
699
+ * Creates a cache function
700
+ */
701
+ function createCache(maxSize) {
702
+ if (maxSize === void 0) { maxSize = 1; }
703
+ var cacheStorage = [];
704
+ var cache = function (deps, cacheAction) {
705
+ var cacheHit = cache.get(deps);
706
+ // cache hit is not null
707
+ if (cacheHit)
708
+ return cacheHit[1];
709
+ var result = cacheAction();
710
+ cacheStorage.unshift([deps.concat(), result]);
711
+ if (longerThan(cacheStorage, maxSize))
712
+ cacheStorage.length = maxSize;
713
+ return result;
693
714
  };
694
- var registrations = [];
695
- return {
696
- registerStateKey: registerStateKey,
697
- reset: reset
715
+ // invalidate an item in the cache by its dependencies
716
+ cache.invalidate = function (deps) {
717
+ var index = findIndex(deps);
718
+ if (index > -1)
719
+ cacheStorage.splice(index, 1);
698
720
  };
699
- /**
700
- * Registers a new key in the state, takes the initial value (may be a function that returns the initial value), returns a function.
701
- *
702
- * @example
703
- *
704
- * const useColor = state.registerStateKey("blue");
705
- *
706
- * let [color, setColor] = useColor(); // -> ["blue", Function]
707
- *
708
- * setColor("green");
709
- *
710
- * useColor()[0]; -> "green"
711
- */
712
- function registerStateKey(initialState, onUpdate) {
713
- var key = registrations.length;
714
- registrations.push([initialState, onUpdate]);
715
- return initKey(key, initialState);
716
- }
717
- function reset() {
718
- var prev = current();
719
- state.references = [];
720
- registrations.forEach(function (_a, index) {
721
- var initialValue = _a[0];
722
- return initKey(index, initialValue, prev[index]);
721
+ // Retrieves an item from the cache.
722
+ cache.get = function (deps) {
723
+ return cacheStorage[findIndex(deps)] || null;
724
+ };
725
+ return cache;
726
+ function findIndex(deps) {
727
+ return cacheStorage.findIndex(function (_a) {
728
+ var cachedDeps = _a[0];
729
+ return lengthEquals(deps, cachedDeps.length) &&
730
+ deps.every(function (dep, i) { return dep === cachedDeps[i]; });
723
731
  });
724
732
  }
725
- function initKey(key, initialState, prevState) {
726
- current().push();
727
- set(key, optionalFunctionValue(initialState, prevState));
728
- return function useStateKey() {
729
- return [
730
- current()[key],
731
- function (nextState) {
732
- return set(key, optionalFunctionValue(nextState, current()[key]));
733
- },
734
- ];
735
- };
736
- }
737
- function current() {
738
- return state.references;
739
- }
740
- function set(index, value) {
741
- var prevValue = state.references[index];
742
- state.references[index] = value;
743
- var _a = registrations[index], onUpdate = _a[1];
744
- if (isFunction(onUpdate)) {
745
- onUpdate(value, prevValue);
733
+ }
734
+
735
+ function last(values) {
736
+ var valuesArray = asArray(values);
737
+ return valuesArray[valuesArray.length - 1];
738
+ }
739
+
740
+ // This is kind of a map/filter in one function.
741
+ // Normally, behaves like a nested-array map,
742
+ // but returning `null` will drop the element from the array
743
+ function transform(array, cb) {
744
+ var res = [];
745
+ for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
746
+ var v = array_1[_i];
747
+ if (isArray(v)) {
748
+ res.push(transform(v, cb));
746
749
  }
747
- if (isFunction(onStateChange)) {
748
- onStateChange();
750
+ else {
751
+ var output = cb(v);
752
+ if (isNotNull(output)) {
753
+ res.push(output);
754
+ }
749
755
  }
750
756
  }
757
+ return res;
751
758
  }
752
-
753
- var IsolateTypes;
754
- (function (IsolateTypes) {
755
- IsolateTypes[IsolateTypes["DEFAULT"] = 0] = "DEFAULT";
756
- IsolateTypes[IsolateTypes["SUITE"] = 1] = "SUITE";
757
- IsolateTypes[IsolateTypes["EACH"] = 2] = "EACH";
758
- IsolateTypes[IsolateTypes["SKIP_WHEN"] = 3] = "SKIP_WHEN";
759
- IsolateTypes[IsolateTypes["OMIT_WHEN"] = 4] = "OMIT_WHEN";
760
- IsolateTypes[IsolateTypes["GROUP"] = 5] = "GROUP";
761
- })(IsolateTypes || (IsolateTypes = {}));
762
-
763
- function createStateRef(state, _a) {
764
- var suiteId = _a.suiteId, suiteName = _a.suiteName;
765
- return {
766
- optionalFields: state.registerStateKey(function () { return ({}); }),
767
- suiteId: state.registerStateKey(suiteId),
768
- suiteName: state.registerStateKey(suiteName),
769
- testCallbacks: state.registerStateKey(function () { return ({
770
- fieldCallbacks: {},
771
- doneCallbacks: []
772
- }); }),
773
- testObjects: state.registerStateKey(function (prev) {
774
- return {
775
- prev: prev ? prev.current : [],
776
- current: []
777
- };
778
- })
779
- };
759
+ function valueAtPath(array, path) {
760
+ return getCurrent(array, path)[last(path)];
780
761
  }
781
-
782
- function asArray(possibleArg) {
783
- return [].concat(possibleArg);
762
+ function setValueAtPath(array, path, value) {
763
+ var current = getCurrent(array, path);
764
+ current[last(path)] = value;
765
+ return array;
784
766
  }
785
-
786
- function last(values) {
787
- var valuesArray = asArray(values);
788
- return valuesArray[valuesArray.length - 1];
767
+ function flatten(values) {
768
+ return asArray(values).reduce(function (acc, value) {
769
+ if (isArray(value)) {
770
+ return acc.concat(flatten(value));
771
+ }
772
+ return asArray(acc).concat(value);
773
+ }, []);
774
+ }
775
+ function getCurrent(array, path) {
776
+ var current = array;
777
+ for (var _i = 0, _a = path.slice(0, -1); _i < _a.length; _i++) {
778
+ var p = _a[_i];
779
+ current[p] = defaultTo(current[p], []);
780
+ current = current[p];
781
+ }
782
+ return current;
789
783
  }
790
784
 
791
785
  function createCursor() {
@@ -822,6 +816,16 @@
822
816
  };
823
817
  }
824
818
 
819
+ var IsolateTypes;
820
+ (function (IsolateTypes) {
821
+ IsolateTypes[IsolateTypes["DEFAULT"] = 0] = "DEFAULT";
822
+ IsolateTypes[IsolateTypes["SUITE"] = 1] = "SUITE";
823
+ IsolateTypes[IsolateTypes["EACH"] = 2] = "EACH";
824
+ IsolateTypes[IsolateTypes["SKIP_WHEN"] = 3] = "SKIP_WHEN";
825
+ IsolateTypes[IsolateTypes["OMIT_WHEN"] = 4] = "OMIT_WHEN";
826
+ IsolateTypes[IsolateTypes["GROUP"] = 5] = "GROUP";
827
+ })(IsolateTypes || (IsolateTypes = {}));
828
+
825
829
  var Modes;
826
830
  (function (Modes) {
827
831
  Modes[Modes["ALL"] = 0] = "ALL";
@@ -849,113 +853,20 @@
849
853
  }, ctxRef);
850
854
  });
851
855
 
852
- // This is kind of a map/filter in one function.
853
- // Normally, behaves like a nested-array map,
854
- // but returning `null` will drop the element from the array
855
- function transform(array, cb) {
856
- var res = [];
857
- for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
858
- var v = array_1[_i];
859
- if (isArray(v)) {
860
- res.push(transform(v, cb));
861
- }
862
- else {
863
- var output = cb(v);
864
- if (isNotNull(output)) {
865
- res.push(output);
866
- }
867
- }
868
- }
869
- return res;
856
+ // STATE REF
857
+ function useStateRef() {
858
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
859
+ return context.useX().stateRef; // I should revisit this
870
860
  }
871
- function valueAtPath(array, path) {
872
- return getCurrent(array, path)[last(path)];
861
+ // STATE KEYS
862
+ function useSuiteId() {
863
+ return useStateRef().suiteId()[0];
873
864
  }
874
- function setValueAtPath(array, path, value) {
875
- var current = getCurrent(array, path);
876
- current[last(path)] = value;
877
- return array;
865
+ function useSuiteName() {
866
+ return useStateRef().suiteName()[0];
878
867
  }
879
- function flatten(values) {
880
- return asArray(values).reduce(function (acc, value) {
881
- if (isArray(value)) {
882
- return acc.concat(flatten(value));
883
- }
884
- return asArray(acc).concat(value);
885
- }, []);
886
- }
887
- function getCurrent(array, path) {
888
- var current = array;
889
- for (var _i = 0, _a = path.slice(0, -1); _i < _a.length; _i++) {
890
- var p = _a[_i];
891
- current[p] = defaultTo(current[p], []);
892
- current = current[p];
893
- }
894
- return current;
895
- }
896
-
897
- function deferThrow(message) {
898
- setTimeout(function () {
899
- throw new Error(message);
900
- }, 0);
901
- }
902
-
903
- function shouldUseErrorAsMessage(message, error) {
904
- // kind of cheating with this safe guard, but it does the job
905
- return isUndefined(message) && isStringValue(error);
906
- }
907
-
908
- /**
909
- * Creates a cache function
910
- */
911
- function createCache(maxSize) {
912
- if (maxSize === void 0) { maxSize = 1; }
913
- var cacheStorage = [];
914
- var cache = function (deps, cacheAction) {
915
- var cacheHit = cache.get(deps);
916
- // cache hit is not null
917
- if (cacheHit)
918
- return cacheHit[1];
919
- var result = cacheAction();
920
- cacheStorage.unshift([deps.concat(), result]);
921
- if (longerThan(cacheStorage, maxSize))
922
- cacheStorage.length = maxSize;
923
- return result;
924
- };
925
- // invalidate an item in the cache by its dependencies
926
- cache.invalidate = function (deps) {
927
- var index = findIndex(deps);
928
- if (index > -1)
929
- cacheStorage.splice(index, 1);
930
- };
931
- // Retrieves an item from the cache.
932
- cache.get = function (deps) {
933
- return cacheStorage[findIndex(deps)] || null;
934
- };
935
- return cache;
936
- function findIndex(deps) {
937
- return cacheStorage.findIndex(function (_a) {
938
- var cachedDeps = _a[0];
939
- return lengthEquals(deps, cachedDeps.length) &&
940
- deps.every(function (dep, i) { return dep === cachedDeps[i]; });
941
- });
942
- }
943
- }
944
-
945
- // STATE REF
946
- function useStateRef() {
947
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
948
- return context.useX().stateRef; // I should revisit this
949
- }
950
- // STATE KEYS
951
- function useSuiteId() {
952
- return useStateRef().suiteId()[0];
953
- }
954
- function useSuiteName() {
955
- return useStateRef().suiteName()[0];
956
- }
957
- function useTestCallbacks() {
958
- return useStateRef().testCallbacks();
868
+ function useTestCallbacks() {
869
+ return useStateRef().testCallbacks();
959
870
  }
960
871
  function useOptionalFields() {
961
872
  return useStateRef().optionalFields();
@@ -1157,6 +1068,95 @@
1157
1068
  var STATUS_CANCELED = 'CANCELED';
1158
1069
  var STATUS_OMITTED = 'OMITTED';
1159
1070
 
1071
+ // eslint-disable-next-line max-lines-per-function
1072
+ function createState(onStateChange) {
1073
+ var state = {
1074
+ references: []
1075
+ };
1076
+ var registrations = [];
1077
+ return {
1078
+ registerStateKey: registerStateKey,
1079
+ reset: reset
1080
+ };
1081
+ /**
1082
+ * Registers a new key in the state, takes the initial value (may be a function that returns the initial value), returns a function.
1083
+ *
1084
+ * @example
1085
+ *
1086
+ * const useColor = state.registerStateKey("blue");
1087
+ *
1088
+ * let [color, setColor] = useColor(); // -> ["blue", Function]
1089
+ *
1090
+ * setColor("green");
1091
+ *
1092
+ * useColor()[0]; -> "green"
1093
+ */
1094
+ function registerStateKey(initialState, onUpdate) {
1095
+ var key = registrations.length;
1096
+ registrations.push([initialState, onUpdate]);
1097
+ return initKey(key, initialState);
1098
+ }
1099
+ function reset() {
1100
+ var prev = current();
1101
+ state.references = [];
1102
+ registrations.forEach(function (_a, index) {
1103
+ var initialValue = _a[0];
1104
+ return initKey(index, initialValue, prev[index]);
1105
+ });
1106
+ }
1107
+ function initKey(key, initialState, prevState) {
1108
+ current().push();
1109
+ set(key, optionalFunctionValue(initialState, prevState));
1110
+ return function useStateKey() {
1111
+ return [
1112
+ current()[key],
1113
+ function (nextState) {
1114
+ return set(key, optionalFunctionValue(nextState, current()[key]));
1115
+ },
1116
+ ];
1117
+ };
1118
+ }
1119
+ function current() {
1120
+ return state.references;
1121
+ }
1122
+ function set(index, value) {
1123
+ var prevValue = state.references[index];
1124
+ state.references[index] = value;
1125
+ var _a = registrations[index], onUpdate = _a[1];
1126
+ if (isFunction(onUpdate)) {
1127
+ onUpdate(value, prevValue);
1128
+ }
1129
+ if (isFunction(onStateChange)) {
1130
+ onStateChange();
1131
+ }
1132
+ }
1133
+ }
1134
+
1135
+ function createStateRef(state, _a) {
1136
+ var suiteId = _a.suiteId, suiteName = _a.suiteName;
1137
+ return {
1138
+ optionalFields: state.registerStateKey(function () { return ({}); }),
1139
+ suiteId: state.registerStateKey(suiteId),
1140
+ suiteName: state.registerStateKey(suiteName),
1141
+ testCallbacks: state.registerStateKey(function () { return ({
1142
+ fieldCallbacks: {},
1143
+ doneCallbacks: []
1144
+ }); }),
1145
+ testObjects: state.registerStateKey(function (prev) {
1146
+ return {
1147
+ prev: prev ? prev.current : [],
1148
+ current: []
1149
+ };
1150
+ })
1151
+ };
1152
+ }
1153
+
1154
+ function deferThrow(message) {
1155
+ setTimeout(function () {
1156
+ throw new Error(message);
1157
+ }, 0);
1158
+ }
1159
+
1160
1160
  function usePath() {
1161
1161
  var context$1 = context.useX();
1162
1162
  return context$1.testCursor.getCursor();
@@ -1241,6 +1241,107 @@
1241
1241
  SeverityCount["WARN_COUNT"] = "warnCount";
1242
1242
  })(SeverityCount || (SeverityCount = {}));
1243
1243
 
1244
+ function nonMatchingFieldName(testObject, fieldName) {
1245
+ return !!fieldName && !matchingFieldName(testObject, fieldName);
1246
+ }
1247
+ function matchingFieldName(testObject, fieldName) {
1248
+ return !!(fieldName && testObject.fieldName === fieldName);
1249
+ }
1250
+
1251
+ function either(a, b) {
1252
+ return !!a !== !!b;
1253
+ }
1254
+
1255
+ /**
1256
+ * Checks that a given test object matches the currently specified severity level
1257
+ */
1258
+ function nonMatchingSeverityProfile(severity, testObject) {
1259
+ return either(severity === Severity.WARNINGS, testObject.warns());
1260
+ }
1261
+
1262
+ /**
1263
+ * Determines whether a certain test profile has failures.
1264
+ */
1265
+ function hasFailuresLogic(testObject, severityKey, fieldName) {
1266
+ if (!testObject.hasFailures()) {
1267
+ return false;
1268
+ }
1269
+ if (nonMatchingFieldName(testObject, fieldName)) {
1270
+ return false;
1271
+ }
1272
+ if (nonMatchingSeverityProfile(severityKey, testObject)) {
1273
+ return false;
1274
+ }
1275
+ return true;
1276
+ }
1277
+
1278
+ function hasErrors(fieldName) {
1279
+ return has(Severity.ERRORS, fieldName);
1280
+ }
1281
+ function hasWarnings(fieldName) {
1282
+ return has(Severity.WARNINGS, fieldName);
1283
+ }
1284
+ function has(severityKey, fieldName) {
1285
+ var testObjects = useTestsFlat();
1286
+ return testObjects.some(function (testObject) {
1287
+ return hasFailuresLogic(testObject, severityKey, fieldName);
1288
+ });
1289
+ }
1290
+
1291
+ // eslint-disable-next-line max-statements, complexity
1292
+ function isValid(fieldName) {
1293
+ if (fieldIsOmitted(fieldName)) {
1294
+ return true;
1295
+ }
1296
+ if (hasErrors(fieldName)) {
1297
+ return false;
1298
+ }
1299
+ var testObjects = useTestsFlat();
1300
+ if (isEmpty(testObjects)) {
1301
+ return false;
1302
+ }
1303
+ if (fieldDoesNotExist(fieldName)) {
1304
+ return false;
1305
+ }
1306
+ if (hasNonOptionalIncomplete(fieldName)) {
1307
+ return false;
1308
+ }
1309
+ return noMissingTests(fieldName);
1310
+ }
1311
+ function fieldIsOmitted(fieldName) {
1312
+ var omittedFields = useOmittedFields();
1313
+ if (!fieldName) {
1314
+ return false;
1315
+ }
1316
+ return !!omittedFields[fieldName];
1317
+ }
1318
+ function hasNonOptionalIncomplete(fieldName) {
1319
+ var optionalFields = useOptionalFields()[0];
1320
+ return isNotEmpty(useAllIncomplete().filter(function (testObject) {
1321
+ if (nonMatchingFieldName(testObject, fieldName)) {
1322
+ return false;
1323
+ }
1324
+ return optionalFields[testObject.fieldName] !== true;
1325
+ }));
1326
+ }
1327
+ function fieldDoesNotExist(fieldName) {
1328
+ var testObjects = useTestsFlat();
1329
+ return (!!fieldName &&
1330
+ !testObjects.find(function (testObject) { return testObject.fieldName === fieldName; }));
1331
+ }
1332
+ function noMissingTests(fieldName) {
1333
+ var testObjects = useTestsFlat();
1334
+ var optionalFields = useOptionalFields()[0];
1335
+ return testObjects.every(function (testObject) {
1336
+ if (nonMatchingFieldName(testObject, fieldName)) {
1337
+ return true;
1338
+ }
1339
+ return (optionalFields[testObject.fieldName] === true ||
1340
+ testObject.isTested() ||
1341
+ testObject.isOmitted());
1342
+ });
1343
+ }
1344
+
1244
1345
  /**
1245
1346
  * Reads the testObjects list and gets full validation result from it.
1246
1347
  */
@@ -1248,17 +1349,24 @@
1248
1349
  var testObjects = useTestsFlat();
1249
1350
  var summary = assign(baseStats(), {
1250
1351
  groups: {},
1251
- tests: {}
1352
+ tests: {},
1353
+ valid: false
1252
1354
  });
1253
1355
  testObjects.reduce(function (summary, testObject) {
1254
1356
  appendToTest(summary.tests, testObject);
1255
1357
  appendToGroup(summary.groups, testObject);
1256
1358
  return summary;
1257
1359
  }, summary);
1360
+ summary.valid = isValid();
1258
1361
  return countFailures(summary);
1259
1362
  }
1260
1363
  function appendToTest(tests, testObject) {
1261
1364
  tests[testObject.fieldName] = appendTestObject(tests, testObject);
1365
+ // If `valid` is false to begin with, keep it that way. Otherwise, assess.
1366
+ tests[testObject.fieldName].valid =
1367
+ tests[testObject.fieldName].valid === false
1368
+ ? false
1369
+ : isValid(testObject.fieldName);
1262
1370
  }
1263
1371
  /**
1264
1372
  * Appends to a group object if within a group
@@ -1321,24 +1429,6 @@
1321
1429
  };
1322
1430
  }
1323
1431
 
1324
- function nonMatchingFieldName(testObject, fieldName) {
1325
- return !!fieldName && !matchingFieldName(testObject, fieldName);
1326
- }
1327
- function matchingFieldName(testObject, fieldName) {
1328
- return !!(fieldName && testObject.fieldName === fieldName);
1329
- }
1330
-
1331
- function either(a, b) {
1332
- return !!a !== !!b;
1333
- }
1334
-
1335
- /**
1336
- * Checks that a given test object matches the currently specified severity level
1337
- */
1338
- function nonMatchingSeverityProfile(severity, testObject) {
1339
- return either(severity === Severity.WARNINGS, testObject.warns());
1340
- }
1341
-
1342
1432
  function collectFailureMessages(severity, testObjects, options) {
1343
1433
  var _a;
1344
1434
  if (options === void 0) { options = {}; }
@@ -1414,35 +1504,6 @@
1414
1504
  });
1415
1505
  }
1416
1506
 
1417
- /**
1418
- * Determines whether a certain test profile has failures.
1419
- */
1420
- function hasFailuresLogic(testObject, severityKey, fieldName) {
1421
- if (!testObject.hasFailures()) {
1422
- return false;
1423
- }
1424
- if (nonMatchingFieldName(testObject, fieldName)) {
1425
- return false;
1426
- }
1427
- if (nonMatchingSeverityProfile(severityKey, testObject)) {
1428
- return false;
1429
- }
1430
- return true;
1431
- }
1432
-
1433
- function hasErrors(fieldName) {
1434
- return has(Severity.ERRORS, fieldName);
1435
- }
1436
- function hasWarnings(fieldName) {
1437
- return has(Severity.WARNINGS, fieldName);
1438
- }
1439
- function has(severityKey, fieldName) {
1440
- var testObjects = useTestsFlat();
1441
- return testObjects.some(function (testObject) {
1442
- return hasFailuresLogic(testObject, severityKey, fieldName);
1443
- });
1444
- }
1445
-
1446
1507
  function hasErrorsByGroup(groupName, fieldName) {
1447
1508
  return hasByGroup(Severity.ERRORS, groupName, fieldName);
1448
1509
  }
@@ -1461,60 +1522,6 @@
1461
1522
  });
1462
1523
  }
1463
1524
 
1464
- // eslint-disable-next-line max-statements, complexity
1465
- function isValid(fieldName) {
1466
- if (fieldIsOmitted(fieldName)) {
1467
- return true;
1468
- }
1469
- if (hasErrors(fieldName)) {
1470
- return false;
1471
- }
1472
- var testObjects = useTestsFlat();
1473
- if (isEmpty(testObjects)) {
1474
- return false;
1475
- }
1476
- if (fieldDoesNotExist(fieldName)) {
1477
- return false;
1478
- }
1479
- if (hasNonOptionalIncomplete(fieldName)) {
1480
- return false;
1481
- }
1482
- return noMissingTests(fieldName);
1483
- }
1484
- function fieldIsOmitted(fieldName) {
1485
- var omittedFields = useOmittedFields();
1486
- if (!fieldName) {
1487
- return false;
1488
- }
1489
- return !!omittedFields[fieldName];
1490
- }
1491
- function hasNonOptionalIncomplete(fieldName) {
1492
- var optionalFields = useOptionalFields()[0];
1493
- return isNotEmpty(useAllIncomplete().filter(function (testObject) {
1494
- if (nonMatchingFieldName(testObject, fieldName)) {
1495
- return false;
1496
- }
1497
- return optionalFields[testObject.fieldName] !== true;
1498
- }));
1499
- }
1500
- function fieldDoesNotExist(fieldName) {
1501
- var testObjects = useTestsFlat();
1502
- return (!!fieldName &&
1503
- !testObjects.find(function (testObject) { return testObject.fieldName === fieldName; }));
1504
- }
1505
- function noMissingTests(fieldName) {
1506
- var testObjects = useTestsFlat();
1507
- var optionalFields = useOptionalFields()[0];
1508
- return testObjects.every(function (testObject) {
1509
- if (nonMatchingFieldName(testObject, fieldName)) {
1510
- return true;
1511
- }
1512
- return (optionalFields[testObject.fieldName] === true ||
1513
- testObject.isTested() ||
1514
- testObject.isOmitted());
1515
- });
1516
- }
1517
-
1518
1525
  var cache$1 = createCache(20);
1519
1526
  function produceSuiteResult() {
1520
1527
  var testObjects = useTestsFlat();
@@ -2421,7 +2428,7 @@
2421
2428
  ctx.currentTest.warn();
2422
2429
  }
2423
2430
 
2424
- var VERSION = "4.2.3-dev-87ebfa";
2431
+ var VERSION = "4.3.0";
2425
2432
 
2426
2433
  exports.VERSION = VERSION;
2427
2434
  exports.context = context;