vest 4.3.1 → 4.3.2-dev-2805e3
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 +121 -134
- 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 +121 -134
- 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 +128 -141
- 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 +10 -6
|
@@ -4,13 +4,6 @@ function isFunction(value) {
|
|
|
4
4
|
return typeof value === 'function';
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* A safe hasOwnProperty access
|
|
9
|
-
*/
|
|
10
|
-
function hasOwnProperty(obj, key) {
|
|
11
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
7
|
function optionalFunctionValue(value) {
|
|
15
8
|
var args = [];
|
|
16
9
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
@@ -19,6 +12,18 @@ function optionalFunctionValue(value) {
|
|
|
19
12
|
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
20
13
|
}
|
|
21
14
|
|
|
15
|
+
function defaultTo(callback, defaultValue) {
|
|
16
|
+
var _a;
|
|
17
|
+
return (_a = optionalFunctionValue(callback)) !== null && _a !== void 0 ? _a : defaultValue;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A safe hasOwnProperty access
|
|
22
|
+
*/
|
|
23
|
+
function hasOwnProperty(obj, key) {
|
|
24
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
25
|
+
}
|
|
26
|
+
|
|
22
27
|
function invariant(condition,
|
|
23
28
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
24
29
|
message) {
|
|
@@ -86,22 +91,20 @@ function parse(res) {
|
|
|
86
91
|
return res.testCount === 0 || !selectors.tested(fieldName);
|
|
87
92
|
}
|
|
88
93
|
function isValid(fieldName) {
|
|
89
|
-
var _a
|
|
90
|
-
return
|
|
94
|
+
var _a;
|
|
95
|
+
return fieldName ? Boolean((_a = res.tests[fieldName]) === null || _a === void 0 ? void 0 : _a.valid) : res.valid;
|
|
91
96
|
}
|
|
92
97
|
function hasWarnings(fieldName) {
|
|
93
|
-
return hasFailures(
|
|
98
|
+
return hasFailures(SeverityCount.WARN_COUNT, fieldName);
|
|
94
99
|
}
|
|
95
100
|
function hasErrors(fieldName) {
|
|
96
|
-
return hasFailures(
|
|
101
|
+
return hasFailures(SeverityCount.ERROR_COUNT, fieldName);
|
|
102
|
+
}
|
|
103
|
+
function hasFailures(countKey, fieldName) {
|
|
104
|
+
var _a;
|
|
105
|
+
var failureCount = defaultTo(fieldName ? (_a = res.tests[fieldName]) === null || _a === void 0 ? void 0 : _a[countKey] : res[countKey], 0);
|
|
106
|
+
return isPositive(failureCount);
|
|
97
107
|
}
|
|
98
|
-
}
|
|
99
|
-
function hasFailures(res, countKey, fieldName) {
|
|
100
|
-
var _a, _b, _c;
|
|
101
|
-
var failureCount = fieldName
|
|
102
|
-
? (_b = (_a = res.tests) === null || _a === void 0 ? void 0 : _a[fieldName]) === null || _b === void 0 ? void 0 : _b[countKey]
|
|
103
|
-
: (_c = res[countKey]) !== null && _c !== void 0 ? _c : 0;
|
|
104
|
-
return isPositive(failureCount);
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function t(t){return"function"==typeof t}function n(
|
|
1
|
+
"use strict";function t(t){return"function"==typeof t}function n(n){for(var r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];return t(n)?n.apply(void 0,r):n}function r(t,n){return Object.prototype.hasOwnProperty.call(t,n)}function e(t){var n=Number(t);return!(isNaN(parseFloat(String(t)))||isNaN(Number(t))||!isFinite(n))}function u(t){return function(t,n){return e(t)&&e(n)&&Number(t)>Number(n)}(t,0)}var o,i,s;function a(t){function e(r,e){var o;return u(r=function(t,r){var e;return null!==(e=n(t))&&void 0!==e?e:r}(e?null===(o=t.tests[e])||void 0===o?void 0:o[r]:t[r],0))}!function(t,r){if(!t)throw r instanceof String?r.valueOf():Error(r?n(r):r)}(t&&r(t,"valid"),"Vest parser: expected argument at position 0 to be Vest's result object.");var o={},i={invalid:function(t){return e(s.ERROR_COUNT,t)},tested:function(n){return n?r(o,n)?o[n]:(o[n]=r(t.tests,n)&&u(t.tests[n].testCount),i.tested(n)):u(t.testCount)},untested:function(n){return 0===t.testCount||!i.tested(n)},valid:function(n){var r;return n?!(null===(r=t.tests[n])||void 0===r||!r.valid):t.valid},warning:function(t){return e(s.WARN_COUNT,t)}};return i}(i=o||(o={})).WARNINGS="warnings",i.ERRORS="errors",function(t){t.ERROR_COUNT="errorCount",t.WARN_COUNT="warnCount"}(s||(s={})),module.exports=function(n,r){void 0===r&&(r={});var e=a(n);return function(n){var u,o=[];for(u in r){var i=u;t(e[i])&&e[i](n)&&o.push(r[i])}return o.join(" ")}};
|
|
@@ -133,13 +133,13 @@ function oneOf(value) {
|
|
|
133
133
|
}
|
|
134
134
|
var passing = [];
|
|
135
135
|
rules.some(function (rule) {
|
|
136
|
-
if (longerThan(passing, REQUIRED_COUNT)) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
136
|
var res = runLazyRule(rule, value);
|
|
140
137
|
if (res.pass) {
|
|
141
138
|
passing.push(res);
|
|
142
139
|
}
|
|
140
|
+
if (longerThan(passing, REQUIRED_COUNT)) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
143
|
});
|
|
144
144
|
return ruleReturn(lengthEquals(passing, REQUIRED_COUNT));
|
|
145
145
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var n=require("n4s");function r(n,r){function t(n){u=!0,e=n}for(var u=!1,e=null,f=0;f<n.length;f++)if(r(n[f],t,f),u)return e}function t(n){return"function"==typeof n}function u(n,r){var u;return null!==(u=function(n){for(var r=[],u=1;u<arguments.length;u++)r[u-1]=arguments[u];return t(n)?n.apply(void 0,r):n}(n))&&void 0!==u?u:r}function e(n,r){return n={pass:n},r&&(n.message=r),n}function f(){return e(!1)}function o(n){return u(n,f())}function i(n){return u(n,e(!0))}function c(n,r){try{return n.run(r)}catch(n){return f()}}function a(n){var r=Number(n);return!(isNaN(parseFloat(String(n)))||isNaN(Number(n))||!isFinite(r))}function s(n,r){return function(n,r){return a(n)&&a(r)&&Number(n)===Number(r)}(n.length,r)}function l(n,r){return function(n,r){return a(n)&&a(r)&&Number(n)>Number(r)}(n.length,r)}n.enforce.extend({allOf:function(n){for(var t=[],u=1;u<arguments.length;u++)t[u-1]=arguments[u];return i(r(t,(function(r,t){(r=c(r,n)).pass||t(r)})))},anyOf:function(n){for(var t=[],u=1;u<arguments.length;u++)t[u-1]=arguments[u];return o(r(t,(function(r,t){(r=c(r,n)).pass&&t(r)})))},noneOf:function(n){for(var t=[],u=1;u<arguments.length;u++)t[u-1]=arguments[u];return i(r(t,(function(r,t){c(r,n).pass&&t(f())})))},oneOf:function(n){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];var u=[];return r.some((function(r){if(
|
|
1
|
+
"use strict";var n=require("n4s");function r(n,r){function t(n){u=!0,e=n}for(var u=!1,e=null,f=0;f<n.length;f++)if(r(n[f],t,f),u)return e}function t(n){return"function"==typeof n}function u(n,r){var u;return null!==(u=function(n){for(var r=[],u=1;u<arguments.length;u++)r[u-1]=arguments[u];return t(n)?n.apply(void 0,r):n}(n))&&void 0!==u?u:r}function e(n,r){return n={pass:n},r&&(n.message=r),n}function f(){return e(!1)}function o(n){return u(n,f())}function i(n){return u(n,e(!0))}function c(n,r){try{return n.run(r)}catch(n){return f()}}function a(n){var r=Number(n);return!(isNaN(parseFloat(String(n)))||isNaN(Number(n))||!isFinite(r))}function s(n,r){return function(n,r){return a(n)&&a(r)&&Number(n)===Number(r)}(n.length,r)}function l(n,r){return function(n,r){return a(n)&&a(r)&&Number(n)>Number(r)}(n.length,r)}n.enforce.extend({allOf:function(n){for(var t=[],u=1;u<arguments.length;u++)t[u-1]=arguments[u];return i(r(t,(function(r,t){(r=c(r,n)).pass||t(r)})))},anyOf:function(n){for(var t=[],u=1;u<arguments.length;u++)t[u-1]=arguments[u];return o(r(t,(function(r,t){(r=c(r,n)).pass&&t(r)})))},noneOf:function(n){for(var t=[],u=1;u<arguments.length;u++)t[u-1]=arguments[u];return i(r(t,(function(r,t){c(r,n).pass&&t(f())})))},oneOf:function(n){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];var u=[];return r.some((function(r){if((r=c(r,n)).pass&&u.push(r),l(u,1))return!1})),e(s(u,1))}});
|
|
@@ -2,13 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* A safe hasOwnProperty access
|
|
7
|
-
*/
|
|
8
|
-
function hasOwnProperty(obj, key) {
|
|
9
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
5
|
function isFunction(value) {
|
|
13
6
|
return typeof value === 'function';
|
|
14
7
|
}
|
|
@@ -21,6 +14,18 @@ function optionalFunctionValue(value) {
|
|
|
21
14
|
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
22
15
|
}
|
|
23
16
|
|
|
17
|
+
function defaultTo(callback, defaultValue) {
|
|
18
|
+
var _a;
|
|
19
|
+
return (_a = optionalFunctionValue(callback)) !== null && _a !== void 0 ? _a : defaultValue;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A safe hasOwnProperty access
|
|
24
|
+
*/
|
|
25
|
+
function hasOwnProperty(obj, key) {
|
|
26
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
27
|
+
}
|
|
28
|
+
|
|
24
29
|
function invariant(condition,
|
|
25
30
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
26
31
|
message) {
|
|
@@ -88,22 +93,20 @@ function parse(res) {
|
|
|
88
93
|
return res.testCount === 0 || !selectors.tested(fieldName);
|
|
89
94
|
}
|
|
90
95
|
function isValid(fieldName) {
|
|
91
|
-
var _a
|
|
92
|
-
return
|
|
96
|
+
var _a;
|
|
97
|
+
return fieldName ? Boolean((_a = res.tests[fieldName]) === null || _a === void 0 ? void 0 : _a.valid) : res.valid;
|
|
93
98
|
}
|
|
94
99
|
function hasWarnings(fieldName) {
|
|
95
|
-
return hasFailures(
|
|
100
|
+
return hasFailures(SeverityCount.WARN_COUNT, fieldName);
|
|
96
101
|
}
|
|
97
102
|
function hasErrors(fieldName) {
|
|
98
|
-
return hasFailures(
|
|
103
|
+
return hasFailures(SeverityCount.ERROR_COUNT, fieldName);
|
|
104
|
+
}
|
|
105
|
+
function hasFailures(countKey, fieldName) {
|
|
106
|
+
var _a;
|
|
107
|
+
var failureCount = defaultTo(fieldName ? (_a = res.tests[fieldName]) === null || _a === void 0 ? void 0 : _a[countKey] : res[countKey], 0);
|
|
108
|
+
return isPositive(failureCount);
|
|
99
109
|
}
|
|
100
|
-
}
|
|
101
|
-
function hasFailures(res, countKey, fieldName) {
|
|
102
|
-
var _a, _b, _c;
|
|
103
|
-
var failureCount = fieldName
|
|
104
|
-
? (_b = (_a = res.tests) === null || _a === void 0 ? void 0 : _a[fieldName]) === null || _b === void 0 ? void 0 : _b[countKey]
|
|
105
|
-
: (_c = res[countKey]) !== null && _c !== void 0 ? _c : 0;
|
|
106
|
-
return isPositive(failureCount);
|
|
107
110
|
}
|
|
108
111
|
|
|
109
112
|
exports.parse = parse;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function t(t
|
|
1
|
+
"use strict";function t(t){return"function"==typeof t}function n(n){for(var r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];return t(n)?n.apply(void 0,r):n}function r(t,n){return Object.prototype.hasOwnProperty.call(t,n)}function e(t){var n=Number(t);return!(isNaN(parseFloat(String(t)))||isNaN(Number(t))||!isFinite(n))}function u(t){return function(t,n){return e(t)&&e(n)&&Number(t)>Number(n)}(t,0)}var o,i,s;Object.defineProperty(exports,"__esModule",{value:!0}),(i=o||(o={})).WARNINGS="warnings",i.ERRORS="errors",function(t){t.ERROR_COUNT="errorCount",t.WARN_COUNT="warnCount"}(s||(s={})),exports.parse=function(t){function e(r,e){var o;return u(r=function(t,r){var e;return null!==(e=n(t))&&void 0!==e?e:r}(e?null===(o=t.tests[e])||void 0===o?void 0:o[r]:t[r],0))}!function(t,r){if(!t)throw r instanceof String?r.valueOf():Error(r?n(r):r)}(t&&r(t,"valid"),"Vest parser: expected argument at position 0 to be Vest's result object.");var o={},i={invalid:function(t){return e(s.ERROR_COUNT,t)},tested:function(n){return n?r(o,n)?o[n]:(o[n]=r(t.tests,n)&&u(t.tests[n].testCount),i.tested(n)):u(t.testCount)},untested:function(n){return 0===t.testCount||!i.tested(n)},valid:function(n){var r;return n?!(null===(r=t.tests[n])||void 0===r||!r.valid):t.valid},warning:function(t){return e(s.WARN_COUNT,t)}};return i};
|
|
@@ -300,18 +300,6 @@ function useAllIncomplete() {
|
|
|
300
300
|
return testObject.isPending() ? testObject : null;
|
|
301
301
|
}));
|
|
302
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
|
-
}, {});
|
|
314
|
-
}
|
|
315
303
|
var flatCache = createCache();
|
|
316
304
|
function useTestsFlat() {
|
|
317
305
|
var current = useTestObjects()[0].current;
|
|
@@ -624,9 +612,7 @@ function useRetainTestKey(key, testObject) {
|
|
|
624
612
|
|
|
625
613
|
function isolate(_a, callback) {
|
|
626
614
|
var _b = _a.type, type = _b === void 0 ? IsolateTypes.DEFAULT : _b;
|
|
627
|
-
|
|
628
|
-
return;
|
|
629
|
-
}
|
|
615
|
+
invariant(isFunction(callback));
|
|
630
616
|
var keys = {
|
|
631
617
|
current: {},
|
|
632
618
|
prev: {}
|
|
@@ -656,6 +642,11 @@ var SeverityCount;
|
|
|
656
642
|
SeverityCount["ERROR_COUNT"] = "errorCount";
|
|
657
643
|
SeverityCount["WARN_COUNT"] = "warnCount";
|
|
658
644
|
})(SeverityCount || (SeverityCount = {}));
|
|
645
|
+
function countKeyBySeverity(severity) {
|
|
646
|
+
return severity === Severity.ERRORS
|
|
647
|
+
? SeverityCount.ERROR_COUNT
|
|
648
|
+
: SeverityCount.WARN_COUNT;
|
|
649
|
+
}
|
|
659
650
|
|
|
660
651
|
/**
|
|
661
652
|
* A safe hasOwnProperty access
|
|
@@ -681,7 +672,7 @@ function isEmpty(value) {
|
|
|
681
672
|
else if (typeof value === 'object') {
|
|
682
673
|
return lengthEquals(Object.keys(value), 0);
|
|
683
674
|
}
|
|
684
|
-
return
|
|
675
|
+
return false;
|
|
685
676
|
}
|
|
686
677
|
var isNotEmpty = bindNot(isEmpty);
|
|
687
678
|
|
|
@@ -703,10 +694,23 @@ function nonMatchingSeverityProfile(severity, testObject) {
|
|
|
703
694
|
return either(severity === Severity.WARNINGS, testObject.warns());
|
|
704
695
|
}
|
|
705
696
|
|
|
697
|
+
/**
|
|
698
|
+
* The difference between this file and hasFailures is that hasFailures uses the static
|
|
699
|
+
* summary object, while this one uses the actual validation state
|
|
700
|
+
*/
|
|
701
|
+
function hasErrorsByTestObjects(fieldName) {
|
|
702
|
+
return hasFailuresByTestObjects(Severity.ERRORS, fieldName);
|
|
703
|
+
}
|
|
704
|
+
function hasFailuresByTestObjects(severityKey, fieldName) {
|
|
705
|
+
var testObjects = useTestsFlat();
|
|
706
|
+
return testObjects.some(function (testObject) {
|
|
707
|
+
return hasFailuresByTestObject(testObject, severityKey, fieldName);
|
|
708
|
+
});
|
|
709
|
+
}
|
|
706
710
|
/**
|
|
707
711
|
* Determines whether a certain test profile has failures.
|
|
708
712
|
*/
|
|
709
|
-
function
|
|
713
|
+
function hasFailuresByTestObject(testObject, severityKey, fieldName) {
|
|
710
714
|
if (!testObject.hasFailures()) {
|
|
711
715
|
return false;
|
|
712
716
|
}
|
|
@@ -719,51 +723,29 @@ function hasFailuresLogic(testObject, severityKey, fieldName) {
|
|
|
719
723
|
return true;
|
|
720
724
|
}
|
|
721
725
|
|
|
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
726
|
// eslint-disable-next-line max-statements, complexity
|
|
742
727
|
function shouldAddValidProp(fieldName) {
|
|
743
728
|
if (fieldIsOmitted(fieldName)) {
|
|
744
729
|
return true;
|
|
745
730
|
}
|
|
746
|
-
if (
|
|
731
|
+
if (hasErrorsByTestObjects(fieldName)) {
|
|
747
732
|
return false;
|
|
748
733
|
}
|
|
749
734
|
var testObjects = useTestsFlat();
|
|
750
735
|
if (isEmpty(testObjects)) {
|
|
751
736
|
return false;
|
|
752
737
|
}
|
|
753
|
-
if (fieldDoesNotExist(fieldName)) {
|
|
754
|
-
return false;
|
|
755
|
-
}
|
|
756
738
|
if (hasNonOptionalIncomplete(fieldName)) {
|
|
757
739
|
return false;
|
|
758
740
|
}
|
|
759
741
|
return noMissingTests(fieldName);
|
|
760
742
|
}
|
|
761
743
|
function fieldIsOmitted(fieldName) {
|
|
762
|
-
var omittedFields = useOmittedFields();
|
|
763
744
|
if (!fieldName) {
|
|
764
745
|
return false;
|
|
765
746
|
}
|
|
766
|
-
|
|
747
|
+
var flatTests = useTestsFlat();
|
|
748
|
+
return flatTests.some(function (testObject) { return testObject.fieldName === fieldName && testObject.isOmitted(); });
|
|
767
749
|
}
|
|
768
750
|
function hasNonOptionalIncomplete(fieldName) {
|
|
769
751
|
var optionalFields = useOptionalFields()[0];
|
|
@@ -774,11 +756,6 @@ function hasNonOptionalIncomplete(fieldName) {
|
|
|
774
756
|
return optionalFields[testObject.fieldName] !== true;
|
|
775
757
|
}));
|
|
776
758
|
}
|
|
777
|
-
function fieldDoesNotExist(fieldName) {
|
|
778
|
-
var testObjects = useTestsFlat();
|
|
779
|
-
return (!!fieldName &&
|
|
780
|
-
!testObjects.find(function (testObject) { return testObject.fieldName === fieldName; }));
|
|
781
|
-
}
|
|
782
759
|
function noMissingTests(fieldName) {
|
|
783
760
|
var testObjects = useTestsFlat();
|
|
784
761
|
var optionalFields = useOptionalFields()[0];
|
|
@@ -792,6 +769,11 @@ function noMissingTests(fieldName) {
|
|
|
792
769
|
});
|
|
793
770
|
}
|
|
794
771
|
|
|
772
|
+
function useSummary() {
|
|
773
|
+
var summary = context.useX().summary;
|
|
774
|
+
invariant(summary);
|
|
775
|
+
return summary;
|
|
776
|
+
}
|
|
795
777
|
/**
|
|
796
778
|
* Reads the testObjects list and gets full validation result from it.
|
|
797
779
|
*/
|
|
@@ -840,13 +822,9 @@ function countFailures(summary) {
|
|
|
840
822
|
}
|
|
841
823
|
return summary;
|
|
842
824
|
}
|
|
843
|
-
/**
|
|
844
|
-
* Appends the test to a results object
|
|
845
|
-
*/
|
|
846
|
-
// eslint-disable-next-line max-statements
|
|
847
825
|
function appendTestObject(summaryKey, testObject) {
|
|
848
826
|
var fieldName = testObject.fieldName, message = testObject.message;
|
|
849
|
-
summaryKey[fieldName] = summaryKey[fieldName] ||
|
|
827
|
+
summaryKey[fieldName] = summaryKey[fieldName] || baseTestStats();
|
|
850
828
|
var testKey = summaryKey[fieldName];
|
|
851
829
|
if (testObject.isNonActionable())
|
|
852
830
|
return testKey;
|
|
@@ -859,18 +837,13 @@ function appendTestObject(summaryKey, testObject) {
|
|
|
859
837
|
}
|
|
860
838
|
return testKey;
|
|
861
839
|
function incrementFailures(severity) {
|
|
862
|
-
var countKey =
|
|
840
|
+
var countKey = countKeyBySeverity(severity);
|
|
863
841
|
testKey[countKey]++;
|
|
864
842
|
if (message) {
|
|
865
843
|
testKey[severity] = (testKey[severity] || []).concat(message);
|
|
866
844
|
}
|
|
867
845
|
}
|
|
868
846
|
}
|
|
869
|
-
function getCountKey(severity) {
|
|
870
|
-
return severity === Severity.ERRORS
|
|
871
|
-
? SeverityCount.ERROR_COUNT
|
|
872
|
-
: SeverityCount.WARN_COUNT;
|
|
873
|
-
}
|
|
874
847
|
function baseStats() {
|
|
875
848
|
return {
|
|
876
849
|
errorCount: 0,
|
|
@@ -878,6 +851,12 @@ function baseStats() {
|
|
|
878
851
|
testCount: 0
|
|
879
852
|
};
|
|
880
853
|
}
|
|
854
|
+
function baseTestStats() {
|
|
855
|
+
return assign(baseStats(), {
|
|
856
|
+
errors: [],
|
|
857
|
+
warnings: []
|
|
858
|
+
});
|
|
859
|
+
}
|
|
881
860
|
|
|
882
861
|
// calls collectAll or getByFieldName depending on whether fieldName is provided
|
|
883
862
|
function gatherFailures(testGroup, severityKey, fieldName) {
|
|
@@ -890,10 +869,11 @@ function getByFieldName(testGroup, severityKey, fieldName) {
|
|
|
890
869
|
return ((_a = testGroup === null || testGroup === void 0 ? void 0 : testGroup[fieldName]) === null || _a === void 0 ? void 0 : _a[severityKey]) || [];
|
|
891
870
|
}
|
|
892
871
|
function collectAll(testGroup, severityKey) {
|
|
893
|
-
var _a;
|
|
894
872
|
var output = {};
|
|
895
873
|
for (var field in testGroup) {
|
|
896
|
-
|
|
874
|
+
// We will probably never get to the fallback array
|
|
875
|
+
// leaving it just in case the implementation changes
|
|
876
|
+
output[field] = testGroup[field][severityKey] || [];
|
|
897
877
|
}
|
|
898
878
|
return output;
|
|
899
879
|
}
|
|
@@ -908,8 +888,7 @@ function getWarnings(fieldName) {
|
|
|
908
888
|
* @returns suite or field's errors or warnings.
|
|
909
889
|
*/
|
|
910
890
|
function getFailures(severityKey, fieldName) {
|
|
911
|
-
var summary =
|
|
912
|
-
invariant(summary);
|
|
891
|
+
var summary = useSummary();
|
|
913
892
|
return gatherFailures(summary.tests, severityKey, fieldName);
|
|
914
893
|
}
|
|
915
894
|
|
|
@@ -920,27 +899,59 @@ function getWarningsByGroup(groupName, fieldName) {
|
|
|
920
899
|
return getFailuresByGroup(groupName, Severity.WARNINGS, fieldName);
|
|
921
900
|
}
|
|
922
901
|
function getFailuresByGroup(groupName, severityKey, fieldName) {
|
|
923
|
-
var summary =
|
|
924
|
-
invariant(summary);
|
|
902
|
+
var summary = useSummary();
|
|
925
903
|
return gatherFailures(summary.groups[groupName], severityKey, fieldName);
|
|
926
904
|
}
|
|
927
905
|
|
|
906
|
+
function isPositive(value) {
|
|
907
|
+
return greaterThan(value, 0);
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
function hasErrors(fieldName) {
|
|
911
|
+
return hasFailures(SeverityCount.ERROR_COUNT, fieldName);
|
|
912
|
+
}
|
|
913
|
+
function hasWarnings(fieldName) {
|
|
914
|
+
return hasFailures(SeverityCount.WARN_COUNT, fieldName);
|
|
915
|
+
}
|
|
916
|
+
function hasFailures(severityCount, fieldName) {
|
|
917
|
+
var _a;
|
|
918
|
+
var summary = useSummary();
|
|
919
|
+
if (fieldName) {
|
|
920
|
+
return isPositive((_a = summary.tests[fieldName]) === null || _a === void 0 ? void 0 : _a[severityCount]);
|
|
921
|
+
}
|
|
922
|
+
return isPositive(summary[severityCount]);
|
|
923
|
+
}
|
|
924
|
+
|
|
928
925
|
function hasErrorsByGroup(groupName, fieldName) {
|
|
929
|
-
return
|
|
926
|
+
return hasFailuresByGroup(Severity.ERRORS, groupName, fieldName);
|
|
930
927
|
}
|
|
931
928
|
function hasWarningsByGroup(groupName, fieldName) {
|
|
932
|
-
return
|
|
929
|
+
return hasFailuresByGroup(Severity.WARNINGS, groupName, fieldName);
|
|
933
930
|
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
var
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
931
|
+
// eslint-disable-next-line max-statements
|
|
932
|
+
function hasFailuresByGroup(severityKey, groupName, fieldName) {
|
|
933
|
+
var _a, _b;
|
|
934
|
+
var summary = useSummary();
|
|
935
|
+
var severityCount = countKeyBySeverity(severityKey);
|
|
936
|
+
var group = summary.groups[groupName];
|
|
937
|
+
if (!group) {
|
|
938
|
+
return false;
|
|
939
|
+
}
|
|
940
|
+
if (fieldName) {
|
|
941
|
+
return isPositive((_a = group[fieldName]) === null || _a === void 0 ? void 0 : _a[severityCount]);
|
|
942
|
+
}
|
|
943
|
+
for (var field in group) {
|
|
944
|
+
if (isPositive((_b = group[field]) === null || _b === void 0 ? void 0 : _b[severityCount])) {
|
|
945
|
+
return true;
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
return false;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
function isValid(fieldName) {
|
|
952
|
+
var _a;
|
|
953
|
+
var summary = useSummary();
|
|
954
|
+
return fieldName ? Boolean((_a = summary.tests[fieldName]) === null || _a === void 0 ? void 0 : _a.valid) : summary.valid;
|
|
944
955
|
}
|
|
945
956
|
|
|
946
957
|
var cache$1 = createCache(1);
|
|
@@ -950,7 +961,7 @@ function produceSuiteResult() {
|
|
|
950
961
|
return cache$1([testObjects], context.bind(ctxRef, function () {
|
|
951
962
|
var summary = genTestsSummary();
|
|
952
963
|
var suiteName = useSuiteName();
|
|
953
|
-
var ref =
|
|
964
|
+
var ref = { summary: summary };
|
|
954
965
|
return assign(summary, {
|
|
955
966
|
getErrors: context.bind(ref, getErrors),
|
|
956
967
|
getErrorsByGroup: context.bind(ref, getErrorsByGroup),
|
|
@@ -1343,7 +1354,7 @@ function isExcluded(testObject) {
|
|
|
1343
1354
|
return keyTests[fieldName] === false;
|
|
1344
1355
|
}
|
|
1345
1356
|
}
|
|
1346
|
-
if (
|
|
1357
|
+
if (isTopLevelWhenThereIsAnIncludedGroup(groupName)) {
|
|
1347
1358
|
return true;
|
|
1348
1359
|
}
|
|
1349
1360
|
// if field is only'ed
|
|
@@ -1352,39 +1363,13 @@ function isExcluded(testObject) {
|
|
|
1352
1363
|
// If there is _ANY_ `only`ed test (and we already know this one isn't) return true
|
|
1353
1364
|
if (hasIncludedTests(keyTests)) {
|
|
1354
1365
|
// Check if inclusion rules for this field (`include` hook)
|
|
1366
|
+
// TODO: Check if this may need to be moved outside of the condition.
|
|
1367
|
+
// What if there are no included tests? This shouldn't run then?
|
|
1355
1368
|
return !optionalFunctionValue(inclusion[fieldName]);
|
|
1356
1369
|
}
|
|
1357
1370
|
// We're done here. This field is not excluded
|
|
1358
1371
|
return false;
|
|
1359
1372
|
}
|
|
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
1373
|
/**
|
|
1389
1374
|
* Checks whether a given group is excluded from running.
|
|
1390
1375
|
*/
|
|
@@ -1399,13 +1384,8 @@ function isGroupExcluded(groupName) {
|
|
|
1399
1384
|
return keyGroups[groupName] === false;
|
|
1400
1385
|
}
|
|
1401
1386
|
// Group is not present
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
if (keyGroups[group] === true) {
|
|
1405
|
-
return true;
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
|
-
return false;
|
|
1387
|
+
// Return whether other groups are included
|
|
1388
|
+
return hasIncludedGroups();
|
|
1409
1389
|
}
|
|
1410
1390
|
/**
|
|
1411
1391
|
* Adds fields to a specified exclusion group.
|
|
@@ -1434,6 +1414,24 @@ function hasIncludedTests(keyTests) {
|
|
|
1434
1414
|
}
|
|
1435
1415
|
return false;
|
|
1436
1416
|
}
|
|
1417
|
+
// are we not in a group and there is an included group?
|
|
1418
|
+
function isTopLevelWhenThereIsAnIncludedGroup(groupName) {
|
|
1419
|
+
if (!hasIncludedGroups()) {
|
|
1420
|
+
return false;
|
|
1421
|
+
}
|
|
1422
|
+
// Return whether there's an included group, and we're not inside a group
|
|
1423
|
+
return !groupName;
|
|
1424
|
+
}
|
|
1425
|
+
function hasIncludedGroups() {
|
|
1426
|
+
var context$1 = context.useX();
|
|
1427
|
+
var exclusion = context$1.exclusion;
|
|
1428
|
+
for (var group in exclusion.groups) {
|
|
1429
|
+
if (exclusion.groups[group]) {
|
|
1430
|
+
return true;
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
return false;
|
|
1434
|
+
}
|
|
1437
1435
|
|
|
1438
1436
|
/**
|
|
1439
1437
|
* Runs tests within a group so that they can be controlled or queried separately.
|
|
@@ -1459,16 +1457,18 @@ function groupErrorMsg(error) {
|
|
|
1459
1457
|
function include(fieldName) {
|
|
1460
1458
|
var context$1 = context.useX();
|
|
1461
1459
|
var inclusion = context$1.inclusion, exclusion = context$1.exclusion;
|
|
1462
|
-
|
|
1463
|
-
return { when: when };
|
|
1464
|
-
}
|
|
1460
|
+
invariant(isStringValue(fieldName));
|
|
1465
1461
|
inclusion[fieldName] = defaultTo(exclusion.tests[fieldName], true);
|
|
1466
1462
|
return { when: when };
|
|
1467
1463
|
function when(condition) {
|
|
1468
1464
|
var context$1 = context.useX();
|
|
1469
1465
|
var inclusion = context$1.inclusion, exclusion = context$1.exclusion;
|
|
1466
|
+
// This callback will run as part of the "isExcluded" series of checks
|
|
1470
1467
|
inclusion[fieldName] = function () {
|
|
1471
1468
|
if (hasOwnProperty(exclusion.tests, fieldName)) {
|
|
1469
|
+
// I suspect this code is technically unreachable because
|
|
1470
|
+
// if there are any skip/only rules applied to the current
|
|
1471
|
+
// field, the "isExcluded" function will have already bailed
|
|
1472
1472
|
return defaultTo(exclusion.tests[fieldName], true);
|
|
1473
1473
|
}
|
|
1474
1474
|
if (isStringValue(condition)) {
|
|
@@ -1502,7 +1502,7 @@ function eager() {
|
|
|
1502
1502
|
setMode(Modes.EAGER);
|
|
1503
1503
|
}
|
|
1504
1504
|
function shouldSkipBasedOnMode(testObject) {
|
|
1505
|
-
if (isEager() &&
|
|
1505
|
+
if (isEager() && hasErrorsByTestObjects(testObject.fieldName))
|
|
1506
1506
|
return true;
|
|
1507
1507
|
return false;
|
|
1508
1508
|
}
|
|
@@ -1639,6 +1639,8 @@ function runAsyncTest(testObject) {
|
|
|
1639
1639
|
asyncTest.then(done, fail);
|
|
1640
1640
|
}
|
|
1641
1641
|
catch (e) {
|
|
1642
|
+
// We will probably never get here, unless the consumer uses a buggy custom Promise
|
|
1643
|
+
// implementation that behaves differently than the native one, or if they for some
|
|
1642
1644
|
fail();
|
|
1643
1645
|
}
|
|
1644
1646
|
}
|
|
@@ -1647,22 +1649,7 @@ function runAsyncTest(testObject) {
|
|
|
1647
1649
|
* Runs sync tests - or extracts promise.
|
|
1648
1650
|
*/
|
|
1649
1651
|
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
|
-
});
|
|
1652
|
+
return context.run({ currentTest: testObject }, function () { return testObject.run(); });
|
|
1666
1653
|
}
|
|
1667
1654
|
|
|
1668
1655
|
/**
|
|
@@ -1881,7 +1868,7 @@ function warn() {
|
|
|
1881
1868
|
ctx.currentTest.warn();
|
|
1882
1869
|
}
|
|
1883
1870
|
|
|
1884
|
-
var VERSION = "4.3.
|
|
1871
|
+
var VERSION = "4.3.2-dev-2805e3";
|
|
1885
1872
|
|
|
1886
1873
|
Object.defineProperty(exports, 'enforce', {
|
|
1887
1874
|
enumerable: true,
|