vest 5.0.0-dev-9c596e → 5.0.0-dev-ae6b14
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 +516 -682
- 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 +512 -676
- 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 +520 -687
- 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 +152 -140
- package/types/vest.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export{enforce}from"n4s";import{isNullish as t,optionalFunctionValue as e,invariant as n,isNotNullish as r,bindNot as s,either as i,assign as o,tinyState as u,cache as c,defaultTo as a,isPositive as l,asArray as E,isStringValue as d,hasOwnProperty as f,deferThrow as N,text as T,isUndefined as h,seq as R,isPromise as I,isArray as S,callEach as _,bus as m,isNull as p,isFunction as v,numberEquals as A}from"vest-utils";import{createCascade as g}from"context";var D,O,C,y,U;function L(n,r,s){if(t(n.children))return;let i=!1;for(const u of n.children){if(i)return;if((t(s)||e(s,u))&&r(u,o),i)return;L(u,((t,e)=>{r(t,(()=>{e(),o()}))}),s)}function o(){i=!0}}function P(t,e,n){let r=!1;return L(t,((t,n)=>{e(t)&&(n(),r=!0)}),n),r}function F(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"}(D||(D={})),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}."}(O||(O={})),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"}(C||(C={}));class G{static reconciler(e,n){return t(n),e}static reconcile(t,e){var r;const s=Zt(),i=Jt();let o=i;s&&(o=null!==(r=null==i?void 0:i.at(zt()))&&void 0!==r?r:null);const u=this.reconciler(t,o);return n(u),Object.is(u,t)?[t,W(o,t,e)]:[u,u.output]}static removeAllNextNodesInIsolate(){const t=Zt(),e=Jt();e&&t&&e.slice(zt())}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(e){n(e.usesKey());const r=function(e){var n;if(t(e))return null;const r=Bt().historyNode;return null!==(n=null==r?void 0:r.keys[e])&&void 0!==n?n:null}(e.key);let s=e;return t(r)||(s=r),function(e,r){if(!e)return;const s=Zt();if(n(s,O.NO_ACTIVE_ISOLATE),t(s.keys[e]))return void(s.keys[e]=r);N(T(O.ENCOUNTERED_THE_SAME_KEY_TWICE,{key:e}))}(e.key,e),s}}function W(t,e,n){const r=$t(),s=bt.run(Object.assign({historyNode:t,runtimeNode:e},!r&&{runtimeRoot:e}),(()=>n(e)));return e.output=s,s}class k{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 r(this.key)}addChild(t){n(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(e){t(this.children)||(this.children.length=e)}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=!!F(this,(t=>t.allowReorder)))&&void 0!==t&&t}get rootNode(){var e;return null!==(e=F(this,(e=>t(e.parent))))&&void 0!==e?e:this}static create(t,e){return this.createImplementation(t,e)}static createImplementation(t,e){const n=Zt(),r=new this(e).setParent(n),[s,i]=this.reconciler.reconcile(r,t);return s.saveOutput(i),this.setNode(s),s}static setNode(t){const e=Zt();e?function(t){const e=Zt();n(e,O.NO_ACTIVE_ISOLATE),e.addChild(t)}(t):function(t){const e=bt.useX(),[,n]=e.historyRoot();n(t)}(t),t.setParent(e)}static is(t){return t instanceof k}}function w(t,e){return!!e&&!M(t,e)}function M(t,e){return!(!e||t.fieldName!==e)}function b(t,e){return M(t,e.fieldName)&&t.groupName===e.groupName&&t.key===e.key}function K(t){return t===y.ERRORS?U.ERROR_COUNT:U.WARN_COUNT}k.reconciler=G,function(t){t.WARNINGS="warnings",t.ERRORS="errors"}(y||(y={})),function(t){t.ERROR_COUNT="errorCount",t.WARN_COUNT="warnCount"}(U||(U={}));const x=s((function(t,e){return t.groupName===e}));function B(t){return function(t,e){return kt.someTests((n=>X(n,t,e)))}(y.ERRORS,t)}function X(t,e,n){return!!t.hasFailures()&&(!w(t,n)&&!function(t,e){return i(t===y.WARNINGS,e.warns())}(e,t))}var V;function H(t){const[,e]=Q();e(t)}function j(){return function(t){const[e]=Q();return e===t}(V.EAGER)}!function(t){t.ALL="ALL",t.EAGER="EAGER"}(V||(V={}));const q=g(((t,e)=>e?null:o({exclusion:{tests:{},groups:{}},inclusion:{},mode:u.createTinyState(V.EAGER),testMemoCache:Z},t)));function Y(t){return q.useX(t).exclusion}function J(){return q.useX().inclusion}function Q(){return q.useX().mode()}const Z=c(10);var z,$,tt,et;class nt{constructor(){this.errorCount=0,this.warnCount=0,this.testCount=0}}class rt extends nt{constructor(){super(...arguments),this[z]=[],this[$]=[],this.groups={},this.tests={},this.valid=!1}}function st(t){return!!ne(t)||!kt.hasNoTests()&&(!B(t)&&(!function(t){return kt.someIncompleteTests((e=>ot(e,t)))}(t)&&function(t){return kt.everyTest((e=>ut(e,t)))}(t)))}function it(t,e){return!!ne(e)||!function(t,e,n){return kt.someTests((r=>!x(r,e)&&X(r,t,n)))}(y.ERRORS,t,e)&&(!function(t,e){return kt.someIncompleteTests((n=>!x(n,t)&&ot(n,e)))}(t,e)&&function(t,e){return kt.everyTest((n=>!!x(n,t)||ut(n,e)))}(t,e))}function ot(t,e){return!w(t,e)&&ne(e)}function ut(t,e){return!!w(t,e)||(function(t){var e;return(null===(e=te())||void 0===e?void 0:e.getOptionalField(t.fieldName).type)===D.Delayed&&t.awaitsResolution()}(t)||t.isTested()||t.isOmitted())}function ct(){const t=new rt;return kt.walkTests((e=>{t.tests=function(t,e){const{fieldName:n}=e,r=Object.assign({},t);return r[n]=lt(r[n],e),r[n].valid=!1!==r[n].valid&&st(n),r}(t.tests,e),t.groups=function(t,e){const{groupName:n,fieldName:r}=e;if(!n)return t;const s=Object.assign({},t);return s[n]=s[n]||{},s[n][r]=lt(s[n][r],e),s[n][r].valid=!1!==s[n][r].valid&&it(n,r),s}(t.groups,e),t.errors=at(y.ERRORS,t.errors,e),t.warnings=at(y.WARNINGS,t.warnings,e)})),t.valid=st(),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 at(t,e,n){return(t===y.WARNINGS?n.isWarning():n.isFailing())?e.concat({fieldName:n.fieldName,groupName:n.groupName,message:n.message}):e}function lt(t,e){const{message:n}=e,r=a(t?Object.assign({},t):null,Et);return e.isNonActionable()||(r.testCount++,e.isFailing()?s(y.ERRORS):e.isWarning()&&s(y.WARNINGS)),r;function s(t){const e=K(t);r[e]++,n&&(r[t]=(r[t]||[]).concat(n))}}function Et(){return o(new nt,{errors:[],warnings:[],valid:!0})}function dt(t,e,n){return n?function(t,e,n){var r;return(null===(r=null==t?void 0:t[n])||void 0===r?void 0:r[e])||[]}(t,e,n):function(t,e){const n={},r=K(e);for(const s in t)l(t[s][r])&&(n[s]=t[s][e]||[]);return n}(t,e)}function ft(t){const e={getError:function(e){return St(y.ERRORS,t,e)},getErrors:function(e){return Nt(t,y.ERRORS,e)},getErrorsByGroup:function(e,n){return Tt(t,y.ERRORS,e,n)},getWarning:function(e){return St(y.WARNINGS,t,e)},getWarnings:function(e){return Nt(t,y.WARNINGS,e)},getWarningsByGroup:function(e,n){return Tt(t,y.WARNINGS,e,n)},hasErrors:function(e){return It(t,U.ERROR_COUNT,e)},hasErrorsByGroup:function(e,n){return Rt(t,U.ERROR_COUNT,e,n)},hasWarnings:function(e){return It(t,U.WARN_COUNT,e)},hasWarningsByGroup:function(e,n){return Rt(t,U.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 r=t.groups[e];if(!r)return!1;if(n)return ht(r,n);for(const t in r)if(!ht(r,t))return!1;return!0}};return e}function Nt(t,e,n){return dt(t.tests,e,n)}function Tt(t,e,n,r){return dt(t.groups[n],e,r)}function ht(t,e){var n;return!!(null===(n=t[e])||void 0===n?void 0:n.valid)}function Rt(t,e,n,r){var s,i;const o=t.groups[n];if(!o)return!1;if(r)return l(null===(s=o[r])||void 0===s?void 0:s[e]);for(const t in o)if(l(null===(i=o[t])||void 0===i?void 0:i[e]))return!0;return!1}function It(t,e,n){var r;const s=n?null===(r=t.tests[n])||void 0===r?void 0:r[e]:t[e]||0;return l(s)}function St(t,e,n){var r;const s=e[t];return n?null===(r=s.find((t=>M(t,n))))||void 0===r?void 0:r.message:s[0]}function _t(){const t=ct(),e=Bt().suiteName;return function(t){const e=Bt().suiteResultCache;return e([Qt()],t)}((()=>o(t,ft(t),{suiteName:e})))}function mt(t,n){k.create((()=>{q.run({skipped:pt()||e(t,e(_t))},n)}))}function pt(){return function(){var t;return null!==(t=q.useX().skipped)&&void 0!==t&&t}()}function vt(t){return Dt(0,"tests",t)}function At(t){return Dt(1,"tests",t)}function gt(t){const{fieldName:n,groupName:r}=t;if(pt())return!0;const s=Y(),i=J(),o=s.tests,u=o[n];if(!1===u)return!0;const c=!0===u;if(r){if(function(t){const e=Y(),n=e.groups,r=f(n,t);if(r)return!1===n[t];return Ct()}(r))return!0;if(!0===s.groups[r])return!c&&(!!Ot(o)||!1===o[n])}return!!function(t){if(!Ct())return!1;return!t}(r)||!c&&(!!Ot(o)&&!e(i[n]))}function Dt(t,e,n){const r=Y(O.HOOK_CALLED_OUTSIDE);n&&E(n).forEach((n=>{d(n)&&(r[e][n]=0===t)}))}function Ot(t){for(const e in t)if(!0===t[e])return!0;return!1}function Ct(){const t=Y();for(const e in t.groups)if(t.groups[e])return!0;return!1}function yt(t,n){k.create((()=>{q.run({omitted:Ut()||e(t,e(_t))},n)}))}function Ut(){return function(){var t;return null!==(t=q.useX().omitted)&&void 0!==t&&t}()}function Lt(t,e=t){return function(t){return j()&&B(t.fieldName)}(t)?((n=t).skip(),n):function(t){return Ut()||ne(t.fieldName)}(t)?function(t){return t.omit(),t}(t):gt(t)?function(t){return t.skip(pt()),t}(e):t;var n}z=y.ERRORS,$=y.WARNINGS,vt.group=function(t){return Dt(0,"groups",t)},At.group=function(t){return Dt(1,"groups",t)};function Pt(){return function(t){let e=t.initial;return{getState:function(){return e},transition:function(n,r){let s=t.states[e][n];if(Array.isArray(s)){const[,t]=s;if(!t(r))return;s=s[0]}s&&s!==e&&(e=s)}}}(Ft)}!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"}(tt||(tt={})),function(t){t.RESET="RESET"}(et||(et={}));const Ft={initial:tt.UNTESTED,states:{[tt.UNTESTED]:{[tt.CANCELED]:tt.CANCELED,[tt.FAILED]:tt.FAILED,[tt.OMITTED]:tt.OMITTED,[tt.PASSING]:tt.PASSING,[tt.PENDING]:tt.PENDING,[tt.SKIPPED]:tt.SKIPPED,[tt.WARNING]:tt.WARNING},[tt.SKIPPED]:{[et.RESET]:tt.UNTESTED},[tt.FAILED]:{[et.RESET]:tt.UNTESTED},[tt.WARNING]:{[et.RESET]:tt.UNTESTED},[tt.PASSING]:{[et.RESET]:tt.UNTESTED},[tt.PENDING]:{[et.RESET]:tt.UNTESTED,[tt.CANCELED]:tt.CANCELED,[tt.FAILED]:tt.FAILED,[tt.OMITTED]:tt.OMITTED,[tt.PASSING]:tt.PASSING,[tt.SKIPPED]:[tt.SKIPPED,t=>!0===t],[tt.WARNING]:tt.WARNING},[tt.CANCELED]:{[et.RESET]:tt.UNTESTED},[tt.OMITTED]:{[et.RESET]:tt.UNTESTED}}};class Gt extends k{constructor({fieldName:t,testFn:e,message:n,groupName:r,key:s=null}){super(),this.children=null,this.id=R(),this.severity=Wt.Error,this.stateMachine=Pt(),this.fieldName=t,this.testFn=e,r&&(this.groupName=r),n&&(this.message=n),this.setKey(s)}static create(t,e){return Gt.cast(super.create(t,e))}static cast(t){return Gt.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 h(t)&&d(e)})(this.message,e)&&(this.message=e),t=!1}return!1===t&&this.fail(),t}warns(){return this.severity===Wt.Warning}isPending(){return this.statusEquals(tt.PENDING)}isOmitted(){return this.statusEquals(tt.OMITTED)}isUntested(){return this.statusEquals(tt.UNTESTED)}isFailing(){return this.statusEquals(tt.FAILED)}isCanceled(){return this.statusEquals(tt.CANCELED)}isSkipped(){return this.statusEquals(tt.SKIPPED)}isPassing(){return this.statusEquals(tt.PASSING)}isWarning(){return this.statusEquals(tt.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(tt.PENDING)}fail(){this.setStatus(this.warns()?tt.WARNING:tt.FAILED)}pass(){this.setStatus(tt.PASSING)}warn(){this.severity=Wt.Warning}skip(t){this.setStatus(tt.SKIPPED,t)}cancel(){this.setStatus(tt.CANCELED)}reset(){this.stateMachine.transition(et.RESET)}omit(){this.setStatus(tt.OMITTED)}valueOf(){return!this.isFailing()}isAsyncTest(){return I(this.asyncTest)}static is(t){return t instanceof Gt}static isX(t){n(this.is(t))}}var Wt;Gt.reconciler=class extends G{static reconciler(e,n){if(!Gt.is(e))return e;if(t(n))return this.handleNoHistoryNode(e);if(!Gt.is(n))return e;const r=this.pickNode(n,e);return function(t,e,n){t===e&&Gt.is(e)&&(s=e)!==(r=n)&&b(r,s)&&r.isPending()&&r.cancel();var r,s}(r,e,n),r}static nodeReorderDetected(t,e){return!!Gt.is(e)&&!b(e,t)}static handleCollision(t,e){return t.usesKey()?Gt.cast(this.handleIsolateNodeWithKey(t)):this.nodeReorderDetected(t,e)?this.onNodeReorder(t,e):Gt.cast(e||t)}static onNodeReorder(t,e){return function(t,e){if(t.shouldAllowReorder())return;N(T(O.TESTS_CALLED_IN_DIFFERENT_ORDER,{fieldName:t.fieldName,prevName:Gt.is(e)?e.fieldName:void 0}))}(t,e),this.removeAllNextNodesInIsolate(),t}static pickNode(t,e){return Lt(e,this.handleCollision(e,t))}static handleNoHistoryNode(t){return t.usesKey()?Gt.cast(this.handleIsolateNodeWithKey(t)):t}},function(t){t.Error="error",t.Warning="warning"}(Wt||(Wt={}));class kt{static defaultRoot(){return te()}static hasNoTests(t=kt.defaultRoot()){return!t||(e=t,n=Gt.is,!P(e,(()=>!0),n));var e,n}static someIncompleteTests(t,e=kt.defaultRoot()){return!!e&&P(e,(e=>(Gt.isX(e),e.isPending()&&t(e))),Gt.is)}static someTests(t,e=kt.defaultRoot()){return!!e&&P(e,(e=>(Gt.isX(e),t(e))),Gt.is)}static everyTest(t,e=kt.defaultRoot()){return!!e&&function(t,e,n){let r=!0;return L(t,((t,n)=>{e(t)||(n(),r=!1)}),n),r}(e,(e=>(Gt.isX(e),t(e))),Gt.is)}static walkTests(t,e=kt.defaultRoot()){e&&L(e,((e,n)=>{t(Gt.cast(e),n)}),Gt.is)}static hasRemainingTests(t){return kt.someIncompleteTests((e=>!t||M(e,t)))}static pluckTests(t,e=kt.defaultRoot()){e&&function(t,e,n){L(t,(t=>{e(t)&&t.parent&&t.parent.removeChild(t)}),n)}(e,(e=>(Gt.isX(e),t(e))),Gt.is)}static resetField(t){kt.walkTests((e=>{M(e,t)&&e.reset()}),kt.defaultRoot())}static removeTestByFieldName(t,e=kt.defaultRoot()){kt.pluckTests((e=>M(e,t)),e)}}function wt(){const t=m.createBus();return e(C.TEST_COMPLETED,(e=>{e.isCanceled()||(!function(t){const[e]=qt();t&&!kt.hasRemainingTests(t)&&S(e[t])&&_(e[t])}(e.fieldName),kt.hasRemainingTests()||t.emit(C.ALL_RUNNING_TESTS_FINISHED))})),e(C.TEST_RUN_STARTED,(()=>{})),e(C.ALL_RUNNING_TESTS_FINISHED,(()=>{!function(){const[t]=jt();_(t)}()})),e(C.RESET_FIELD,(t=>{kt.resetField(t)})),e(C.SUITE_RUN_STARTED,(()=>{xt()})),e(C.REMOVE_FIELD,(t=>{kt.removeTestByFieldName(t)})),e(C.RESET_SUITE,(()=>{!function(){xt();const[,,t]=Yt();t()}()})),t;function e(e,n){t.on(e,((...t)=>{!function(){const t=Bt().suiteResultCache;t.invalidate([Qt()])}(),n(...t)}))}}const Mt=c(),bt=g(((t,e)=>{if(e)return null;n(t.historyRoot);const[r]=t.historyRoot(),s={};return o(s,{historyNode:r,runtimeNode:null,runtimeRoot:null},t),s}));function Kt(t){const e=bt.useX();return function(...n){var r;const s=null!==(r=bt.use())&&void 0!==r?r:e;return bt.run(s,(()=>t(...n)))}}function xt(){const[,,t]=jt(),[,,e]=qt();t(),e()}function Bt(){return bt.useX()}function Xt(){return Bt().VestBus}function Vt(){return Kt(Xt().emit)}function Ht(t){const e=Vt();return n=>e(t,n)}function jt(){return Bt().doneCallbacks()}function qt(){return Bt().fieldCallbacks()}function Yt(){return Bt().historyRoot()}function Jt(){return Bt().historyNode}function Qt(){return Bt().suiteId}function Zt(){var t;return null!==(t=Bt().runtimeNode)&&void 0!==t?t:null}function zt(){var t,e;return null!==(e=null===(t=Zt())||void 0===t?void 0:t.cursor())&&void 0!==e?e:0}function $t(){return Bt().runtimeRoot}function te(){const t=$t();if(t)return t;const[e]=Yt();return e}function ee(t){const n=$t();if(S(t)||d(t))E(t).forEach((t=>{n.setOptionalField(t,(()=>({type:D.Delayed,applied:!1,rule:null})))}));else for(const r in t){const s=t[r];n.setOptionalField(r,(()=>({type:D.Immediate,rule:s,applied:e(s)})))}}function ne(t){var e,n,r;return!!t&&(null!==(r=null===(n=null===(e=te())||void 0===e?void 0:e.getOptionalField(t))||void 0===n?void 0:n.applied)&&void 0!==r&&r)}class re extends k{constructor(){super(...arguments),this.optional={}}setOptionalField(t,e){const n=this.optional,r=n[t];Object.assign(n,{[t]:Object.assign({},r,e(r))})}getOptionalField(t){var e;return null!==(e=this.optional[t])&&void 0!==e?e:{}}}function se(t){const r=J(),s=Y();return n(d(t)),r[t]=a(s.tests[t],!0),{when:function(n){const r=J(),s=Y();r[t]=()=>f(s.tests,t)?a(s.tests[t],!0):d(n)?Boolean(s.tests[n]):e(n,e(_t))}}}function ie(t){Lt(t),t.isNonActionable()||(t.isUntested()?function(t){const e=Xt(),n=function(t){return q.run({currentTest:t},(()=>t.run()))}(t);try{I(n)?(t.asyncTest=n,t.setPending(),oe(t)):ue(e,t)}catch(e){throw new Error(T(O.UNEXPECTED_TEST_REGISTRATION_ERROR,{testObject:JSON.stringify(t),error:e}))}}(t):t.isAsyncTest()&&(t.setPending(),oe(t)))}function oe(t){const{asyncTest:e,message:n}=t;if(!I(e))return;const r=Xt(),s=Kt((()=>{ue(r,t)})),i=Kt((e=>{t.isCanceled()||(t.message=d(e)?e:n,t.fail(),s())}));e.then(s,i)}function ue(t,e){e.pass(),t.emit(C.TEST_COMPLETED,e)}function ce(t,...e){const[r,s,i]=v(e[1])?e:[void 0,...e];!function(t,e){const r="test";n(d(t),T(O.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:r,param:"fieldName",expected:"string"})),n(v(e),T(O.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:r,param:"callback",expected:"function"}))}(t,s);const o={fieldName:t,groupName:q.useX().groupName,key:i,message:r,testFn:s};return Vt()(C.TEST_RUN_STARTED),Gt.create(ie,o)}const ae=o(ce,{memo:function(t){return function(e,...n){const[r,s,i]=n.reverse();return function(t,e){const n=q.useX().testMemoCache,r=n.get(t);if(p(r))return n(t,e);const[,s]=r;if(s.isCanceled())return n.invalidate(t),n(t,e);return Gt.setNode(s),s}([Qt(),e,zt()].concat(r),(function(){return t(e,i,s)}))}}(ce)});function le(){return{group:he,include:se,omitWhen:yt,only:vt,optional:ee,skip:At,skipWhen:mt,test:ae}}function Ee(){return o({},_t(),{done:Kt(de)})}function de(...t){const[e,n]=t.reverse(),r=Ee();if(function(t,e,n){var r;return!!(!v(t)||e&&A(null===(r=n.tests[e])||void 0===r?void 0:r.testCount,0))}(e,n,r))return r;const s=()=>e(_t());return kt.hasRemainingTests(n)?(function(t,e){const[,n]=qt(),[,r]=jt();e?n((n=>o(n,{[e]:(n[e]||[]).concat(t)}))):r((e=>e.concat(t)))}(s,n),r):(s(),r)}function fe(...t){const[e,r]=t.reverse();!function(t){n(v(t),O.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION)}(e);const s=function({suiteName:t}={}){return{VestBus:wt(),doneCallbacks:u.createTinyState((()=>[])),fieldCallbacks:u.createTinyState((()=>({}))),historyRoot:u.createTinyState(null),suiteId:R(),suiteName:t,suiteResultCache:Mt}}({suiteName:r});function i(...t){return q.run({},(()=>(Vt()(C.SUITE_RUN_STARTED),re.create(function(t,...e){return()=>(t(...e),Ee())}(e,...t))))).output}return bt.run(s,(()=>o(bt.bind(s,i),Object.assign({get:Kt(_t),remove:Ht(C.REMOVE_FIELD),reset:Ht(C.RESET_SUITE),resetField:Ht(C.RESET_FIELD)},le()))))}class Ne extends k{constructor(){super(...arguments),this.allowReorder=!0}}function Te(t,e){n(v(e),O.EACH_CALLBACK_MUST_BE_A_FUNCTION),Ne.create((()=>{t.forEach(((t,n)=>{e(t,n)}))}))}function he(t,e){return k.create((()=>{q.run({groupName:t},e)}))}function Re(t){return o(((...e)=>fe(t)(...e)),Object.assign({},le()))}const Ie=O.WARN_MUST_BE_CALLED_FROM_TEST;function Se(){const t=(e=O.HOOK_CALLED_OUTSIDE,q.useX(e).currentTest);var e;n(t,Ie),t.warn()}export{V as Modes,fe as create,Te as each,he as group,se as include,H as mode,yt as omitWhen,vt as only,ee as optional,At as skip,mt as skipWhen,Re as staticSuite,ft as suiteSelectors,ae as test,Se as warn};
|
|
1
|
+
export{enforce}from"n4s";import{isArray as t,isStringValue as e,asArray as n,cache as s,tinyState as r,seq as i,assign as u,bindNot as o,either as a,defaultTo as c,isPositive as E,optionalFunctionValue as l,hasOwnProperty as f,isNullish as N,deferThrow as T,text as d,StateMachine as S,isUndefined as R,isPromise as I,invariant as _,isEmpty as p,callEach as m,isNull as g,isFunction as h,numberEquals as O}from"vest-utils";import{VestRuntime as A,Isolate as D,Reconciler as C,Walker as v}from"vestjs-runtime";import{createCascade as U}from"context";var L,P,F;function G(s){const r=A.useAvailableRoot();if(t(s)||e(s))n(s).forEach((t=>{r.setOptionalField(t,(()=>({type:L.AUTO,applied:!1,rule:null})))}));else for(const t in s){const e=s[t];r.setOptionalField(t,(()=>({type:L.CUSTOM_LOGIC,rule:e,applied:!0===e})))}}function y(t){var e,n,s;return!!t&&(null!==(s=null===(n=null===(e=A.useAvailableRoot())||void 0===e?void 0:e.getOptionalField(t))||void 0===n?void 0:n.applied)&&void 0!==s&&s)}!function(t){t[t.CUSTOM_LOGIC=0]="CUSTOM_LOGIC",t[t.AUTO=1]="AUTO"}(L||(L={})),function(t){t.EAGER="EAGER",t.ALL="ALL",t.ONE="ONE"}(P||(P={})),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"}(F||(F={}));class W extends D{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 b=s();function M(){return A.useXAppData()}function w(){return M().doneCallbacks()}function B(){return M().fieldCallbacks()}function k(){return M().suiteId}function K(){const[,,t]=w(),[,,e]=B();t(),e()}const j=U(((t,e)=>e?null:u({exclusion:{tests:{},groups:{}},inclusion:{},mode:r.createTinyState(P.EAGER),testMemoCache:H},t)));function X(t){return j.useX(t).exclusion}function V(){return j.useX().inclusion}function x(){return j.useX().mode()}const H=s(10);var q,z,J,Y,Q,Z;function $(t,e){return!!e&&!tt(t,e)}function tt(t,e){return!(!e||t.fieldName!==e)}function et(t,e){return tt(t,e.fieldName)&&t.groupName===e.groupName&&t.key===e.key}function nt(t){return t===z.ERRORS?J.ERROR_COUNT:J.WARN_COUNT}!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}."}(q||(q={})),function(t){t.WARNINGS="warnings",t.ERRORS="errors"}(z||(z={})),function(t){t.ERROR_COUNT="errorCount",t.WARN_COUNT="warnCount"}(J||(J={})),function(t){t.Error="error",t.Warning="warning"}(Y||(Y={}));class st{constructor(){this.errorCount=0,this.warnCount=0,this.testCount=0}}class rt extends st{constructor(){super(...arguments),this[Q]=[],this[Z]=[],this.groups={},this.tests={},this.valid=!1}}Q=z.ERRORS,Z=z.WARNINGS;class it{constructor(t,e,n){this.fieldName=t,this.message=e,this.groupName=n}static fromTestObject(t){return new it(t.fieldName,t.message,t.groupName)}toString(){return this.message||""}}const ut=o((function(t,e){return t.groupName===e}));function ot(t){return function(t,e){return Xt.someTests((n=>at(n,t,e)))}(z.ERRORS,t)}function at(t,e,n){return!!t.hasFailures()&&(!$(t,n)&&!function(t,e){return a(t===z.WARNINGS,e.warns())}(e,t))}function ct(t){return!!y(t)||!Xt.hasNoTests()&&(!ot(t)&&(!function(t){return Xt.someIncompleteTests((e=>!$(e,t)&&!y(t)))}(t)&&function(t){return Xt.everyTest((e=>lt(e,t)))}(t)))}function Et(t,e){return!!y(e)||!function(t,e,n){return Xt.someTests((s=>!ut(s,e)&&at(s,t,n)))}(z.ERRORS,t,e)&&(!function(t,e){return Xt.someIncompleteTests((n=>!ut(n,t)&&(!$(n,e)&&!y(e))))}(t,e)&&function(t,e){return Xt.everyTest((n=>!!ut(n,t)||lt(n,e)))}(t,e))}function lt(t,e){return!!$(t,e)||(t.isOmitted()||t.isTested()||function(t){var e;return(null===(e=A.useAvailableRoot())||void 0===e?void 0:e.getOptionalField(t.fieldName).type)===L.AUTO&&t.awaitsResolution()}(t))}function ft(){const t=new rt;return Xt.walkTests((e=>{t.tests=function(t,e){const{fieldName:n}=e,s=Object.assign({},t);return s[n]=Tt(s[n],e),s[n].valid=!1!==s[n].valid&&ct(n),s}(t.tests,e),t.groups=function(t,e){const{groupName:n,fieldName:s}=e;if(!n)return t;const r=Object.assign({},t);return r[n]=r[n]||{},r[n][s]=Tt(r[n][s],e),r[n][s].valid=!1!==r[n][s].valid&&Et(n,s),r}(t.groups,e),t.errors=Nt(z.ERRORS,t.errors,e),t.warnings=Nt(z.WARNINGS,t.warnings,e)})),t.valid=ct(),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 Nt(t,e,n){if(n.isOmitted())return e;return(t===z.WARNINGS?n.isWarning():n.isFailing())?e.concat(it.fromTestObject(n)):e}function Tt(t,e){const{message:n}=e,s=c(t?Object.assign({},t):null,dt);return e.isNonActionable()||(s.testCount++,e.isFailing()?r(z.ERRORS):e.isWarning()&&r(z.WARNINGS)),s;function r(t){const e=nt(t);s[e]++,n&&(s[t]=(s[t]||[]).concat(n))}}function dt(){return u(new st,{errors:[],warnings:[],valid:!0})}function St(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={},s=nt(e);for(const r in t)E(t[r][s])&&(n[r]=t[r][e]||[]);return n}(t,e)}function Rt(t){const e={getError:function(e){return ht(z.ERRORS,t,e)},getErrors:function(e){return It(t,z.ERRORS,e)},getErrorsByGroup:function(e,n){return _t(t,z.ERRORS,e,n)},getWarning:function(e){return ht(z.WARNINGS,t,e)},getWarnings:function(e){return It(t,z.WARNINGS,e)},getWarningsByGroup:function(e,n){return _t(t,z.WARNINGS,e,n)},hasErrors:function(e){return gt(t,J.ERROR_COUNT,e)},hasErrorsByGroup:function(e,n){return mt(t,J.ERROR_COUNT,e,n)},hasWarnings:function(e){return gt(t,J.WARN_COUNT,e)},hasWarningsByGroup:function(e,n){return mt(t,J.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 pt(s,n);for(const t in s)if(!pt(s,t))return!1;return!0}};return e}function It(t,e,n){return St(t.tests,e,n)}function _t(t,e,n,s){return St(t.groups[n],e,s)}function pt(t,e){var n;return!!(null===(n=t[e])||void 0===n?void 0:n.valid)}function mt(t,e,n,s){var r,i;const u=t.groups[n];if(!u)return!1;if(s)return E(null===(r=u[s])||void 0===r?void 0:r[e]);for(const t in u)if(E(null===(i=u[t])||void 0===i?void 0:i[e]))return!0;return!1}function gt(t,e,n){var s;const r=n?null===(s=t.tests[n])||void 0===s?void 0:s[e]:t[e]||0;return E(r)}function ht(t,e,n){var s;const r=e[t];return n?null===(s=r.find((t=>tt(t,n))))||void 0===s?void 0:s.message:r[0]}function Ot(){return t=()=>{const t=ft(),e=M().suiteName;return Object.freeze(u(t,Rt(t),{suiteName:e}))},(0,M().suiteResultCache)([k()],t);var t}function At(t,e){D.create((()=>{j.run({skipped:Dt()||l(t,l(Ot))},e)}))}function Dt(){return function(){var t;return null!==(t=j.useX().skipped)&&void 0!==t&&t}()}function Ct(t){return Lt(0,"tests",t)}function vt(t){return Lt(1,"tests",t)}function Ut(t){const{fieldName:e,groupName:n}=t;if(Dt())return!0;const s=X(),r=V(),i=s.tests,u=i[e];if(!1===u)return!0;const o=!0===u;if(n){if(function(t){const e=X().groups;if(f(e,t))return!1===e[t];return Ft()}(n))return!0;if(!0===s.groups[n])return!o&&(!!Pt(i)||!1===i[e])}return!!function(t){if(!Ft())return!1;return!t}(n)||!o&&(!!Pt(i)&&!l(r[e]))}function Lt(t,s,r){const i=X(q.HOOK_CALLED_OUTSIDE);r&&n(r).forEach((n=>{e(n)&&(i[s][n]=0===t)}))}function Pt(t){for(const e in t)if(!0===t[e])return!0;return!1}function Ft(){const t=X();for(const e in t.groups)if(t.groups[e])return!0;return!1}function Gt(t){const[,e]=x();e(t)}function yt(t){const[e]=x();return e===t}function Wt(t){return yt(P.ONE)?ot():!!yt(P.EAGER)&&ot(t.fieldName)}function bt(t,e){D.create((()=>{j.run({omitted:Mt()||l(t,l(Ot))},e)}))}function Mt(){return function(){var t;return null!==(t=j.useX().omitted)&&void 0!==t&&t}()}function wt(t,e=t){return Wt(t)?((n=t).skip(),n):function(t){return Mt()||y(t.fieldName)}(t)?function(t){return t.omit(),t}(t):Ut(t)?function(t){return t.skip(Dt()),t}(e):t;var n}var Bt,kt;Ct.group=function(t){return Lt(0,"groups",t)},vt.group=function(t){return Lt(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"}(Bt||(Bt={})),function(t){t.RESET="RESET"}(kt||(kt={}));const Kt={initial:Bt.UNTESTED,states:{"*":{[Bt.OMITTED]:Bt.OMITTED,[kt.RESET]:Bt.UNTESTED},[Bt.UNTESTED]:{[Bt.CANCELED]:Bt.CANCELED,[Bt.FAILED]:Bt.FAILED,[Bt.PASSING]:Bt.PASSING,[Bt.PENDING]:Bt.PENDING,[Bt.SKIPPED]:Bt.SKIPPED,[Bt.WARNING]:Bt.WARNING},[Bt.PENDING]:{[Bt.CANCELED]:Bt.CANCELED,[Bt.FAILED]:Bt.FAILED,[Bt.PASSING]:Bt.PASSING,[Bt.SKIPPED]:[Bt.SKIPPED,t=>!0===t],[Bt.WARNING]:Bt.WARNING},[Bt.SKIPPED]:{},[Bt.FAILED]:{},[Bt.WARNING]:{},[Bt.PASSING]:{},[Bt.CANCELED]:{},[Bt.OMITTED]:{}}};class jt extends D{constructor({fieldName:t,testFn:e,message:n,groupName:s,key:r=null}){super(),this.children=null,this.id=i(),this.severity=Y.Error,this.stateMachine=S(Kt),this.fieldName=t,this.testFn=e,s&&(this.groupName=s),n&&(this.message=n),this.setKey(r)}static create(t,e){return jt.cast(super.create(t,e))}static cast(t){return jt.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(n){(function(t,n){return R(t)&&e(n)})(this.message,n)&&(this.message=n),t=!1}return!1===t&&this.fail(),t}warns(){return this.severity===Y.Warning}isPending(){return this.statusEquals(Bt.PENDING)}isOmitted(){return this.statusEquals(Bt.OMITTED)}isUntested(){return this.statusEquals(Bt.UNTESTED)}isFailing(){return this.statusEquals(Bt.FAILED)}isCanceled(){return this.statusEquals(Bt.CANCELED)}isSkipped(){return this.statusEquals(Bt.SKIPPED)}isPassing(){return this.statusEquals(Bt.PASSING)}isWarning(){return this.statusEquals(Bt.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(Bt.PENDING)}fail(){this.setStatus(this.warns()?Bt.WARNING:Bt.FAILED)}pass(){this.setStatus(Bt.PASSING)}warn(){this.severity=Y.Warning}skip(t){this.setStatus(Bt.SKIPPED,t)}cancel(){this.setStatus(Bt.CANCELED)}reset(){this.stateMachine.transition(kt.RESET)}omit(){this.setStatus(Bt.OMITTED)}valueOf(){return!this.isFailing()}isAsyncTest(){return I(this.asyncTest)}static is(t){return t instanceof jt}static isX(t){_(this.is(t))}}jt.reconciler=function(t,e){if(!jt.is(t))return t;if(N(e))return function(t){if(t.usesKey())return jt.cast(C.handleIsolateNodeWithKey(t));return t}(t);if(!jt.is(e))return t;const n=function(t,e){const n=function(t,e){if(t.usesKey())return jt.cast(C.handleIsolateNodeWithKey(t));if(function(t,e){return!!jt.is(e)&&!et(e,t)}(t,e))return function(t,e){return function(t,e){if(t.shouldAllowReorder())return;T(d(q.TESTS_CALLED_IN_DIFFERENT_ORDER,{fieldName:t.fieldName,prevName:jt.is(e)?e.fieldName:void 0}))}(t,e),C.removeAllNextNodesInIsolate(),t}(t,e);if(!jt.is(e))return t;if(e.isOmitted())return t;return e}(e,t);return wt(e,n)}(e,t);return function(t,e,n){t===e&&jt.is(e)&&(r=e)!==(s=n)&&et(s,r)&&s.isPending()&&s.cancel();var s,r}(n,t,e),n};class Xt{static defaultRoot(){return A.useAvailableRoot()}static hasNoTests(t=Xt.defaultRoot()){return!t||!v.has(t,jt.is)}static someIncompleteTests(t,e=Xt.defaultRoot()){return!!e&&v.some(e,(e=>(jt.isX(e),e.isPending()&&t(e))),jt.is)}static someTests(t,e=Xt.defaultRoot()){return!!e&&v.some(e,(e=>(jt.isX(e),t(e))),jt.is)}static everyTest(t,e=Xt.defaultRoot()){return!!e&&v.every(e,(e=>(jt.isX(e),t(e))),jt.is)}static walkTests(t,e=Xt.defaultRoot()){e&&v.walk(e,((e,n)=>{t(jt.cast(e),n)}),jt.is)}static hasRemainingTests(t){return Xt.someIncompleteTests((e=>!t||tt(e,t)))}static pluckTests(t,e=Xt.defaultRoot()){e&&v.pluck(e,(e=>(jt.isX(e),t(e))),jt.is)}static resetField(t){Xt.walkTests((e=>{tt(e,t)&&e.reset()}),Xt.defaultRoot())}static removeTestByFieldName(t,e=Xt.defaultRoot()){Xt.pluckTests((e=>tt(e,t)),e)}}function Vt(){const t=A.useAvailableRoot(),e=A.useEmit(),n=null==t?void 0:t.getOptionalFields();if(p(n))return;const s=new Set;function r(e){s.has(e.fieldName)&&(e.omit(),null==t||t.setOptionalField(e.fieldName,(t=>Object.assign(Object.assign({},t),{applied:!0}))))}Xt.walkTests((e=>{e.isPending()||(f(s,e.fieldName)?r(e):function(e){const n=null==t?void 0:t.getOptionalField(e.fieldName);if(N(n))return;!0===l(n.rule)&&s.add(e.fieldName);r(e)}(e))})),e(F.DONE_TEST_OMISSION_PASS)}function xt(){const e=A.useBus();return n(F.TEST_COMPLETED,(n=>{n.isCanceled()||(!function(e){const[n]=B();e&&!Xt.hasRemainingTests(e)&&t(n[e])&&m(n[e])}(n.fieldName),Xt.hasRemainingTests()||e.emit(F.ALL_RUNNING_TESTS_FINISHED))})),n(F.TEST_RUN_STARTED,(()=>{})),n(F.DONE_TEST_OMISSION_PASS,(()=>{})),n(F.ALL_RUNNING_TESTS_FINISHED,(()=>{Xt.someTests((t=>t.isAsyncTest()))&&Vt(),function(){const[t]=w();m(t)}()})),n(F.RESET_FIELD,(t=>{Xt.resetField(t)})),n(F.SUITE_RUN_STARTED,(()=>{K()})),n(F.SUITE_CALLBACK_RUN_FINISHED,(()=>{Vt()})),n(F.REMOVE_FIELD,(t=>{Xt.removeTestByFieldName(t)})),n(F.RESET_SUITE,(()=>{K(),A.reset()})),e;function n(t,n){e.on(t,((...t)=>{M().suiteResultCache.invalidate([k()]),n(...t)}))}}function Ht(t,e){return D.create((()=>{j.run({groupName:t},e)}))}function qt(t){const n=V(),s=X();return _(e(t)),n[t]=c(s.tests[t],!0),{when:function(n){const s=V(),r=X();s[t]=()=>f(r.tests,t)?c(r.tests[t],!0):e(n)?Boolean(r.tests[n]):l(n,l(Ot))}}}function zt(t){if(wt(t),t.isUntested())return function(t){const n=A.useBus(),s=function(t){return j.run({currentTest:t},(()=>t.run()))}(t);try{I(s)?(t.asyncTest=s,function(t){const{asyncTest:n,message:s}=t;if(!I(n))return;t.setPending();const r=A.useBus(),i=A.persist((()=>{Jt(r,t)})),u=A.persist((n=>{t.isCanceled()||(t.message=e(n)?n:s,t.fail(),i())}));n.then(i,u)}(t)):Jt(n,t)}catch(e){throw new Error(d(q.UNEXPECTED_TEST_REGISTRATION_ERROR,{testObject:JSON.stringify(t),error:e}))}}(t);t.isNonActionable()||T(d(q.UNEXPECTED_TEST_REGISTRATION_ERROR,{testObject:JSON.stringify(t)}))}function Jt(t,e){e.pass(),t.emit(F.TEST_COMPLETED,e)}function Yt(t,...n){const[s,r,i]=h(n[1])?n:[void 0,...n];!function(t,n){const s="test";_(e(t),d(q.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:s,param:"fieldName",expected:"string"})),_(h(n),d(q.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:s,param:"callback",expected:"function"}))}(t,r);const u={fieldName:t,groupName:j.useX().groupName,key:i,message:s,testFn:r};return A.useEmit()(F.TEST_RUN_STARTED),jt.create(zt,u)}const Qt=u(Yt,{memo:function(t){return function(e,...n){const[s,r,i]=n.reverse();return function(t,e){const n=j.useX().testMemoCache,s=n.get(t);if(g(s))return n(t,e);const[,r]=s;if(r.isCanceled())return n.invalidate(t),n(t,e);return jt.setNode(r),r}([k(),e,A.useCurrentCursor()].concat(s),(function(){return t(e,i,r)}))}}(Yt)});function Zt(){return{group:Ht,include:qt,omitWhen:bt,only:Ct,optional:G,skip:vt,skipWhen:At,test:Qt}}function $t(){return Object.freeze(u({done:A.persist(te)},Ot()))}function te(...t){const[e,n]=t.reverse(),s=$t();if(function(t,e,n){var s;return!!(!h(t)||e&&O(null===(s=n.tests[e])||void 0===s?void 0:s.testCount,0))}(e,n,s))return s;const r=()=>e(Ot());return Xt.hasRemainingTests(n)?(function(t,e){const[,n]=B(),[,s]=w();e?n((n=>u(n,{[e]:(n[e]||[]).concat(t)}))):s((e=>e.concat(t)))}(r,n),s):(r(),s)}function ee(...t){const[e,n]=t.reverse();!function(t){_(h(t),q.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION)}(e);const s=function({suiteName:t}={}){const e={doneCallbacks:r.createTinyState((()=>[])),fieldCallbacks:r.createTinyState((()=>({}))),suiteId:i(),suiteName:t,suiteResultCache:b};return A.createRef(e)}({suiteName:n});function o(...t){return j.run({},(()=>(A.useEmit()(F.SUITE_RUN_STARTED),W.create(function(t,...e){const n=A.useEmit();return()=>(t(...e),n(F.SUITE_CALLBACK_RUN_FINISHED),$t())}(e,...t))))).output}return A.Run(s,(()=>{return xt(),u(A.persist(o),Object.assign(Object.assign({get:A.persist(Ot),remove:A.usePrepareEmitter(F.REMOVE_FIELD),reset:A.usePrepareEmitter(F.RESET_SUITE),resetField:A.usePrepareEmitter(F.RESET_FIELD)},(t=A.persist(Ot),{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)})),Zt()));var t}))}class ne extends D{constructor(){super(...arguments),this.allowReorder=!0}}function se(t,e){_(h(e),q.EACH_CALLBACK_MUST_BE_A_FUNCTION),ne.create((()=>{t.forEach(((t,n)=>{e(t,n)}))}))}function re(t){return u(((...e)=>ee(t)(...e)),Object.assign({},Zt()))}const ie=q.WARN_MUST_BE_CALLED_FROM_TEST;function ue(){const t=(e=q.HOOK_CALLED_OUTSIDE,j.useX(e).currentTest);var e;_(t,ie),t.warn()}export{P as Modes,ee as create,se as each,Ht as group,qt as include,Gt as mode,bt as omitWhen,Ct as only,G as optional,vt as skip,At as skipWhen,re as staticSuite,Rt as suiteSelectors,Qt as test,ue as warn};
|
|
@@ -10,15 +10,14 @@
|
|
|
10
10
|
ErrorStrings["EXPECTED_VEST_TEST"] = "Expected value to be an instance of IsolateTest";
|
|
11
11
|
ErrorStrings["FIELD_NAME_REQUIRED"] = "Field name must be passed";
|
|
12
12
|
ErrorStrings["SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION"] = "Suite must be initialized with a function";
|
|
13
|
-
ErrorStrings["NO_ACTIVE_ISOLATE"] = "Not within an active isolate";
|
|
14
13
|
ErrorStrings["PROMISIFY_REQUIRE_FUNCTION"] = "Vest.Promisify must be called with a function";
|
|
15
14
|
ErrorStrings["PARSER_EXPECT_RESULT_OBJECT"] = "Vest parser: expected argument at position 0 to be Vest's result object.";
|
|
16
15
|
ErrorStrings["WARN_MUST_BE_CALLED_FROM_TEST"] = "Warn must be called from within the body of a test function";
|
|
17
16
|
ErrorStrings["EACH_CALLBACK_MUST_BE_A_FUNCTION"] = "Each must be called with a function";
|
|
18
17
|
ErrorStrings["INVALID_PARAM_PASSED_TO_FUNCTION"] = "Incompatible params passed to {fn_name} function. \"{param}\" must be of type {expected}";
|
|
19
|
-
ErrorStrings["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.";
|
|
20
18
|
ErrorStrings["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.";
|
|
21
19
|
ErrorStrings["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}.";
|
|
20
|
+
ErrorStrings["UNEXPECTED_TEST_RUN_ERROR"] = "Unexpected error encountered during test run. Please report this issue to Vest's Github repository.\n Test Object: {testObject}.";
|
|
22
21
|
})(ErrorStrings || (ErrorStrings = {}));
|
|
23
22
|
|
|
24
23
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vest-utils"),require("vest")):"function"==typeof define&&define.amd?define(["vest-utils","vest"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).classnames=t(e["vest-utils"],e.vest)}(this,(function(e,t){"use strict";var s;return function(e){e.HOOK_CALLED_OUTSIDE="hook called outside of a running suite.",e.EXPECTED_VEST_TEST="Expected value to be an instance of IsolateTest",e.FIELD_NAME_REQUIRED="Field name must be passed",e.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION="Suite must be initialized with a function",e.
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vest-utils"),require("vest")):"function"==typeof define&&define.amd?define(["vest-utils","vest"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).classnames=t(e["vest-utils"],e.vest)}(this,(function(e,t){"use strict";var s;return function(e){e.HOOK_CALLED_OUTSIDE="hook called outside of a running suite.",e.EXPECTED_VEST_TEST="Expected value to be an instance of IsolateTest",e.FIELD_NAME_REQUIRED="Field name must be passed",e.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION="Suite must be initialized with a function",e.PROMISIFY_REQUIRE_FUNCTION="Vest.Promisify must be called with a function",e.PARSER_EXPECT_RESULT_OBJECT="Vest parser: expected argument at position 0 to be Vest's result object.",e.WARN_MUST_BE_CALLED_FROM_TEST="Warn must be called from within the body of a test function",e.EACH_CALLBACK_MUST_BE_A_FUNCTION="Each must be called with a function",e.INVALID_PARAM_PASSED_TO_FUNCTION='Incompatible params passed to {fn_name} function. "{param}" must be of type {expected}',e.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.',e.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}.",e.UNEXPECTED_TEST_RUN_ERROR="Unexpected error encountered during test run. Please report this issue to Vest's Github repository.\n Test Object: {testObject}."}(s||(s={})),function(n,i={}){const o=function(n){e.invariant(n&&e.hasOwnProperty(n,"valid"),s.PARSER_EXPECT_RESULT_OBJECT);const i=t.suiteSelectors(n),o={},r={invalid:i.hasErrors,tested:function(t){return e.isNullish(t)?e.isPositive(n.testCount):e.hasOwnProperty(o,t)?o[t]:(a(t),r.tested(t))},untested:function(t){return!(e.isPositive(n.testCount)&&r.tested(t))},valid:i.isValid,warning:i.hasWarnings};return r;function a(t){o[t]=e.hasOwnProperty(n.tests,t)&&e.isPositive(n.tests[t].testCount)}}(n);return function(t){const s=[];for(const n in i){const r=n;e.isFunction(o[r])&&o[r](t)&&s.push(i[r])}return s.join(" ")}}}));
|
|
@@ -4,12 +4,6 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.compose = factory(global.compose));
|
|
5
5
|
})(this, (function (compose) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var compose__default = /*#__PURE__*/_interopDefaultLegacy(compose);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return compose__default["default"];
|
|
7
|
+
return compose;
|
|
14
8
|
|
|
15
9
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("n4s/compose")):"function"==typeof define&&define.amd?define(["n4s/compose"],o):(e="undefined"!=typeof globalThis?globalThis:e||self).compose=o(e.compose)}(this,(function(e){"use strict";
|
|
1
|
+
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("n4s/compose")):"function"==typeof define&&define.amd?define(["n4s/compose"],o):(e="undefined"!=typeof globalThis?globalThis:e||self).compose=o(e.compose)}(this,(function(e){"use strict";return e}));
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.compounds = {}, global.compounds));
|
|
5
5
|
})(this, (function (exports, compounds) { 'use strict';
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
if (e && e.__esModule) return e;
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
9
8
|
var n = Object.create(null);
|
|
10
9
|
if (e) {
|
|
11
10
|
Object.keys(e).forEach(function (k) {
|
|
@@ -18,16 +17,14 @@
|
|
|
18
17
|
}
|
|
19
18
|
});
|
|
20
19
|
}
|
|
21
|
-
n
|
|
20
|
+
n.default = e;
|
|
22
21
|
return Object.freeze(n);
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
var compounds__namespace = /*#__PURE__*/
|
|
24
|
+
var compounds__namespace = /*#__PURE__*/_interopNamespaceDefault(compounds);
|
|
26
25
|
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
exports.compounds = compounds__namespace;
|
|
30
29
|
|
|
31
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
32
|
-
|
|
33
30
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("n4s/compounds")):"function"==typeof define&&define.amd?define(["exports","n4s/compounds"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).compounds={},e.compounds)}(this,(function(e,t){"use strict";function n(e){
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("n4s/compounds")):"function"==typeof define&&define.amd?define(["exports","n4s/compounds"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).compounds={},e.compounds)}(this,(function(e,t){"use strict";function n(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var o=n(t);e.compounds=o}));
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.schema = {}, global.schema));
|
|
5
5
|
})(this, (function (exports, schema) { 'use strict';
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
if (e && e.__esModule) return e;
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
9
8
|
var n = Object.create(null);
|
|
10
9
|
if (e) {
|
|
11
10
|
Object.keys(e).forEach(function (k) {
|
|
@@ -18,16 +17,14 @@
|
|
|
18
17
|
}
|
|
19
18
|
});
|
|
20
19
|
}
|
|
21
|
-
n
|
|
20
|
+
n.default = e;
|
|
22
21
|
return Object.freeze(n);
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
var schema__namespace = /*#__PURE__*/
|
|
24
|
+
var schema__namespace = /*#__PURE__*/_interopNamespaceDefault(schema);
|
|
26
25
|
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
exports.schema = schema__namespace;
|
|
30
29
|
|
|
31
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
32
|
-
|
|
33
30
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("n4s/schema")):"function"==typeof define&&define.amd?define(["exports","n4s/schema"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).schema={},e.schema)}(this,(function(e,t){"use strict";function n(e){
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("n4s/schema")):"function"==typeof define&&define.amd?define(["exports","n4s/schema"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).schema={},e.schema)}(this,(function(e,t){"use strict";function n(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var r=n(t);e.schema=r}));
|
|
@@ -10,15 +10,14 @@
|
|
|
10
10
|
ErrorStrings["EXPECTED_VEST_TEST"] = "Expected value to be an instance of IsolateTest";
|
|
11
11
|
ErrorStrings["FIELD_NAME_REQUIRED"] = "Field name must be passed";
|
|
12
12
|
ErrorStrings["SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION"] = "Suite must be initialized with a function";
|
|
13
|
-
ErrorStrings["NO_ACTIVE_ISOLATE"] = "Not within an active isolate";
|
|
14
13
|
ErrorStrings["PROMISIFY_REQUIRE_FUNCTION"] = "Vest.Promisify must be called with a function";
|
|
15
14
|
ErrorStrings["PARSER_EXPECT_RESULT_OBJECT"] = "Vest parser: expected argument at position 0 to be Vest's result object.";
|
|
16
15
|
ErrorStrings["WARN_MUST_BE_CALLED_FROM_TEST"] = "Warn must be called from within the body of a test function";
|
|
17
16
|
ErrorStrings["EACH_CALLBACK_MUST_BE_A_FUNCTION"] = "Each must be called with a function";
|
|
18
17
|
ErrorStrings["INVALID_PARAM_PASSED_TO_FUNCTION"] = "Incompatible params passed to {fn_name} function. \"{param}\" must be of type {expected}";
|
|
19
|
-
ErrorStrings["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.";
|
|
20
18
|
ErrorStrings["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.";
|
|
21
19
|
ErrorStrings["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}.";
|
|
20
|
+
ErrorStrings["UNEXPECTED_TEST_RUN_ERROR"] = "Unexpected error encountered during test run. Please report this issue to Vest's Github repository.\n Test Object: {testObject}.";
|
|
22
21
|
})(ErrorStrings || (ErrorStrings = {}));
|
|
23
22
|
|
|
24
23
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -58,6 +57,4 @@
|
|
|
58
57
|
|
|
59
58
|
exports.parse = parse;
|
|
60
59
|
|
|
61
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
62
|
-
|
|
63
60
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vest"),require("vest-utils")):"function"==typeof define&&define.amd?define(["exports","vest","vest-utils"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).parser={},e.vest,e["vest-utils"])}(this,(function(e,t,s){"use strict";var n;!function(e){e.HOOK_CALLED_OUTSIDE="hook called outside of a running suite.",e.EXPECTED_VEST_TEST="Expected value to be an instance of IsolateTest",e.FIELD_NAME_REQUIRED="Field name must be passed",e.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION="Suite must be initialized with a function",e.
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vest"),require("vest-utils")):"function"==typeof define&&define.amd?define(["exports","vest","vest-utils"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).parser={},e.vest,e["vest-utils"])}(this,(function(e,t,s){"use strict";var n;!function(e){e.HOOK_CALLED_OUTSIDE="hook called outside of a running suite.",e.EXPECTED_VEST_TEST="Expected value to be an instance of IsolateTest",e.FIELD_NAME_REQUIRED="Field name must be passed",e.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION="Suite must be initialized with a function",e.PROMISIFY_REQUIRE_FUNCTION="Vest.Promisify must be called with a function",e.PARSER_EXPECT_RESULT_OBJECT="Vest parser: expected argument at position 0 to be Vest's result object.",e.WARN_MUST_BE_CALLED_FROM_TEST="Warn must be called from within the body of a test function",e.EACH_CALLBACK_MUST_BE_A_FUNCTION="Each must be called with a function",e.INVALID_PARAM_PASSED_TO_FUNCTION='Incompatible params passed to {fn_name} function. "{param}" must be of type {expected}',e.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.',e.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}.",e.UNEXPECTED_TEST_RUN_ERROR="Unexpected error encountered during test run. Please report this issue to Vest's Github repository.\n Test Object: {testObject}."}(n||(n={})),e.parse=function(e){s.invariant(e&&s.hasOwnProperty(e,"valid"),n.PARSER_EXPECT_RESULT_OBJECT);const i=t.suiteSelectors(e),r={},o={invalid:i.hasErrors,tested:function(t){if(s.isNullish(t))return s.isPositive(e.testCount);if(s.hasOwnProperty(r,t))return r[t];return a(t),o.tested(t)},untested:function(t){return!(s.isPositive(e.testCount)&&o.tested(t))},valid:i.isValid,warning:i.hasWarnings};return o;function a(t){r[t]=s.hasOwnProperty(e.tests,t)&&s.isPositive(e.tests[t].testCount)}}}));
|
|
@@ -10,15 +10,14 @@
|
|
|
10
10
|
ErrorStrings["EXPECTED_VEST_TEST"] = "Expected value to be an instance of IsolateTest";
|
|
11
11
|
ErrorStrings["FIELD_NAME_REQUIRED"] = "Field name must be passed";
|
|
12
12
|
ErrorStrings["SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION"] = "Suite must be initialized with a function";
|
|
13
|
-
ErrorStrings["NO_ACTIVE_ISOLATE"] = "Not within an active isolate";
|
|
14
13
|
ErrorStrings["PROMISIFY_REQUIRE_FUNCTION"] = "Vest.Promisify must be called with a function";
|
|
15
14
|
ErrorStrings["PARSER_EXPECT_RESULT_OBJECT"] = "Vest parser: expected argument at position 0 to be Vest's result object.";
|
|
16
15
|
ErrorStrings["WARN_MUST_BE_CALLED_FROM_TEST"] = "Warn must be called from within the body of a test function";
|
|
17
16
|
ErrorStrings["EACH_CALLBACK_MUST_BE_A_FUNCTION"] = "Each must be called with a function";
|
|
18
17
|
ErrorStrings["INVALID_PARAM_PASSED_TO_FUNCTION"] = "Incompatible params passed to {fn_name} function. \"{param}\" must be of type {expected}";
|
|
19
|
-
ErrorStrings["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.";
|
|
20
18
|
ErrorStrings["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.";
|
|
21
19
|
ErrorStrings["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}.";
|
|
20
|
+
ErrorStrings["UNEXPECTED_TEST_RUN_ERROR"] = "Unexpected error encountered during test run. Please report this issue to Vest's Github repository.\n Test Object: {testObject}.";
|
|
22
21
|
})(ErrorStrings || (ErrorStrings = {}));
|
|
23
22
|
|
|
24
23
|
function promisify(validatorFn) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vest-utils")):"function"==typeof define&&define.amd?define(["vest-utils"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).promisify=t(e["vest-utils"])}(this,(function(e){"use strict";var t;return function(e){e.HOOK_CALLED_OUTSIDE="hook called outside of a running suite.",e.EXPECTED_VEST_TEST="Expected value to be an instance of IsolateTest",e.FIELD_NAME_REQUIRED="Field name must be passed",e.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION="Suite must be initialized with a function",e.
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vest-utils")):"function"==typeof define&&define.amd?define(["vest-utils"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).promisify=t(e["vest-utils"])}(this,(function(e){"use strict";var t;return function(e){e.HOOK_CALLED_OUTSIDE="hook called outside of a running suite.",e.EXPECTED_VEST_TEST="Expected value to be an instance of IsolateTest",e.FIELD_NAME_REQUIRED="Field name must be passed",e.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION="Suite must be initialized with a function",e.PROMISIFY_REQUIRE_FUNCTION="Vest.Promisify must be called with a function",e.PARSER_EXPECT_RESULT_OBJECT="Vest parser: expected argument at position 0 to be Vest's result object.",e.WARN_MUST_BE_CALLED_FROM_TEST="Warn must be called from within the body of a test function",e.EACH_CALLBACK_MUST_BE_A_FUNCTION="Each must be called with a function",e.INVALID_PARAM_PASSED_TO_FUNCTION='Incompatible params passed to {fn_name} function. "{param}" must be of type {expected}',e.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.',e.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}.",e.UNEXPECTED_TEST_RUN_ERROR="Unexpected error encountered during test run. Please report this issue to Vest's Github repository.\n Test Object: {testObject}."}(t||(t={})),function(n){return(...s)=>(e.invariant(e.isFunction(n),t.PROMISIFY_REQUIRE_FUNCTION),new Promise((e=>n(...s).done(e))))}}));
|