vest 5.0.0-dev-781e21 → 5.0.0-dev-ec989a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +2 -57
- package/dist/cjs/classnames.development.js +37 -17
- package/dist/cjs/classnames.production.js +1 -1
- package/dist/cjs/enforce/compose.development.js +1 -54
- package/dist/cjs/enforce/compose.production.js +1 -1
- package/dist/cjs/enforce/compounds.development.js +18 -84
- package/dist/cjs/enforce/compounds.production.js +1 -1
- package/dist/cjs/enforce/schema.development.js +18 -84
- package/dist/cjs/enforce/schema.production.js +1 -1
- package/dist/cjs/parser.development.js +30 -11
- package/dist/cjs/parser.production.js +1 -1
- package/dist/cjs/promisify.development.js +21 -9
- package/dist/cjs/promisify.production.js +1 -1
- package/dist/cjs/vest.development.js +1324 -1294
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/classnames.development.js +39 -19
- package/dist/es/classnames.production.js +1 -1
- package/dist/es/enforce/compose.development.js +1 -58
- package/dist/es/enforce/compose.production.js +1 -1
- package/dist/es/enforce/compounds.development.js +2 -90
- package/dist/es/enforce/compounds.production.js +1 -1
- package/dist/es/enforce/schema.development.js +2 -88
- package/dist/es/enforce/schema.production.js +1 -1
- package/dist/es/parser.development.js +31 -10
- package/dist/es/parser.production.js +1 -1
- package/dist/es/promisify.development.js +22 -10
- package/dist/es/promisify.production.js +1 -1
- package/dist/es/vest.development.js +1321 -1286
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/classnames.development.js +40 -20
- package/dist/umd/classnames.production.js +1 -1
- package/dist/umd/enforce/compose.development.js +6 -60
- package/dist/umd/enforce/compose.production.js +1 -1
- package/dist/umd/enforce/compounds.development.js +29 -94
- package/dist/umd/enforce/compounds.production.js +1 -1
- package/dist/umd/enforce/schema.development.js +29 -94
- package/dist/umd/enforce/schema.production.js +1 -1
- package/dist/umd/parser.development.js +33 -14
- package/dist/umd/parser.production.js +1 -1
- package/dist/umd/promisify.development.js +24 -12
- package/dist/umd/promisify.production.js +1 -1
- package/dist/umd/vest.development.js +1327 -1298
- package/dist/umd/vest.production.js +1 -1
- package/package.json +144 -147
- package/testUtils/TVestMock.ts +7 -0
- package/testUtils/__tests__/partition.test.ts +4 -4
- package/testUtils/asVestTest.ts +9 -0
- package/testUtils/mockThrowError.ts +4 -2
- package/testUtils/suiteDummy.ts +4 -1
- package/testUtils/testDummy.ts +12 -10
- package/testUtils/testPromise.ts +3 -0
- package/types/classnames.d.ts +141 -12
- package/types/classnames.d.ts.map +1 -0
- package/types/enforce/compose.d.ts +2 -126
- package/types/enforce/compose.d.ts.map +1 -0
- package/types/enforce/compounds.d.ts +2 -136
- package/types/enforce/compounds.d.ts.map +1 -0
- package/types/enforce/schema.d.ts +2 -144
- package/types/enforce/schema.d.ts.map +1 -0
- package/types/parser.d.ts +147 -18
- package/types/parser.d.ts.map +1 -0
- package/types/promisify.d.ts +139 -43
- package/types/promisify.d.ts.map +1 -0
- package/types/vest.d.ts +257 -242
- package/types/vest.d.ts.map +1 -0
- package/CHANGELOG.md +0 -87
- package/testUtils/expandStateRef.ts +0 -8
- package/testUtils/runCreateRef.ts +0 -10
- package/testUtils/testObjects.ts +0 -6
- package/tsconfig.json +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createCascade as t}from"context";import{isUndefined as n,isStringValue as e,assign as r,cache as i,nestedArray as u,asArray as s,seq as o,optionalFunctionValue as a,isFunction as c,isNullish as f,deferThrow as l,invariant as d,bindNot as p,either as v,isArray as E,isEmpty as N,isNotEmpty as h,isPositive as m,numberEquals as g,hasOwnProperty as y,callEach as R,bus as S,defaultTo as C,isPromise as T,isNull as _}from"vest-utils";export{enforce}from"n4s";var O,I=O||(O={});I[I.DEFAULT=0]="DEFAULT",I[I.SUITE=1]="SUITE",I[I.EACH=2]="EACH",I[I.SKIP_WHEN=3]="SKIP_WHEN",I[I.OMIT_WHEN=4]="OMIT_WHEN",I[I.GROUP=5]="GROUP";var A,k=A||(A={});function b(){var t=0;return{current:function(){return t},next:function(){t++}}}function U(t,n){return void 0===n&&(n=[]),{cursor:b(),keys:{current:{},prev:{}},path:n,type:t}}k[k.ALL=0]="ALL",k[k.EAGER=1]="EAGER";var L=t((function(t,n){return n?null:r({exclusion:{tests:{},groups:{}},inclusion:{},isolate:U(O.DEFAULT),mode:[A.ALL]},t)}));function F(){return L.useX().stateRef}function D(t,n){(0,F().optionalFields()[1])((function(e){var i;return r(e,((i={})[t]=r({},e[t],n(e[t])),i))}))}function W(t){var n;return null!==(n=F().optionalFields()[0][t])&&void 0!==n?n:{}}function P(){G((function(t){return t}))}function G(t){(0,F().testObjects()[1])((function(n){return{prev:n.prev,current:s(t(n.current))}}))}function w(){return X().filter((function(t){return t.isPending()}))}var x=i();function X(){var t=F().testObjects()[0].current;return x([t],(function(){return u.flatten(t)}))}var H,K=H||(H={});K.Error="error",K.Warning="warning";var M=function(){function t(t,n,e){var r=void 0===e?{}:e;e=r.message;var i=r.groupName;r=r.key,this.key=null,this.id=o(),this.severity=H.Error,this.status=q,this.fieldName=t,this.testFn=n,i&&(this.groupName=i),e&&(this.message=e),r&&(this.key=r)}return t.prototype.run=function(){try{var t=this.testFn()}catch(r){t=r,n(this.message)&&e(t)&&(this.message=r),t=!1}return!1===t&&this.fail(),t},t.prototype.setStatus=function(t){this.isFinalStatus()&&t!==Q||(this.status=t)},t.prototype.warns=function(){return this.severity===H.Warning},t.prototype.setPending=function(){this.setStatus(J)},t.prototype.fail=function(){this.setStatus(this.warns()?j:V)},t.prototype.done=function(){this.isFinalStatus()||this.setStatus(Y)},t.prototype.warn=function(){this.severity=H.Warning},t.prototype.isFinalStatus=function(){return this.hasFailures()||this.isCanceled()||this.isPassing()},t.prototype.skip=function(t){this.isPending()&&!t||this.setStatus(B)},t.prototype.cancel=function(){this.setStatus(z),P()},t.prototype.reset=function(){this.status=q,P()},t.prototype.omit=function(){this.setStatus(Q)},t.prototype.valueOf=function(){return!this.isFailing()},t.prototype.isPending=function(){return this.statusEquals(J)},t.prototype.isOmitted=function(){return this.statusEquals(Q)},t.prototype.isUntested=function(){return this.statusEquals(q)},t.prototype.isFailing=function(){return this.statusEquals(V)},t.prototype.isCanceled=function(){return this.statusEquals(z)},t.prototype.isSkipped=function(){return this.statusEquals(B)},t.prototype.isPassing=function(){return this.statusEquals(Y)},t.prototype.isWarning=function(){return this.statusEquals(j)},t.prototype.hasFailures=function(){return this.isFailing()||this.isWarning()},t.prototype.isNonActionable=function(){return this.isSkipped()||this.isOmitted()||this.isCanceled()},t.prototype.isTested=function(){return this.hasFailures()||this.isPassing()},t.prototype.awaitsResolution=function(){return this.isSkipped()||this.isUntested()||this.isPending()},t.prototype.statusEquals=function(t){return this.status===t},t}(),q="UNTESTED",B="SKIPPED",V="FAILED",j="WARNING",Y="PASSING",J="PENDING",z="CANCELED",Q="OMITTED";function Z(t){function n(t,n,i){return r.references.push(),e(t,a(n,i)),function(){return[r.references[t],function(n){return e(t,a(n,r.references[t]))}]}}function e(n,e){var u=r.references[n];r.references[n]=e,n=i[n][1],c(n)&&n(e,u),c(t)&&t()}var r={references:[]},i=[];return{registerStateKey:function(t,e){var r=i.length;return i.push([t,e]),n(r,t)},reset:function(){var t=r.references;r.references=[],i.forEach((function(e,r){return n(r,e[0],t[r])}))}}}function $(t,n){var e=n.suiteId;return n=n.suiteName,{optionalFields:t.registerStateKey((function(){return{}})),suiteId:t.registerStateKey(e),suiteName:t.registerStateKey(n),testCallbacks:t.registerStateKey((function(){return{fieldCallbacks:{},doneCallbacks:[]}})),testObjects:t.registerStateKey((function(t){return{prev:t?t.current:[],current:[]}}))}}function tt(){return L.useX().isolate}function nt(){var t=tt();return t.path.concat(t.cursor.current())}function et(t,n){t=void 0===(t=t.type)?O.DEFAULT:t,d(c(n));var e=U(t,nt());return t=L.run({isolate:e},(function(){return e.keys.prev=function(){var t=F().testObjects()[0].prev;return s(u.getCurrent(t,nt())).reduce((function(t,n){return n instanceof M&&!f(n.key)?(t[n.key]=n,t):t}),{})}(),G((function(t){return u.setValueAtPath(t,e.path,[])})),n()})),tt().cursor.next(),t}var rt,it=rt||(rt={});it.WARNINGS="warnings",it.ERRORS="errors";var ut,st=ut||(ut={});function ot(t,n){return!(!n||t.fieldName!==n)}st.ERROR_COUNT="errorCount",st.WARN_COUNT="warnCount";var at=p((function(t,n){return t.groupName===n}));function ct(t,n){return X().some((function(e){return ft(e,t,n)}))}function ft(t,n,e){return!(!t.hasFailures()||e&&!ot(t,e)||v(n===rt.WARNINGS,t.warns()))}function lt(t){return!!t&&W(t).applied}var dt,pt=dt||(dt={});function vt(t){if(lt(t))return!0;var n=X();return!(N(n)||ct(rt.ERRORS,t)||function(t){return h(w().filter((function(n){return Et(n,t)})))}(t))&&function(t){return X().every((function(n){return Nt(n,t)}))}(t)}function Et(t,n){return!(n&&!ot(t,n))&<(n)}function Nt(t,n){return!(!n||ot(t,n))||(W(t.fieldName).type===dt.Delayed&&t.awaitsResolution()||t.isTested()||t.isOmitted())}function ht(){var t=X(),n=r({errorCount:0,warnCount:0,testCount:0},{groups:{},tests:{},valid:!1});return t.reduce((function(t,n){var e=t.tests;e[n.fieldName]=mt(e,n),e[n.fieldName].valid=!1!==e[n.fieldName].valid&&vt(n.fieldName);var r=t.groups,i=n.groupName;return i&&(r[i]=r[i]||{},r[i][n.fieldName]=mt(r[i],n),e=r[i][n.fieldName],!1===r[i][n.fieldName].valid?n=!1:n=!!lt(n=n.fieldName)||!function(t,n,e){return X().some((function(r){return!at(r,n)&&ft(r,t,e)}))}(rt.ERRORS,i,n)&&!function(t,n){return h(w().filter((function(e){return!at(e,t)&&Et(e,n)})))}(i,n)&&function(t,n){return X().every((function(e){return!!at(e,t)||Nt(e,n)}))}(i,n),e.valid=n),t}),n),n.valid=vt(),function(t){for(var n in t.tests)t.errorCount+=t.tests[n].errorCount,t.warnCount+=t.tests[n].warnCount,t.testCount+=t.tests[n].testCount;return t}(n)}function mt(t,n){function e(t){s[t===rt.ERRORS?ut.ERROR_COUNT:ut.WARN_COUNT]++,u&&(s[t]=(s[t]||[]).concat(u))}var i=n.fieldName,u=n.message;t[i]=t[i]||r({errorCount:0,warnCount:0,testCount:0},{errors:[],warnings:[]});var s=t[i];return n.isNonActionable()||(t[i].testCount++,n.isFailing()?e(rt.ERRORS):n.isWarning()&&e(rt.WARNINGS)),s}function gt(t,n,e){if(e){var r;t=(null===(r=null==t?void 0:t[e])||void 0===r?void 0:r[n])||[]}else{for(var i in r={},e=n===rt.ERRORS?ut.ERROR_COUNT:ut.WARN_COUNT,t)m(t[i][e])&&(r[i]=t[i][n]||[]);t=r}return t}function yt(t){return{getErrors:function(n){return gt(t.tests,rt.ERRORS,n)},getErrorsByGroup:function(n,e){return gt(t.groups[n],rt.ERRORS,e)},getWarnings:function(n){return gt(t.tests,rt.WARNINGS,n)},getWarningsByGroup:function(n,e){return gt(t.groups[n],rt.WARNINGS,e)},hasErrors:function(n){return Ct(t,ut.ERROR_COUNT,n)},hasErrorsByGroup:function(n,e){return St(t,ut.ERROR_COUNT,n,e)},hasWarnings:function(n){return Ct(t,ut.WARN_COUNT,n)},hasWarningsByGroup:function(n,e){return St(t,ut.WARN_COUNT,n,e)},isValid:function(n){var e;return n?!(null===(e=t.tests[n])||void 0===e||!e.valid):t.valid},isValidByGroup:function(n,e){if(!(n=t.groups[n]))return!1;if(e)return Rt(n,e);for(var r in n)if(!Rt(n,r))return!1;return!0}}}function Rt(t,n){var e;return!(null===(e=t[n])||void 0===e||!e.valid)}function St(t,n,e,r){var i,u;if(!(t=t.groups[e]))return!1;if(r)return m(null===(i=t[r])||void 0===i?void 0:i[n]);for(var s in t)if(m(null===(u=t[s])||void 0===u?void 0:u[n]))return!0;return!1}function Ct(t,n,e){var r;return t=e?null===(r=t.tests[e])||void 0===r?void 0:r[n]:t[n]||0,m(t)}pt[pt.Immediate=0]="Immediate",pt[pt.Delayed=1]="Delayed";var Tt=i(1);function _t(){var t=X(),n={stateRef:F()};return Tt([t],L.bind(n,(function(){var t=ht(),n=F().suiteName()[0];return r(t,yt(t),{suiteName:n})})))}function Ot(t){var n=w();return!N(n)&&(!t||n.some((function(n){return ot(n,t)})))}var It=i(20);function At(){var t=X(),n={stateRef:F()};return It([t],L.bind(n,(function(){return r({},_t(),{done:L.bind(n,Ut)})})))}function kt(t,n,e){var r;return!!(!c(t)||n&&g(null===(r=e.tests[n])||void 0===r?void 0:r.testCount,0))}function bt(t){return!(Ot()&&(!t||Ot(t)))}function Ut(){function t(){return r(_t())}for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var r=(n=n.reverse())[0];return n=n[1],e=At(),kt(r,n,e)?e:bt(n)?(t(),e):(Lt(t,n),e)}function Lt(t,n){(0,F().testCallbacks()[1])((function(e){return n?e.fieldCallbacks[n]=(e.fieldCallbacks[n]||[]).concat(t):e.doneCallbacks.push(t),e}))}function Ft(){var t=S.createBus();return t.on(Wt.TEST_COMPLETED,(function(n){if(!n.isCanceled()){n.done(),n=n.fieldName;var e=F().testCallbacks()[0].fieldCallbacks;n&&!Ot(n)&&E(e[n])&&R(e[n]),Ot()||t.emit(Wt.ALL_RUNNING_TESTS_FINISHED)}})),t.on(Wt.SUITE_CALLBACK_DONE_RUNNING,(function(){!function(){function t(t){e[t.fieldName]&&(t.omit(),D(t.fieldName,(function(){return{applied:!0}})))}var n=F().optionalFields()[0];if(!N(n)){var e={};X().forEach((function(n){if(y(e,n.fieldName))t(n);else{var r=W(n.fieldName);r.type===dt.Immediate&&(e[n.fieldName]=a(r.rule),t(n))}})),P()}}()})),t.on(Wt.ALL_RUNNING_TESTS_FINISHED,(function(){var t=F().testCallbacks()[0].doneCallbacks;R(t)})),t.on(Wt.REMOVE_FIELD,(function(t){X().forEach((function(n){ot(n,t)&&(n.cancel(),function(t){G((function(n){return u.transform(n,(function(n){return t!==n?n:null}))}))}(n))}))})),t.on(Wt.RESET_FIELD,(function(t){X().forEach((function(n){ot(n,t)&&n.reset()}))})),t}function Dt(){var t=L.useX();return d(t.bus),t.bus}var Wt,Pt=Wt||(Wt={});function Gt(t){return xt(0,"tests",t)}function wt(t){return xt(1,"tests",t)}function xt(t,n,r){var i=L.useX("hook called outside of a running suite.");r&&s(r).forEach((function(r){e(r)&&(i.exclusion[n][r]=0===t)}))}function Xt(t){for(var n in t)if(!0===t[n])return!0;return!1}function Ht(){var t,n=L.useX().exclusion;for(t in n.groups)if(n.groups[t])return!0;return!1}function Kt(t){return"Wrong arguments passed to group. Group ".concat(t,".")}function Mt(t,n,e){if(e||2===arguments.length)for(var r,i=0,u=n.length;i<u;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return t.concat(r||Array.prototype.slice.call(n))}function qt(t){var n=t.asyncTest,r=t.message;if(T(n)){var i=Dt().emit,u=F(),s=L.bind({stateRef:u},(function(){P(),i(Wt.TEST_COMPLETED,t)}));u=L.bind({stateRef:u},(function(n){t.isCanceled()||(t.message=e(n)?n:r,t.fail(),s())}));try{n.then(s,u)}catch(t){u()}}}function Bt(t){var n=F().testObjects()[0].prev;if(N(n))return Vt(t),t;var e=nt();if(n=u.valueAtPath(n,e),!f(t.key)){n=t.key,(e=tt().keys.prev[n])&&(t=e),e=t;var r=tt().keys.current;return f(r[n])?r[n]=e:l('Encountered the same test key "'.concat(n,"\" twice. This may lead to tests overriding each other's results, or to tests being unexpectedly omitted.")),Vt(t),t}return!h(e=n)||e.fieldName===t.fieldName&&e.groupName===t.groupName||(tt().type===O.EACH||l("Vest Critical Error: Tests called in different order than previous run.\n expected: ".concat(n.fieldName,"\n received: ").concat(t.fieldName,'\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.')),function(){var t=tt().cursor.current();G((function(n){return n.splice(t),n}))}(),n=null),Vt(t=C(n,t)),t}function Vt(t){var n=nt();G((function(e){return u.setValueAtPath(e,n,t)}))}function jt(t){var n=tt().cursor,e=A.EAGER;if(L.useX().mode[0]===e&&ct(rt.ERRORS,t.fieldName))return t.skip(),Bt(t),n.next(),t;if(e=Bt(t),L.useX().omitted||lt(t.fieldName))return e.omit(),n.next(),e;if(function(t){var n=t.fieldName;if(t=t.groupName,L.useX().skipped)return!0;var e=L.useX(),r=e.exclusion;e=e.inclusion;var i=r.tests,u=i[n];if(!1===u)return!0;if(u=!0===u,t){var s=L.useX().exclusion.groups;if(s=y(s,t)?!1===s[t]:Ht())return!0;if(!0===r.groups[t])return!(u||!Xt(i)&&!1!==i[n])}return!!(t=!!Ht()&&!t)||!u&&!!Xt(i)&&!a(e[n])}(t))return e.skip(!!L.useX().skipped),n.next(),e;if(t!==e&&e.fieldName===t.fieldName&&e.groupName===t.groupName&&e.isPending()&&e.cancel(),Vt(t),t.isUntested()){e=Dt();var r=function(t){return L.run({currentTest:t},(function(){return t.run()}))}(t);try{T(r)?(t.asyncTest=r,t.setPending(),qt(t)):e.emit(Wt.TEST_COMPLETED,t)}catch(n){throw Error("Unexpected error encountered during test registration.\n Test Object: ".concat(JSON.stringify(t),".\n Error: ").concat(n,"."))}}else T(t.asyncTest)&&(t.setPending(),qt(t));return n.next(),t}function Yt(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=c(n[1])?n:Mt([void 0],n,!0);n=i[0],r=i[1],i=i[2],d(e(t),Zt("fieldName","string")),d(c(r),Zt("Test callback","function"));var u=L.useX();return jt(n=new M(t,r,{message:n,groupName:u.groupName,key:i}))}Pt.TEST_COMPLETED="test_completed",Pt.ALL_RUNNING_TESTS_FINISHED="all_running_tests_finished",Pt.REMOVE_FIELD="remove_field",Pt.RESET_FIELD="reset_field",Pt.SUITE_CALLBACK_DONE_RUNNING="suite_callback_done_running",Gt.group=function(t){return xt(0,"groups",t)},wt.group=function(t){return xt(1,"groups",t)};var Jt,zt,Qt=r(Yt,{memo:(Jt=Yt,zt=i(10),function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];e=tt().cursor.current();var r=(n=n.reverse())[0],i=n[1],u=n[2];return e=[F().suiteId()[0],t,e].concat(r),n=zt.get(e),_(n)?zt(e,(function(){return Jt(t,u,i)})):n[1].isCanceled()?(zt.invalidate(e),zt(e,(function(){return Jt(t,u,i)}))):jt(n[1])})});function Zt(t,n){return"Incompatible params passed to test function. ".concat(t," must be a ").concat(n)}var $t="5.0.0-dev-781e21";function tn(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=(t=t.reverse())[0];t=t[1],d(c(e),"vest.create: Expected callback to be a function.");var i=Ft(),u=Z();return t={stateRef:$(u,{suiteId:o(),suiteName:t}),bus:i},r(L.bind(t,(function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return u.reset(),et({type:O.SUITE},(function(){e.apply(void 0,t)})),i.emit(Wt.SUITE_CALLBACK_DONE_RUNNING),At()})),{get:L.bind(t,_t),remove:L.bind(t,(function(t){i.emit(Wt.REMOVE_FIELD,t)})),reset:u.reset,resetField:L.bind(t,(function(t){i.emit(Wt.RESET_FIELD,t)}))})}function nn(t,n){d(c(n),"each callback must be a function"),et({type:O.EACH},(function(){t.forEach((function(t,e){n(t,e)}))}))}function en(){var t=A.EAGER;L.useX().mode[0]=t}function rn(t,n){d(e(t),Kt("name must be a string")),d(c(n),Kt("callback must be a function")),et({type:O.GROUP},(function(){L.run({groupName:t},n)}))}function un(t){var n=L.useX(),r=n.inclusion;return n=n.exclusion,d(e(t)),r[t]=C(n.tests[t],!0),{when:function(n){var r=L.useX(),i=r.exclusion;r.inclusion[t]=function(){return y(i.tests,t)?C(i.tests[t],!0):e(n)?!!i.tests[n]:a(n,a(_t))}}}}function sn(t,n){et({type:O.OMIT_WHEN},(function(){L.run({omitted:!!L.useX().omitted||a(t,a(_t))},(function(){return n()}))}))}function on(t){if(E(t)||e(t))s(t).forEach((function(t){D(t,(function(){return{type:dt.Delayed,applied:!1,rule:null}}))}));else{var n,r=function(n){var e=t[n];D(n,(function(){return{type:dt.Immediate,rule:e,applied:a(e)}}))};for(n in t)r(n)}}function an(t,n){et({type:O.SKIP_WHEN},(function(){L.run({skipped:!!L.useX().skipped||a(t,a(_t))},(function(){return n()}))}))}function cn(){var t=L.useX("warn hook called outside of a running suite.");d(t.currentTest,"warn called outside of a test."),t.currentTest.warn()}export{$t as VERSION,L as context,tn as create,nn as each,en as eager,rn as group,un as include,sn as omitWhen,Gt as only,on as optional,wt as skip,an as skipWhen,yt as suiteSelectors,Qt as test,cn as warn};
|
|
1
|
+
export{enforce}from"n4s";import{VestRuntime as t,Isolate as e,Reconciler as n,Walker as s}from"vest-runtime";import{isArray as r,isStringValue as i,asArray as u,cache as o,tinyState as a,seq as c,bindNot as E,defaultTo as l,assign as f,isPositive as N,optionalFunctionValue as T,hasOwnProperty as d,isNullish as S,deferThrow as R,text as I,StateMachine as _,isUndefined as p,isPromise as m,invariant as g,either as h,isEmpty as O,callEach as A,isNull as D,isFunction as C,numberEquals as v}from"vest-utils";import{createCascade as U}from"context";var L,P;function F(e){const n=t.useAvailableRoot();if(r(e)||i(e))u(e).forEach((t=>{n.setOptionalField(t,(()=>({type:L.AUTO,applied:!1,rule:null})))}));else for(const t in e){const s=e[t];n.setOptionalField(t,(()=>({type:L.CUSTOM_LOGIC,rule:s,applied:!0===s})))}}function G(e){var n,s,r;return!!e&&(null!==(r=null===(s=null===(n=t.useAvailableRoot())||void 0===n?void 0:n.getOptionalField(e))||void 0===s?void 0:s.applied)&&void 0!==r&&r)}!function(t){t[t.CUSTOM_LOGIC=0]="CUSTOM_LOGIC",t[t.AUTO=1]="AUTO"}(L||(L={})),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={}));class y extends e{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 W=o();function b(){return t.useXAppData()}function M(){return b().doneCallbacks()}function w(){return b().fieldCallbacks()}function B(){return b().suiteId}function k(){const[,,t]=M(),[,,e]=w();t(),e()}var K,j,X,V,x,H;function q(t){return t===K.ERRORS?j.ERROR_COUNT:j.WARN_COUNT}function z(t,e){return!!e&&!J(t,e)}function J(t,e){return!(!e||t.fieldName!==e)}function Y(t,e){return J(t,e.fieldName)&&t.groupName===e.groupName&&t.key===e.key}!function(t){t.WARNINGS="warnings",t.ERRORS="errors"}(K||(K={})),function(t){t.ERROR_COUNT="errorCount",t.WARN_COUNT="warnCount"}(j||(j={})),function(t){t.Error="error",t.Warning="warning"}(X||(X={})),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}."}(V||(V={}));class Q{constructor(){this.errorCount=0,this.warnCount=0,this.testCount=0}}class Z extends Q{constructor(){super(...arguments),this[x]=[],this[H]=[],this.groups={},this.tests={},this.valid=!1}}x=K.ERRORS,H=K.WARNINGS;class ${constructor(t,e,n){this.fieldName=t,this.message=e,this.groupName=n}static fromTestObject(t){return new $(t.fieldName,t.message,t.groupName)}toString(){return this.message||""}}const tt=E((function(t,e){return t.groupName===e}));function et(t){return!!G(t)||!Ft.hasNoTests()&&(!Gt(t)&&(!function(t){return Ft.someIncompleteTests((e=>!z(e,t)&&!G(t)))}(t)&&function(t){return Ft.everyTest((e=>st(e,t)))}(t)))}function nt(t,e){return!!G(e)||!function(t,e,n){return Ft.someTests((s=>!tt(s,e)&&yt(s,t,n)))}(K.ERRORS,t,e)&&(!function(t,e){return Ft.someIncompleteTests((n=>!tt(n,t)&&(!z(n,e)&&!G(e))))}(t,e)&&function(t,e){return Ft.everyTest((n=>!!tt(n,t)||st(n,e)))}(t,e))}function st(e,n){return!!z(e,n)||(e.isOmitted()||e.isTested()||function(e){var n;return(null===(n=t.useAvailableRoot())||void 0===n?void 0:n.getOptionalField(e.fieldName).type)===L.AUTO&&e.awaitsResolution()}(e))}function rt(){const t=new Z;return Ft.walkTests((e=>{t.tests=function(t,e){const{fieldName:n}=e,s=Object.assign({},t);return s[n]=ut(s[n],e),s[n].valid=!1!==s[n].valid&&et(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]=ut(r[n][s],e),r[n][s].valid=!1!==r[n][s].valid&&nt(n,s),r}(t.groups,e),t.errors=it(K.ERRORS,t.errors,e),t.warnings=it(K.WARNINGS,t.warnings,e)})),t.valid=et(),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 it(t,e,n){if(n.isOmitted())return e;return(t===K.WARNINGS?n.isWarning():n.isFailing())?e.concat($.fromTestObject(n)):e}function ut(t,e){const{message:n}=e,s=l(t?Object.assign({},t):null,ot);return e.isNonActionable()||(s.testCount++,e.isFailing()?r(K.ERRORS):e.isWarning()&&r(K.WARNINGS)),s;function r(t){const e=q(t);s[e]++,n&&(s[t]=(s[t]||[]).concat(n))}}function ot(){return f(new Q,{errors:[],warnings:[],valid:!0})}function at(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=q(e);for(const r in t)N(t[r][s])&&(n[r]=t[r][e]||[]);return n}(t,e)}function ct(t){const e={getError:function(e){return dt(K.ERRORS,t,e)},getErrors:function(e){return Et(t,K.ERRORS,e)},getErrorsByGroup:function(e,n){return lt(t,K.ERRORS,e,n)},getWarning:function(e){return dt(K.WARNINGS,t,e)},getWarnings:function(e){return Et(t,K.WARNINGS,e)},getWarningsByGroup:function(e,n){return lt(t,K.WARNINGS,e,n)},hasErrors:function(e){return Tt(t,j.ERROR_COUNT,e)},hasErrorsByGroup:function(e,n){return Nt(t,j.ERROR_COUNT,e,n)},hasWarnings:function(e){return Tt(t,j.WARN_COUNT,e)},hasWarningsByGroup:function(e,n){return Nt(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 ft(s,n);for(const t in s)if(!ft(s,t))return!1;return!0}};return e}function Et(t,e,n){return at(t.tests,e,n)}function lt(t,e,n,s){return at(t.groups[n],e,s)}function ft(t,e){var n;return!!(null===(n=t[e])||void 0===n?void 0:n.valid)}function Nt(t,e,n,s){var r,i;const u=t.groups[n];if(!u)return!1;if(s)return N(null===(r=u[s])||void 0===r?void 0:r[e]);for(const t in u)if(N(null===(i=u[t])||void 0===i?void 0:i[e]))return!0;return!1}function Tt(t,e,n){var s;const r=n?null===(s=t.tests[n])||void 0===s?void 0:s[e]:t[e]||0;return N(r)}function dt(t,e,n){var s;const r=e[t];return n?null===(s=r.find((t=>J(t,n))))||void 0===s?void 0:s.message:r[0]}function St(){return t=()=>{const t=rt(),e=b().suiteName;return Object.freeze(f(t,ct(t),{suiteName:e}))},(0,b().suiteResultCache)([B()],t);var t}function Rt(t,n){e.create((()=>{wt.run({skipped:It()||T(t,T(St))},n)}))}function It(){return function(){var t;return null!==(t=wt.useX().skipped)&&void 0!==t&&t}()}function _t(t){return gt(0,"tests",t)}function pt(t){return gt(1,"tests",t)}function mt(t){const{fieldName:e,groupName:n}=t;if(It())return!0;const s=Bt(),r=kt(),i=s.tests,u=i[e];if(!1===u)return!0;const o=!0===u;if(n){if(function(t){const e=Bt().groups;if(d(e,t))return!1===e[t];return Ot()}(n))return!0;if(!0===s.groups[n])return!o&&(!!ht(i)||!1===i[e])}return!!function(t){if(!Ot())return!1;return!t}(n)||!o&&(!!ht(i)&&!T(r[e]))}function gt(t,e,n){const s=Bt(V.HOOK_CALLED_OUTSIDE);n&&u(n).forEach((n=>{i(n)&&(s[e][n]=0===t)}))}function ht(t){for(const e in t)if(!0===t[e])return!0;return!1}function Ot(){const t=Bt();for(const e in t.groups)if(t.groups[e])return!0;return!1}function At(t,n){e.create((()=>{wt.run({omitted:Dt()||T(t,T(St))},n)}))}function Dt(){return function(){var t;return null!==(t=wt.useX().omitted)&&void 0!==t&&t}()}function Ct(t,e=t){return function(t){if(Mt(Wt.ONE))return Gt();if(Mt(Wt.EAGER))return Gt(t.fieldName);return!1}(t)?((n=t).skip(),n):function(t){return Dt()||G(t.fieldName)}(t)?function(t){return t.omit(),t}(t):mt(t)?function(t){return t.skip(It()),t}(e):t;var n}var vt,Ut;_t.group=function(t){return gt(0,"groups",t)},pt.group=function(t){return gt(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"}(vt||(vt={})),function(t){t.RESET="RESET"}(Ut||(Ut={}));const Lt={initial:vt.UNTESTED,states:{"*":{[vt.OMITTED]:vt.OMITTED,[Ut.RESET]:vt.UNTESTED},[vt.UNTESTED]:{[vt.CANCELED]:vt.CANCELED,[vt.FAILED]:vt.FAILED,[vt.PASSING]:vt.PASSING,[vt.PENDING]:vt.PENDING,[vt.SKIPPED]:vt.SKIPPED,[vt.WARNING]:vt.WARNING},[vt.PENDING]:{[vt.CANCELED]:vt.CANCELED,[vt.FAILED]:vt.FAILED,[vt.PASSING]:vt.PASSING,[vt.SKIPPED]:[vt.SKIPPED,t=>!0===t],[vt.WARNING]:vt.WARNING},[vt.SKIPPED]:{},[vt.FAILED]:{},[vt.WARNING]:{},[vt.PASSING]:{},[vt.CANCELED]:{},[vt.OMITTED]:{}}};class Pt extends e{constructor({fieldName:t,testFn:e,message:n,groupName:s,key:r=null}){super(),this.children=null,this.id=c(),this.severity=X.Error,this.stateMachine=_(Lt),this.fieldName=t,this.testFn=e,s&&(this.groupName=s),n&&(this.message=n),this.setKey(r)}static create(t,e){return Pt.cast(super.create(t,e))}static cast(t){return Pt.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 p(t)&&i(e)})(this.message,e)&&(this.message=e),t=!1}return!1===t&&this.fail(),t}warns(){return this.severity===X.Warning}isPending(){return this.statusEquals(vt.PENDING)}isOmitted(){return this.statusEquals(vt.OMITTED)}isUntested(){return this.statusEquals(vt.UNTESTED)}isFailing(){return this.statusEquals(vt.FAILED)}isCanceled(){return this.statusEquals(vt.CANCELED)}isSkipped(){return this.statusEquals(vt.SKIPPED)}isPassing(){return this.statusEquals(vt.PASSING)}isWarning(){return this.statusEquals(vt.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(vt.PENDING)}fail(){this.setStatus(this.warns()?vt.WARNING:vt.FAILED)}pass(){this.setStatus(vt.PASSING)}warn(){this.severity=X.Warning}skip(t){this.setStatus(vt.SKIPPED,t)}cancel(){this.setStatus(vt.CANCELED)}reset(){this.stateMachine.transition(Ut.RESET)}omit(){this.setStatus(vt.OMITTED)}valueOf(){return!this.isFailing()}isAsyncTest(){return m(this.asyncTest)}static is(t){return t instanceof Pt}static isX(t){g(this.is(t))}}Pt.reconciler=function(t,e){if(!Pt.is(t))return t;if(S(e))return function(t){if(t.usesKey())return Pt.cast(n.handleIsolateNodeWithKey(t));return t}(t);if(!Pt.is(e))return t;const s=function(t,e){const s=function(t,e){if(t.usesKey())return Pt.cast(n.handleIsolateNodeWithKey(t));if(function(t,e){return!!Pt.is(e)&&!Y(e,t)}(t,e))return function(t,e){return function(t,e){if(t.shouldAllowReorder())return;R(I(V.TESTS_CALLED_IN_DIFFERENT_ORDER,{fieldName:t.fieldName,prevName:Pt.is(e)?e.fieldName:void 0}))}(t,e),n.removeAllNextNodesInIsolate(),t}(t,e);if(!Pt.is(e))return t;if(e.isOmitted())return t;return e}(e,t);return Ct(e,s)}(e,t);return function(t,e,n){t===e&&Pt.is(e)&&(r=e)!==(s=n)&&Y(s,r)&&s.isPending()&&s.cancel();var s,r}(s,t,e),s};class Ft{static defaultRoot(){return t.useAvailableRoot()}static hasNoTests(t=Ft.defaultRoot()){return!t||!s.has(t,Pt.is)}static someIncompleteTests(t,e=Ft.defaultRoot()){return!!e&&s.some(e,(e=>(Pt.isX(e),e.isPending()&&t(e))),Pt.is)}static someTests(t,e=Ft.defaultRoot()){return!!e&&s.some(e,(e=>(Pt.isX(e),t(e))),Pt.is)}static everyTest(t,e=Ft.defaultRoot()){return!!e&&s.every(e,(e=>(Pt.isX(e),t(e))),Pt.is)}static walkTests(t,e=Ft.defaultRoot()){e&&s.walk(e,((e,n)=>{t(Pt.cast(e),n)}),Pt.is)}static hasRemainingTests(t){return Ft.someIncompleteTests((e=>!t||J(e,t)))}static pluckTests(t,e=Ft.defaultRoot()){e&&s.pluck(e,(e=>(Pt.isX(e),t(e))),Pt.is)}static resetField(t){Ft.walkTests((e=>{J(e,t)&&e.reset()}),Ft.defaultRoot())}static removeTestByFieldName(t,e=Ft.defaultRoot()){Ft.pluckTests((e=>J(e,t)),e)}}function Gt(t){return function(t,e){return Ft.someTests((n=>yt(n,t,e)))}(K.ERRORS,t)}function yt(t,e,n){return!!t.hasFailures()&&(!z(t,n)&&!function(t,e){return h(t===K.WARNINGS,e.warns())}(e,t))}var Wt;function bt(t){const[,e]=Kt();e(t)}function Mt(t){const[e]=Kt();return e===t}!function(t){t.EAGER="EAGER",t.ALL="ALL",t.ONE="ONE"}(Wt||(Wt={}));const wt=U(((t,e)=>e?null:f({exclusion:{tests:{},groups:{}},inclusion:{},mode:a.createTinyState(Wt.EAGER),testMemoCache:jt},t)));function Bt(t){return wt.useX(t).exclusion}function kt(){return wt.useX().inclusion}function Kt(){return wt.useX().mode()}const jt=o(10);function Xt(){const e=t.useAvailableRoot(),n=t.useEmit(),s=null==e?void 0:e.getOptionalFields();if(O(s))return;const r=new Set;function i(t){r.has(t.fieldName)&&(t.omit(),null==e||e.setOptionalField(t.fieldName,(t=>Object.assign(Object.assign({},t),{applied:!0}))))}Ft.walkTests((t=>{t.isPending()||(d(r,t.fieldName)?i(t):function(t){const n=null==e?void 0:e.getOptionalField(t.fieldName);if(S(n))return;!0===T(n.rule)&&r.add(t.fieldName);i(t)}(t))})),n(P.DONE_TEST_OMISSION_PASS)}function Vt(){const e=t.useBus();return n(P.TEST_COMPLETED,(t=>{t.isCanceled()||(!function(t){const[e]=w();t&&!Ft.hasRemainingTests(t)&&r(e[t])&&A(e[t])}(t.fieldName),Ft.hasRemainingTests()||e.emit(P.ALL_RUNNING_TESTS_FINISHED))})),n(P.TEST_RUN_STARTED,(()=>{})),n(P.DONE_TEST_OMISSION_PASS,(()=>{})),n(P.ALL_RUNNING_TESTS_FINISHED,(()=>{Ft.someTests((t=>t.isAsyncTest()))&&Xt(),function(){const[t]=M();A(t)}()})),n(P.RESET_FIELD,(t=>{Ft.resetField(t)})),n(P.SUITE_RUN_STARTED,(()=>{k()})),n(P.SUITE_CALLBACK_RUN_FINISHED,(()=>{Xt()})),n(P.REMOVE_FIELD,(t=>{Ft.removeTestByFieldName(t)})),n(P.RESET_SUITE,(()=>{k(),t.reset()})),e;function n(t,n){e.on(t,((...t)=>{b().suiteResultCache.invalidate([B()]),n(...t)}))}}function xt(t){const e=kt(),n=Bt();return g(i(t)),e[t]=l(n.tests[t],!0),{when:function(e){const n=kt(),s=Bt();n[t]=()=>d(s.tests,t)?l(s.tests[t],!0):i(e)?Boolean(s.tests[e]):T(e,T(St))}}}function Ht(e){if(Ct(e),e.isUntested())return function(e){const n=t.useBus(),s=function(t){return wt.run({currentTest:t},(()=>t.run()))}(e);try{m(s)?(e.asyncTest=s,function(e){const{asyncTest:n,message:s}=e;if(!m(n))return;e.setPending();const r=t.useBus(),u=t.persist((()=>{qt(r,e)})),o=t.persist((t=>{e.isCanceled()||(e.message=i(t)?t:s,e.fail(),u())}));n.then(u,o)}(e)):qt(n,e)}catch(t){throw new Error(I(V.UNEXPECTED_TEST_REGISTRATION_ERROR,{testObject:JSON.stringify(e),error:t}))}}(e);e.isNonActionable()||R(I(V.UNEXPECTED_TEST_REGISTRATION_ERROR,{testObject:JSON.stringify(e)}))}function qt(t,e){e.pass(),t.emit(P.TEST_COMPLETED,e)}function zt(e,...n){const[s,r,u]=C(n[1])?n:[void 0,...n];!function(t,e){const n="test";g(i(t),I(V.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:n,param:"fieldName",expected:"string"})),g(C(e),I(V.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:n,param:"callback",expected:"function"}))}(e,r);const o={fieldName:e,groupName:wt.useX().groupName,key:u,message:s,testFn:r};return t.useEmit()(P.TEST_RUN_STARTED),Pt.create(Ht,o)}const Jt=f(zt,{memo:function(e){return function(n,...s){const[r,i,u]=s.reverse();return function(t,e){const n=wt.useX().testMemoCache,s=n.get(t);if(D(s))return n(t,e);const[,r]=s;if(r.isCanceled())return n.invalidate(t),n(t,e);return Pt.setNode(r),r}([B(),n,t.useCurrentCursor()].concat(r),(function(){return e(n,u,i)}))}}(zt)});function Yt(){return{group:ne,include:xt,omitWhen:At,only:_t,optional:F,skip:pt,skipWhen:Rt,test:Jt}}function Qt(){return Object.freeze(f({done:t.persist(Zt)},St()))}function Zt(...t){const[e,n]=t.reverse(),s=Qt();if(function(t,e,n){var s;return!!(!C(t)||e&&v(null===(s=n.tests[e])||void 0===s?void 0:s.testCount,0))}(e,n,s))return s;const r=()=>e(St());return Ft.hasRemainingTests(n)?(function(t,e){const[,n]=w(),[,s]=M();e?n((n=>f(n,{[e]:(n[e]||[]).concat(t)}))):s((e=>e.concat(t)))}(r,n),s):(r(),s)}function $t(...e){const[n,s]=e.reverse();!function(t){g(C(t),V.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION)}(n);const r=function({suiteName:e}={}){const n={doneCallbacks:a.createTinyState((()=>[])),fieldCallbacks:a.createTinyState((()=>({}))),suiteId:c(),suiteName:e,suiteResultCache:W};return t.createRef(n)}({suiteName:s});function i(...e){return wt.run({},(()=>(t.useEmit()(P.SUITE_RUN_STARTED),y.create(function(e,...n){const s=t.useEmit();return()=>(e(...n),s(P.SUITE_CALLBACK_RUN_FINISHED),Qt())}(n,...e))))).output}return t.Run(r,(()=>{return Vt(),f(t.persist(i),Object.assign(Object.assign({get:t.persist(St),remove:t.usePrepareEmitter(P.REMOVE_FIELD),reset:t.usePrepareEmitter(P.RESET_SUITE),resetField:t.usePrepareEmitter(P.RESET_FIELD)},(e=t.persist(St),{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),isValid:(...t)=>e().isValid(...t),isValidByGroup:(...t)=>e().isValidByGroup(...t)})),Yt()));var e}))}class te extends e{constructor(){super(...arguments),this.allowReorder=!0}}function ee(t,e){g(C(e),V.EACH_CALLBACK_MUST_BE_A_FUNCTION),te.create((()=>{t.forEach(((t,n)=>{e(t,n)}))}))}function ne(t,n){return e.create((()=>{wt.run({groupName:t},n)}))}function se(t){return f(((...e)=>$t(t)(...e)),Object.assign({},Yt()))}const re=V.WARN_MUST_BE_CALLED_FROM_TEST;function ie(){const t=(e=V.HOOK_CALLED_OUTSIDE,wt.useX(e).currentTest);var e;g(t,re),t.warn()}export{Wt as Modes,$t as create,ee as each,ne as group,xt as include,bt as mode,At as omitWhen,_t as only,F as optional,pt as skip,Rt as skipWhen,se as staticSuite,ct as suiteSelectors,Jt as test,ie as warn};
|
|
@@ -1,33 +1,54 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('vest-utils'), require('vest')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['vest-utils', 'vest'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.classnames = factory(global[
|
|
5
|
-
}(this, (function (vestUtils, vest) { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.classnames = factory(global["vest-utils"], global.vest));
|
|
5
|
+
})(this, (function (vestUtils, vest) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
var ErrorStrings;
|
|
8
|
+
(function (ErrorStrings) {
|
|
9
|
+
ErrorStrings["HOOK_CALLED_OUTSIDE"] = "hook called outside of a running suite.";
|
|
10
|
+
ErrorStrings["EXPECTED_VEST_TEST"] = "Expected value to be an instance of IsolateTest";
|
|
11
|
+
ErrorStrings["FIELD_NAME_REQUIRED"] = "Field name must be passed";
|
|
12
|
+
ErrorStrings["SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION"] = "Suite must be initialized with a function";
|
|
13
|
+
ErrorStrings["PROMISIFY_REQUIRE_FUNCTION"] = "Vest.Promisify must be called with a function";
|
|
14
|
+
ErrorStrings["PARSER_EXPECT_RESULT_OBJECT"] = "Vest parser: expected argument at position 0 to be Vest's result object.";
|
|
15
|
+
ErrorStrings["WARN_MUST_BE_CALLED_FROM_TEST"] = "Warn must be called from within the body of a test function";
|
|
16
|
+
ErrorStrings["EACH_CALLBACK_MUST_BE_A_FUNCTION"] = "Each must be called with a function";
|
|
17
|
+
ErrorStrings["INVALID_PARAM_PASSED_TO_FUNCTION"] = "Incompatible params passed to {fn_name} function. \"{param}\" must be of type {expected}";
|
|
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.";
|
|
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}.";
|
|
21
|
+
})(ErrorStrings || (ErrorStrings = {}));
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
24
|
+
// @ts-ignore - Need to understand why Vest is not being recognized
|
|
8
25
|
function parse(summary) {
|
|
9
|
-
vestUtils.invariant(summary && vestUtils.hasOwnProperty(summary, 'valid'),
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
26
|
+
vestUtils.invariant(summary && vestUtils.hasOwnProperty(summary, 'valid'), ErrorStrings.PARSER_EXPECT_RESULT_OBJECT);
|
|
27
|
+
const sel = vest.suiteSelectors(summary);
|
|
28
|
+
const testedStorage = {};
|
|
29
|
+
const selectors = {
|
|
13
30
|
invalid: sel.hasErrors,
|
|
14
31
|
tested: isTested,
|
|
15
32
|
untested: isUntested,
|
|
16
33
|
valid: sel.isValid,
|
|
17
|
-
warning: sel.hasWarnings
|
|
34
|
+
warning: sel.hasWarnings,
|
|
18
35
|
};
|
|
19
36
|
return selectors;
|
|
20
37
|
// Booleans
|
|
21
38
|
function isTested(fieldName) {
|
|
22
|
-
if (
|
|
39
|
+
if (vestUtils.isNullish(fieldName)) {
|
|
23
40
|
return vestUtils.isPositive(summary.testCount);
|
|
24
41
|
}
|
|
25
|
-
if (vestUtils.hasOwnProperty(testedStorage, fieldName))
|
|
42
|
+
if (vestUtils.hasOwnProperty(testedStorage, fieldName)) {
|
|
26
43
|
return testedStorage[fieldName];
|
|
44
|
+
}
|
|
45
|
+
addFieldToTestedStorage(fieldName);
|
|
46
|
+
return selectors.tested(fieldName);
|
|
47
|
+
}
|
|
48
|
+
function addFieldToTestedStorage(fieldName) {
|
|
27
49
|
testedStorage[fieldName] =
|
|
28
50
|
vestUtils.hasOwnProperty(summary.tests, fieldName) &&
|
|
29
51
|
vestUtils.isPositive(summary.tests[fieldName].testCount);
|
|
30
|
-
return selectors.tested(fieldName);
|
|
31
52
|
}
|
|
32
53
|
function isUntested(fieldName) {
|
|
33
54
|
return !(vestUtils.isPositive(summary.testCount) && selectors.tested(fieldName));
|
|
@@ -37,14 +58,13 @@
|
|
|
37
58
|
/**
|
|
38
59
|
* Creates a function that returns class names that match the validation result
|
|
39
60
|
*/
|
|
40
|
-
function classnames(res, classes) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (vestUtils.isFunction(selectors[sel]) && selectors[sel](key)) {
|
|
61
|
+
function classnames(res, classes = {}) {
|
|
62
|
+
const selectors = parse(res);
|
|
63
|
+
return function cn(fieldName) {
|
|
64
|
+
const classesArray = [];
|
|
65
|
+
for (const selector in classes) {
|
|
66
|
+
const sel = selector;
|
|
67
|
+
if (vestUtils.isFunction(selectors[sel]) && selectors[sel](fieldName)) {
|
|
48
68
|
classesArray.push(classes[sel]);
|
|
49
69
|
}
|
|
50
70
|
}
|
|
@@ -54,4 +74,4 @@
|
|
|
54
74
|
|
|
55
75
|
return classnames;
|
|
56
76
|
|
|
57
|
-
}))
|
|
77
|
+
}));
|
|
@@ -1 +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.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(" ")}}}));
|
|
@@ -1,63 +1,9 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}(this, (function (
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('n4s/compose')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['n4s/compose'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.compose = factory(global.compose));
|
|
5
|
+
})(this, (function (compose) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
var output = { pass: pass };
|
|
9
|
-
if (message) {
|
|
10
|
-
output.message = message;
|
|
11
|
-
}
|
|
12
|
-
return output;
|
|
13
|
-
}
|
|
14
|
-
function failing() {
|
|
15
|
-
return ruleReturn(false);
|
|
16
|
-
}
|
|
17
|
-
function passing() {
|
|
18
|
-
return ruleReturn(true);
|
|
19
|
-
}
|
|
20
|
-
function defaultToPassing(callback) {
|
|
21
|
-
return vestUtils.defaultTo(callback, passing());
|
|
22
|
-
}
|
|
7
|
+
return compose;
|
|
23
8
|
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
return lazyRule.run(currentValue);
|
|
27
|
-
}
|
|
28
|
-
catch (_a) {
|
|
29
|
-
return failing();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/* eslint-disable max-lines-per-function */
|
|
34
|
-
function compose() {
|
|
35
|
-
var composites = [];
|
|
36
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
37
|
-
composites[_i] = arguments[_i];
|
|
38
|
-
}
|
|
39
|
-
return vestUtils.assign(function (value) {
|
|
40
|
-
var res = run(value);
|
|
41
|
-
vestUtils.invariant(res.pass, vestUtils.StringObject(res.message));
|
|
42
|
-
}, {
|
|
43
|
-
run: run,
|
|
44
|
-
test: function (value) { return run(value).pass; }
|
|
45
|
-
});
|
|
46
|
-
function run(value) {
|
|
47
|
-
return n4s.ctx.run({ value: value }, function () {
|
|
48
|
-
return defaultToPassing(vestUtils.mapFirst(composites, function (composite, breakout) {
|
|
49
|
-
/* HACK: Just a small white lie. ~~HELP WANTED~~.
|
|
50
|
-
The ideal is that instead of `LazyRuleRunners` We would simply use `Lazy` to begin with.
|
|
51
|
-
The problem is that lazy rules can't really be passed to this function due to some generic hell
|
|
52
|
-
so we're limiting it to a small set of functions.
|
|
53
|
-
*/
|
|
54
|
-
var res = runLazyRule(composite, value);
|
|
55
|
-
breakout(!res.pass, res);
|
|
56
|
-
}));
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return compose;
|
|
62
|
-
|
|
63
|
-
})));
|
|
9
|
+
}));
|
|
@@ -1 +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";return e}));
|
|
@@ -1,95 +1,30 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}(this, (function (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
catch (_a) {
|
|
32
|
-
return failing();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function allOf(value) {
|
|
37
|
-
var rules = [];
|
|
38
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
39
|
-
rules[_i - 1] = arguments[_i];
|
|
40
|
-
}
|
|
41
|
-
return defaultToPassing(vestUtils.mapFirst(rules, function (rule, breakout) {
|
|
42
|
-
var res = runLazyRule(rule, value);
|
|
43
|
-
breakout(!res.pass, res);
|
|
44
|
-
}));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function anyOf(value) {
|
|
48
|
-
var rules = [];
|
|
49
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
50
|
-
rules[_i - 1] = arguments[_i];
|
|
51
|
-
}
|
|
52
|
-
return defaultToFailing(vestUtils.mapFirst(rules, function (rule, breakout) {
|
|
53
|
-
var res = runLazyRule(rule, value);
|
|
54
|
-
breakout(res.pass, res);
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function noneOf(value) {
|
|
59
|
-
var rules = [];
|
|
60
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
61
|
-
rules[_i - 1] = arguments[_i];
|
|
62
|
-
}
|
|
63
|
-
return defaultToPassing(vestUtils.mapFirst(rules, function (rule, breakout) {
|
|
64
|
-
var res = runLazyRule(rule, value);
|
|
65
|
-
breakout(res.pass, failing());
|
|
66
|
-
}));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function equals(value, arg1) {
|
|
70
|
-
return value === arg1;
|
|
71
|
-
}
|
|
72
|
-
vestUtils.bindNot(equals);
|
|
73
|
-
|
|
74
|
-
var REQUIRED_COUNT = 1;
|
|
75
|
-
function oneOf(value) {
|
|
76
|
-
var rules = [];
|
|
77
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
78
|
-
rules[_i - 1] = arguments[_i];
|
|
79
|
-
}
|
|
80
|
-
var passingCount = 0;
|
|
81
|
-
rules.some(function (rule) {
|
|
82
|
-
var res = runLazyRule(rule, value);
|
|
83
|
-
if (res.pass) {
|
|
84
|
-
passingCount++;
|
|
85
|
-
}
|
|
86
|
-
if (vestUtils.greaterThan(passingCount, REQUIRED_COUNT)) {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
return ruleReturn(equals(passingCount, REQUIRED_COUNT));
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
n4s.enforce.extend({ allOf: allOf, anyOf: anyOf, noneOf: noneOf, oneOf: oneOf });
|
|
94
|
-
|
|
95
|
-
})));
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('n4s/compounds')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'n4s/compounds'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.compounds = {}, global.compounds));
|
|
5
|
+
})(this, (function (exports, compounds) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var compounds__namespace = /*#__PURE__*/_interopNamespaceDefault(compounds);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
exports.compounds = compounds__namespace;
|
|
29
|
+
|
|
30
|
+
}));
|
|
@@ -1 +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){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}));
|
|
@@ -1,95 +1,30 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}(this, (function (exports,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function isArrayOf(inputArray, currentRule) {
|
|
34
|
-
return defaultToPassing(vestUtils.mapFirst(inputArray, function (currentValue, breakout, index) {
|
|
35
|
-
var res = n4s.ctx.run({ value: currentValue, set: true, meta: { index: index } }, function () { return runLazyRule(currentRule, currentValue); });
|
|
36
|
-
breakout(!res.pass, res);
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function loose(inputObject, shapeObject) {
|
|
41
|
-
var _loop_1 = function (key) {
|
|
42
|
-
var currentValue = inputObject[key];
|
|
43
|
-
var currentRule = shapeObject[key];
|
|
44
|
-
var res = n4s.ctx.run({ value: currentValue, set: true, meta: { key: key } }, function () {
|
|
45
|
-
return runLazyRule(currentRule, currentValue);
|
|
46
|
-
});
|
|
47
|
-
if (!res.pass) {
|
|
48
|
-
return { value: res };
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
for (var key in shapeObject) {
|
|
52
|
-
var state_1 = _loop_1(key);
|
|
53
|
-
if (typeof state_1 === "object")
|
|
54
|
-
return state_1.value;
|
|
55
|
-
}
|
|
56
|
-
return passing();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function optional(value, ruleChain) {
|
|
60
|
-
if (vestUtils.isNullish(value)) {
|
|
61
|
-
return passing();
|
|
62
|
-
}
|
|
63
|
-
return runLazyRule(ruleChain, value);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function shape(inputObject, shapeObject) {
|
|
67
|
-
var baseRes = loose(inputObject, shapeObject);
|
|
68
|
-
if (!baseRes.pass) {
|
|
69
|
-
return baseRes;
|
|
70
|
-
}
|
|
71
|
-
for (var key in inputObject) {
|
|
72
|
-
if (!vestUtils.hasOwnProperty(shapeObject, key)) {
|
|
73
|
-
return failing();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return passing();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Help needed improving the typings of this file.
|
|
80
|
-
// Ideally, we'd be able to extend ShapeObject, but that's not possible.
|
|
81
|
-
function partial(shapeObject) {
|
|
82
|
-
var output = {};
|
|
83
|
-
for (var key in shapeObject) {
|
|
84
|
-
output[key] = n4s.enforce.optional(shapeObject[key]);
|
|
85
|
-
}
|
|
86
|
-
return output;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
n4s.enforce.extend({ isArrayOf: isArrayOf, loose: loose, optional: optional, shape: shape });
|
|
90
|
-
|
|
91
|
-
exports.partial = partial;
|
|
92
|
-
|
|
93
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
94
|
-
|
|
95
|
-
})));
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('n4s/schema')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'n4s/schema'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.schema = {}, global.schema));
|
|
5
|
+
})(this, (function (exports, schema) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var schema__namespace = /*#__PURE__*/_interopNamespaceDefault(schema);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
exports.schema = schema__namespace;
|
|
29
|
+
|
|
30
|
+
}));
|
|
@@ -1 +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){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}));
|
|
@@ -1,33 +1,54 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vest'), require('vest-utils')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'vest', 'vest-utils'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.parser = {}, global.vest, global[
|
|
5
|
-
}(this, (function (exports, vest, vestUtils) { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.parser = {}, global.vest, global["vest-utils"]));
|
|
5
|
+
})(this, (function (exports, vest, vestUtils) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
var ErrorStrings;
|
|
8
|
+
(function (ErrorStrings) {
|
|
9
|
+
ErrorStrings["HOOK_CALLED_OUTSIDE"] = "hook called outside of a running suite.";
|
|
10
|
+
ErrorStrings["EXPECTED_VEST_TEST"] = "Expected value to be an instance of IsolateTest";
|
|
11
|
+
ErrorStrings["FIELD_NAME_REQUIRED"] = "Field name must be passed";
|
|
12
|
+
ErrorStrings["SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION"] = "Suite must be initialized with a function";
|
|
13
|
+
ErrorStrings["PROMISIFY_REQUIRE_FUNCTION"] = "Vest.Promisify must be called with a function";
|
|
14
|
+
ErrorStrings["PARSER_EXPECT_RESULT_OBJECT"] = "Vest parser: expected argument at position 0 to be Vest's result object.";
|
|
15
|
+
ErrorStrings["WARN_MUST_BE_CALLED_FROM_TEST"] = "Warn must be called from within the body of a test function";
|
|
16
|
+
ErrorStrings["EACH_CALLBACK_MUST_BE_A_FUNCTION"] = "Each must be called with a function";
|
|
17
|
+
ErrorStrings["INVALID_PARAM_PASSED_TO_FUNCTION"] = "Incompatible params passed to {fn_name} function. \"{param}\" must be of type {expected}";
|
|
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.";
|
|
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}.";
|
|
21
|
+
})(ErrorStrings || (ErrorStrings = {}));
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
24
|
+
// @ts-ignore - Need to understand why Vest is not being recognized
|
|
8
25
|
function parse(summary) {
|
|
9
|
-
vestUtils.invariant(summary && vestUtils.hasOwnProperty(summary, 'valid'),
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
26
|
+
vestUtils.invariant(summary && vestUtils.hasOwnProperty(summary, 'valid'), ErrorStrings.PARSER_EXPECT_RESULT_OBJECT);
|
|
27
|
+
const sel = vest.suiteSelectors(summary);
|
|
28
|
+
const testedStorage = {};
|
|
29
|
+
const selectors = {
|
|
13
30
|
invalid: sel.hasErrors,
|
|
14
31
|
tested: isTested,
|
|
15
32
|
untested: isUntested,
|
|
16
33
|
valid: sel.isValid,
|
|
17
|
-
warning: sel.hasWarnings
|
|
34
|
+
warning: sel.hasWarnings,
|
|
18
35
|
};
|
|
19
36
|
return selectors;
|
|
20
37
|
// Booleans
|
|
21
38
|
function isTested(fieldName) {
|
|
22
|
-
if (
|
|
39
|
+
if (vestUtils.isNullish(fieldName)) {
|
|
23
40
|
return vestUtils.isPositive(summary.testCount);
|
|
24
41
|
}
|
|
25
|
-
if (vestUtils.hasOwnProperty(testedStorage, fieldName))
|
|
42
|
+
if (vestUtils.hasOwnProperty(testedStorage, fieldName)) {
|
|
26
43
|
return testedStorage[fieldName];
|
|
44
|
+
}
|
|
45
|
+
addFieldToTestedStorage(fieldName);
|
|
46
|
+
return selectors.tested(fieldName);
|
|
47
|
+
}
|
|
48
|
+
function addFieldToTestedStorage(fieldName) {
|
|
27
49
|
testedStorage[fieldName] =
|
|
28
50
|
vestUtils.hasOwnProperty(summary.tests, fieldName) &&
|
|
29
51
|
vestUtils.isPositive(summary.tests[fieldName].testCount);
|
|
30
|
-
return selectors.tested(fieldName);
|
|
31
52
|
}
|
|
32
53
|
function isUntested(fieldName) {
|
|
33
54
|
return !(vestUtils.isPositive(summary.testCount) && selectors.tested(fieldName));
|
|
@@ -36,6 +57,4 @@
|
|
|
36
57
|
|
|
37
58
|
exports.parse = parse;
|
|
38
59
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
})));
|
|
60
|
+
}));
|
|
@@ -1 +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.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)}}}));
|