vest 5.1.4 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("n4s"),require("vest-utils"),require("vestjs-runtime"),require("context")):"function"==typeof define&&define.amd?define(["exports","n4s","vest-utils","vestjs-runtime","context"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).vest={},t.n4s,t["vest-utils"],t["vestjs-runtime"],t.context)}(this,(function(t,e,n,s,i){"use strict";const r="Each",a="Focused",o="Group",u="OmitWhen",c="SkipWhen",l="Suite",E="Test";class d{static setOptionalField(t,e,s){const i=t.data.optional,r=i[e];n.assign(i,{[e]:n.assign({},r,s(r))})}static getOptionalField(t,e){var n;return null!==(n=t.data.optional[e])&&void 0!==n?n:{}}static getOptionalFields(t){return t.data.optional}}var f,N;!function(t){t[t.CUSTOM_LOGIC=0]="CUSTOM_LOGIC",t[t.AUTO=1]="AUTO"}(f||(f={})),t.Modes=void 0,(N=t.Modes||(t.Modes={})).EAGER="EAGER",N.ALL="ALL",N.ONE="ONE";const T=i.createCascade(((e,s)=>s?null:n.assign({inclusion:{},mode:n.tinyState.createTinyState(t.Modes.EAGER),suiteParams:[],testMemoCache:R},e)));function g(){return T.useX().inclusion}function S(){return T.useX().mode()}const R=n.cache(10);function m(t){var i;const r=s.VestRuntime.useAvailableRoot(),a=T.useX().suiteParams,o=null!==(i=null==a?void 0:a[0])&&void 0!==i?i:{};if(n.isArray(t)||n.isStringValue(t))n.asArray(t).forEach((t=>{d.setOptionalField(r,t,(()=>({type:f.AUTO,applied:!!n.hasOwnProperty(o,t)&&e.enforce.isBlank().test(null==o?void 0:o[t]),rule:null})))}));else for(const n in t){const s=t[n];d.setOptionalField(r,n,(()=>({type:f.CUSTOM_LOGIC,rule:s,applied:e.enforce.isBlank().test(s)||!0===s})))}}function I(t){var e,n;if(!t)return!1;const i=s.VestRuntime.useAvailableRoot();return null!==(n=null===(e=d.getOptionalField(i,t))||void 0===e?void 0:e.applied)&&void 0!==n&&n}var 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"}(p||(p={}));const _=n.cache();function D(){return s.VestRuntime.useXAppData()}function O(){return D().doneCallbacks()}function A(){return D().fieldCallbacks()}function v(){return D().suiteId}function C(){D().suiteResultCache.invalidate([v()])}function h(){const[,,t]=O(),[,,e]=A();t(),e()}function F(t){s.VestRuntime.useLoadRootNode(t),C()}var P,L;!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"}(P||(P={})),function(t){t.RESET="RESET"}(L||(L={}));const U={initial:P.UNTESTED,states:{"*":{[P.OMITTED]:P.OMITTED,[L.RESET]:P.UNTESTED},[P.UNTESTED]:{[P.CANCELED]:P.CANCELED,[P.FAILED]:P.FAILED,[P.PASSING]:P.PASSING,[P.PENDING]:P.PENDING,[P.SKIPPED]:P.SKIPPED,[P.WARNING]:P.WARNING},[P.PENDING]:{[P.CANCELED]:P.CANCELED,[P.FAILED]:P.FAILED,[P.PASSING]:P.PASSING,[P.SKIPPED]:[P.SKIPPED,t=>!0===t],[P.WARNING]:P.WARNING},[P.SKIPPED]:{},[P.FAILED]:{},[P.WARNING]:{},[P.PASSING]:{},[P.CANCELED]:{},[P.OMITTED]:{}}};var y,b,G;function W(t){return t===y.ERRORS?b.ERROR_COUNT:b.WARN_COUNT}!function(t){t.WARNINGS="warnings",t.ERRORS="errors"}(y||(y={})),function(t){t.ERROR_COUNT="errorCount",t.WARN_COUNT="warnCount"}(b||(b={})),function(t){t.Error="error",t.Warning="warning"}(G||(G={}));const V=n.StateMachine(U);class B{static getData(t){return n.invariant(t.data),t.data}static warns(t){return B.getData(t).severity===G.Warning}static isPending(t){return B.statusEquals(t,P.PENDING)}static isOmitted(t){return B.statusEquals(t,P.OMITTED)}static isUntested(t){return B.statusEquals(t,P.UNTESTED)}static isFailing(t){return B.statusEquals(t,P.FAILED)}static isCanceled(t){return B.statusEquals(t,P.CANCELED)}static isSkipped(t){return B.statusEquals(t,P.SKIPPED)}static isPassing(t){return B.statusEquals(t,P.PASSING)}static isWarning(t){return B.statusEquals(t,P.WARNING)}static hasFailures(t){return B.isFailing(t)||B.isWarning(t)}static isNonActionable(t){return B.isSkipped(t)||B.isOmitted(t)||B.isCanceled(t)}static isTested(t){return B.hasFailures(t)||B.isPassing(t)}static awaitsResolution(t){return B.isSkipped(t)||B.isUntested(t)||B.isPending(t)}static isAsyncTest(t){return n.isPromise(B.getData(t).asyncTest)}static statusEquals(t,e){return B.getData(t).status===e}static setPending(t){B.setStatus(t,P.PENDING)}static fail(t){B.setStatus(t,B.warns(t)?P.WARNING:P.FAILED)}static pass(t){B.setStatus(t,P.PASSING)}static warn(t){B.setData(t,(t=>Object.assign(Object.assign({},t),{severity:G.Warning})))}static setData(t,e){t.data=n.optionalFunctionValue(e,B.getData(t))}static skip(t,e){B.setStatus(t,P.SKIPPED,e)}static cancel(t){B.setStatus(t,P.CANCELED),B.getData(t).abortController.abort(P.CANCELED)}static omit(t){B.setStatus(t,P.OMITTED)}static reset(t){B.setStatus(t,L.RESET)}static setStatus(t,e,n){B.setData(t,(t=>Object.assign(Object.assign({},t),{status:V.staticTransition(t.status,e,n)})))}}function M(t){return s.IsolateSelectors.isIsolateType(t,E)}function k(t){n.invariant(M(t))}function w(t){return k(t),t}function j(t,e){return!!e&&!K(t,e)}function K(t,e){return!(!e||t.fieldName!==e)}class x{static hasNoTests(t=x.defaultRoot()){return!t||!s.Walker.has(t,M)}static someIncompleteTests(t,e=x.defaultRoot()){return!!e&&s.Walker.some(e,(e=>(k(e),B.isPending(e)&&t(e))),M)}static someTests(t,e=x.defaultRoot()){return!!e&&s.Walker.some(e,(e=>(k(e),t(e))),M)}static everyTest(t,e=x.defaultRoot()){return!!e&&s.Walker.every(e,(e=>(k(e),t(e))),M)}static walkTests(t,e=x.defaultRoot()){e&&s.Walker.walk(e,((e,n)=>{t(w(e),n)}),M)}static hasRemainingTests(t){return x.someIncompleteTests((e=>!t||K(B.getData(e),t)))}static pluckTests(t,e=x.defaultRoot()){e&&s.Walker.pluck(e,(e=>(k(e),t(e))),M)}static resetField(t){x.walkTests((e=>{K(B.getData(e),t)&&B.reset(e)}),x.defaultRoot())}static removeTestByFieldName(t,e=x.defaultRoot()){x.pluckTests((e=>K(B.getData(e),t)),e)}}function q(){const t=s.VestRuntime.useAvailableRoot(),e=d.getOptionalFields(t);if(n.isEmpty(e))return;const i=new Set;function r(e){const{fieldName:n}=B.getData(e);i.has(n)&&(B.omit(e),d.setOptionalField(t,n,(t=>Object.assign(Object.assign({},t),{applied:!0}))))}x.walkTests((e=>{if(B.isPending(e))return;const{fieldName:s}=B.getData(e);i.has(s)?r(e):function(e){const{fieldName:s}=B.getData(e),a=d.getOptionalField(t,s);!0===n.optionalFunctionValue(a.rule)&&i.add(s);r(e)}(e)})),s.Bus.useEmit(p.DONE_TEST_OMISSION_PASS)}function X(){const t=s.Bus.useBus();return e(p.TEST_COMPLETED,(e=>{if(B.isCanceled(e))return;const{fieldName:s}=B.getData(e);!function(t){const[e]=A();t&&!x.hasRemainingTests(t)&&n.isArray(e[t])&&n.callEach(e[t])}(s),x.hasRemainingTests()||t.emit(p.ALL_RUNNING_TESTS_FINISHED)})),e(p.TEST_RUN_STARTED,(()=>{})),e(p.DONE_TEST_OMISSION_PASS,(()=>{})),e(p.ALL_RUNNING_TESTS_FINISHED,(()=>{x.someTests(B.isAsyncTest)&&q(),function(){const[t]=O();n.callEach(t)}()})),e(p.RESET_FIELD,(t=>{x.resetField(t)})),e(p.SUITE_RUN_STARTED,(()=>{h()})),e(p.SUITE_CALLBACK_RUN_FINISHED,(()=>{q()})),e(p.REMOVE_FIELD,(t=>{x.removeTestByFieldName(t)})),e(p.RESET_SUITE,(()=>{h(),s.VestRuntime.reset()})),{subscribe:function(e){return t.on("*",(()=>{e()})).off}};function e(e,n){t.on(e,((...t)=>{C(),n(...t)}))}}var H;x.defaultRoot=s.VestRuntime.useAvailableRoot,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}.",t.INCLUDE_SELF="Trying to call include.when on the same field."}(H||(H={}));function Y(t,e){const{groupName:n}=B.getData(t),{groupName:s,fieldName:i}=B.getData(e);return K(B.getData(t),i)&&n===s&&t.key===e.key}const z=n.bindNot((function(t,e){return B.getData(t).groupName===e}));function J(t){return function(t,e){return x.someTests((n=>Q(n,t,e)))}(y.ERRORS,t)}function Q(t,e,s){return!!B.hasFailures(t)&&(!j(B.getData(t),s)&&!function(t,e){return n.either(t===y.WARNINGS,B.warns(e))}(e,t))}function Z(t){const[e]=S();return e===t}function $(e){return Z(t.Modes.ONE)?J():!!Z(t.Modes.EAGER)&&J(e.fieldName)}function tt(t,e,s){return s?function(t,e,n){var s;return(null===(s=null==t?void 0:t[n])||void 0===s?void 0:s[e])||[]}(t,e,s):function(t,e){const s={},i=W(e);for(const r in t)n.isPositive(t[r][i])&&(s[r]=t[r][e]||[]);return s}(t,e)}function et(t){const e={getError:function(e){return ot(y.ERRORS,t,e)},getErrors:function(e){return nt(t,y.ERRORS,e)},getErrorsByGroup:function(e,n){return st(t,y.ERRORS,e,n)},getWarning:function(e){return ot(y.WARNINGS,t,e)},getWarnings:function(e){return nt(t,y.WARNINGS,e)},getWarningsByGroup:function(e,n){return st(t,y.WARNINGS,e,n)},hasErrors:function(e){return at(t,b.ERROR_COUNT,e)},hasErrorsByGroup:function(e,n){return rt(t,b.ERROR_COUNT,e,n)},hasWarnings:function(e){return at(t,b.WARN_COUNT,e)},hasWarningsByGroup:function(e,n){return rt(t,b.WARN_COUNT,e,n)},isPending:function(e){var s;return e?n.greaterThan(null===(s=t.tests[e])||void 0===s?void 0:s.pendingCount,0):n.greaterThan(t.pendingCount,0)},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 it(s,n);for(const t in s)if(!it(s,t))return!1;return!0}};return e}function nt(t,e,n){return tt(t.tests,e,n)}function st(t,e,n,s){return tt(t.groups[n],e,s)}function it(t,e){var n;return!!(null===(n=t[e])||void 0===n?void 0:n.valid)}function rt(t,e,s,i){var r,a;const o=t.groups[s];if(!o)return!1;if(i)return n.isPositive(null===(r=o[i])||void 0===r?void 0:r[e]);for(const t in o)if(n.isPositive(null===(a=o[t])||void 0===a?void 0:a[e]))return!0;return!1}function at(t,e,s){var i;const r=s?null===(i=t.tests[s])||void 0===i?void 0:i[e]:t[e]||0;return n.isPositive(r)}function ot(t,e,n){var s;const i=e[t];return n?null===(s=i.find((t=>K(t,n))))||void 0===s?void 0:s.message:i[0]}var ut,ct,lt;class Et{constructor(){this.errorCount=0,this.warnCount=0,this.testCount=0,this.pendingCount=0}}class dt extends Et{constructor(){super(...arguments),this[ut]=[],this[ct]=[],this.groups={},this.tests={},this.valid=!1}}ut=y.ERRORS,ct=y.WARNINGS;class ft{constructor(t,e,n){this.fieldName=t,this.message=e,this.groupName=n}static fromTestObject(t){const{fieldName:e,message:n,groupName:s}=B.getData(t);return new ft(e,n,s)}}function Nt(t){return!!I(t)||!x.hasNoTests()&&(!J(t)&&(!function(t){return x.someIncompleteTests((e=>!j(B.getData(e),t)&&!I(t)))}(t)&&function(t){return x.everyTest((e=>gt(e,t)))}(t)))}function Tt(t,e){return!!I(e)||!function(t,e,n){return x.someTests((s=>!z(s,e)&&Q(s,t,n)))}(y.ERRORS,t,e)&&(!function(t,e){return x.someIncompleteTests((n=>!z(n,t)&&(!j(B.getData(n),e)&&!I(e))))}(t,e)&&function(t,e){return x.everyTest((n=>!!z(n,t)||gt(n,e)))}(t,e))}function gt(t,e){return!!j(B.getData(t),e)||(B.isOmitted(t)||B.isTested(t)||function(t){const e=s.VestRuntime.useAvailableRoot(),{fieldName:n}=B.getData(t);return d.getOptionalField(e,n).type===f.AUTO&&B.awaitsResolution(t)}(t))}function St(){const t=new dt;return x.walkTests((e=>{t.tests=function(t,e){const n=B.getData(e).fieldName,s=Object.assign({},t);return s[n]=mt(s[n],e),s[n].valid=!1!==s[n].valid&&Nt(n),s}(t.tests,e),t.groups=function(t,e){const{groupName:n,fieldName:s}=B.getData(e);if(!n)return t;const i=Object.assign({},t);return i[n]=i[n]||{},i[n][s]=mt(i[n][s],e),i[n][s].valid=!1!==i[n][s].valid&&Tt(n,s),i}(t.groups,e),t.errors=Rt(y.ERRORS,t.errors,e),t.warnings=Rt(y.WARNINGS,t.warnings,e)})),t.valid=Nt(),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,t.pendingCount+=t.tests[e].pendingCount;return t}(t)}function Rt(t,e,n){if(B.isOmitted(n))return e;return(t===y.WARNINGS?B.isWarning(n):B.isFailing(n))?e.concat(ft.fromTestObject(n)):e}function mt(t,e){const{message:s}=B.getData(e),i=n.defaultTo(t?Object.assign({},t):null,It);return B.isNonActionable(e)||(B.isPending(e)&&i.pendingCount++,B.isFailing(e)?r(y.ERRORS):B.isWarning(e)&&r(y.WARNINGS),i.testCount++),i;function r(t){const e=W(t);i[e]++,s&&(i[t]=(i[t]||[]).concat(s))}}function It(){return n.assign(new Et,{errors:[],valid:!0,warnings:[]})}function pt(){return t=()=>{const t=St(),e=D().suiteName;return Object.freeze(n.assign(t,et(t),{suiteName:e}))},(0,D().suiteResultCache)([v()],t);var t}function _t(t,e){s.Isolate.create(u,(()=>{T.run({omitted:Dt()||n.optionalFunctionValue(t,n.optionalFunctionValue(pt))},e)}))}function Dt(){return function(){var t;return null!==(t=T.useX().omitted)&&void 0!==t&&t}()}function Ot(t,e){s.Isolate.create(c,(()=>{T.run({skipped:At()||n.optionalFunctionValue(t,n.optionalFunctionValue(pt))},e)}))}function At(){return function(){var t;return null!==(t=T.useX().skipped)&&void 0!==t&&t}()}function vt(t,e){return s.Isolate.create(a,n.noop,{focusMode:t,match:n.asArray(e).filter(n.isStringValue),matchAll:!0===e})}!function(t){t[t.ONLY=0]="ONLY",t[t.SKIP=1]="SKIP"}(lt||(lt={}));class Ct{static isSkipFocused(t,e){return(null==t?void 0:t.data.focusMode)===lt.SKIP&&(Lt(t,e)||!0===t.data.matchAll)}static isOnlyFocused(t,e){return(null==t?void 0:t.data.focusMode)===lt.ONLY&&Lt(t,e)}static isIsolateFocused(t){return s.IsolateSelectors.isIsolateType(t,a)}}function ht(t){return vt(lt.ONLY,Pt(t))}function Ft(t){return vt(lt.SKIP,Pt(t))}function Pt(t){return!1===t?[]:t}function Lt(t,e){var s,i;return n.isNotEmpty(null==t?void 0:t.data.match)&&(!e||(null===(i=null===(s=null==t?void 0:t.data.match)||void 0===s?void 0:s.includes(e))||void 0===i||i))}function Ut(t,e){return n.isNotNullish(s.Walker.findClosest(t,(t=>!!Ct.isIsolateFocused(t)&&Ct.isOnlyFocused(t,e))))}function yt(t){const{fieldName:e}=B.getData(t);if(At())return!0;const i=g(),r=function(t){return s.Walker.findClosest(t,(e=>{var n;if(!Ct.isIsolateFocused(e))return!1;const{fieldName:s}=B.getData(t);return(null===(n=e.data.match)||void 0===n?void 0:n.includes(s))||e.data.matchAll}))}(t);if(Ct.isSkipFocused(r))return!0;return!Ct.isOnlyFocused(r)&&(!!Ut(t)&&!n.optionalFunctionValue(i[e],t))}function bt(t,e=t){const n=B.getData(t);return $(n)?(s=t,B.skip(s),s):(i=n.fieldName,Dt()||I(i)?function(t){return B.omit(t),t}(t):yt(t)?function(t){return B.skip(t,At()),t}(e):t);var s,i}class Gt extends class{static match(t,e){return!1}static reconcile(t,e){return null!=t?t:e}}{static match(t,e){return M(t)&&M(e)}static reconcile(t,e){const i=function(t,e){const i=function(t,e){if(s.IsolateInspector.usesKey(t))return w(s.Reconciler.handleIsolateNodeWithKey(t));if(s.Reconciler.dropNextNodesOnReorder(Wt,t,e))return function(t,e){if(s.IsolateInspector.canReorder(t))return;n.deferThrow(n.text(H.TESTS_CALLED_IN_DIFFERENT_ORDER,{fieldName:B.getData(t).fieldName,prevName:M(e)?B.getData(e).fieldName:void 0}))}(t,e),t;if(!M(e))return t;if(B.isOmitted(e))return t;return e}(e,t);return bt(e,i)}(e,t);return function(t,e,n){t===e&&M(e)&&(i=e)!==(s=n)&&Y(s,i)&&B.isPending(s)&&B.cancel(s);var s,i}(i,t,e),i}}function Wt(t,e){return M(e)&&!Y(e,t)}function Vt(t,e){var n,s;return null!==(s=null===(n=[Gt].find((n=>n.match(t,e))))||void 0===n?void 0:n.reconcile(t,e))&&void 0!==s?s:null}function Bt(...t){const[e,n]=t.reverse();return s.Isolate.create(o,(()=>T.run(Object.assign({},n&&{groupName:n}),e)))}function Mt(t){n.invariant(n.isStringValue(t));return g()[t]=!0,{when:function(e){n.invariant(e!==t,H.INCLUDE_SELF);g()[t]=function(t){return n.isStringValue(e)?Ut(t,e):n.optionalFunctionValue(e,n.optionalFunctionValue(pt))}}}}function kt(t,e,n){const i=Object.assign(Object.assign({},{severity:G.Error,status:P.UNTESTED,abortController:new AbortController}),{fieldName:e.fieldName,testFn:e.testFn});e.groupName&&(i.groupName=e.groupName),e.message&&(i.message=e.message);return s.Isolate.create(E,t,i,null!=n?n:null)}function wt(t){if(bt(t),B.isUntested(t))return function(t){const e=s.Bus.useBus(),i=function(t){return T.run({currentTest:t},(()=>{let e;const{message:s,testFn:i,abortController:r}=B.getData(t);try{e=i({signal:r.signal})}catch(i){(function(t,e){return n.isUndefined(t)&&n.isStringValue(e)})(s,i)&&(B.getData(t).message=i),e=!1}return!1===e&&B.fail(t),e}))}(t);try{n.isPromise(i)?(B.getData(t).asyncTest=i,function(t){const{asyncTest:e,message:i}=B.getData(t);if(!n.isPromise(e))return;B.setPending(t);const r=s.Bus.useBus(),a=s.VestRuntime.persist((()=>{jt(r,t)})),o=s.VestRuntime.persist((e=>{B.isCanceled(t)||(B.getData(t).message=n.isStringValue(e)?e:i,B.fail(t),a())}));e.then(a,o)}(t)):jt(e,t)}catch(e){throw new Error(n.text(H.UNEXPECTED_TEST_REGISTRATION_ERROR,{testObject:JSON.stringify(t),error:e}))}}(t);B.isNonActionable(t)||n.deferThrow(n.text(H.UNEXPECTED_TEST_REGISTRATION_ERROR,{testObject:JSON.stringify(t)}))}function jt(t,e){B.pass(e),t.emit(p.TEST_COMPLETED,e)}function Kt(t,...e){const[i,r,a]=n.isFunction(e[1])?e:[void 0,...e];!function(t,e){const s="test";n.invariant(n.isStringValue(t),n.text(H.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:s,param:"fieldName",expected:"string"})),n.invariant(n.isFunction(e),n.text(H.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:s,param:"callback",expected:"function"}))}(t,r);const o={fieldName:t,groupName:T.useX().groupName,message:i,testFn:r};return s.Bus.useEmit(p.TEST_RUN_STARTED),kt(wt,o,a)}const xt=n.assign(Kt,{memo:function(t){return function(e,...i){const[r,a,o]=i.reverse();return function(t,e){const i=T.useX().testMemoCache,r=i.get(t);if(n.isNull(r))return i(t,e);const[,a]=r;if(B.isCanceled(a))return i.invalidate(t),i(t,e);return s.VestRuntime.addNodeToHistory(a),a}([v(),e,s.VestRuntime.useCurrentCursor()].concat(r),(function(){return t(e,o,a)}))}}(Kt)});function qt(){return{group:Bt,include:Mt,omitWhen:_t,only:ht,optional:m,skip:Ft,skipWhen:Ot,test:xt}}function Xt(){return Object.freeze(n.assign({done:s.VestRuntime.persist(Ht)},pt()))}function Ht(...t){const[e,s]=t.reverse(),i=Xt();if(function(t,e,s){var i,r;return!!(!n.isFunction(t)||e&&n.numberEquals(null!==(r=null===(i=s.tests[e])||void 0===i?void 0:i.testCount)&&void 0!==r?r:0,0))}(e,s,i))return i;const r=()=>e(pt());return x.hasRemainingTests(s)?(function(t,e){const[,s]=A(),[,i]=O();e?s((s=>n.assign(s,{[e]:(s[e]||[]).concat(t)}))):i((e=>e.concat(t)))}(r,s),i):(r(),i)}function Yt(...t){const[e,i]=t.reverse();!function(t){n.invariant(n.isFunction(t),H.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION)}(e);const r=function({suiteName:t,VestReconciler:e}){const i={doneCallbacks:n.tinyState.createTinyState((()=>[])),fieldCallbacks:n.tinyState.createTinyState((()=>({}))),suiteId:n.seq(),suiteName:t,suiteResultCache:_};return s.VestRuntime.createRef(e,i)}({suiteName:i,VestReconciler:Vt});function a(...t){return T.run({suiteParams:t},(()=>{return s.Bus.useEmit(p.SUITE_RUN_STARTED),n=function(t,...e){const n=s.Bus.useEmit();return()=>(t(...e),n(p.SUITE_CALLBACK_RUN_FINISHED),Xt())}(e,...t),s.Isolate.create(l,n,{optional:{}});var n})).output}return s.VestRuntime.Run(r,(()=>{const t=X();return n.assign(s.VestRuntime.persist(a),Object.assign(Object.assign({dump:s.VestRuntime.persist((()=>s.VestRuntime.useAvailableRoot())),get:s.VestRuntime.persist(pt),remove:s.Bus.usePrepareEmitter(p.REMOVE_FIELD),reset:s.Bus.usePrepareEmitter(p.RESET_SUITE),resetField:s.Bus.usePrepareEmitter(p.RESET_FIELD),resume:s.VestRuntime.persist(F),subscribe:t.subscribe},(e=s.VestRuntime.persist(pt),{getError:(...t)=>e().getError(...t),getErrors:(...t)=>e().getErrors(...t),getErrorsByGroup:(...t)=>e().getErrorsByGroup(...t),getWarning:(...t)=>e().getWarning(...t),getWarnings:(...t)=>e().getWarnings(...t),getWarningsByGroup:(...t)=>e().getWarningsByGroup(...t),hasErrors:(...t)=>e().hasErrors(...t),hasErrorsByGroup:(...t)=>e().hasErrorsByGroup(...t),hasWarnings:(...t)=>e().hasWarnings(...t),hasWarningsByGroup:(...t)=>e().hasWarningsByGroup(...t),isPending:(...t)=>e().isPending(...t),isValid:(...t)=>e().isValid(...t),isValidByGroup:(...t)=>e().isValidByGroup(...t)})),qt()));var e}))}const zt=H.WARN_MUST_BE_CALLED_FROM_TEST;Object.defineProperty(t,"enforce",{enumerable:!0,get:function(){return e.enforce}}),t.create=Yt,t.each=function(t,e){n.invariant(n.isFunction(e),H.EACH_CALLBACK_MUST_BE_A_FUNCTION),function(t){s.Isolate.create(r,t,{allowReorder:!0})}((()=>{t.forEach(((t,n)=>{e(t,n)}))}))},t.group=Bt,t.include=Mt,t.mode=function(t){const[,e]=S();e(t)},t.omitWhen=_t,t.only=ht,t.optional=m,t.skip=Ft,t.skipWhen=Ot,t.staticSuite=function(t){return n.assign(((...e)=>{const s=Yt(t),i=s(...e);return Object.freeze(n.assign({dump:s.dump},i))}),Object.assign({},qt()))},t.suiteSelectors=et,t.test=xt,t.warn=function(){const t=(e=H.HOOK_CALLED_OUTSIDE,T.useX(e).currentTest);var e;n.invariant(t,zt),B.warn(t)}}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("n4s"),require("vest-utils"),require("vestjs-runtime"),require("context")):"function"==typeof define&&define.amd?define(["exports","n4s","vest-utils","vestjs-runtime","context"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).vest={},t.n4s,t["vest-utils"],t["vestjs-runtime"],t.context)}(this,(function(t,e,n,s,i){"use strict";const r="Each",a="Focused",o="Group",u="OmitWhen",c="SkipWhen",l="Suite",E="Test";class d{static setOptionalField(t,e,s){const i=t.data.optional,r=i[e];n.assign(i,{[e]:n.assign({},r,s(r))})}static getOptionalField(t,e){var n;return null!==(n=t.data.optional[e])&&void 0!==n?n:{}}static getOptionalFields(t){return t.data.optional}}var f,N;!function(t){t[t.CUSTOM_LOGIC=0]="CUSTOM_LOGIC",t[t.AUTO=1]="AUTO"}(f||(f={})),t.Modes=void 0,(N=t.Modes||(t.Modes={})).EAGER="EAGER",N.ALL="ALL",N.ONE="ONE";const T=i.createCascade(((e,s)=>s?null:n.assign({inclusion:{},mode:n.tinyState.createTinyState(t.Modes.EAGER),suiteParams:[],testMemoCache:I},e)));function g(){return T.useX().inclusion}function S(){return T.useX().mode()}const I=n.cache(10);function R(t){var i;const r=s.VestRuntime.useAvailableRoot(),a=T.useX().suiteParams,o=null!==(i=null==a?void 0:a[0])&&void 0!==i?i:{};if(n.isArray(t)||n.isStringValue(t))n.asArray(t).forEach((t=>{d.setOptionalField(r,t,(()=>({type:f.AUTO,applied:!!n.hasOwnProperty(o,t)&&e.enforce.isBlank().test(null==o?void 0:o[t]),rule:null})))}));else for(const n in t){const s=t[n];d.setOptionalField(r,n,(()=>({type:f.CUSTOM_LOGIC,rule:s,applied:e.enforce.isBlank().test(s)||!0===s})))}}function m(t){var e,n;if(!t)return!1;const i=s.VestRuntime.useAvailableRoot();return null!==(n=null===(e=d.getOptionalField(i,t))||void 0===e?void 0:e.applied)&&void 0!==n&&n}var 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"}(p||(p={}));const _=n.cache();function D(){return s.VestRuntime.useXAppData()}function O(){return D().doneCallbacks()}function A(){return D().fieldCallbacks()}function v(){return D().suiteId}function h(){D().suiteResultCache.invalidate([v()])}function C(){const[,,t]=O(),[,,e]=A();t(),e()}function P(t){s.VestRuntime.useLoadRootNode(t),h()}const F="PENDING",L={[F]:F,INITIAL:"INITIAL",DONE:"DONE"},U={initial:L.INITIAL,states:{[L.DONE]:{},[L.INITIAL]:{[L.PENDING]:L.PENDING,[L.DONE]:L.DONE},[L.PENDING]:{[L.DONE]:L.DONE}}};function y(t,e){return G.staticTransition(null!=t?t:L.INITIAL,e)}const G=n.StateMachine(U);var W;!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}.",t.INCLUDE_SELF="Trying to call include.when on the same field."}(W||(W={}));const b={[F]:F,CANCELED:"CANCELED",FAILED:"FAILED",OMITTED:"OMITTED",PASSING:"PASSING",SKIPPED:"SKIPPED",UNTESTED:"UNTESTED",WARNING:"WARNING"},V="RESET",M={initial:b.UNTESTED,states:{"*":{[b.OMITTED]:b.OMITTED,[V]:b.UNTESTED},[b.UNTESTED]:{[b.CANCELED]:b.CANCELED,[b.FAILED]:b.FAILED,[b.PASSING]:b.PASSING,[b.PENDING]:b.PENDING,[b.SKIPPED]:b.SKIPPED,[b.WARNING]:b.WARNING},[b.PENDING]:{[b.CANCELED]:b.CANCELED,[b.FAILED]:b.FAILED,[b.PASSING]:b.PASSING,[b.SKIPPED]:[b.SKIPPED,t=>!0===t],[b.WARNING]:b.WARNING},[b.SKIPPED]:{},[b.FAILED]:{},[b.WARNING]:{},[b.PASSING]:{},[b.CANCELED]:{},[b.OMITTED]:{}}},k=n.StateMachine(M);var B,w,j;function K(t){return t===B.ERRORS?w.ERROR_COUNT:w.WARN_COUNT}!function(t){t.WARNINGS="warnings",t.ERRORS="errors"}(B||(B={})),function(t){t.ERROR_COUNT="errorCount",t.WARN_COUNT="warnCount"}(w||(w={})),function(t){t.Error="error",t.Warning="warning"}(j||(j={}));class x{static getData(t){return n.invariant(t.data),t.data}static is(t){return s.IsolateSelectors.isIsolateType(t,E)}static isX(t){n.invariant(x.is(t),W.EXPECTED_VEST_TEST)}static cast(t){return x.isX(t),t}static warns(t){return x.getData(t).severity===j.Warning}static isPending(t){return x.statusEquals(t,b.PENDING)}static isOmitted(t){return x.statusEquals(t,b.OMITTED)}static isUntested(t){return x.statusEquals(t,b.UNTESTED)}static isFailing(t){return x.statusEquals(t,b.FAILED)}static isCanceled(t){return x.statusEquals(t,b.CANCELED)}static isSkipped(t){return x.statusEquals(t,b.SKIPPED)}static isPassing(t){return x.statusEquals(t,b.PASSING)}static isWarning(t){return x.statusEquals(t,b.WARNING)}static hasFailures(t){return x.isFailing(t)||x.isWarning(t)}static isNonActionable(t){return x.isSkipped(t)||x.isOmitted(t)||x.isCanceled(t)}static isTested(t){return x.hasFailures(t)||x.isPassing(t)}static awaitsResolution(t){return x.isSkipped(t)||x.isUntested(t)||x.isPending(t)}static isAsyncTest(t){return n.isPromise(x.getData(t).asyncTest)}static statusEquals(t,e){return t.status===e}static setPending(t){x.setStatus(t,b.PENDING)}static fail(t){x.setStatus(t,x.warns(t)?b.WARNING:b.FAILED)}static pass(t){x.setStatus(t,b.PASSING)}static warn(t){x.setData(t,(t=>Object.assign(Object.assign({},t),{severity:j.Warning})))}static setData(t,e){t.data=n.optionalFunctionValue(e,x.getData(t))}static skip(t,e){x.setStatus(t,b.SKIPPED,e)}static cancel(t){x.setStatus(t,b.CANCELED),s.IsolateMutator.abort(t,b.CANCELED)}static omit(t){x.setStatus(t,b.OMITTED)}static reset(t){x.setStatus(t,V)}static setStatus(t,e,n){t.status=k.staticTransition(t.status,e,n)}}function X(t,e){return!!e&&!q(t,e)}function q(t,e){return!(!e||t.fieldName!==e)}class H{static hasPending(t){const e=H.defaultRoot();return!!e&&s.Walker.some(e,n.Predicates.all(Y,null==t||t))}static hasRemainingWithTestNameMatching(t){return H.hasPending(n.Predicates.any(n.isNullish(t),n.Predicates.all(x.is,(e=>function(t,e){return!e||q(t,e)}(x.getData(e),t)))))}}function Y(t){return t.status===F}H.defaultRoot=s.VestRuntime.useAvailableRoot;class z{static hasNoTests(t=z.defaultRoot()){return!t||!s.Walker.has(t,x.is)}static someTests(t,e=z.defaultRoot()){return!!e&&s.Walker.some(e,(e=>(x.isX(e),t(e))),x.is)}static everyTest(t,e=z.defaultRoot()){return!!e&&s.Walker.every(e,(e=>(x.isX(e),t(e))),x.is)}static walkTests(t,e=z.defaultRoot()){e&&s.Walker.walk(e,((e,n)=>{t(x.cast(e),n)}),x.is)}static pluckTests(t,e=z.defaultRoot()){e&&s.Walker.pluck(e,(e=>(x.isX(e),t(e))),x.is)}static resetField(t){z.walkTests((e=>{q(x.getData(e),t)&&x.reset(e)}),z.defaultRoot())}static removeTestByFieldName(t,e=z.defaultRoot()){z.pluckTests((e=>q(x.getData(e),t)),e)}}function J(){const t=s.VestRuntime.useAvailableRoot(),e=d.getOptionalFields(t);if(n.isEmpty(e))return;const i=new Set;function r(e){const{fieldName:n}=x.getData(e);i.has(n)&&(x.omit(e),d.setOptionalField(t,n,(t=>Object.assign(Object.assign({},t),{applied:!0}))))}z.walkTests((e=>{if(x.isPending(e))return;const{fieldName:s}=x.getData(e);i.has(s)?r(e):function(e){const{fieldName:s}=x.getData(e),a=d.getOptionalField(t,s);!0===n.optionalFunctionValue(a.rule)&&i.add(s);r(e)}(e)})),s.Bus.useEmit(p.DONE_TEST_OMISSION_PASS)}function Q(){const t=s.Bus.useBus();return e(p.TEST_COMPLETED,(t=>{if(x.isCanceled(t))return;const{fieldName:e}=x.getData(t);!function(t){const[e]=A();t&&!H.hasRemainingWithTestNameMatching(t)&&n.isArray(e[t])&&n.callEach(e[t])}(e)})),e(p.TEST_RUN_STARTED,(()=>{})),e(s.RuntimeEvents.ISOLATE_PENDING,(t=>{x.is(t)&&x.setPending(t),function(t){t.status=y(t.status,L.PENDING)}(t)})),e(s.RuntimeEvents.ISOLATE_DONE,(e=>{x.is(e)&&t.emit(p.TEST_COMPLETED,e),function(t){t.status=y(t.status,L.DONE)}(e),H.hasPending()||t.emit(p.ALL_RUNNING_TESTS_FINISHED)})),e(p.DONE_TEST_OMISSION_PASS,(()=>{})),e(p.ALL_RUNNING_TESTS_FINISHED,(()=>{z.someTests(x.isAsyncTest)&&J(),function(){const[t]=O();n.callEach(t)}()})),e(p.RESET_FIELD,(t=>{z.resetField(t)})),e(p.SUITE_RUN_STARTED,(()=>{C()})),e(p.SUITE_CALLBACK_RUN_FINISHED,(()=>{J()})),e(p.REMOVE_FIELD,(t=>{z.removeTestByFieldName(t)})),e(p.RESET_SUITE,(()=>{C(),s.VestRuntime.reset()})),{subscribe:function(e){return t.on("*",(()=>{e()})).off}};function e(e,n){t.on(e,((...t)=>{h(),n(...t)}))}}z.defaultRoot=s.VestRuntime.useAvailableRoot;function Z(t,e){const{groupName:n}=x.getData(t),{groupName:s,fieldName:i}=x.getData(e);return q(x.getData(t),i)&&n===s&&t.key===e.key}const $=n.bindNot((function(t,e){return x.getData(t).groupName===e}));function tt(t){return function(t,e){return z.someTests((n=>et(n,t,e)))}(B.ERRORS,t)}function et(t,e,s){return!!x.hasFailures(t)&&(!X(x.getData(t),s)&&!function(t,e){return n.either(t===B.WARNINGS,x.warns(e))}(e,t))}function nt(t){const[e]=S();return e===t}function st(e){return nt(t.Modes.ONE)?tt():!!nt(t.Modes.EAGER)&&tt(e.fieldName)}function it(t,e,s){return s?function(t,e,n){var s;return(null===(s=null==t?void 0:t[n])||void 0===s?void 0:s[e])||[]}(t,e,s):function(t,e){const s={},i=K(e);for(const r in t)n.isPositive(t[r][i])&&(s[r]=t[r][e]||[]);return s}(t,e)}function rt(t){const e={getError:function(e){return Et(B.ERRORS,t,e)},getErrors:function(e){return at(t,B.ERRORS,e)},getErrorsByGroup:function(e,n){return ot(t,B.ERRORS,e,n)},getWarning:function(e){return Et(B.WARNINGS,t,e)},getWarnings:function(e){return at(t,B.WARNINGS,e)},getWarningsByGroup:function(e,n){return ot(t,B.WARNINGS,e,n)},hasErrors:function(e){return lt(t,w.ERROR_COUNT,e)},hasErrorsByGroup:function(e,n){return ct(t,w.ERROR_COUNT,e,n)},hasWarnings:function(e){return lt(t,w.WARN_COUNT,e)},hasWarningsByGroup:function(e,n){return ct(t,w.WARN_COUNT,e,n)},isPending:function(e){var s;return e?n.greaterThan(null===(s=t.tests[e])||void 0===s?void 0:s.pendingCount,0):n.greaterThan(t.pendingCount,0)},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 ut(s,n);for(const t in s)if(!ut(s,t))return!1;return!0}};return e}function at(t,e,n){return it(t.tests,e,n)}function ot(t,e,n,s){return it(t.groups[n],e,s)}function ut(t,e){var n;return!!(null===(n=t[e])||void 0===n?void 0:n.valid)}function ct(t,e,s,i){var r,a;const o=t.groups[s];if(!o)return!1;if(i)return n.isPositive(null===(r=o[i])||void 0===r?void 0:r[e]);for(const t in o)if(n.isPositive(null===(a=o[t])||void 0===a?void 0:a[e]))return!0;return!1}function lt(t,e,s){var i;const r=s?null===(i=t.tests[s])||void 0===i?void 0:i[e]:t[e]||0;return n.isPositive(r)}function Et(t,e,n){var s;const i=e[t];return n?null===(s=i.find((t=>q(t,n))))||void 0===s?void 0:s.message:i[0]}var dt,ft,Nt;class Tt{constructor(){this.errorCount=0,this.warnCount=0,this.testCount=0,this.pendingCount=0}}class gt extends Tt{constructor(){super(...arguments),this[dt]=[],this[ft]=[],this.groups={},this.tests={},this.valid=!1}}dt=B.ERRORS,ft=B.WARNINGS;class St{constructor(t,e,n){this.fieldName=t,this.message=e,this.groupName=n}static fromTestObject(t){const{fieldName:e,message:n,groupName:s}=x.getData(t);return new St(e,n,s)}}function It(t){return!!m(t)||!z.hasNoTests()&&(!tt(t)&&(!function(t){return H.hasPending(n.Predicates.all(x.is,(e=>!X(x.getData(e),t)),(()=>!m(t))))}(t)&&function(t){return z.everyTest((e=>mt(e,t)))}(t)))}function Rt(t,e){return!!m(e)||!function(t,e,n){return z.someTests((s=>!$(s,e)&&et(s,t,n)))}(B.ERRORS,t,e)&&(!function(t,e){return H.hasPending(n.Predicates.all(x.is,(e=>!$(e,t)),(t=>!X(x.getData(t),e)),(()=>!m(e))))}(t,e)&&function(t,e){return z.everyTest((n=>!!$(n,t)||mt(n,e)))}(t,e))}function mt(t,e){return!!X(x.getData(t),e)||(x.isOmitted(t)||x.isTested(t)||function(t){const e=s.VestRuntime.useAvailableRoot(),{fieldName:n}=x.getData(t);return d.getOptionalField(e,n).type===f.AUTO&&x.awaitsResolution(t)}(t))}function pt(){const t=new gt;return z.walkTests((e=>{t.tests=function(t,e){const n=x.getData(e).fieldName,s=Object.assign({},t);return s[n]=Dt(s[n],e),s[n].valid=!1!==s[n].valid&&It(n),s}(t.tests,e),t.groups=function(t,e){const{groupName:n,fieldName:s}=x.getData(e);if(!n)return t;const i=Object.assign({},t);return i[n]=i[n]||{},i[n][s]=Dt(i[n][s],e),i[n][s].valid=!1!==i[n][s].valid&&Rt(n,s),i}(t.groups,e),t.errors=_t(B.ERRORS,t.errors,e),t.warnings=_t(B.WARNINGS,t.warnings,e)})),t.valid=It(),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,t.pendingCount+=t.tests[e].pendingCount;return t}(t)}function _t(t,e,n){if(x.isOmitted(n))return e;return(t===B.WARNINGS?x.isWarning(n):x.isFailing(n))?e.concat(St.fromTestObject(n)):e}function Dt(t,e){const{message:s}=x.getData(e),i=n.defaultTo(t?Object.assign({},t):null,Ot);return x.isNonActionable(e)||(x.isPending(e)&&i.pendingCount++,x.isFailing(e)?r(B.ERRORS):x.isWarning(e)&&r(B.WARNINGS),i.testCount++),i;function r(t){const e=K(t);i[e]++,s&&(i[t]=(i[t]||[]).concat(s))}}function Ot(){return n.assign(new Tt,{errors:[],valid:!0,warnings:[]})}function At(){return t=()=>{const t=pt(),e=D().suiteName;return Object.freeze(n.assign(t,rt(t),{suiteName:e}))},(0,D().suiteResultCache)([v()],t);var t}function vt(t,e){s.Isolate.create(u,(()=>{T.run({omitted:ht()||n.optionalFunctionValue(t,n.optionalFunctionValue(At))},e)}))}function ht(){return function(){var t;return null!==(t=T.useX().omitted)&&void 0!==t&&t}()}function Ct(t,e){s.Isolate.create(c,(()=>{T.run({skipped:Pt()||n.optionalFunctionValue(t,n.optionalFunctionValue(At))},e)}))}function Pt(){return function(){var t;return null!==(t=T.useX().skipped)&&void 0!==t&&t}()}function Ft(t,e){return s.Isolate.create(a,n.noop,{focusMode:t,match:n.asArray(e).filter(n.isStringValue),matchAll:!0===e})}!function(t){t[t.ONLY=0]="ONLY",t[t.SKIP=1]="SKIP"}(Nt||(Nt={}));class Lt{static isSkipFocused(t,e){return(null==t?void 0:t.data.focusMode)===Nt.SKIP&&(Wt(t,e)||!0===t.data.matchAll)}static isOnlyFocused(t,e){return(null==t?void 0:t.data.focusMode)===Nt.ONLY&&Wt(t,e)}static isIsolateFocused(t){return s.IsolateSelectors.isIsolateType(t,a)}}function Ut(t){return Ft(Nt.ONLY,Gt(t))}function yt(t){return Ft(Nt.SKIP,Gt(t))}function Gt(t){return!1===t?[]:t}function Wt(t,e){var s,i;return n.isNotEmpty(null==t?void 0:t.data.match)&&(!e||(null===(i=null===(s=null==t?void 0:t.data.match)||void 0===s?void 0:s.includes(e))||void 0===i||i))}function bt(t,e){return n.isNotNullish(s.Walker.findClosest(t,(t=>!!Lt.isIsolateFocused(t)&&Lt.isOnlyFocused(t,e))))}function Vt(t){const{fieldName:e}=x.getData(t);if(Pt())return!0;const i=g(),r=function(t){return s.Walker.findClosest(t,(e=>{var n;if(!Lt.isIsolateFocused(e))return!1;const{fieldName:s}=x.getData(t);return(null===(n=e.data.match)||void 0===n?void 0:n.includes(s))||e.data.matchAll}))}(t);if(Lt.isSkipFocused(r))return!0;return!Lt.isOnlyFocused(r)&&(!!bt(t)&&!n.optionalFunctionValue(i[e],t))}function Mt(t,e=t){const n=x.getData(t);return st(n)?(s=t,x.skip(s),s):(i=n.fieldName,ht()||m(i)?function(t){return x.omit(t),t}(t):Vt(t)?function(t){return x.skip(t,Pt()),t}(e):t);var s,i}class kt extends class{static match(t,e){return!1}static reconcile(t,e){return null!=t?t:e}}{static match(t,e){return x.is(t)&&x.is(e)}static reconcile(t,e){const i=function(t,e){const i=function(t,e){if(s.IsolateInspector.usesKey(t))return x.cast(s.Reconciler.handleIsolateNodeWithKey(t));if(s.Reconciler.dropNextNodesOnReorder(Bt,t,e))return function(t,e){if(s.IsolateInspector.canReorder(t))return;n.deferThrow(n.text(W.TESTS_CALLED_IN_DIFFERENT_ORDER,{fieldName:x.getData(t).fieldName,prevName:x.is(e)?x.getData(e).fieldName:void 0}))}(t,e),t;if(!x.is(e))return t;if(x.isOmitted(e))return t;return e}(e,t);return Mt(e,i)}(e,t);return function(t,e,n){t===e&&x.is(e)&&(i=e)!==(s=n)&&Z(s,i)&&x.isPending(s)&&x.cancel(s);var s,i}(i,t,e),i}}function Bt(t,e){return x.is(e)&&!Z(e,t)}function wt(t,e){var n,s;return null!==(s=null===(n=[kt].find((n=>n.match(t,e))))||void 0===n?void 0:n.reconcile(t,e))&&void 0!==s?s:null}function jt(...t){const[e,n]=t.reverse();return s.Isolate.create(o,(()=>T.run(Object.assign({},n&&{groupName:n}),e)))}function Kt(t){n.invariant(n.isStringValue(t));return g()[t]=!0,{when:function(e){n.invariant(e!==t,W.INCLUDE_SELF);g()[t]=function(t){return n.isStringValue(e)?bt(t,e):n.optionalFunctionValue(e,n.optionalFunctionValue(At))}}}}function xt(t,e,n){const i=Object.assign(Object.assign({},{severity:j.Error,status:k.initial()}),{fieldName:e.fieldName,testFn:e.testFn});e.groupName&&(i.groupName=e.groupName),e.message&&(i.message=e.message);return s.Isolate.create(E,t,i,null!=n?n:null)}function Xt(t){if(Mt(t),x.isUntested(t))return function(t){const e=function(t){return T.run({currentTest:t},(()=>{let e;const{message:s,testFn:i}=x.getData(t);try{e=i({signal:t.abortController.signal})}catch(i){(function(t,e){return n.isUndefined(t)&&n.isStringValue(e)})(s,i)&&(x.getData(t).message=i),e=!1}return!1===e&&x.fail(t),e}))}(t);try{if(n.isPromise(e))return x.getData(t).asyncTest=e,function(t){const{asyncTest:e,message:i}=x.getData(t);if(!n.isPromise(e))return;const r=s.VestRuntime.persist((()=>{qt(t)})),a=s.VestRuntime.persist((e=>{x.isCanceled(t)||(x.getData(t).message=n.isStringValue(e)?e:i,x.fail(t),r())}));return e.then(r,a)}(t);qt(t)}catch(e){throw new Error(n.text(W.UNEXPECTED_TEST_REGISTRATION_ERROR,{testObject:JSON.stringify(t),error:e}))}}(t);x.isNonActionable(t)||n.deferThrow(n.text(W.UNEXPECTED_TEST_REGISTRATION_ERROR,{testObject:JSON.stringify(t)}))}function qt(t){x.pass(t)}function Ht(t,...e){const[i,r,a]=n.isFunction(e[1])?e:[void 0,...e];!function(t,e){const s="test";n.invariant(n.isStringValue(t),n.text(W.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:s,param:"fieldName",expected:"string"})),n.invariant(n.isFunction(e),n.text(W.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:s,param:"callback",expected:"function"}))}(t,r);const o={fieldName:t,groupName:T.useX().groupName,message:i,testFn:r};return s.Bus.useEmit(p.TEST_RUN_STARTED),xt(Xt,o,a)}const Yt=n.assign(Ht,{memo:function(t){return function(e,...i){const[r,a,o]=i.reverse();return function(t,e){const i=T.useX().testMemoCache,r=i.get(t);if(n.isNull(r))return i(t,e);const[,a]=r;if(x.isCanceled(a))return i.invalidate(t),i(t,e);return s.VestRuntime.addNodeToHistory(a),a}([v(),e,s.VestRuntime.useCurrentCursor()].concat(r),(function(){return t(e,o,a)}))}}(Ht)});function zt(){return{group:jt,include:Kt,omitWhen:vt,only:Ut,optional:R,skip:yt,skipWhen:Ct,test:Yt}}function Jt(){return Object.freeze(n.assign({done:s.VestRuntime.persist(Qt)},At()))}function Qt(...t){const[e,s]=t.reverse(),i=Jt();if(function(t,e,s){var i,r;return!!(!n.isFunction(t)||e&&n.numberEquals(null!==(r=null===(i=s.tests[e])||void 0===i?void 0:i.testCount)&&void 0!==r?r:0,0))}(e,s,i))return i;const r=()=>e(At());return H.hasRemainingWithTestNameMatching(s)?(function(t,e){const[,s]=A(),[,i]=O();e?s((s=>n.assign(s,{[e]:(s[e]||[]).concat(t)}))):i((e=>e.concat(t)))}(r,s),i):(r(),i)}function Zt(...t){const[e,i]=t.reverse();!function(t){n.invariant(n.isFunction(t),W.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION)}(e);const r=function({suiteName:t,VestReconciler:e}){const i={doneCallbacks:n.tinyState.createTinyState((()=>[])),fieldCallbacks:n.tinyState.createTinyState((()=>({}))),suiteId:n.seq(),suiteName:t,suiteResultCache:_};return s.VestRuntime.createRef(e,i)}({suiteName:i,VestReconciler:wt});function a(...t){return T.run({suiteParams:t},(()=>{return s.Bus.useEmit(p.SUITE_RUN_STARTED),n=function(t,...e){const n=s.Bus.useEmit();return()=>(t(...e),n(p.SUITE_CALLBACK_RUN_FINISHED),Jt())}(e,...t),s.Isolate.create(l,n,{optional:{}});var n})).output}return s.VestRuntime.Run(r,(()=>{const t=Q();return n.assign(s.VestRuntime.persist(a),Object.assign(Object.assign({dump:s.VestRuntime.persist((()=>s.VestRuntime.useAvailableRoot())),get:s.VestRuntime.persist(At),remove:s.Bus.usePrepareEmitter(p.REMOVE_FIELD),reset:s.Bus.usePrepareEmitter(p.RESET_SUITE),resetField:s.Bus.usePrepareEmitter(p.RESET_FIELD),resume:s.VestRuntime.persist(P),subscribe:t.subscribe},(e=s.VestRuntime.persist(At),{getError:(...t)=>e().getError(...t),getErrors:(...t)=>e().getErrors(...t),getErrorsByGroup:(...t)=>e().getErrorsByGroup(...t),getWarning:(...t)=>e().getWarning(...t),getWarnings:(...t)=>e().getWarnings(...t),getWarningsByGroup:(...t)=>e().getWarningsByGroup(...t),hasErrors:(...t)=>e().hasErrors(...t),hasErrorsByGroup:(...t)=>e().hasErrorsByGroup(...t),hasWarnings:(...t)=>e().hasWarnings(...t),hasWarningsByGroup:(...t)=>e().hasWarningsByGroup(...t),isPending:(...t)=>e().isPending(...t),isValid:(...t)=>e().isValid(...t),isValidByGroup:(...t)=>e().isValidByGroup(...t)})),zt()));var e}))}const $t=W.WARN_MUST_BE_CALLED_FROM_TEST;Object.defineProperty(t,"enforce",{enumerable:!0,get:function(){return e.enforce}}),t.create=Zt,t.each=function(t,e){n.invariant(n.isFunction(e),W.EACH_CALLBACK_MUST_BE_A_FUNCTION),function(t){s.Isolate.create(r,t,{allowReorder:!0})}((()=>{t.forEach(((t,n)=>{e(t,n)}))}))},t.group=jt,t.include=Kt,t.mode=function(t){const[,e]=S();e(t)},t.omitWhen=vt,t.only=Ut,t.optional=R,t.skip=yt,t.skipWhen=Ct,t.staticSuite=function(t){return n.assign(((...e)=>{const s=Zt(t),i=s(...e);return Object.freeze(n.assign({dump:s.dump},i))}),Object.assign({},zt()))},t.suiteSelectors=rt,t.test=Yt,t.warn=function(){const t=(e=W.HOOK_CALLED_OUTSIDE,T.useX(e).currentTest);var e;n.invariant(t,$t),x.warn(t)}}));
2
2
  //# sourceMappingURL=vest.production.js.map