vest 4.3.1 → 4.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/classnames.development.js +21 -18
- package/dist/cjs/classnames.production.js +1 -1
- package/dist/cjs/enforce/compounds.development.js +3 -3
- package/dist/cjs/enforce/compounds.production.js +1 -1
- package/dist/cjs/parser.development.js +21 -18
- package/dist/cjs/parser.production.js +1 -1
- package/dist/cjs/vest.development.js +166 -170
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/classnames.development.js +21 -18
- package/dist/es/classnames.production.js +1 -1
- package/dist/es/enforce/compounds.development.js +3 -3
- package/dist/es/enforce/compounds.production.js +1 -1
- package/dist/es/parser.development.js +21 -18
- package/dist/es/parser.production.js +1 -1
- package/dist/es/vest.development.js +166 -170
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/classnames.development.js +21 -18
- package/dist/umd/classnames.production.js +1 -1
- package/dist/umd/enforce/compose.development.js +12 -8
- package/dist/umd/enforce/compose.production.js +1 -1
- package/dist/umd/enforce/compounds.development.js +15 -11
- package/dist/umd/enforce/compounds.production.js +1 -1
- package/dist/umd/enforce/schema.development.js +12 -8
- package/dist/umd/enforce/schema.production.js +1 -1
- package/dist/umd/parser.development.js +21 -18
- package/dist/umd/parser.production.js +1 -1
- package/dist/umd/vest.development.js +171 -175
- package/dist/umd/vest.production.js +1 -1
- package/package.json +3 -3
- package/types/classnames.d.ts +9 -5
- package/types/parser.d.ts +9 -5
- package/types/promisify.d.ts +9 -5
- package/types/vest.d.ts +14 -7
|
@@ -39,6 +39,8 @@ function asArray(possibleArg) {
|
|
|
39
39
|
return [].concat(possibleArg);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
var assign = Object.assign;
|
|
43
|
+
|
|
42
44
|
function isNumeric(value) {
|
|
43
45
|
var str = String(value);
|
|
44
46
|
var num = Number(value);
|
|
@@ -178,8 +180,6 @@ function getCurrent(array, path) {
|
|
|
178
180
|
return current;
|
|
179
181
|
}
|
|
180
182
|
|
|
181
|
-
var assign = Object.assign;
|
|
182
|
-
|
|
183
183
|
function createCursor() {
|
|
184
184
|
var storage = {
|
|
185
185
|
cursor: []
|
|
@@ -266,22 +266,37 @@ function useSuiteName() {
|
|
|
266
266
|
function useTestCallbacks() {
|
|
267
267
|
return useStateRef().testCallbacks();
|
|
268
268
|
}
|
|
269
|
+
// OPTIONAL FIELDS
|
|
270
|
+
function useOptionalField(fieldName) {
|
|
271
|
+
var optionalFields = useOptionalFields()[0];
|
|
272
|
+
return optionalFields[fieldName];
|
|
273
|
+
}
|
|
269
274
|
function useOptionalFields() {
|
|
270
275
|
return useStateRef().optionalFields();
|
|
271
276
|
}
|
|
277
|
+
function useSetOptionalField(fieldName, setter) {
|
|
278
|
+
var _a = useOptionalFields(), setOptionalFields = _a[1];
|
|
279
|
+
setOptionalFields(function (optionalFields) {
|
|
280
|
+
var _a;
|
|
281
|
+
return assign(optionalFields, (_a = {},
|
|
282
|
+
_a[fieldName] = optionalFunctionValue(setter, optionalFields[fieldName]),
|
|
283
|
+
_a));
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
function useOptionalFieldApplied(fieldName) {
|
|
287
|
+
var _a;
|
|
288
|
+
return (_a = useOptionalField(fieldName)) === null || _a === void 0 ? void 0 : _a[1];
|
|
289
|
+
}
|
|
290
|
+
function useOptionalFieldConfig(fieldName) {
|
|
291
|
+
var _a;
|
|
292
|
+
return (_a = useOptionalField(fieldName)) === null || _a === void 0 ? void 0 : _a[0];
|
|
293
|
+
}
|
|
272
294
|
function useTestObjects() {
|
|
273
295
|
return useStateRef().testObjects();
|
|
274
296
|
}
|
|
275
297
|
// STATE ACTIONS
|
|
276
298
|
function useRefreshTestObjects() {
|
|
277
|
-
|
|
278
|
-
setTestObjects(function (_a) {
|
|
279
|
-
var current = _a.current, prev = _a.prev;
|
|
280
|
-
return ({
|
|
281
|
-
prev: prev,
|
|
282
|
-
current: asArray(current)
|
|
283
|
-
});
|
|
284
|
-
});
|
|
299
|
+
useSetTests(function (tests) { return tests; });
|
|
285
300
|
}
|
|
286
301
|
function useSetTests(handler) {
|
|
287
302
|
var _a = useTestObjects(), testObjects = _a[1];
|
|
@@ -295,22 +310,7 @@ function useSetTests(handler) {
|
|
|
295
310
|
}
|
|
296
311
|
// Derived state
|
|
297
312
|
function useAllIncomplete() {
|
|
298
|
-
|
|
299
|
-
return flatten(transform(current, function (testObject) {
|
|
300
|
-
return testObject.isPending() ? testObject : null;
|
|
301
|
-
}));
|
|
302
|
-
}
|
|
303
|
-
function useOmittedFields() {
|
|
304
|
-
var testObjects = useTestsFlat();
|
|
305
|
-
return testObjects.reduce(function (omittedFields, testObject) {
|
|
306
|
-
if (omittedFields[testObject.fieldName]) {
|
|
307
|
-
return omittedFields;
|
|
308
|
-
}
|
|
309
|
-
if (testObject.isOmitted()) {
|
|
310
|
-
omittedFields[testObject.fieldName] = true;
|
|
311
|
-
}
|
|
312
|
-
return omittedFields;
|
|
313
|
-
}, {});
|
|
313
|
+
return useTestsFlat().filter(function (test) { return test.isPending(); });
|
|
314
314
|
}
|
|
315
315
|
var flatCache = createCache();
|
|
316
316
|
function useTestsFlat() {
|
|
@@ -624,9 +624,7 @@ function useRetainTestKey(key, testObject) {
|
|
|
624
624
|
|
|
625
625
|
function isolate(_a, callback) {
|
|
626
626
|
var _b = _a.type, type = _b === void 0 ? IsolateTypes.DEFAULT : _b;
|
|
627
|
-
|
|
628
|
-
return;
|
|
629
|
-
}
|
|
627
|
+
invariant(isFunction(callback));
|
|
630
628
|
var keys = {
|
|
631
629
|
current: {},
|
|
632
630
|
prev: {}
|
|
@@ -656,6 +654,11 @@ var SeverityCount;
|
|
|
656
654
|
SeverityCount["ERROR_COUNT"] = "errorCount";
|
|
657
655
|
SeverityCount["WARN_COUNT"] = "warnCount";
|
|
658
656
|
})(SeverityCount || (SeverityCount = {}));
|
|
657
|
+
function countKeyBySeverity(severity) {
|
|
658
|
+
return severity === Severity.ERRORS
|
|
659
|
+
? SeverityCount.ERROR_COUNT
|
|
660
|
+
: SeverityCount.WARN_COUNT;
|
|
661
|
+
}
|
|
659
662
|
|
|
660
663
|
/**
|
|
661
664
|
* A safe hasOwnProperty access
|
|
@@ -681,7 +684,7 @@ function isEmpty(value) {
|
|
|
681
684
|
else if (typeof value === 'object') {
|
|
682
685
|
return lengthEquals(Object.keys(value), 0);
|
|
683
686
|
}
|
|
684
|
-
return
|
|
687
|
+
return false;
|
|
685
688
|
}
|
|
686
689
|
var isNotEmpty = bindNot(isEmpty);
|
|
687
690
|
|
|
@@ -703,10 +706,23 @@ function nonMatchingSeverityProfile(severity, testObject) {
|
|
|
703
706
|
return either(severity === Severity.WARNINGS, testObject.warns());
|
|
704
707
|
}
|
|
705
708
|
|
|
709
|
+
/**
|
|
710
|
+
* The difference between this file and hasFailures is that hasFailures uses the static
|
|
711
|
+
* summary object, while this one uses the actual validation state
|
|
712
|
+
*/
|
|
713
|
+
function hasErrorsByTestObjects(fieldName) {
|
|
714
|
+
return hasFailuresByTestObjects(Severity.ERRORS, fieldName);
|
|
715
|
+
}
|
|
716
|
+
function hasFailuresByTestObjects(severityKey, fieldName) {
|
|
717
|
+
var testObjects = useTestsFlat();
|
|
718
|
+
return testObjects.some(function (testObject) {
|
|
719
|
+
return hasFailuresByTestObject(testObject, severityKey, fieldName);
|
|
720
|
+
});
|
|
721
|
+
}
|
|
706
722
|
/**
|
|
707
723
|
* Determines whether a certain test profile has failures.
|
|
708
724
|
*/
|
|
709
|
-
function
|
|
725
|
+
function hasFailuresByTestObject(testObject, severityKey, fieldName) {
|
|
710
726
|
if (!testObject.hasFailures()) {
|
|
711
727
|
return false;
|
|
712
728
|
}
|
|
@@ -719,79 +735,54 @@ function hasFailuresLogic(testObject, severityKey, fieldName) {
|
|
|
719
735
|
return true;
|
|
720
736
|
}
|
|
721
737
|
|
|
722
|
-
function hasErrors(fieldName) {
|
|
723
|
-
return has(Severity.ERRORS, fieldName);
|
|
724
|
-
}
|
|
725
|
-
function hasWarnings(fieldName) {
|
|
726
|
-
return has(Severity.WARNINGS, fieldName);
|
|
727
|
-
}
|
|
728
|
-
function has(severityKey, fieldName) {
|
|
729
|
-
var testObjects = useTestsFlat();
|
|
730
|
-
return testObjects.some(function (testObject) {
|
|
731
|
-
return hasFailuresLogic(testObject, severityKey, fieldName);
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
function isValid(fieldName) {
|
|
736
|
-
var _a, _b;
|
|
737
|
-
var summary = context.useX().summary;
|
|
738
|
-
invariant(summary);
|
|
739
|
-
return Boolean(fieldName ? (_b = (_a = summary.tests) === null || _a === void 0 ? void 0 : _a[fieldName]) === null || _b === void 0 ? void 0 : _b.valid : summary.valid);
|
|
740
|
-
}
|
|
741
738
|
// eslint-disable-next-line max-statements, complexity
|
|
742
739
|
function shouldAddValidProp(fieldName) {
|
|
743
740
|
if (fieldIsOmitted(fieldName)) {
|
|
744
741
|
return true;
|
|
745
742
|
}
|
|
746
|
-
if (
|
|
743
|
+
if (hasErrorsByTestObjects(fieldName)) {
|
|
747
744
|
return false;
|
|
748
745
|
}
|
|
749
746
|
var testObjects = useTestsFlat();
|
|
750
747
|
if (isEmpty(testObjects)) {
|
|
751
748
|
return false;
|
|
752
749
|
}
|
|
753
|
-
if (fieldDoesNotExist(fieldName)) {
|
|
754
|
-
return false;
|
|
755
|
-
}
|
|
756
750
|
if (hasNonOptionalIncomplete(fieldName)) {
|
|
757
751
|
return false;
|
|
758
752
|
}
|
|
759
753
|
return noMissingTests(fieldName);
|
|
760
754
|
}
|
|
761
755
|
function fieldIsOmitted(fieldName) {
|
|
762
|
-
var omittedFields = useOmittedFields();
|
|
763
756
|
if (!fieldName) {
|
|
764
757
|
return false;
|
|
765
758
|
}
|
|
766
|
-
return
|
|
759
|
+
return useOptionalFieldApplied(fieldName) === true;
|
|
767
760
|
}
|
|
768
761
|
function hasNonOptionalIncomplete(fieldName) {
|
|
769
|
-
var optionalFields = useOptionalFields()[0];
|
|
770
762
|
return isNotEmpty(useAllIncomplete().filter(function (testObject) {
|
|
771
763
|
if (nonMatchingFieldName(testObject, fieldName)) {
|
|
772
764
|
return false;
|
|
773
765
|
}
|
|
774
|
-
return
|
|
766
|
+
return useOptionalFieldConfig(testObject.fieldName) !== true;
|
|
775
767
|
}));
|
|
776
768
|
}
|
|
777
|
-
function fieldDoesNotExist(fieldName) {
|
|
778
|
-
var testObjects = useTestsFlat();
|
|
779
|
-
return (!!fieldName &&
|
|
780
|
-
!testObjects.find(function (testObject) { return testObject.fieldName === fieldName; }));
|
|
781
|
-
}
|
|
782
769
|
function noMissingTests(fieldName) {
|
|
783
770
|
var testObjects = useTestsFlat();
|
|
784
|
-
var optionalFields = useOptionalFields()[0];
|
|
785
771
|
return testObjects.every(function (testObject) {
|
|
786
772
|
if (nonMatchingFieldName(testObject, fieldName)) {
|
|
787
773
|
return true;
|
|
788
774
|
}
|
|
789
|
-
return (
|
|
775
|
+
return (useOptionalFieldConfig(testObject.fieldName) === true ||
|
|
790
776
|
testObject.isTested() ||
|
|
791
777
|
testObject.isOmitted());
|
|
792
778
|
});
|
|
793
779
|
}
|
|
794
780
|
|
|
781
|
+
function useSummary() {
|
|
782
|
+
var summary = context.useX().summary;
|
|
783
|
+
invariant(summary);
|
|
784
|
+
return summary;
|
|
785
|
+
}
|
|
795
786
|
/**
|
|
796
787
|
* Reads the testObjects list and gets full validation result from it.
|
|
797
788
|
*/
|
|
@@ -840,13 +831,9 @@ function countFailures(summary) {
|
|
|
840
831
|
}
|
|
841
832
|
return summary;
|
|
842
833
|
}
|
|
843
|
-
/**
|
|
844
|
-
* Appends the test to a results object
|
|
845
|
-
*/
|
|
846
|
-
// eslint-disable-next-line max-statements
|
|
847
834
|
function appendTestObject(summaryKey, testObject) {
|
|
848
835
|
var fieldName = testObject.fieldName, message = testObject.message;
|
|
849
|
-
summaryKey[fieldName] = summaryKey[fieldName] ||
|
|
836
|
+
summaryKey[fieldName] = summaryKey[fieldName] || baseTestStats();
|
|
850
837
|
var testKey = summaryKey[fieldName];
|
|
851
838
|
if (testObject.isNonActionable())
|
|
852
839
|
return testKey;
|
|
@@ -859,18 +846,13 @@ function appendTestObject(summaryKey, testObject) {
|
|
|
859
846
|
}
|
|
860
847
|
return testKey;
|
|
861
848
|
function incrementFailures(severity) {
|
|
862
|
-
var countKey =
|
|
849
|
+
var countKey = countKeyBySeverity(severity);
|
|
863
850
|
testKey[countKey]++;
|
|
864
851
|
if (message) {
|
|
865
852
|
testKey[severity] = (testKey[severity] || []).concat(message);
|
|
866
853
|
}
|
|
867
854
|
}
|
|
868
855
|
}
|
|
869
|
-
function getCountKey(severity) {
|
|
870
|
-
return severity === Severity.ERRORS
|
|
871
|
-
? SeverityCount.ERROR_COUNT
|
|
872
|
-
: SeverityCount.WARN_COUNT;
|
|
873
|
-
}
|
|
874
856
|
function baseStats() {
|
|
875
857
|
return {
|
|
876
858
|
errorCount: 0,
|
|
@@ -878,6 +860,12 @@ function baseStats() {
|
|
|
878
860
|
testCount: 0
|
|
879
861
|
};
|
|
880
862
|
}
|
|
863
|
+
function baseTestStats() {
|
|
864
|
+
return assign(baseStats(), {
|
|
865
|
+
errors: [],
|
|
866
|
+
warnings: []
|
|
867
|
+
});
|
|
868
|
+
}
|
|
881
869
|
|
|
882
870
|
// calls collectAll or getByFieldName depending on whether fieldName is provided
|
|
883
871
|
function gatherFailures(testGroup, severityKey, fieldName) {
|
|
@@ -890,10 +878,11 @@ function getByFieldName(testGroup, severityKey, fieldName) {
|
|
|
890
878
|
return ((_a = testGroup === null || testGroup === void 0 ? void 0 : testGroup[fieldName]) === null || _a === void 0 ? void 0 : _a[severityKey]) || [];
|
|
891
879
|
}
|
|
892
880
|
function collectAll(testGroup, severityKey) {
|
|
893
|
-
var _a;
|
|
894
881
|
var output = {};
|
|
895
882
|
for (var field in testGroup) {
|
|
896
|
-
|
|
883
|
+
// We will probably never get to the fallback array
|
|
884
|
+
// leaving it just in case the implementation changes
|
|
885
|
+
output[field] = testGroup[field][severityKey] || [];
|
|
897
886
|
}
|
|
898
887
|
return output;
|
|
899
888
|
}
|
|
@@ -908,8 +897,7 @@ function getWarnings(fieldName) {
|
|
|
908
897
|
* @returns suite or field's errors or warnings.
|
|
909
898
|
*/
|
|
910
899
|
function getFailures(severityKey, fieldName) {
|
|
911
|
-
var summary =
|
|
912
|
-
invariant(summary);
|
|
900
|
+
var summary = useSummary();
|
|
913
901
|
return gatherFailures(summary.tests, severityKey, fieldName);
|
|
914
902
|
}
|
|
915
903
|
|
|
@@ -920,27 +908,59 @@ function getWarningsByGroup(groupName, fieldName) {
|
|
|
920
908
|
return getFailuresByGroup(groupName, Severity.WARNINGS, fieldName);
|
|
921
909
|
}
|
|
922
910
|
function getFailuresByGroup(groupName, severityKey, fieldName) {
|
|
923
|
-
var summary =
|
|
924
|
-
invariant(summary);
|
|
911
|
+
var summary = useSummary();
|
|
925
912
|
return gatherFailures(summary.groups[groupName], severityKey, fieldName);
|
|
926
913
|
}
|
|
927
914
|
|
|
915
|
+
function isPositive(value) {
|
|
916
|
+
return greaterThan(value, 0);
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
function hasErrors(fieldName) {
|
|
920
|
+
return hasFailures(SeverityCount.ERROR_COUNT, fieldName);
|
|
921
|
+
}
|
|
922
|
+
function hasWarnings(fieldName) {
|
|
923
|
+
return hasFailures(SeverityCount.WARN_COUNT, fieldName);
|
|
924
|
+
}
|
|
925
|
+
function hasFailures(severityCount, fieldName) {
|
|
926
|
+
var _a;
|
|
927
|
+
var summary = useSummary();
|
|
928
|
+
if (fieldName) {
|
|
929
|
+
return isPositive((_a = summary.tests[fieldName]) === null || _a === void 0 ? void 0 : _a[severityCount]);
|
|
930
|
+
}
|
|
931
|
+
return isPositive(summary[severityCount]);
|
|
932
|
+
}
|
|
933
|
+
|
|
928
934
|
function hasErrorsByGroup(groupName, fieldName) {
|
|
929
|
-
return
|
|
935
|
+
return hasFailuresByGroup(Severity.ERRORS, groupName, fieldName);
|
|
930
936
|
}
|
|
931
937
|
function hasWarningsByGroup(groupName, fieldName) {
|
|
932
|
-
return
|
|
938
|
+
return hasFailuresByGroup(Severity.WARNINGS, groupName, fieldName);
|
|
933
939
|
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
var
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
940
|
+
// eslint-disable-next-line max-statements
|
|
941
|
+
function hasFailuresByGroup(severityKey, groupName, fieldName) {
|
|
942
|
+
var _a, _b;
|
|
943
|
+
var summary = useSummary();
|
|
944
|
+
var severityCount = countKeyBySeverity(severityKey);
|
|
945
|
+
var group = summary.groups[groupName];
|
|
946
|
+
if (!group) {
|
|
947
|
+
return false;
|
|
948
|
+
}
|
|
949
|
+
if (fieldName) {
|
|
950
|
+
return isPositive((_a = group[fieldName]) === null || _a === void 0 ? void 0 : _a[severityCount]);
|
|
951
|
+
}
|
|
952
|
+
for (var field in group) {
|
|
953
|
+
if (isPositive((_b = group[field]) === null || _b === void 0 ? void 0 : _b[severityCount])) {
|
|
954
|
+
return true;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
return false;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
function isValid(fieldName) {
|
|
961
|
+
var _a;
|
|
962
|
+
var summary = useSummary();
|
|
963
|
+
return fieldName ? Boolean((_a = summary.tests[fieldName]) === null || _a === void 0 ? void 0 : _a.valid) : summary.valid;
|
|
944
964
|
}
|
|
945
965
|
|
|
946
966
|
var cache$1 = createCache(1);
|
|
@@ -950,7 +970,7 @@ function produceSuiteResult() {
|
|
|
950
970
|
return cache$1([testObjects], context.bind(ctxRef, function () {
|
|
951
971
|
var summary = genTestsSummary();
|
|
952
972
|
var suiteName = useSuiteName();
|
|
953
|
-
var ref =
|
|
973
|
+
var ref = { summary: summary };
|
|
954
974
|
return assign(summary, {
|
|
955
975
|
getErrors: context.bind(ref, getErrors),
|
|
956
976
|
getErrorsByGroup: context.bind(ref, getErrorsByGroup),
|
|
@@ -1063,7 +1083,7 @@ function createBus() {
|
|
|
1063
1083
|
}
|
|
1064
1084
|
}
|
|
1065
1085
|
|
|
1066
|
-
function
|
|
1086
|
+
function omitOptionalFields() {
|
|
1067
1087
|
var optionalFields = useOptionalFields()[0];
|
|
1068
1088
|
if (isEmpty(optionalFields)) {
|
|
1069
1089
|
return;
|
|
@@ -1084,10 +1104,11 @@ function omitOptionalTests() {
|
|
|
1084
1104
|
function verifyAndOmit(testObject) {
|
|
1085
1105
|
if (shouldOmit[testObject.fieldName]) {
|
|
1086
1106
|
testObject.omit();
|
|
1107
|
+
useSetOptionalField(testObject.fieldName, function (current) { return [current[0], true]; });
|
|
1087
1108
|
}
|
|
1088
1109
|
}
|
|
1089
1110
|
function runOptionalConfig(testObject) {
|
|
1090
|
-
var optionalConfig =
|
|
1111
|
+
var optionalConfig = useOptionalFieldConfig(testObject.fieldName);
|
|
1091
1112
|
if (isFunction(optionalConfig)) {
|
|
1092
1113
|
shouldOmit[testObject.fieldName] = optionalConfig();
|
|
1093
1114
|
verifyAndOmit(testObject);
|
|
@@ -1147,7 +1168,7 @@ function initBus() {
|
|
|
1147
1168
|
// Async operations may still be running.
|
|
1148
1169
|
bus.on(Events.SUITE_CALLBACK_DONE_RUNNING, function () {
|
|
1149
1170
|
// Remove tests that are optional and need to be omitted
|
|
1150
|
-
|
|
1171
|
+
omitOptionalFields();
|
|
1151
1172
|
});
|
|
1152
1173
|
// Called when all the tests, including async, are done running
|
|
1153
1174
|
bus.on(Events.ALL_RUNNING_TESTS_FINISHED, function () {
|
|
@@ -1343,7 +1364,7 @@ function isExcluded(testObject) {
|
|
|
1343
1364
|
return keyTests[fieldName] === false;
|
|
1344
1365
|
}
|
|
1345
1366
|
}
|
|
1346
|
-
if (
|
|
1367
|
+
if (isTopLevelWhenThereIsAnIncludedGroup(groupName)) {
|
|
1347
1368
|
return true;
|
|
1348
1369
|
}
|
|
1349
1370
|
// if field is only'ed
|
|
@@ -1352,39 +1373,13 @@ function isExcluded(testObject) {
|
|
|
1352
1373
|
// If there is _ANY_ `only`ed test (and we already know this one isn't) return true
|
|
1353
1374
|
if (hasIncludedTests(keyTests)) {
|
|
1354
1375
|
// Check if inclusion rules for this field (`include` hook)
|
|
1376
|
+
// TODO: Check if this may need to be moved outside of the condition.
|
|
1377
|
+
// What if there are no included tests? This shouldn't run then?
|
|
1355
1378
|
return !optionalFunctionValue(inclusion[fieldName]);
|
|
1356
1379
|
}
|
|
1357
1380
|
// We're done here. This field is not excluded
|
|
1358
1381
|
return false;
|
|
1359
1382
|
}
|
|
1360
|
-
// eslint-disable-next-line max-statements
|
|
1361
|
-
function isMissingFromIncludedGroup(groupName) {
|
|
1362
|
-
var context$1 = context.useX();
|
|
1363
|
-
var exclusion = context$1.exclusion;
|
|
1364
|
-
if (!hasIncludedGroups()) {
|
|
1365
|
-
return false;
|
|
1366
|
-
}
|
|
1367
|
-
if (!groupName) {
|
|
1368
|
-
return true;
|
|
1369
|
-
}
|
|
1370
|
-
if (groupName in exclusion.groups) {
|
|
1371
|
-
if (exclusion.groups[groupName]) {
|
|
1372
|
-
return false;
|
|
1373
|
-
}
|
|
1374
|
-
return true;
|
|
1375
|
-
}
|
|
1376
|
-
return true;
|
|
1377
|
-
}
|
|
1378
|
-
function hasIncludedGroups() {
|
|
1379
|
-
var context$1 = context.useX();
|
|
1380
|
-
var exclusion = context$1.exclusion;
|
|
1381
|
-
for (var group in exclusion.groups) {
|
|
1382
|
-
if (exclusion.groups[group]) {
|
|
1383
|
-
return true;
|
|
1384
|
-
}
|
|
1385
|
-
}
|
|
1386
|
-
return false;
|
|
1387
|
-
}
|
|
1388
1383
|
/**
|
|
1389
1384
|
* Checks whether a given group is excluded from running.
|
|
1390
1385
|
*/
|
|
@@ -1399,13 +1394,8 @@ function isGroupExcluded(groupName) {
|
|
|
1399
1394
|
return keyGroups[groupName] === false;
|
|
1400
1395
|
}
|
|
1401
1396
|
// Group is not present
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
if (keyGroups[group] === true) {
|
|
1405
|
-
return true;
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
|
-
return false;
|
|
1397
|
+
// Return whether other groups are included
|
|
1398
|
+
return hasIncludedGroups();
|
|
1409
1399
|
}
|
|
1410
1400
|
/**
|
|
1411
1401
|
* Adds fields to a specified exclusion group.
|
|
@@ -1434,6 +1424,24 @@ function hasIncludedTests(keyTests) {
|
|
|
1434
1424
|
}
|
|
1435
1425
|
return false;
|
|
1436
1426
|
}
|
|
1427
|
+
// are we not in a group and there is an included group?
|
|
1428
|
+
function isTopLevelWhenThereIsAnIncludedGroup(groupName) {
|
|
1429
|
+
if (!hasIncludedGroups()) {
|
|
1430
|
+
return false;
|
|
1431
|
+
}
|
|
1432
|
+
// Return whether there's an included group, and we're not inside a group
|
|
1433
|
+
return !groupName;
|
|
1434
|
+
}
|
|
1435
|
+
function hasIncludedGroups() {
|
|
1436
|
+
var context$1 = context.useX();
|
|
1437
|
+
var exclusion = context$1.exclusion;
|
|
1438
|
+
for (var group in exclusion.groups) {
|
|
1439
|
+
if (exclusion.groups[group]) {
|
|
1440
|
+
return true;
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
return false;
|
|
1444
|
+
}
|
|
1437
1445
|
|
|
1438
1446
|
/**
|
|
1439
1447
|
* Runs tests within a group so that they can be controlled or queried separately.
|
|
@@ -1459,16 +1467,18 @@ function groupErrorMsg(error) {
|
|
|
1459
1467
|
function include(fieldName) {
|
|
1460
1468
|
var context$1 = context.useX();
|
|
1461
1469
|
var inclusion = context$1.inclusion, exclusion = context$1.exclusion;
|
|
1462
|
-
|
|
1463
|
-
return { when: when };
|
|
1464
|
-
}
|
|
1470
|
+
invariant(isStringValue(fieldName));
|
|
1465
1471
|
inclusion[fieldName] = defaultTo(exclusion.tests[fieldName], true);
|
|
1466
1472
|
return { when: when };
|
|
1467
1473
|
function when(condition) {
|
|
1468
1474
|
var context$1 = context.useX();
|
|
1469
1475
|
var inclusion = context$1.inclusion, exclusion = context$1.exclusion;
|
|
1476
|
+
// This callback will run as part of the "isExcluded" series of checks
|
|
1470
1477
|
inclusion[fieldName] = function () {
|
|
1471
1478
|
if (hasOwnProperty(exclusion.tests, fieldName)) {
|
|
1479
|
+
// I suspect this code is technically unreachable because
|
|
1480
|
+
// if there are any skip/only rules applied to the current
|
|
1481
|
+
// field, the "isExcluded" function will have already bailed
|
|
1472
1482
|
return defaultTo(exclusion.tests[fieldName], true);
|
|
1473
1483
|
}
|
|
1474
1484
|
if (isStringValue(condition)) {
|
|
@@ -1502,7 +1512,7 @@ function eager() {
|
|
|
1502
1512
|
setMode(Modes.EAGER);
|
|
1503
1513
|
}
|
|
1504
1514
|
function shouldSkipBasedOnMode(testObject) {
|
|
1505
|
-
if (isEager() &&
|
|
1515
|
+
if (isEager() && hasErrorsByTestObjects(testObject.fieldName))
|
|
1506
1516
|
return true;
|
|
1507
1517
|
return false;
|
|
1508
1518
|
}
|
|
@@ -1551,22 +1561,21 @@ function isOmitted() {
|
|
|
1551
1561
|
* });
|
|
1552
1562
|
*/
|
|
1553
1563
|
function optional(optionals) {
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1564
|
+
// When the optional is given as a string or a list of strings
|
|
1565
|
+
// we just add them to the list of optional fields.
|
|
1566
|
+
if (isArray(optionals) || isStringValue(optionals)) {
|
|
1567
|
+
asArray(optionals).forEach(function (optionalField) {
|
|
1568
|
+
useSetOptionalField(optionalField, [true, false]);
|
|
1569
|
+
});
|
|
1570
|
+
}
|
|
1571
|
+
else {
|
|
1572
|
+
// if it's an object, we iterate over the keys and add them to the list
|
|
1573
|
+
var optionalFunctions = optionals;
|
|
1574
|
+
for (var field in optionalFunctions) {
|
|
1575
|
+
var predicate = optionalFunctions[field];
|
|
1576
|
+
useSetOptionalField(field, [predicate, false]);
|
|
1567
1577
|
}
|
|
1568
|
-
|
|
1569
|
-
});
|
|
1578
|
+
}
|
|
1570
1579
|
}
|
|
1571
1580
|
|
|
1572
1581
|
/*! *****************************************************************************
|
|
@@ -1639,6 +1648,8 @@ function runAsyncTest(testObject) {
|
|
|
1639
1648
|
asyncTest.then(done, fail);
|
|
1640
1649
|
}
|
|
1641
1650
|
catch (e) {
|
|
1651
|
+
// We will probably never get here, unless the consumer uses a buggy custom Promise
|
|
1652
|
+
// implementation that behaves differently than the native one, or if they for some
|
|
1642
1653
|
fail();
|
|
1643
1654
|
}
|
|
1644
1655
|
}
|
|
@@ -1647,22 +1658,7 @@ function runAsyncTest(testObject) {
|
|
|
1647
1658
|
* Runs sync tests - or extracts promise.
|
|
1648
1659
|
*/
|
|
1649
1660
|
function runSyncTest(testObject) {
|
|
1650
|
-
return context.run({ currentTest: testObject }, function () {
|
|
1651
|
-
var result;
|
|
1652
|
-
try {
|
|
1653
|
-
result = testObject.testFn();
|
|
1654
|
-
}
|
|
1655
|
-
catch (e) {
|
|
1656
|
-
if (shouldUseErrorAsMessage(testObject.message, e)) {
|
|
1657
|
-
testObject.message = e;
|
|
1658
|
-
}
|
|
1659
|
-
result = false;
|
|
1660
|
-
}
|
|
1661
|
-
if (result === false) {
|
|
1662
|
-
testObject.fail();
|
|
1663
|
-
}
|
|
1664
|
-
return result;
|
|
1665
|
-
});
|
|
1661
|
+
return context.run({ currentTest: testObject }, function () { return testObject.run(); });
|
|
1666
1662
|
}
|
|
1667
1663
|
|
|
1668
1664
|
/**
|
|
@@ -1881,7 +1877,7 @@ function warn() {
|
|
|
1881
1877
|
ctx.currentTest.warn();
|
|
1882
1878
|
}
|
|
1883
1879
|
|
|
1884
|
-
var VERSION = "4.3.
|
|
1880
|
+
var VERSION = "4.3.3";
|
|
1885
1881
|
|
|
1886
1882
|
Object.defineProperty(exports, 'enforce', {
|
|
1887
1883
|
enumerable: true,
|