vest 5.0.0-dev-9c596e → 5.0.0-dev-ec989a
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 +1 -2
- package/dist/cjs/classnames.production.js +1 -1
- package/dist/cjs/enforce/compose.development.js +1 -5
- package/dist/cjs/enforce/compose.production.js +1 -1
- package/dist/cjs/enforce/compounds.development.js +3 -6
- package/dist/cjs/enforce/compounds.production.js +1 -1
- package/dist/cjs/enforce/schema.development.js +3 -6
- package/dist/cjs/enforce/schema.production.js +1 -1
- package/dist/cjs/parser.development.js +1 -4
- package/dist/cjs/parser.production.js +1 -1
- package/dist/cjs/promisify.development.js +1 -2
- package/dist/cjs/promisify.production.js +1 -1
- package/dist/cjs/vest.development.js +596 -764
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/classnames.development.js +1 -2
- package/dist/es/classnames.production.js +1 -1
- package/dist/es/parser.development.js +1 -2
- package/dist/es/parser.production.js +1 -1
- package/dist/es/promisify.development.js +1 -2
- package/dist/es/promisify.production.js +1 -1
- package/dist/es/vest.development.js +591 -757
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/classnames.development.js +1 -2
- package/dist/umd/classnames.production.js +1 -1
- package/dist/umd/enforce/compose.development.js +1 -7
- package/dist/umd/enforce/compose.production.js +1 -1
- package/dist/umd/enforce/compounds.development.js +3 -6
- package/dist/umd/enforce/compounds.production.js +1 -1
- package/dist/umd/enforce/schema.development.js +3 -6
- package/dist/umd/enforce/schema.production.js +1 -1
- package/dist/umd/parser.development.js +1 -4
- package/dist/umd/parser.production.js +1 -1
- package/dist/umd/promisify.development.js +1 -2
- package/dist/umd/promisify.production.js +1 -1
- package/dist/umd/vest.development.js +599 -768
- package/dist/umd/vest.production.js +1 -1
- package/package.json +137 -136
- package/testUtils/TVestMock.ts +1 -1
- package/testUtils/asVestTest.ts +9 -0
- package/types/classnames.d.ts +82 -4
- package/types/classnames.d.ts.map +1 -1
- package/types/parser.d.ts +82 -4
- package/types/parser.d.ts.map +1 -1
- package/types/promisify.d.ts +82 -4
- package/types/promisify.d.ts.map +1 -1
- package/types/vest.d.ts +150 -138
- package/types/vest.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("n4s"),require("vest-utils"),require("context")):"function"==typeof define&&define.amd?define(["exports","n4s","vest-utils","context"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).vest={},t.n4s,t["vest-utils"],t.context)}(this,(function(t,e,n,i){"use strict";var s,r,o,u,a;function c(t,e,i){if(n.isNullish(t.children))return;let s=!1;for(const o of t.children){if(s)return;if((n.isNullish(i)||n.optionalFunctionValue(i,o))&&e(o,r),s)return;c(o,((t,n)=>{e(t,(()=>{n(),r()}))}),i)}function r(){s=!0}}function l(t,e,n){let i=!1;return c(t,((t,n)=>{e(t)&&(n(),i=!0)}),n),i}function d(t,e){let n=t;for(;n.parent;){if(e(n))return n;n=n.parent}return null}!function(t){t[t.Immediate=0]="Immediate",t[t.Delayed=1]="Delayed"}(s||(s={})),function(t){t.HOOK_CALLED_OUTSIDE="hook called outside of a running suite.",t.EXPECTED_VEST_TEST="Expected value to be an instance of IsolateTest",t.FIELD_NAME_REQUIRED="Field name must be passed",t.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION="Suite must be initialized with a function",t.NO_ACTIVE_ISOLATE="Not within an active isolate",t.PROMISIFY_REQUIRE_FUNCTION="Vest.Promisify must be called with a function",t.PARSER_EXPECT_RESULT_OBJECT="Vest parser: expected argument at position 0 to be Vest's result object.",t.WARN_MUST_BE_CALLED_FROM_TEST="Warn must be called from within the body of a test function",t.EACH_CALLBACK_MUST_BE_A_FUNCTION="Each must be called with a function",t.INVALID_PARAM_PASSED_TO_FUNCTION='Incompatible params passed to {fn_name} function. "{param}" must be of type {expected}',t.ENCOUNTERED_THE_SAME_KEY_TWICE='Encountered the same test key "{key}" twice. This may lead to tests overriding each other\'s results, or to tests being unexpectedly omitted.',t.TESTS_CALLED_IN_DIFFERENT_ORDER='Vest Critical Error: Tests called in different order than previous run.\n expected: {fieldName}\n received: {prevName}\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.',t.UNEXPECTED_TEST_REGISTRATION_ERROR="Unexpected error encountered during test registration.\n Please report this issue to Vest's Github repository.\n Test Object: {testObject}.\n Error: {error}."}(r||(r={})),function(t){t.TEST_RUN_STARTED="test_run_started",t.TEST_COMPLETED="test_completed",t.ALL_RUNNING_TESTS_FINISHED="all_running_tests_finished",t.REMOVE_FIELD="remove_field",t.RESET_FIELD="reset_field",t.RESET_SUITE="reset_suite",t.SUITE_RUN_STARTED="suite_run_started"}(o||(o={}));class f{static reconciler(t,e){return n.isNullish(e),t}static reconcile(t,e){var i;const s=Ct(),r=Dt();let o=r;s&&(o=null!==(i=null==r?void 0:r.at(yt()))&&void 0!==i?i:null);const u=this.reconciler(t,o);return n.invariant(u),Object.is(u,t)?[t,E(o,t,e)]:[u,u.output]}static removeAllNextNodesInIsolate(){const t=Ct(),e=Dt();e&&t&&e.slice(yt())}static handleCollision(t,e){return t.usesKey()?this.handleIsolateNodeWithKey(t):(this.nodeReorderDetected(t,e)&&this.onNodeReorder(t,e),e||t)}static nodeReorderDetected(t,e){return!(null!=t?t:e)}static onNodeReorder(t,e){return this.removeAllNextNodesInIsolate(),null!=t?t:e}static handleIsolateNodeWithKey(t){n.invariant(t.usesKey());const e=function(t){var e;if(n.isNullish(t))return null;const i=It().historyNode;return null!==(e=null==i?void 0:i.keys[t])&&void 0!==e?e:null}(t.key);let i=t;return n.isNullish(e)||(i=e),function(t,e){if(!t)return;const i=Ct();if(n.invariant(i,r.NO_ACTIVE_ISOLATE),n.isNullish(i.keys[t]))return void(i.keys[t]=e);n.deferThrow(n.text(r.ENCOUNTERED_THE_SAME_KEY_TWICE,{key:t}))}(t.key,t),i}}function E(t,e,n){const i=Pt(),s=Tt.run(Object.assign({historyNode:t,runtimeNode:e},!i&&{runtimeRoot:e}),(()=>n(e)));return e.output=s,s}class N{constructor(t){this.children=[],this.keys={},this.parent=null,this.key=null,this.allowReorder=!1}setParent(t){return this.parent=t,this}saveOutput(t){return this.output=t,this}setKey(t){return this.key=t,this}usesKey(){return n.isNotNullish(this.key)}addChild(t){n.invariant(this.children),this.children.push(t)}removeChild(t){var e,n;this.children=null!==(n=null===(e=this.children)||void 0===e?void 0:e.filter((e=>e!==t)))&&void 0!==n?n:null}slice(t){n.isNullish(this.children)||(this.children.length=t)}at(t){var e,n;return null!==(n=null===(e=this.children)||void 0===e?void 0:e[t])&&void 0!==n?n:null}cursor(){var t,e;return null!==(e=null===(t=this.children)||void 0===t?void 0:t.length)&&void 0!==e?e:0}shouldAllowReorder(){var t;return null!==(t=!!d(this,(t=>t.allowReorder)))&&void 0!==t&&t}get rootNode(){var t;return null!==(t=d(this,(t=>n.isNullish(t.parent))))&&void 0!==t?t:this}static create(t,e){return this.createImplementation(t,e)}static createImplementation(t,e){const n=Ct(),i=new this(e).setParent(n),[s,r]=this.reconciler.reconcile(i,t);return s.saveOutput(r),this.setNode(s),s}static setNode(t){const e=Ct();e?function(t){const e=Ct();n.invariant(e,r.NO_ACTIVE_ISOLATE),e.addChild(t)}(t):function(t){const e=Tt.useX(),[,n]=e.historyRoot();n(t)}(t),t.setParent(e)}static is(t){return t instanceof N}}function h(t,e){return!!e&&!T(t,e)}function T(t,e){return!(!e||t.fieldName!==e)}function R(t,e){return T(t,e.fieldName)&&t.groupName===e.groupName&&t.key===e.key}function S(t){return t===u.ERRORS?a.ERROR_COUNT:a.WARN_COUNT}N.reconciler=f,function(t){t.WARNINGS="warnings",t.ERRORS="errors"}(u||(u={})),function(t){t.ERROR_COUNT="errorCount",t.WARN_COUNT="warnCount"}(a||(a={}));const I=n.bindNot((function(t,e){return t.groupName===e}));function p(t){return function(t,e){return Et.someTests((n=>v(n,t,e)))}(u.ERRORS,t)}function v(t,e,i){return!!t.hasFailures()&&(!h(t,i)&&!function(t,e){return n.either(t===u.WARNINGS,e.warns())}(e,t))}var _;function m(){return function(t){const[e]=O();return e===t}(t.Modes.EAGER)}t.Modes=void 0,(_=t.Modes||(t.Modes={})).ALL="ALL",_.EAGER="EAGER";const g=i.createCascade(((e,i)=>i?null:n.assign({exclusion:{tests:{},groups:{}},inclusion:{},mode:n.tinyState.createTinyState(t.Modes.EAGER),testMemoCache:C},e)));function A(t){return g.useX(t).exclusion}function D(){return g.useX().inclusion}function O(){return g.useX().mode()}const C=n.cache(10);var y,P,F,U;class L{constructor(){this.errorCount=0,this.warnCount=0,this.testCount=0}}class W extends L{constructor(){super(...arguments),this[y]=[],this[P]=[],this.groups={},this.tests={},this.valid=!1}}function G(t){return!!Lt(t)||!Et.hasNoTests()&&(!p(t)&&(!function(t){return Et.someIncompleteTests((e=>k(e,t)))}(t)&&function(t){return Et.everyTest((e=>w(e,t)))}(t)))}function b(t,e){return!!Lt(e)||!function(t,e,n){return Et.someTests((i=>!I(i,e)&&v(i,t,n)))}(u.ERRORS,t,e)&&(!function(t,e){return Et.someIncompleteTests((n=>!I(n,t)&&k(n,e)))}(t,e)&&function(t,e){return Et.everyTest((n=>!!I(n,t)||w(n,e)))}(t,e))}function k(t,e){return!h(t,e)&&Lt(e)}function w(t,e){return!!h(t,e)||(function(t){var e;return(null===(e=Ft())||void 0===e?void 0:e.getOptionalField(t.fieldName).type)===s.Delayed&&t.awaitsResolution()}(t)||t.isTested()||t.isOmitted())}function M(){const t=new W;return Et.walkTests((e=>{t.tests=function(t,e){const{fieldName:n}=e,i=Object.assign({},t);return i[n]=x(i[n],e),i[n].valid=!1!==i[n].valid&&G(n),i}(t.tests,e),t.groups=function(t,e){const{groupName:n,fieldName:i}=e;if(!n)return t;const s=Object.assign({},t);return s[n]=s[n]||{},s[n][i]=x(s[n][i],e),s[n][i].valid=!1!==s[n][i].valid&&b(n,i),s}(t.groups,e),t.errors=V(u.ERRORS,t.errors,e),t.warnings=V(u.WARNINGS,t.warnings,e)})),t.valid=G(),function(t){for(const e in t.tests)t.errorCount+=t.tests[e].errorCount,t.warnCount+=t.tests[e].warnCount,t.testCount+=t.tests[e].testCount;return t}(t)}function V(t,e,n){return(t===u.WARNINGS?n.isWarning():n.isFailing())?e.concat({fieldName:n.fieldName,groupName:n.groupName,message:n.message}):e}function x(t,e){const{message:i}=e,s=n.defaultTo(t?Object.assign({},t):null,K);return e.isNonActionable()||(s.testCount++,e.isFailing()?r(u.ERRORS):e.isWarning()&&r(u.WARNINGS)),s;function r(t){const e=S(t);s[e]++,i&&(s[t]=(s[t]||[]).concat(i))}}function K(){return n.assign(new L,{errors:[],warnings:[],valid:!0})}function B(t,e,i){return i?function(t,e,n){var i;return(null===(i=null==t?void 0:t[n])||void 0===i?void 0:i[e])||[]}(t,e,i):function(t,e){const i={},s=S(e);for(const r in t)n.isPositive(t[r][s])&&(i[r]=t[r][e]||[]);return i}(t,e)}function X(t){const e={getError:function(e){return Q(u.ERRORS,t,e)},getErrors:function(e){return j(t,u.ERRORS,e)},getErrorsByGroup:function(e,n){return q(t,u.ERRORS,e,n)},getWarning:function(e){return Q(u.WARNINGS,t,e)},getWarnings:function(e){return j(t,u.WARNINGS,e)},getWarningsByGroup:function(e,n){return q(t,u.WARNINGS,e,n)},hasErrors:function(e){return J(t,a.ERROR_COUNT,e)},hasErrorsByGroup:function(e,n){return Y(t,a.ERROR_COUNT,e,n)},hasWarnings:function(e){return J(t,a.WARN_COUNT,e)},hasWarningsByGroup:function(e,n){return Y(t,a.WARN_COUNT,e,n)},isValid:function(e){var n;return e?Boolean(null===(n=t.tests[e])||void 0===n?void 0:n.valid):t.valid},isValidByGroup:function(e,n){const i=t.groups[e];if(!i)return!1;if(n)return H(i,n);for(const t in i)if(!H(i,t))return!1;return!0}};return e}function j(t,e,n){return B(t.tests,e,n)}function q(t,e,n,i){return B(t.groups[n],e,i)}function H(t,e){var n;return!!(null===(n=t[e])||void 0===n?void 0:n.valid)}function Y(t,e,i,s){var r,o;const u=t.groups[i];if(!u)return!1;if(s)return n.isPositive(null===(r=u[s])||void 0===r?void 0:r[e]);for(const t in u)if(n.isPositive(null===(o=u[t])||void 0===o?void 0:o[e]))return!0;return!1}function J(t,e,i){var s;const r=i?null===(s=t.tests[i])||void 0===s?void 0:s[e]:t[e]||0;return n.isPositive(r)}function Q(t,e,n){var i;const s=e[t];return n?null===(i=s.find((t=>T(t,n))))||void 0===i?void 0:i.message:s[0]}function Z(){const t=M(),e=It().suiteName;return function(t){const e=It().suiteResultCache;return e([Ot()],t)}((()=>n.assign(t,X(t),{suiteName:e})))}function z(t,e){N.create((()=>{g.run({skipped:$()||n.optionalFunctionValue(t,n.optionalFunctionValue(Z))},e)}))}function $(){return function(){var t;return null!==(t=g.useX().skipped)&&void 0!==t&&t}()}function tt(t){return it(0,"tests",t)}function et(t){return it(1,"tests",t)}function nt(t){const{fieldName:e,groupName:i}=t;if($())return!0;const s=A(),r=D(),o=s.tests,u=o[e];if(!1===u)return!0;const a=!0===u;if(i){if(function(t){const e=A(),i=e.groups,s=n.hasOwnProperty(i,t);if(s)return!1===i[t];return rt()}(i))return!0;if(!0===s.groups[i])return!a&&(!!st(o)||!1===o[e])}return!!function(t){if(!rt())return!1;return!t}(i)||!a&&(!!st(o)&&!n.optionalFunctionValue(r[e]))}function it(t,e,i){const s=A(r.HOOK_CALLED_OUTSIDE);i&&n.asArray(i).forEach((i=>{n.isStringValue(i)&&(s[e][i]=0===t)}))}function st(t){for(const e in t)if(!0===t[e])return!0;return!1}function rt(){const t=A();for(const e in t.groups)if(t.groups[e])return!0;return!1}function ot(t,e){N.create((()=>{g.run({omitted:ut()||n.optionalFunctionValue(t,n.optionalFunctionValue(Z))},e)}))}function ut(){return function(){var t;return null!==(t=g.useX().omitted)&&void 0!==t&&t}()}function at(t,e=t){return function(t){return m()&&p(t.fieldName)}(t)?((n=t).skip(),n):function(t){return ut()||Lt(t.fieldName)}(t)?function(t){return t.omit(),t}(t):nt(t)?function(t){return t.skip($()),t}(e):t;var n}y=u.ERRORS,P=u.WARNINGS,tt.group=function(t){return it(0,"groups",t)},et.group=function(t){return it(1,"groups",t)};function ct(){return function(t){let e=t.initial;return{getState:function(){return e},transition:function(n,i){let s=t.states[e][n];if(Array.isArray(s)){const[,t]=s;if(!t(i))return;s=s[0]}s&&s!==e&&(e=s)}}}(lt)}!function(t){t.UNTESTED="UNTESTED",t.SKIPPED="SKIPPED",t.FAILED="FAILED",t.WARNING="WARNING",t.PASSING="PASSING",t.PENDING="PENDING",t.CANCELED="CANCELED",t.OMITTED="OMITTED"}(F||(F={})),function(t){t.RESET="RESET"}(U||(U={}));const lt={initial:F.UNTESTED,states:{[F.UNTESTED]:{[F.CANCELED]:F.CANCELED,[F.FAILED]:F.FAILED,[F.OMITTED]:F.OMITTED,[F.PASSING]:F.PASSING,[F.PENDING]:F.PENDING,[F.SKIPPED]:F.SKIPPED,[F.WARNING]:F.WARNING},[F.SKIPPED]:{[U.RESET]:F.UNTESTED},[F.FAILED]:{[U.RESET]:F.UNTESTED},[F.WARNING]:{[U.RESET]:F.UNTESTED},[F.PASSING]:{[U.RESET]:F.UNTESTED},[F.PENDING]:{[U.RESET]:F.UNTESTED,[F.CANCELED]:F.CANCELED,[F.FAILED]:F.FAILED,[F.OMITTED]:F.OMITTED,[F.PASSING]:F.PASSING,[F.SKIPPED]:[F.SKIPPED,t=>!0===t],[F.WARNING]:F.WARNING},[F.CANCELED]:{[U.RESET]:F.UNTESTED},[F.OMITTED]:{[U.RESET]:F.UNTESTED}}};class dt extends N{constructor({fieldName:t,testFn:e,message:i,groupName:s,key:r=null}){super(),this.children=null,this.id=n.seq(),this.severity=ft.Error,this.stateMachine=ct(),this.fieldName=t,this.testFn=e,s&&(this.groupName=s),i&&(this.message=i),this.setKey(r)}static create(t,e){return dt.cast(super.create(t,e))}static cast(t){return dt.isX(t),t}get status(){return this.stateMachine.getState()}setStatus(t,e){this.stateMachine.transition(t,e)}run(){let t;try{t=this.testFn()}catch(e){(function(t,e){return n.isUndefined(t)&&n.isStringValue(e)})(this.message,e)&&(this.message=e),t=!1}return!1===t&&this.fail(),t}warns(){return this.severity===ft.Warning}isPending(){return this.statusEquals(F.PENDING)}isOmitted(){return this.statusEquals(F.OMITTED)}isUntested(){return this.statusEquals(F.UNTESTED)}isFailing(){return this.statusEquals(F.FAILED)}isCanceled(){return this.statusEquals(F.CANCELED)}isSkipped(){return this.statusEquals(F.SKIPPED)}isPassing(){return this.statusEquals(F.PASSING)}isWarning(){return this.statusEquals(F.WARNING)}hasFailures(){return this.isFailing()||this.isWarning()}isNonActionable(){return this.isSkipped()||this.isOmitted()||this.isCanceled()}isTested(){return this.hasFailures()||this.isPassing()}awaitsResolution(){return this.isSkipped()||this.isUntested()||this.isPending()}statusEquals(t){return this.status===t}setPending(){this.setStatus(F.PENDING)}fail(){this.setStatus(this.warns()?F.WARNING:F.FAILED)}pass(){this.setStatus(F.PASSING)}warn(){this.severity=ft.Warning}skip(t){this.setStatus(F.SKIPPED,t)}cancel(){this.setStatus(F.CANCELED)}reset(){this.stateMachine.transition(U.RESET)}omit(){this.setStatus(F.OMITTED)}valueOf(){return!this.isFailing()}isAsyncTest(){return n.isPromise(this.asyncTest)}static is(t){return t instanceof dt}static isX(t){n.invariant(this.is(t))}}var ft;dt.reconciler=class extends f{static reconciler(t,e){if(!dt.is(t))return t;if(n.isNullish(e))return this.handleNoHistoryNode(t);if(!dt.is(e))return t;const i=this.pickNode(e,t);return function(t,e,n){t===e&&dt.is(e)&&(s=e)!==(i=n)&&R(i,s)&&i.isPending()&&i.cancel();var i,s}(i,t,e),i}static nodeReorderDetected(t,e){return!!dt.is(e)&&!R(e,t)}static handleCollision(t,e){return t.usesKey()?dt.cast(this.handleIsolateNodeWithKey(t)):this.nodeReorderDetected(t,e)?this.onNodeReorder(t,e):dt.cast(e||t)}static onNodeReorder(t,e){return function(t,e){if(t.shouldAllowReorder())return;n.deferThrow(n.text(r.TESTS_CALLED_IN_DIFFERENT_ORDER,{fieldName:t.fieldName,prevName:dt.is(e)?e.fieldName:void 0}))}(t,e),this.removeAllNextNodesInIsolate(),t}static pickNode(t,e){return at(e,this.handleCollision(e,t))}static handleNoHistoryNode(t){return t.usesKey()?dt.cast(this.handleIsolateNodeWithKey(t)):t}},function(t){t.Error="error",t.Warning="warning"}(ft||(ft={}));class Et{static defaultRoot(){return Ft()}static hasNoTests(t=Et.defaultRoot()){return!t||(e=t,n=dt.is,!l(e,(()=>!0),n));var e,n}static someIncompleteTests(t,e=Et.defaultRoot()){return!!e&&l(e,(e=>(dt.isX(e),e.isPending()&&t(e))),dt.is)}static someTests(t,e=Et.defaultRoot()){return!!e&&l(e,(e=>(dt.isX(e),t(e))),dt.is)}static everyTest(t,e=Et.defaultRoot()){return!!e&&function(t,e,n){let i=!0;return c(t,((t,n)=>{e(t)||(n(),i=!1)}),n),i}(e,(e=>(dt.isX(e),t(e))),dt.is)}static walkTests(t,e=Et.defaultRoot()){e&&c(e,((e,n)=>{t(dt.cast(e),n)}),dt.is)}static hasRemainingTests(t){return Et.someIncompleteTests((e=>!t||T(e,t)))}static pluckTests(t,e=Et.defaultRoot()){e&&function(t,e,n){c(t,(t=>{e(t)&&t.parent&&t.parent.removeChild(t)}),n)}(e,(e=>(dt.isX(e),t(e))),dt.is)}static resetField(t){Et.walkTests((e=>{T(e,t)&&e.reset()}),Et.defaultRoot())}static removeTestByFieldName(t,e=Et.defaultRoot()){Et.pluckTests((e=>T(e,t)),e)}}function Nt(){const t=n.bus.createBus();return e(o.TEST_COMPLETED,(e=>{e.isCanceled()||(!function(t){const[e]=gt();t&&!Et.hasRemainingTests(t)&&n.isArray(e[t])&&n.callEach(e[t])}(e.fieldName),Et.hasRemainingTests()||t.emit(o.ALL_RUNNING_TESTS_FINISHED))})),e(o.TEST_RUN_STARTED,(()=>{})),e(o.ALL_RUNNING_TESTS_FINISHED,(()=>{!function(){const[t]=mt();n.callEach(t)}()})),e(o.RESET_FIELD,(t=>{Et.resetField(t)})),e(o.SUITE_RUN_STARTED,(()=>{St()})),e(o.REMOVE_FIELD,(t=>{Et.removeTestByFieldName(t)})),e(o.RESET_SUITE,(()=>{!function(){St();const[,,t]=At();t()}()})),t;function e(e,n){t.on(e,((...t)=>{!function(){const t=It().suiteResultCache;t.invalidate([Ot()])}(),n(...t)}))}}const ht=n.cache(),Tt=i.createCascade(((t,e)=>{if(e)return null;n.invariant(t.historyRoot);const[i]=t.historyRoot(),s={};return n.assign(s,{historyNode:i,runtimeNode:null,runtimeRoot:null},t),s}));function Rt(t){const e=Tt.useX();return function(...n){var i;const s=null!==(i=Tt.use())&&void 0!==i?i:e;return Tt.run(s,(()=>t(...n)))}}function St(){const[,,t]=mt(),[,,e]=gt();t(),e()}function It(){return Tt.useX()}function pt(){return It().VestBus}function vt(){return Rt(pt().emit)}function _t(t){const e=vt();return n=>e(t,n)}function mt(){return It().doneCallbacks()}function gt(){return It().fieldCallbacks()}function At(){return It().historyRoot()}function Dt(){return It().historyNode}function Ot(){return It().suiteId}function Ct(){var t;return null!==(t=It().runtimeNode)&&void 0!==t?t:null}function yt(){var t,e;return null!==(e=null===(t=Ct())||void 0===t?void 0:t.cursor())&&void 0!==e?e:0}function Pt(){return It().runtimeRoot}function Ft(){const t=Pt();if(t)return t;const[e]=At();return e}function Ut(t){const e=Pt();if(n.isArray(t)||n.isStringValue(t))n.asArray(t).forEach((t=>{e.setOptionalField(t,(()=>({type:s.Delayed,applied:!1,rule:null})))}));else for(const i in t){const r=t[i];e.setOptionalField(i,(()=>({type:s.Immediate,rule:r,applied:n.optionalFunctionValue(r)})))}}function Lt(t){var e,n,i;return!!t&&(null!==(i=null===(n=null===(e=Ft())||void 0===e?void 0:e.getOptionalField(t))||void 0===n?void 0:n.applied)&&void 0!==i&&i)}class Wt extends N{constructor(){super(...arguments),this.optional={}}setOptionalField(t,e){const n=this.optional,i=n[t];Object.assign(n,{[t]:Object.assign({},i,e(i))})}getOptionalField(t){var e;return null!==(e=this.optional[t])&&void 0!==e?e:{}}}function Gt(t){const e=D(),i=A();return n.invariant(n.isStringValue(t)),e[t]=n.defaultTo(i.tests[t],!0),{when:function(e){const i=D(),s=A();i[t]=()=>n.hasOwnProperty(s.tests,t)?n.defaultTo(s.tests[t],!0):n.isStringValue(e)?Boolean(s.tests[e]):n.optionalFunctionValue(e,n.optionalFunctionValue(Z))}}}function bt(t){at(t),t.isNonActionable()||(t.isUntested()?function(t){const e=pt(),i=function(t){return g.run({currentTest:t},(()=>t.run()))}(t);try{n.isPromise(i)?(t.asyncTest=i,t.setPending(),kt(t)):wt(e,t)}catch(e){throw new Error(n.text(r.UNEXPECTED_TEST_REGISTRATION_ERROR,{testObject:JSON.stringify(t),error:e}))}}(t):t.isAsyncTest()&&(t.setPending(),kt(t)))}function kt(t){const{asyncTest:e,message:i}=t;if(!n.isPromise(e))return;const s=pt(),r=Rt((()=>{wt(s,t)})),o=Rt((e=>{t.isCanceled()||(t.message=n.isStringValue(e)?e:i,t.fail(),r())}));e.then(r,o)}function wt(t,e){e.pass(),t.emit(o.TEST_COMPLETED,e)}function Mt(t,...e){const[i,s,u]=n.isFunction(e[1])?e:[void 0,...e];!function(t,e){const i="test";n.invariant(n.isStringValue(t),n.text(r.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:i,param:"fieldName",expected:"string"})),n.invariant(n.isFunction(e),n.text(r.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:i,param:"callback",expected:"function"}))}(t,s);const a={fieldName:t,groupName:g.useX().groupName,key:u,message:i,testFn:s};return vt()(o.TEST_RUN_STARTED),dt.create(bt,a)}const Vt=n.assign(Mt,{memo:function(t){return function(e,...i){const[s,r,o]=i.reverse();return function(t,e){const i=g.useX().testMemoCache,s=i.get(t);if(n.isNull(s))return i(t,e);const[,r]=s;if(r.isCanceled())return i.invalidate(t),i(t,e);return dt.setNode(r),r}([Ot(),e,yt()].concat(s),(function(){return t(e,o,r)}))}}(Mt)});function xt(){return{group:qt,include:Gt,omitWhen:ot,only:tt,optional:Ut,skip:et,skipWhen:z,test:Vt}}function Kt(){return n.assign({},Z(),{done:Rt(Bt)})}function Bt(...t){const[e,i]=t.reverse(),s=Kt();if(function(t,e,i){var s;return!!(!n.isFunction(t)||e&&n.numberEquals(null===(s=i.tests[e])||void 0===s?void 0:s.testCount,0))}(e,i,s))return s;const r=()=>e(Z());return Et.hasRemainingTests(i)?(function(t,e){const[,i]=gt(),[,s]=mt();e?i((i=>n.assign(i,{[e]:(i[e]||[]).concat(t)}))):s((e=>e.concat(t)))}(r,i),s):(r(),s)}function Xt(...t){const[e,i]=t.reverse();!function(t){n.invariant(n.isFunction(t),r.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION)}(e);const s=function({suiteName:t}={}){return{VestBus:Nt(),doneCallbacks:n.tinyState.createTinyState((()=>[])),fieldCallbacks:n.tinyState.createTinyState((()=>({}))),historyRoot:n.tinyState.createTinyState(null),suiteId:n.seq(),suiteName:t,suiteResultCache:ht}}({suiteName:i});function u(...t){return g.run({},(()=>(vt()(o.SUITE_RUN_STARTED),Wt.create(function(t,...e){return()=>(t(...e),Kt())}(e,...t))))).output}return Tt.run(s,(()=>n.assign(Tt.bind(s,u),Object.assign({get:Rt(Z),remove:_t(o.REMOVE_FIELD),reset:_t(o.RESET_SUITE),resetField:_t(o.RESET_FIELD)},xt()))))}class jt extends N{constructor(){super(...arguments),this.allowReorder=!0}}function qt(t,e){return N.create((()=>{g.run({groupName:t},e)}))}const Ht=r.WARN_MUST_BE_CALLED_FROM_TEST;Object.defineProperty(t,"enforce",{enumerable:!0,get:function(){return e.enforce}}),t.create=Xt,t.each=function(t,e){n.invariant(n.isFunction(e),r.EACH_CALLBACK_MUST_BE_A_FUNCTION),jt.create((()=>{t.forEach(((t,n)=>{e(t,n)}))}))},t.group=qt,t.include=Gt,t.mode=function(t){const[,e]=O();e(t)},t.omitWhen=ot,t.only=tt,t.optional=Ut,t.skip=et,t.skipWhen=z,t.staticSuite=function(t){return n.assign(((...e)=>Xt(t)(...e)),Object.assign({},xt()))},t.suiteSelectors=X,t.test=Vt,t.warn=function(){const t=(e=r.HOOK_CALLED_OUTSIDE,g.useX(e).currentTest);var e;n.invariant(t,Ht),t.warn()},Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("n4s"),require("vest-runtime"),require("vest-utils"),require("context")):"function"==typeof define&&define.amd?define(["exports","n4s","vest-runtime","vest-utils","context"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).vest={},t.n4s,t["vest-runtime"],t["vest-utils"],t.context)}(this,(function(t,e,n,s,i){"use strict";var r,u;function o(t){const e=n.VestRuntime.useAvailableRoot();if(s.isArray(t)||s.isStringValue(t))s.asArray(t).forEach((t=>{e.setOptionalField(t,(()=>({type:r.AUTO,applied:!1,rule:null})))}));else for(const n in t){const s=t[n];e.setOptionalField(n,(()=>({type:r.CUSTOM_LOGIC,rule:s,applied:!0===s})))}}function a(t){var e,s,i;return!!t&&(null!==(i=null===(s=null===(e=n.VestRuntime.useAvailableRoot())||void 0===e?void 0:e.getOptionalField(t))||void 0===s?void 0:s.applied)&&void 0!==i&&i)}!function(t){t[t.CUSTOM_LOGIC=0]="CUSTOM_LOGIC",t[t.AUTO=1]="AUTO"}(r||(r={})),function(t){t.TEST_RUN_STARTED="test_run_started",t.TEST_COMPLETED="test_completed",t.ALL_RUNNING_TESTS_FINISHED="all_running_tests_finished",t.REMOVE_FIELD="remove_field",t.RESET_FIELD="reset_field",t.RESET_SUITE="reset_suite",t.SUITE_RUN_STARTED="suite_run_started",t.SUITE_CALLBACK_RUN_FINISHED="SUITE_CALLBACK_RUN_FINISHED",t.DONE_TEST_OMISSION_PASS="DONE_TEST_OMISSION_PASS"}(u||(u={}));class c extends n.Isolate{constructor(){super(...arguments),this.optional={}}setOptionalField(t,e){const n=this.optional,s=n[t];Object.assign(n,{[t]:Object.assign({},s,e(s))})}getOptionalField(t){var e;return null!==(e=this.optional[t])&&void 0!==e?e:{}}getOptionalFields(){return this.optional}}const l=s.cache();function E(){return n.VestRuntime.useXAppData()}function f(){return E().doneCallbacks()}function d(){return E().fieldCallbacks()}function N(){return E().suiteId}function T(){const[,,t]=f(),[,,e]=d();t(),e()}var R,S,m,I,p,_;function g(t){return t===R.ERRORS?S.ERROR_COUNT:S.WARN_COUNT}function h(t,e){return!!e&&!O(t,e)}function O(t,e){return!(!e||t.fieldName!==e)}function A(t,e){return O(t,e.fieldName)&&t.groupName===e.groupName&&t.key===e.key}!function(t){t.WARNINGS="warnings",t.ERRORS="errors"}(R||(R={})),function(t){t.ERROR_COUNT="errorCount",t.WARN_COUNT="warnCount"}(S||(S={})),function(t){t.Error="error",t.Warning="warning"}(m||(m={})),function(t){t.HOOK_CALLED_OUTSIDE="hook called outside of a running suite.",t.EXPECTED_VEST_TEST="Expected value to be an instance of IsolateTest",t.FIELD_NAME_REQUIRED="Field name must be passed",t.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION="Suite must be initialized with a function",t.PROMISIFY_REQUIRE_FUNCTION="Vest.Promisify must be called with a function",t.PARSER_EXPECT_RESULT_OBJECT="Vest parser: expected argument at position 0 to be Vest's result object.",t.WARN_MUST_BE_CALLED_FROM_TEST="Warn must be called from within the body of a test function",t.EACH_CALLBACK_MUST_BE_A_FUNCTION="Each must be called with a function",t.INVALID_PARAM_PASSED_TO_FUNCTION='Incompatible params passed to {fn_name} function. "{param}" must be of type {expected}',t.TESTS_CALLED_IN_DIFFERENT_ORDER='Vest Critical Error: Tests called in different order than previous run.\n expected: {fieldName}\n received: {prevName}\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.',t.UNEXPECTED_TEST_REGISTRATION_ERROR="Unexpected error encountered during test registration.\n Please report this issue to Vest's Github repository.\n Test Object: {testObject}.\n Error: {error}.",t.UNEXPECTED_TEST_RUN_ERROR="Unexpected error encountered during test run. Please report this issue to Vest's Github repository.\n Test Object: {testObject}."}(I||(I={}));class v{constructor(){this.errorCount=0,this.warnCount=0,this.testCount=0}}class D extends v{constructor(){super(...arguments),this[p]=[],this[_]=[],this.groups={},this.tests={},this.valid=!1}}p=R.ERRORS,_=R.WARNINGS;class C{constructor(t,e,n){this.fieldName=t,this.message=e,this.groupName=n}static fromTestObject(t){return new C(t.fieldName,t.message,t.groupName)}toString(){return this.message||""}}const P=s.bindNot((function(t,e){return t.groupName===e}));function F(t){return!!a(t)||!ot.hasNoTests()&&(!at(t)&&(!function(t){return ot.someIncompleteTests((e=>!h(e,t)&&!a(t)))}(t)&&function(t){return ot.everyTest((e=>y(e,t)))}(t)))}function U(t,e){return!!a(e)||!function(t,e,n){return ot.someTests((s=>!P(s,e)&&ct(s,t,n)))}(R.ERRORS,t,e)&&(!function(t,e){return ot.someIncompleteTests((n=>!P(n,t)&&(!h(n,e)&&!a(e))))}(t,e)&&function(t,e){return ot.everyTest((n=>!!P(n,t)||y(n,e)))}(t,e))}function y(t,e){return!!h(t,e)||(t.isOmitted()||t.isTested()||function(t){var e;return(null===(e=n.VestRuntime.useAvailableRoot())||void 0===e?void 0:e.getOptionalField(t.fieldName).type)===r.AUTO&&t.awaitsResolution()}(t))}function L(){const t=new D;return ot.walkTests((e=>{t.tests=function(t,e){const{fieldName:n}=e,s=Object.assign({},t);return s[n]=W(s[n],e),s[n].valid=!1!==s[n].valid&&F(n),s}(t.tests,e),t.groups=function(t,e){const{groupName:n,fieldName:s}=e;if(!n)return t;const i=Object.assign({},t);return i[n]=i[n]||{},i[n][s]=W(i[n][s],e),i[n][s].valid=!1!==i[n][s].valid&&U(n,s),i}(t.groups,e),t.errors=G(R.ERRORS,t.errors,e),t.warnings=G(R.WARNINGS,t.warnings,e)})),t.valid=F(),function(t){for(const e in t.tests)t.errorCount+=t.tests[e].errorCount,t.warnCount+=t.tests[e].warnCount,t.testCount+=t.tests[e].testCount;return t}(t)}function G(t,e,n){if(n.isOmitted())return e;return(t===R.WARNINGS?n.isWarning():n.isFailing())?e.concat(C.fromTestObject(n)):e}function W(t,e){const{message:n}=e,i=s.defaultTo(t?Object.assign({},t):null,V);return e.isNonActionable()||(i.testCount++,e.isFailing()?r(R.ERRORS):e.isWarning()&&r(R.WARNINGS)),i;function r(t){const e=g(t);i[e]++,n&&(i[t]=(i[t]||[]).concat(n))}}function V(){return s.assign(new v,{errors:[],warnings:[],valid:!0})}function b(t,e,n){return n?function(t,e,n){var s;return(null===(s=null==t?void 0:t[n])||void 0===s?void 0:s[e])||[]}(t,e,n):function(t,e){const n={},i=g(e);for(const r in t)s.isPositive(t[r][i])&&(n[r]=t[r][e]||[]);return n}(t,e)}function M(t){const e={getError:function(e){return K(R.ERRORS,t,e)},getErrors:function(e){return w(t,R.ERRORS,e)},getErrorsByGroup:function(e,n){return k(t,R.ERRORS,e,n)},getWarning:function(e){return K(R.WARNINGS,t,e)},getWarnings:function(e){return w(t,R.WARNINGS,e)},getWarningsByGroup:function(e,n){return k(t,R.WARNINGS,e,n)},hasErrors:function(e){return j(t,S.ERROR_COUNT,e)},hasErrorsByGroup:function(e,n){return x(t,S.ERROR_COUNT,e,n)},hasWarnings:function(e){return j(t,S.WARN_COUNT,e)},hasWarningsByGroup:function(e,n){return x(t,S.WARN_COUNT,e,n)},isValid:function(e){var n;return e?Boolean(null===(n=t.tests[e])||void 0===n?void 0:n.valid):t.valid},isValidByGroup:function(e,n){const s=t.groups[e];if(!s)return!1;if(n)return B(s,n);for(const t in s)if(!B(s,t))return!1;return!0}};return e}function w(t,e,n){return b(t.tests,e,n)}function k(t,e,n,s){return b(t.groups[n],e,s)}function B(t,e){var n;return!!(null===(n=t[e])||void 0===n?void 0:n.valid)}function x(t,e,n,i){var r,u;const o=t.groups[n];if(!o)return!1;if(i)return s.isPositive(null===(r=o[i])||void 0===r?void 0:r[e]);for(const t in o)if(s.isPositive(null===(u=o[t])||void 0===u?void 0:u[e]))return!0;return!1}function j(t,e,n){var i;const r=n?null===(i=t.tests[n])||void 0===i?void 0:i[e]:t[e]||0;return s.isPositive(r)}function K(t,e,n){var s;const i=e[t];return n?null===(s=i.find((t=>O(t,n))))||void 0===s?void 0:s.message:i[0]}function X(){return t=()=>{const t=L(),e=E().suiteName;return Object.freeze(s.assign(t,M(t),{suiteName:e}))},(0,E().suiteResultCache)([N()],t);var t}function q(t,e){n.Isolate.create((()=>{ft.run({skipped:H()||s.optionalFunctionValue(t,s.optionalFunctionValue(X))},e)}))}function H(){return function(){var t;return null!==(t=ft.useX().skipped)&&void 0!==t&&t}()}function z(t){return Q(0,"tests",t)}function J(t){return Q(1,"tests",t)}function Y(t){const{fieldName:e,groupName:n}=t;if(H())return!0;const i=dt(),r=Nt(),u=i.tests,o=u[e];if(!1===o)return!0;const a=!0===o;if(n){if(function(t){const e=dt().groups;if(s.hasOwnProperty(e,t))return!1===e[t];return $()}(n))return!0;if(!0===i.groups[n])return!a&&(!!Z(u)||!1===u[e])}return!!function(t){if(!$())return!1;return!t}(n)||!a&&(!!Z(u)&&!s.optionalFunctionValue(r[e]))}function Q(t,e,n){const i=dt(I.HOOK_CALLED_OUTSIDE);n&&s.asArray(n).forEach((n=>{s.isStringValue(n)&&(i[e][n]=0===t)}))}function Z(t){for(const e in t)if(!0===t[e])return!0;return!1}function $(){const t=dt();for(const e in t.groups)if(t.groups[e])return!0;return!1}function tt(t,e){n.Isolate.create((()=>{ft.run({omitted:et()||s.optionalFunctionValue(t,s.optionalFunctionValue(X))},e)}))}function et(){return function(){var t;return null!==(t=ft.useX().omitted)&&void 0!==t&&t}()}function nt(e,n=e){return function(e){if(Et(t.Modes.ONE))return at();if(Et(t.Modes.EAGER))return at(e.fieldName);return!1}(e)?((s=e).skip(),s):function(t){return et()||a(t.fieldName)}(e)?function(t){return t.omit(),t}(e):Y(e)?function(t){return t.skip(H()),t}(n):e;var s}var st,it;z.group=function(t){return Q(0,"groups",t)},J.group=function(t){return Q(1,"groups",t)},function(t){t.UNTESTED="UNTESTED",t.SKIPPED="SKIPPED",t.FAILED="FAILED",t.WARNING="WARNING",t.PASSING="PASSING",t.PENDING="PENDING",t.CANCELED="CANCELED",t.OMITTED="OMITTED"}(st||(st={})),function(t){t.RESET="RESET"}(it||(it={}));const rt={initial:st.UNTESTED,states:{"*":{[st.OMITTED]:st.OMITTED,[it.RESET]:st.UNTESTED},[st.UNTESTED]:{[st.CANCELED]:st.CANCELED,[st.FAILED]:st.FAILED,[st.PASSING]:st.PASSING,[st.PENDING]:st.PENDING,[st.SKIPPED]:st.SKIPPED,[st.WARNING]:st.WARNING},[st.PENDING]:{[st.CANCELED]:st.CANCELED,[st.FAILED]:st.FAILED,[st.PASSING]:st.PASSING,[st.SKIPPED]:[st.SKIPPED,t=>!0===t],[st.WARNING]:st.WARNING},[st.SKIPPED]:{},[st.FAILED]:{},[st.WARNING]:{},[st.PASSING]:{},[st.CANCELED]:{},[st.OMITTED]:{}}};class ut extends n.Isolate{constructor({fieldName:t,testFn:e,message:n,groupName:i,key:r=null}){super(),this.children=null,this.id=s.seq(),this.severity=m.Error,this.stateMachine=s.StateMachine(rt),this.fieldName=t,this.testFn=e,i&&(this.groupName=i),n&&(this.message=n),this.setKey(r)}static create(t,e){return ut.cast(super.create(t,e))}static cast(t){return ut.isX(t),t}get status(){return this.stateMachine.getState()}setStatus(t,e){this.stateMachine.transition(t,e)}run(){let t;try{t=this.testFn()}catch(e){(function(t,e){return s.isUndefined(t)&&s.isStringValue(e)})(this.message,e)&&(this.message=e),t=!1}return!1===t&&this.fail(),t}warns(){return this.severity===m.Warning}isPending(){return this.statusEquals(st.PENDING)}isOmitted(){return this.statusEquals(st.OMITTED)}isUntested(){return this.statusEquals(st.UNTESTED)}isFailing(){return this.statusEquals(st.FAILED)}isCanceled(){return this.statusEquals(st.CANCELED)}isSkipped(){return this.statusEquals(st.SKIPPED)}isPassing(){return this.statusEquals(st.PASSING)}isWarning(){return this.statusEquals(st.WARNING)}hasFailures(){return this.isFailing()||this.isWarning()}isNonActionable(){return this.isSkipped()||this.isOmitted()||this.isCanceled()}isTested(){return this.hasFailures()||this.isPassing()}awaitsResolution(){return this.isSkipped()||this.isUntested()||this.isPending()}statusEquals(t){return this.status===t}setPending(){this.setStatus(st.PENDING)}fail(){this.setStatus(this.warns()?st.WARNING:st.FAILED)}pass(){this.setStatus(st.PASSING)}warn(){this.severity=m.Warning}skip(t){this.setStatus(st.SKIPPED,t)}cancel(){this.setStatus(st.CANCELED)}reset(){this.stateMachine.transition(it.RESET)}omit(){this.setStatus(st.OMITTED)}valueOf(){return!this.isFailing()}isAsyncTest(){return s.isPromise(this.asyncTest)}static is(t){return t instanceof ut}static isX(t){s.invariant(this.is(t))}}ut.reconciler=function(t,e){if(!ut.is(t))return t;if(s.isNullish(e))return function(t){if(t.usesKey())return ut.cast(n.Reconciler.handleIsolateNodeWithKey(t));return t}(t);if(!ut.is(e))return t;const i=function(t,e){const i=function(t,e){if(t.usesKey())return ut.cast(n.Reconciler.handleIsolateNodeWithKey(t));if(function(t,e){return!!ut.is(e)&&!A(e,t)}(t,e))return function(t,e){return function(t,e){if(t.shouldAllowReorder())return;s.deferThrow(s.text(I.TESTS_CALLED_IN_DIFFERENT_ORDER,{fieldName:t.fieldName,prevName:ut.is(e)?e.fieldName:void 0}))}(t,e),n.Reconciler.removeAllNextNodesInIsolate(),t}(t,e);if(!ut.is(e))return t;if(e.isOmitted())return t;return e}(e,t);return nt(e,i)}(e,t);return function(t,e,n){t===e&&ut.is(e)&&(i=e)!==(s=n)&&A(s,i)&&s.isPending()&&s.cancel();var s,i}(i,t,e),i};class ot{static defaultRoot(){return n.VestRuntime.useAvailableRoot()}static hasNoTests(t=ot.defaultRoot()){return!t||!n.Walker.has(t,ut.is)}static someIncompleteTests(t,e=ot.defaultRoot()){return!!e&&n.Walker.some(e,(e=>(ut.isX(e),e.isPending()&&t(e))),ut.is)}static someTests(t,e=ot.defaultRoot()){return!!e&&n.Walker.some(e,(e=>(ut.isX(e),t(e))),ut.is)}static everyTest(t,e=ot.defaultRoot()){return!!e&&n.Walker.every(e,(e=>(ut.isX(e),t(e))),ut.is)}static walkTests(t,e=ot.defaultRoot()){e&&n.Walker.walk(e,((e,n)=>{t(ut.cast(e),n)}),ut.is)}static hasRemainingTests(t){return ot.someIncompleteTests((e=>!t||O(e,t)))}static pluckTests(t,e=ot.defaultRoot()){e&&n.Walker.pluck(e,(e=>(ut.isX(e),t(e))),ut.is)}static resetField(t){ot.walkTests((e=>{O(e,t)&&e.reset()}),ot.defaultRoot())}static removeTestByFieldName(t,e=ot.defaultRoot()){ot.pluckTests((e=>O(e,t)),e)}}function at(t){return function(t,e){return ot.someTests((n=>ct(n,t,e)))}(R.ERRORS,t)}function ct(t,e,n){return!!t.hasFailures()&&(!h(t,n)&&!function(t,e){return s.either(t===R.WARNINGS,e.warns())}(e,t))}var lt;function Et(t){const[e]=Tt();return e===t}t.Modes=void 0,(lt=t.Modes||(t.Modes={})).EAGER="EAGER",lt.ALL="ALL",lt.ONE="ONE";const ft=i.createCascade(((e,n)=>n?null:s.assign({exclusion:{tests:{},groups:{}},inclusion:{},mode:s.tinyState.createTinyState(t.Modes.EAGER),testMemoCache:Rt},e)));function dt(t){return ft.useX(t).exclusion}function Nt(){return ft.useX().inclusion}function Tt(){return ft.useX().mode()}const Rt=s.cache(10);function St(){const t=n.VestRuntime.useAvailableRoot(),e=n.VestRuntime.useEmit(),i=null==t?void 0:t.getOptionalFields();if(s.isEmpty(i))return;const r=new Set;function o(e){r.has(e.fieldName)&&(e.omit(),null==t||t.setOptionalField(e.fieldName,(t=>Object.assign(Object.assign({},t),{applied:!0}))))}ot.walkTests((e=>{e.isPending()||(s.hasOwnProperty(r,e.fieldName)?o(e):function(e){const n=null==t?void 0:t.getOptionalField(e.fieldName);if(s.isNullish(n))return;!0===s.optionalFunctionValue(n.rule)&&r.add(e.fieldName);o(e)}(e))})),e(u.DONE_TEST_OMISSION_PASS)}function mt(){const t=n.VestRuntime.useBus();return e(u.TEST_COMPLETED,(e=>{e.isCanceled()||(!function(t){const[e]=d();t&&!ot.hasRemainingTests(t)&&s.isArray(e[t])&&s.callEach(e[t])}(e.fieldName),ot.hasRemainingTests()||t.emit(u.ALL_RUNNING_TESTS_FINISHED))})),e(u.TEST_RUN_STARTED,(()=>{})),e(u.DONE_TEST_OMISSION_PASS,(()=>{})),e(u.ALL_RUNNING_TESTS_FINISHED,(()=>{ot.someTests((t=>t.isAsyncTest()))&&St(),function(){const[t]=f();s.callEach(t)}()})),e(u.RESET_FIELD,(t=>{ot.resetField(t)})),e(u.SUITE_RUN_STARTED,(()=>{T()})),e(u.SUITE_CALLBACK_RUN_FINISHED,(()=>{St()})),e(u.REMOVE_FIELD,(t=>{ot.removeTestByFieldName(t)})),e(u.RESET_SUITE,(()=>{T(),n.VestRuntime.reset()})),t;function e(e,n){t.on(e,((...t)=>{E().suiteResultCache.invalidate([N()]),n(...t)}))}}function It(t){const e=Nt(),n=dt();return s.invariant(s.isStringValue(t)),e[t]=s.defaultTo(n.tests[t],!0),{when:function(e){const n=Nt(),i=dt();n[t]=()=>s.hasOwnProperty(i.tests,t)?s.defaultTo(i.tests[t],!0):s.isStringValue(e)?Boolean(i.tests[e]):s.optionalFunctionValue(e,s.optionalFunctionValue(X))}}}function pt(t){if(nt(t),t.isUntested())return function(t){const e=n.VestRuntime.useBus(),i=function(t){return ft.run({currentTest:t},(()=>t.run()))}(t);try{s.isPromise(i)?(t.asyncTest=i,function(t){const{asyncTest:e,message:i}=t;if(!s.isPromise(e))return;t.setPending();const r=n.VestRuntime.useBus(),u=n.VestRuntime.persist((()=>{_t(r,t)})),o=n.VestRuntime.persist((e=>{t.isCanceled()||(t.message=s.isStringValue(e)?e:i,t.fail(),u())}));e.then(u,o)}(t)):_t(e,t)}catch(e){throw new Error(s.text(I.UNEXPECTED_TEST_REGISTRATION_ERROR,{testObject:JSON.stringify(t),error:e}))}}(t);t.isNonActionable()||s.deferThrow(s.text(I.UNEXPECTED_TEST_REGISTRATION_ERROR,{testObject:JSON.stringify(t)}))}function _t(t,e){e.pass(),t.emit(u.TEST_COMPLETED,e)}function gt(t,...e){const[i,r,o]=s.isFunction(e[1])?e:[void 0,...e];!function(t,e){const n="test";s.invariant(s.isStringValue(t),s.text(I.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:n,param:"fieldName",expected:"string"})),s.invariant(s.isFunction(e),s.text(I.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:n,param:"callback",expected:"function"}))}(t,r);const a={fieldName:t,groupName:ft.useX().groupName,key:o,message:i,testFn:r};return n.VestRuntime.useEmit()(u.TEST_RUN_STARTED),ut.create(pt,a)}const ht=s.assign(gt,{memo:function(t){return function(e,...i){const[r,u,o]=i.reverse();return function(t,e){const n=ft.useX().testMemoCache,i=n.get(t);if(s.isNull(i))return n(t,e);const[,r]=i;if(r.isCanceled())return n.invalidate(t),n(t,e);return ut.setNode(r),r}([N(),e,n.VestRuntime.useCurrentCursor()].concat(r),(function(){return t(e,o,u)}))}}(gt)});function Ot(){return{group:Pt,include:It,omitWhen:tt,only:z,optional:o,skip:J,skipWhen:q,test:ht}}function At(){return Object.freeze(s.assign({done:n.VestRuntime.persist(vt)},X()))}function vt(...t){const[e,n]=t.reverse(),i=At();if(function(t,e,n){var i;return!!(!s.isFunction(t)||e&&s.numberEquals(null===(i=n.tests[e])||void 0===i?void 0:i.testCount,0))}(e,n,i))return i;const r=()=>e(X());return ot.hasRemainingTests(n)?(function(t,e){const[,n]=d(),[,i]=f();e?n((n=>s.assign(n,{[e]:(n[e]||[]).concat(t)}))):i((e=>e.concat(t)))}(r,n),i):(r(),i)}function Dt(...t){const[e,i]=t.reverse();!function(t){s.invariant(s.isFunction(t),I.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION)}(e);const r=function({suiteName:t}={}){const e={doneCallbacks:s.tinyState.createTinyState((()=>[])),fieldCallbacks:s.tinyState.createTinyState((()=>({}))),suiteId:s.seq(),suiteName:t,suiteResultCache:l};return n.VestRuntime.createRef(e)}({suiteName:i});function o(...t){return ft.run({},(()=>(n.VestRuntime.useEmit()(u.SUITE_RUN_STARTED),c.create(function(t,...e){const s=n.VestRuntime.useEmit();return()=>(t(...e),s(u.SUITE_CALLBACK_RUN_FINISHED),At())}(e,...t))))).output}return n.VestRuntime.Run(r,(()=>{return mt(),s.assign(n.VestRuntime.persist(o),Object.assign(Object.assign({get:n.VestRuntime.persist(X),remove:n.VestRuntime.usePrepareEmitter(u.REMOVE_FIELD),reset:n.VestRuntime.usePrepareEmitter(u.RESET_SUITE),resetField:n.VestRuntime.usePrepareEmitter(u.RESET_FIELD)},(t=n.VestRuntime.persist(X),{getError:(...e)=>t().getError(...e),getErrors:(...e)=>t().getErrors(...e),getErrorsByGroup:(...e)=>t().getErrorsByGroup(...e),getWarning:(...e)=>t().getWarning(...e),getWarnings:(...e)=>t().getWarnings(...e),getWarningsByGroup:(...e)=>t().getWarningsByGroup(...e),hasErrors:(...e)=>t().hasErrors(...e),hasErrorsByGroup:(...e)=>t().hasErrorsByGroup(...e),hasWarnings:(...e)=>t().hasWarnings(...e),hasWarningsByGroup:(...e)=>t().hasWarningsByGroup(...e),isValid:(...e)=>t().isValid(...e),isValidByGroup:(...e)=>t().isValidByGroup(...e)})),Ot()));var t}))}class Ct extends n.Isolate{constructor(){super(...arguments),this.allowReorder=!0}}function Pt(t,e){return n.Isolate.create((()=>{ft.run({groupName:t},e)}))}const Ft=I.WARN_MUST_BE_CALLED_FROM_TEST;Object.defineProperty(t,"enforce",{enumerable:!0,get:function(){return e.enforce}}),t.create=Dt,t.each=function(t,e){s.invariant(s.isFunction(e),I.EACH_CALLBACK_MUST_BE_A_FUNCTION),Ct.create((()=>{t.forEach(((t,n)=>{e(t,n)}))}))},t.group=Pt,t.include=It,t.mode=function(t){const[,e]=Tt();e(t)},t.omitWhen=tt,t.only=z,t.optional=o,t.skip=J,t.skipWhen=q,t.staticSuite=function(t){return s.assign(((...e)=>Dt(t)(...e)),Object.assign({},Ot()))},t.suiteSelectors=M,t.test=ht,t.warn=function(){const t=(e=I.HOOK_CALLED_OUTSIDE,ft.useX(e).currentTest);var e;s.invariant(t,Ft),t.warn()}}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vest",
|
|
3
|
-
"version": "5.0.0-dev-
|
|
3
|
+
"version": "5.0.0-dev-ec989a",
|
|
4
4
|
"description": "Declarative Form Validations Framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ealush",
|
|
@@ -18,101 +18,72 @@
|
|
|
18
18
|
"url": "https://github.com/ealush/vest.git/issues"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"context": "3.0.
|
|
22
|
-
"n4s": "
|
|
23
|
-
"vast": "1.0.18-dev-
|
|
24
|
-
"vest-
|
|
21
|
+
"context": "3.0.9-dev-ec989a",
|
|
22
|
+
"n4s": "5.0.0-dev-ec989a",
|
|
23
|
+
"vast": "1.0.18-dev-ec989a",
|
|
24
|
+
"vest-runtime": "0.0.2-dev-ec989a",
|
|
25
|
+
"vest-utils": "1.0.0-dev-ec989a"
|
|
25
26
|
},
|
|
26
27
|
"exports": {
|
|
27
|
-
"./
|
|
28
|
-
"production": {
|
|
29
|
-
"types": "./types/classnames.d.ts",
|
|
30
|
-
"browser": "./dist/es/classnames.production.js",
|
|
31
|
-
"umd": "./dist/umd/classnames.production.js",
|
|
32
|
-
"import": "./dist/es/classnames.production.js",
|
|
33
|
-
"require": "./dist/cjs/classnames.production.js",
|
|
34
|
-
"node": "./dist/cjs/classnames.production.js",
|
|
35
|
-
"module": "./dist/es/classnames.production.js",
|
|
36
|
-
"default": "./dist/cjs/classnames.production.js"
|
|
37
|
-
},
|
|
38
|
-
"development": {
|
|
39
|
-
"types": "./types/classnames.d.ts",
|
|
40
|
-
"browser": "./dist/es/classnames.development.js",
|
|
41
|
-
"umd": "./dist/umd/classnames.development.js",
|
|
42
|
-
"import": "./dist/es/classnames.development.js",
|
|
43
|
-
"require": "./dist/cjs/classnames.development.js",
|
|
44
|
-
"node": "./dist/cjs/classnames.development.js",
|
|
45
|
-
"module": "./dist/es/classnames.development.js",
|
|
46
|
-
"default": "./dist/cjs/classnames.development.js"
|
|
47
|
-
},
|
|
48
|
-
"types": "./types/classnames.d.ts",
|
|
49
|
-
"browser": "./dist/es/classnames.production.js",
|
|
50
|
-
"umd": "./dist/umd/classnames.production.js",
|
|
51
|
-
"import": "./dist/es/classnames.production.js",
|
|
52
|
-
"require": "./dist/cjs/classnames.production.js",
|
|
53
|
-
"node": "./dist/cjs/classnames.production.js",
|
|
54
|
-
"module": "./dist/es/classnames.production.js",
|
|
55
|
-
"default": "./dist/cjs/classnames.production.js"
|
|
56
|
-
},
|
|
57
|
-
"./enforce/compose": {
|
|
28
|
+
"./promisify": {
|
|
58
29
|
"production": {
|
|
59
|
-
"types": "./types/
|
|
60
|
-
"browser": "./dist/es/
|
|
61
|
-
"umd": "./dist/umd/
|
|
62
|
-
"import": "./dist/es/
|
|
63
|
-
"require": "./dist/cjs/
|
|
64
|
-
"node": "./dist/cjs/
|
|
65
|
-
"module": "./dist/es/
|
|
66
|
-
"default": "./dist/cjs/
|
|
30
|
+
"types": "./types/promisify.d.ts",
|
|
31
|
+
"browser": "./dist/es/promisify.production.js",
|
|
32
|
+
"umd": "./dist/umd/promisify.production.js",
|
|
33
|
+
"import": "./dist/es/promisify.production.js",
|
|
34
|
+
"require": "./dist/cjs/promisify.production.js",
|
|
35
|
+
"node": "./dist/cjs/promisify.production.js",
|
|
36
|
+
"module": "./dist/es/promisify.production.js",
|
|
37
|
+
"default": "./dist/cjs/promisify.production.js"
|
|
67
38
|
},
|
|
68
39
|
"development": {
|
|
69
|
-
"types": "./types/
|
|
70
|
-
"browser": "./dist/es/
|
|
71
|
-
"umd": "./dist/umd/
|
|
72
|
-
"import": "./dist/es/
|
|
73
|
-
"require": "./dist/cjs/
|
|
74
|
-
"node": "./dist/cjs/
|
|
75
|
-
"module": "./dist/es/
|
|
76
|
-
"default": "./dist/cjs/
|
|
40
|
+
"types": "./types/promisify.d.ts",
|
|
41
|
+
"browser": "./dist/es/promisify.development.js",
|
|
42
|
+
"umd": "./dist/umd/promisify.development.js",
|
|
43
|
+
"import": "./dist/es/promisify.development.js",
|
|
44
|
+
"require": "./dist/cjs/promisify.development.js",
|
|
45
|
+
"node": "./dist/cjs/promisify.development.js",
|
|
46
|
+
"module": "./dist/es/promisify.development.js",
|
|
47
|
+
"default": "./dist/cjs/promisify.development.js"
|
|
77
48
|
},
|
|
78
|
-
"types": "./types/
|
|
79
|
-
"browser": "./dist/es/
|
|
80
|
-
"umd": "./dist/umd/
|
|
81
|
-
"import": "./dist/es/
|
|
82
|
-
"require": "./dist/cjs/
|
|
83
|
-
"node": "./dist/cjs/
|
|
84
|
-
"module": "./dist/es/
|
|
85
|
-
"default": "./dist/cjs/
|
|
49
|
+
"types": "./types/promisify.d.ts",
|
|
50
|
+
"browser": "./dist/es/promisify.production.js",
|
|
51
|
+
"umd": "./dist/umd/promisify.production.js",
|
|
52
|
+
"import": "./dist/es/promisify.production.js",
|
|
53
|
+
"require": "./dist/cjs/promisify.production.js",
|
|
54
|
+
"node": "./dist/cjs/promisify.production.js",
|
|
55
|
+
"module": "./dist/es/promisify.production.js",
|
|
56
|
+
"default": "./dist/cjs/promisify.production.js"
|
|
86
57
|
},
|
|
87
|
-
"./
|
|
58
|
+
"./parser": {
|
|
88
59
|
"production": {
|
|
89
|
-
"types": "./types/
|
|
90
|
-
"browser": "./dist/es/
|
|
91
|
-
"umd": "./dist/umd/
|
|
92
|
-
"import": "./dist/es/
|
|
93
|
-
"require": "./dist/cjs/
|
|
94
|
-
"node": "./dist/cjs/
|
|
95
|
-
"module": "./dist/es/
|
|
96
|
-
"default": "./dist/cjs/
|
|
60
|
+
"types": "./types/parser.d.ts",
|
|
61
|
+
"browser": "./dist/es/parser.production.js",
|
|
62
|
+
"umd": "./dist/umd/parser.production.js",
|
|
63
|
+
"import": "./dist/es/parser.production.js",
|
|
64
|
+
"require": "./dist/cjs/parser.production.js",
|
|
65
|
+
"node": "./dist/cjs/parser.production.js",
|
|
66
|
+
"module": "./dist/es/parser.production.js",
|
|
67
|
+
"default": "./dist/cjs/parser.production.js"
|
|
97
68
|
},
|
|
98
69
|
"development": {
|
|
99
|
-
"types": "./types/
|
|
100
|
-
"browser": "./dist/es/
|
|
101
|
-
"umd": "./dist/umd/
|
|
102
|
-
"import": "./dist/es/
|
|
103
|
-
"require": "./dist/cjs/
|
|
104
|
-
"node": "./dist/cjs/
|
|
105
|
-
"module": "./dist/es/
|
|
106
|
-
"default": "./dist/cjs/
|
|
70
|
+
"types": "./types/parser.d.ts",
|
|
71
|
+
"browser": "./dist/es/parser.development.js",
|
|
72
|
+
"umd": "./dist/umd/parser.development.js",
|
|
73
|
+
"import": "./dist/es/parser.development.js",
|
|
74
|
+
"require": "./dist/cjs/parser.development.js",
|
|
75
|
+
"node": "./dist/cjs/parser.development.js",
|
|
76
|
+
"module": "./dist/es/parser.development.js",
|
|
77
|
+
"default": "./dist/cjs/parser.development.js"
|
|
107
78
|
},
|
|
108
|
-
"types": "./types/
|
|
109
|
-
"browser": "./dist/es/
|
|
110
|
-
"umd": "./dist/umd/
|
|
111
|
-
"import": "./dist/es/
|
|
112
|
-
"require": "./dist/cjs/
|
|
113
|
-
"node": "./dist/cjs/
|
|
114
|
-
"module": "./dist/es/
|
|
115
|
-
"default": "./dist/cjs/
|
|
79
|
+
"types": "./types/parser.d.ts",
|
|
80
|
+
"browser": "./dist/es/parser.production.js",
|
|
81
|
+
"umd": "./dist/umd/parser.production.js",
|
|
82
|
+
"import": "./dist/es/parser.production.js",
|
|
83
|
+
"require": "./dist/cjs/parser.production.js",
|
|
84
|
+
"node": "./dist/cjs/parser.production.js",
|
|
85
|
+
"module": "./dist/es/parser.production.js",
|
|
86
|
+
"default": "./dist/cjs/parser.production.js"
|
|
116
87
|
},
|
|
117
88
|
"./enforce/schema": {
|
|
118
89
|
"production": {
|
|
@@ -144,65 +115,95 @@
|
|
|
144
115
|
"module": "./dist/es/enforce/schema.production.js",
|
|
145
116
|
"default": "./dist/cjs/enforce/schema.production.js"
|
|
146
117
|
},
|
|
147
|
-
"./
|
|
118
|
+
"./enforce/compounds": {
|
|
148
119
|
"production": {
|
|
149
|
-
"types": "./types/
|
|
150
|
-
"browser": "./dist/es/
|
|
151
|
-
"umd": "./dist/umd/
|
|
152
|
-
"import": "./dist/es/
|
|
153
|
-
"require": "./dist/cjs/
|
|
154
|
-
"node": "./dist/cjs/
|
|
155
|
-
"module": "./dist/es/
|
|
156
|
-
"default": "./dist/cjs/
|
|
120
|
+
"types": "./types/enforce/compounds.d.ts",
|
|
121
|
+
"browser": "./dist/es/enforce/compounds.production.js",
|
|
122
|
+
"umd": "./dist/umd/enforce/compounds.production.js",
|
|
123
|
+
"import": "./dist/es/enforce/compounds.production.js",
|
|
124
|
+
"require": "./dist/cjs/enforce/compounds.production.js",
|
|
125
|
+
"node": "./dist/cjs/enforce/compounds.production.js",
|
|
126
|
+
"module": "./dist/es/enforce/compounds.production.js",
|
|
127
|
+
"default": "./dist/cjs/enforce/compounds.production.js"
|
|
157
128
|
},
|
|
158
129
|
"development": {
|
|
159
|
-
"types": "./types/
|
|
160
|
-
"browser": "./dist/es/
|
|
161
|
-
"umd": "./dist/umd/
|
|
162
|
-
"import": "./dist/es/
|
|
163
|
-
"require": "./dist/cjs/
|
|
164
|
-
"node": "./dist/cjs/
|
|
165
|
-
"module": "./dist/es/
|
|
166
|
-
"default": "./dist/cjs/
|
|
130
|
+
"types": "./types/enforce/compounds.d.ts",
|
|
131
|
+
"browser": "./dist/es/enforce/compounds.development.js",
|
|
132
|
+
"umd": "./dist/umd/enforce/compounds.development.js",
|
|
133
|
+
"import": "./dist/es/enforce/compounds.development.js",
|
|
134
|
+
"require": "./dist/cjs/enforce/compounds.development.js",
|
|
135
|
+
"node": "./dist/cjs/enforce/compounds.development.js",
|
|
136
|
+
"module": "./dist/es/enforce/compounds.development.js",
|
|
137
|
+
"default": "./dist/cjs/enforce/compounds.development.js"
|
|
167
138
|
},
|
|
168
|
-
"types": "./types/
|
|
169
|
-
"browser": "./dist/es/
|
|
170
|
-
"umd": "./dist/umd/
|
|
171
|
-
"import": "./dist/es/
|
|
172
|
-
"require": "./dist/cjs/
|
|
173
|
-
"node": "./dist/cjs/
|
|
174
|
-
"module": "./dist/es/
|
|
175
|
-
"default": "./dist/cjs/
|
|
139
|
+
"types": "./types/enforce/compounds.d.ts",
|
|
140
|
+
"browser": "./dist/es/enforce/compounds.production.js",
|
|
141
|
+
"umd": "./dist/umd/enforce/compounds.production.js",
|
|
142
|
+
"import": "./dist/es/enforce/compounds.production.js",
|
|
143
|
+
"require": "./dist/cjs/enforce/compounds.production.js",
|
|
144
|
+
"node": "./dist/cjs/enforce/compounds.production.js",
|
|
145
|
+
"module": "./dist/es/enforce/compounds.production.js",
|
|
146
|
+
"default": "./dist/cjs/enforce/compounds.production.js"
|
|
176
147
|
},
|
|
177
|
-
"./
|
|
148
|
+
"./enforce/compose": {
|
|
178
149
|
"production": {
|
|
179
|
-
"types": "./types/
|
|
180
|
-
"browser": "./dist/es/
|
|
181
|
-
"umd": "./dist/umd/
|
|
182
|
-
"import": "./dist/es/
|
|
183
|
-
"require": "./dist/cjs/
|
|
184
|
-
"node": "./dist/cjs/
|
|
185
|
-
"module": "./dist/es/
|
|
186
|
-
"default": "./dist/cjs/
|
|
150
|
+
"types": "./types/enforce/compose.d.ts",
|
|
151
|
+
"browser": "./dist/es/enforce/compose.production.js",
|
|
152
|
+
"umd": "./dist/umd/enforce/compose.production.js",
|
|
153
|
+
"import": "./dist/es/enforce/compose.production.js",
|
|
154
|
+
"require": "./dist/cjs/enforce/compose.production.js",
|
|
155
|
+
"node": "./dist/cjs/enforce/compose.production.js",
|
|
156
|
+
"module": "./dist/es/enforce/compose.production.js",
|
|
157
|
+
"default": "./dist/cjs/enforce/compose.production.js"
|
|
187
158
|
},
|
|
188
159
|
"development": {
|
|
189
|
-
"types": "./types/
|
|
190
|
-
"browser": "./dist/es/
|
|
191
|
-
"umd": "./dist/umd/
|
|
192
|
-
"import": "./dist/es/
|
|
193
|
-
"require": "./dist/cjs/
|
|
194
|
-
"node": "./dist/cjs/
|
|
195
|
-
"module": "./dist/es/
|
|
196
|
-
"default": "./dist/cjs/
|
|
160
|
+
"types": "./types/enforce/compose.d.ts",
|
|
161
|
+
"browser": "./dist/es/enforce/compose.development.js",
|
|
162
|
+
"umd": "./dist/umd/enforce/compose.development.js",
|
|
163
|
+
"import": "./dist/es/enforce/compose.development.js",
|
|
164
|
+
"require": "./dist/cjs/enforce/compose.development.js",
|
|
165
|
+
"node": "./dist/cjs/enforce/compose.development.js",
|
|
166
|
+
"module": "./dist/es/enforce/compose.development.js",
|
|
167
|
+
"default": "./dist/cjs/enforce/compose.development.js"
|
|
197
168
|
},
|
|
198
|
-
"types": "./types/
|
|
199
|
-
"browser": "./dist/es/
|
|
200
|
-
"umd": "./dist/umd/
|
|
201
|
-
"import": "./dist/es/
|
|
202
|
-
"require": "./dist/cjs/
|
|
203
|
-
"node": "./dist/cjs/
|
|
204
|
-
"module": "./dist/es/
|
|
205
|
-
"default": "./dist/cjs/
|
|
169
|
+
"types": "./types/enforce/compose.d.ts",
|
|
170
|
+
"browser": "./dist/es/enforce/compose.production.js",
|
|
171
|
+
"umd": "./dist/umd/enforce/compose.production.js",
|
|
172
|
+
"import": "./dist/es/enforce/compose.production.js",
|
|
173
|
+
"require": "./dist/cjs/enforce/compose.production.js",
|
|
174
|
+
"node": "./dist/cjs/enforce/compose.production.js",
|
|
175
|
+
"module": "./dist/es/enforce/compose.production.js",
|
|
176
|
+
"default": "./dist/cjs/enforce/compose.production.js"
|
|
177
|
+
},
|
|
178
|
+
"./classnames": {
|
|
179
|
+
"production": {
|
|
180
|
+
"types": "./types/classnames.d.ts",
|
|
181
|
+
"browser": "./dist/es/classnames.production.js",
|
|
182
|
+
"umd": "./dist/umd/classnames.production.js",
|
|
183
|
+
"import": "./dist/es/classnames.production.js",
|
|
184
|
+
"require": "./dist/cjs/classnames.production.js",
|
|
185
|
+
"node": "./dist/cjs/classnames.production.js",
|
|
186
|
+
"module": "./dist/es/classnames.production.js",
|
|
187
|
+
"default": "./dist/cjs/classnames.production.js"
|
|
188
|
+
},
|
|
189
|
+
"development": {
|
|
190
|
+
"types": "./types/classnames.d.ts",
|
|
191
|
+
"browser": "./dist/es/classnames.development.js",
|
|
192
|
+
"umd": "./dist/umd/classnames.development.js",
|
|
193
|
+
"import": "./dist/es/classnames.development.js",
|
|
194
|
+
"require": "./dist/cjs/classnames.development.js",
|
|
195
|
+
"node": "./dist/cjs/classnames.development.js",
|
|
196
|
+
"module": "./dist/es/classnames.development.js",
|
|
197
|
+
"default": "./dist/cjs/classnames.development.js"
|
|
198
|
+
},
|
|
199
|
+
"types": "./types/classnames.d.ts",
|
|
200
|
+
"browser": "./dist/es/classnames.production.js",
|
|
201
|
+
"umd": "./dist/umd/classnames.production.js",
|
|
202
|
+
"import": "./dist/es/classnames.production.js",
|
|
203
|
+
"require": "./dist/cjs/classnames.production.js",
|
|
204
|
+
"node": "./dist/cjs/classnames.production.js",
|
|
205
|
+
"module": "./dist/es/classnames.production.js",
|
|
206
|
+
"default": "./dist/cjs/classnames.production.js"
|
|
206
207
|
},
|
|
207
208
|
".": {
|
|
208
209
|
"development": {
|
|
@@ -227,4 +228,4 @@
|
|
|
227
228
|
"./package.json": "./package.json",
|
|
228
229
|
"./*": "./*"
|
|
229
230
|
}
|
|
230
|
-
}
|
|
231
|
+
}
|
package/testUtils/TVestMock.ts
CHANGED
|
@@ -4,4 +4,4 @@ import * as vest from 'vest';
|
|
|
4
4
|
export type TVestMock = typeof vest;
|
|
5
5
|
|
|
6
6
|
export type TTestSuiteCallback = (...args: any[]) => void;
|
|
7
|
-
export type TTestSuite = vest.Suite<
|
|
7
|
+
export type TTestSuite = vest.Suite<TFieldName, TGroupName, TTestSuiteCallback>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ErrorStrings } from 'ErrorStrings';
|
|
2
|
+
import { invariant } from 'vest-utils';
|
|
3
|
+
|
|
4
|
+
import { IsolateTest } from 'IsolateTest';
|
|
5
|
+
|
|
6
|
+
export function asVestTest(value: any): IsolateTest {
|
|
7
|
+
invariant(value instanceof IsolateTest, ErrorStrings.EXPECTED_VEST_TEST);
|
|
8
|
+
return value;
|
|
9
|
+
}
|
package/types/classnames.d.ts
CHANGED
|
@@ -1,10 +1,92 @@
|
|
|
1
|
+
import { Isolate, IsolateKey } from "vest-runtime";
|
|
2
|
+
import { CB } from "vest-utils";
|
|
1
3
|
declare enum Severity {
|
|
2
4
|
WARNINGS = "warnings",
|
|
3
5
|
ERRORS = "errors"
|
|
4
6
|
}
|
|
7
|
+
declare enum TestSeverity {
|
|
8
|
+
Error = "error",
|
|
9
|
+
Warning = "warning"
|
|
10
|
+
}
|
|
11
|
+
// @vx-allow use-use
|
|
12
|
+
declare function IsolateTestReconciler(currentNode: Isolate, historyNode: Isolate | null): Isolate;
|
|
13
|
+
declare enum TestStatus {
|
|
14
|
+
UNTESTED = "UNTESTED",
|
|
15
|
+
SKIPPED = "SKIPPED",
|
|
16
|
+
FAILED = "FAILED",
|
|
17
|
+
WARNING = "WARNING",
|
|
18
|
+
PASSING = "PASSING",
|
|
19
|
+
PENDING = "PENDING",
|
|
20
|
+
CANCELED = "CANCELED",
|
|
21
|
+
OMITTED = "OMITTED"
|
|
22
|
+
}
|
|
23
|
+
type TestFn = () => TestResult;
|
|
24
|
+
type AsyncTest = Promise<string | void | false>;
|
|
25
|
+
type TestResult = AsyncTest | boolean | void;
|
|
5
26
|
type WithFieldName<F extends TFieldName = TFieldName> = {
|
|
6
27
|
fieldName: F;
|
|
7
28
|
};
|
|
29
|
+
type IsolateTestInput = {
|
|
30
|
+
message?: string;
|
|
31
|
+
groupName?: string;
|
|
32
|
+
fieldName: TFieldName;
|
|
33
|
+
testFn: TestFn;
|
|
34
|
+
key?: IsolateKey;
|
|
35
|
+
};
|
|
36
|
+
declare class IsolateTest<F extends TFieldName = TFieldName, G extends TGroupName = TGroupName> extends Isolate {
|
|
37
|
+
children: null;
|
|
38
|
+
fieldName: F;
|
|
39
|
+
testFn: TestFn;
|
|
40
|
+
groupName?: G;
|
|
41
|
+
message?: string;
|
|
42
|
+
asyncTest?: AsyncTest;
|
|
43
|
+
id: string;
|
|
44
|
+
severity: TestSeverity;
|
|
45
|
+
private stateMachine;
|
|
46
|
+
static reconciler: typeof IsolateTestReconciler;
|
|
47
|
+
constructor({ fieldName, testFn, message, groupName, key }: IsolateTestInput);
|
|
48
|
+
static create<Callback extends CB = CB>(callback: Callback, data: IsolateTestInput): IsolateTest;
|
|
49
|
+
static cast<F extends TFieldName = TFieldName, G extends TGroupName = TGroupName>(isolate: Isolate): IsolateTest<F, G>;
|
|
50
|
+
get status(): TestStatus;
|
|
51
|
+
setStatus(status: TestStatus, payload?: any): void;
|
|
52
|
+
run(): TestResult;
|
|
53
|
+
// Selectors
|
|
54
|
+
warns(): boolean;
|
|
55
|
+
isPending(): boolean;
|
|
56
|
+
isOmitted(): boolean;
|
|
57
|
+
isUntested(): boolean;
|
|
58
|
+
isFailing(): boolean;
|
|
59
|
+
isCanceled(): boolean;
|
|
60
|
+
isSkipped(): boolean;
|
|
61
|
+
isPassing(): boolean;
|
|
62
|
+
isWarning(): boolean;
|
|
63
|
+
hasFailures(): boolean;
|
|
64
|
+
isNonActionable(): boolean;
|
|
65
|
+
isTested(): boolean;
|
|
66
|
+
awaitsResolution(): boolean;
|
|
67
|
+
statusEquals(status: TestStatus): boolean;
|
|
68
|
+
// State modifiers
|
|
69
|
+
setPending(): void;
|
|
70
|
+
fail(): void;
|
|
71
|
+
pass(): void;
|
|
72
|
+
warn(): void;
|
|
73
|
+
skip(force?: boolean): void;
|
|
74
|
+
cancel(): void;
|
|
75
|
+
reset(): void;
|
|
76
|
+
omit(): void;
|
|
77
|
+
valueOf(): boolean;
|
|
78
|
+
isAsyncTest(): boolean;
|
|
79
|
+
static is(value: any): value is IsolateTest;
|
|
80
|
+
static isX(value: any): asserts value is IsolateTest;
|
|
81
|
+
}
|
|
82
|
+
declare class SummaryFailure<F extends TFieldName, G extends TGroupName> implements WithFieldName<F> {
|
|
83
|
+
fieldName: F;
|
|
84
|
+
message: string | undefined;
|
|
85
|
+
groupName: G | undefined;
|
|
86
|
+
constructor(fieldName: F, message: string | undefined, groupName: G | undefined);
|
|
87
|
+
static fromTestObject<F extends TFieldName, G extends TGroupName>(testObject: IsolateTest<F, G>): SummaryFailure<F, G>;
|
|
88
|
+
toString(): string;
|
|
89
|
+
}
|
|
8
90
|
interface Done<F extends TFieldName, G extends TGroupName> {
|
|
9
91
|
(...args: [
|
|
10
92
|
cb: (res: SuiteResult<F, G>) => void
|
|
@@ -53,10 +135,6 @@ type SingleTestSummary = SummaryBase & {
|
|
|
53
135
|
warnings: string[];
|
|
54
136
|
valid: boolean;
|
|
55
137
|
};
|
|
56
|
-
type SummaryFailure<F extends TFieldName, G extends TGroupName> = WithFieldName<F> & {
|
|
57
|
-
groupName: G | undefined;
|
|
58
|
-
message: string | undefined;
|
|
59
|
-
};
|
|
60
138
|
type FailureMessages = Record<string, string[]>;
|
|
61
139
|
type SuiteResult<F extends TFieldName, G extends TGroupName> = SuiteSummary<F, G> & SuiteSelectors<F, G> & {
|
|
62
140
|
suiteName: SuiteName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classnames.d.ts","sourceRoot":"","sources":["../src/exports/classnames.ts","../src/suiteResult/Severity.ts","../src/
|
|
1
|
+
{"version":3,"file":"classnames.d.ts","sourceRoot":"","sources":["../src/exports/classnames.ts","../src/suiteResult/Severity.ts","../src/errors/ErrorStrings.ts","../src/core/test/TestTypes.ts","../src/core/test/helpers/matchingFieldName.ts","../src/core/isolate/IsolateTest/isSameProfileTest.ts","../src/core/isolate/IsolateTest/cancelOverriddenPendingTest.ts","../src/hooks/optional/OptionalTypes.ts","../src/core/isolate/IsolateSuite/IsolateSuite.ts","../src/hooks/optional/optional.ts","../src/core/isolate/IsolateTest/TestWalker.ts","../src/core/test/helpers/matchingGroupName.ts","../src/core/test/helpers/nonMatchingSeverityProfile.ts","../src/suiteResult/selectors/hasFailuresByTestObjects.ts","../src/hooks/mode.ts","../src/core/context/SuiteContext.ts","../src/core/Runtime.ts","../src/suiteResult/selectors/shouldAddValidProperty.ts","../src/suiteResult/selectors/produceSuiteSummary.ts","../src/suiteResult/selectors/collectFailures.ts","../src/suiteResult/selectors/suiteSelectors.ts","../src/suiteResult/suiteResult.ts","../src/isolates/skipWhen.ts","../src/hooks/exclusive.ts","../src/isolates/omitWhen.ts","../src/core/test/testLevelFlowControl/verifyTestRun.ts","../src/core/isolate/IsolateTest/IsolateTestReconciler.ts","../src/core/isolate/IsolateTest/IsolateTestStateMachine.ts","../src/core/test/helpers/shouldUseErrorMessage.ts","../src/core/isolate/IsolateTest/IsolateTest.ts","../src/suiteResult/SummaryFailure.ts","../src/suiteResult/done/deferDoneCallback.ts","../src/suiteResult/done/shouldSkipDoneRegistration.ts","../src/suiteResult/suiteRunResult.ts","../src/suiteResult/SuiteResultTypes.ts","../src/exports/parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA;;GAEG;AACH,iBAAwB,UAAU,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,UAAU,EAC3E,GAAG,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,EACvB,OAAO,GAAE,gBAAqB,GAC7B,CAAC,SAAS,EAAE,CAAC,KAAK,MAAM,CAe1B;AAED,KAAK,gBAAgB,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC"}
|