vest 5.0.0-dev-781e21 → 5.0.0-dev-9c596e
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 +38 -17
- package/dist/cjs/classnames.production.js +1 -1
- package/dist/cjs/enforce/compose.development.js +5 -54
- package/dist/cjs/enforce/compose.production.js +1 -1
- package/dist/cjs/enforce/compounds.development.js +20 -83
- package/dist/cjs/enforce/compounds.production.js +1 -1
- package/dist/cjs/enforce/schema.development.js +19 -82
- package/dist/cjs/enforce/schema.production.js +1 -1
- package/dist/cjs/parser.development.js +31 -9
- package/dist/cjs/parser.production.js +1 -1
- package/dist/cjs/promisify.development.js +22 -9
- package/dist/cjs/promisify.production.js +1 -1
- package/dist/cjs/vest.development.js +1421 -1223
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/classnames.development.js +40 -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 +32 -10
- package/dist/es/parser.production.js +1 -1
- package/dist/es/promisify.development.js +23 -10
- package/dist/es/promisify.production.js +1 -1
- package/dist/es/vest.development.js +1415 -1214
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/classnames.development.js +41 -20
- package/dist/umd/classnames.production.js +1 -1
- package/dist/umd/enforce/compose.development.js +9 -57
- package/dist/umd/enforce/compose.production.js +1 -1
- package/dist/umd/enforce/compounds.development.js +32 -94
- package/dist/umd/enforce/compounds.production.js +1 -1
- package/dist/umd/enforce/schema.development.js +32 -94
- package/dist/umd/enforce/schema.production.js +1 -1
- package/dist/umd/parser.development.js +34 -12
- package/dist/umd/parser.production.js +1 -1
- package/dist/umd/promisify.development.js +25 -12
- package/dist/umd/promisify.production.js +1 -1
- package/dist/umd/vest.development.js +1423 -1225
- package/dist/umd/vest.production.js +1 -1
- package/package.json +12 -16
- package/testUtils/TVestMock.ts +7 -0
- package/testUtils/__tests__/partition.test.ts +4 -4
- 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 +63 -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 +69 -18
- package/types/parser.d.ts.map +1 -0
- package/types/promisify.d.ts +60 -42
- package/types/promisify.d.ts.map +1 -0
- package/types/vest.d.ts +246 -243
- 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{isNullish as t,optionalFunctionValue as e,invariant as n,isNotNullish as r,bindNot as s,either as i,assign as o,tinyState as u,cache as c,defaultTo as a,isPositive as l,asArray as E,isStringValue as d,hasOwnProperty as f,deferThrow as N,text as T,isUndefined as h,seq as R,isPromise as I,isArray as S,callEach as _,bus as m,isNull as p,isFunction as v,numberEquals as A}from"vest-utils";import{createCascade as g}from"context";var D,O,C,y,U;function L(n,r,s){if(t(n.children))return;let i=!1;for(const u of n.children){if(i)return;if((t(s)||e(s,u))&&r(u,o),i)return;L(u,((t,e)=>{r(t,(()=>{e(),o()}))}),s)}function o(){i=!0}}function P(t,e,n){let r=!1;return L(t,((t,n)=>{e(t)&&(n(),r=!0)}),n),r}function F(t,e){let n=t;for(;n.parent;){if(e(n))return n;n=n.parent}return null}!function(t){t[t.Immediate=0]="Immediate",t[t.Delayed=1]="Delayed"}(D||(D={})),function(t){t.HOOK_CALLED_OUTSIDE="hook called outside of a running suite.",t.EXPECTED_VEST_TEST="Expected value to be an instance of IsolateTest",t.FIELD_NAME_REQUIRED="Field name must be passed",t.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION="Suite must be initialized with a function",t.NO_ACTIVE_ISOLATE="Not within an active isolate",t.PROMISIFY_REQUIRE_FUNCTION="Vest.Promisify must be called with a function",t.PARSER_EXPECT_RESULT_OBJECT="Vest parser: expected argument at position 0 to be Vest's result object.",t.WARN_MUST_BE_CALLED_FROM_TEST="Warn must be called from within the body of a test function",t.EACH_CALLBACK_MUST_BE_A_FUNCTION="Each must be called with a function",t.INVALID_PARAM_PASSED_TO_FUNCTION='Incompatible params passed to {fn_name} function. "{param}" must be of type {expected}',t.ENCOUNTERED_THE_SAME_KEY_TWICE='Encountered the same test key "{key}" twice. This may lead to tests overriding each other\'s results, or to tests being unexpectedly omitted.',t.TESTS_CALLED_IN_DIFFERENT_ORDER='Vest Critical Error: Tests called in different order than previous run.\n expected: {fieldName}\n received: {prevName}\n This can happen on one of two reasons:\n 1. You\'re using if/else statements to conditionally select tests. Instead, use "skipWhen".\n 2. You are iterating over a list of tests, and their order changed. Use "each" and a custom key prop so that Vest retains their state.',t.UNEXPECTED_TEST_REGISTRATION_ERROR="Unexpected error encountered during test registration.\n Please report this issue to Vest's Github repository.\n Test Object: {testObject}.\n Error: {error}."}(O||(O={})),function(t){t.TEST_RUN_STARTED="test_run_started",t.TEST_COMPLETED="test_completed",t.ALL_RUNNING_TESTS_FINISHED="all_running_tests_finished",t.REMOVE_FIELD="remove_field",t.RESET_FIELD="reset_field",t.RESET_SUITE="reset_suite",t.SUITE_RUN_STARTED="suite_run_started"}(C||(C={}));class G{static reconciler(e,n){return t(n),e}static reconcile(t,e){var r;const s=Zt(),i=Jt();let o=i;s&&(o=null!==(r=null==i?void 0:i.at(zt()))&&void 0!==r?r:null);const u=this.reconciler(t,o);return n(u),Object.is(u,t)?[t,W(o,t,e)]:[u,u.output]}static removeAllNextNodesInIsolate(){const t=Zt(),e=Jt();e&&t&&e.slice(zt())}static handleCollision(t,e){return t.usesKey()?this.handleIsolateNodeWithKey(t):(this.nodeReorderDetected(t,e)&&this.onNodeReorder(t,e),e||t)}static nodeReorderDetected(t,e){return!(null!=t?t:e)}static onNodeReorder(t,e){return this.removeAllNextNodesInIsolate(),null!=t?t:e}static handleIsolateNodeWithKey(e){n(e.usesKey());const r=function(e){var n;if(t(e))return null;const r=Bt().historyNode;return null!==(n=null==r?void 0:r.keys[e])&&void 0!==n?n:null}(e.key);let s=e;return t(r)||(s=r),function(e,r){if(!e)return;const s=Zt();if(n(s,O.NO_ACTIVE_ISOLATE),t(s.keys[e]))return void(s.keys[e]=r);N(T(O.ENCOUNTERED_THE_SAME_KEY_TWICE,{key:e}))}(e.key,e),s}}function W(t,e,n){const r=$t(),s=bt.run(Object.assign({historyNode:t,runtimeNode:e},!r&&{runtimeRoot:e}),(()=>n(e)));return e.output=s,s}class k{constructor(t){this.children=[],this.keys={},this.parent=null,this.key=null,this.allowReorder=!1}setParent(t){return this.parent=t,this}saveOutput(t){return this.output=t,this}setKey(t){return this.key=t,this}usesKey(){return r(this.key)}addChild(t){n(this.children),this.children.push(t)}removeChild(t){var e,n;this.children=null!==(n=null===(e=this.children)||void 0===e?void 0:e.filter((e=>e!==t)))&&void 0!==n?n:null}slice(e){t(this.children)||(this.children.length=e)}at(t){var e,n;return null!==(n=null===(e=this.children)||void 0===e?void 0:e[t])&&void 0!==n?n:null}cursor(){var t,e;return null!==(e=null===(t=this.children)||void 0===t?void 0:t.length)&&void 0!==e?e:0}shouldAllowReorder(){var t;return null!==(t=!!F(this,(t=>t.allowReorder)))&&void 0!==t&&t}get rootNode(){var e;return null!==(e=F(this,(e=>t(e.parent))))&&void 0!==e?e:this}static create(t,e){return this.createImplementation(t,e)}static createImplementation(t,e){const n=Zt(),r=new this(e).setParent(n),[s,i]=this.reconciler.reconcile(r,t);return s.saveOutput(i),this.setNode(s),s}static setNode(t){const e=Zt();e?function(t){const e=Zt();n(e,O.NO_ACTIVE_ISOLATE),e.addChild(t)}(t):function(t){const e=bt.useX(),[,n]=e.historyRoot();n(t)}(t),t.setParent(e)}static is(t){return t instanceof k}}function w(t,e){return!!e&&!M(t,e)}function M(t,e){return!(!e||t.fieldName!==e)}function b(t,e){return M(t,e.fieldName)&&t.groupName===e.groupName&&t.key===e.key}function K(t){return t===y.ERRORS?U.ERROR_COUNT:U.WARN_COUNT}k.reconciler=G,function(t){t.WARNINGS="warnings",t.ERRORS="errors"}(y||(y={})),function(t){t.ERROR_COUNT="errorCount",t.WARN_COUNT="warnCount"}(U||(U={}));const x=s((function(t,e){return t.groupName===e}));function B(t){return function(t,e){return kt.someTests((n=>X(n,t,e)))}(y.ERRORS,t)}function X(t,e,n){return!!t.hasFailures()&&(!w(t,n)&&!function(t,e){return i(t===y.WARNINGS,e.warns())}(e,t))}var V;function H(t){const[,e]=Q();e(t)}function j(){return function(t){const[e]=Q();return e===t}(V.EAGER)}!function(t){t.ALL="ALL",t.EAGER="EAGER"}(V||(V={}));const q=g(((t,e)=>e?null:o({exclusion:{tests:{},groups:{}},inclusion:{},mode:u.createTinyState(V.EAGER),testMemoCache:Z},t)));function Y(t){return q.useX(t).exclusion}function J(){return q.useX().inclusion}function Q(){return q.useX().mode()}const Z=c(10);var z,$,tt,et;class nt{constructor(){this.errorCount=0,this.warnCount=0,this.testCount=0}}class rt extends nt{constructor(){super(...arguments),this[z]=[],this[$]=[],this.groups={},this.tests={},this.valid=!1}}function st(t){return!!ne(t)||!kt.hasNoTests()&&(!B(t)&&(!function(t){return kt.someIncompleteTests((e=>ot(e,t)))}(t)&&function(t){return kt.everyTest((e=>ut(e,t)))}(t)))}function it(t,e){return!!ne(e)||!function(t,e,n){return kt.someTests((r=>!x(r,e)&&X(r,t,n)))}(y.ERRORS,t,e)&&(!function(t,e){return kt.someIncompleteTests((n=>!x(n,t)&&ot(n,e)))}(t,e)&&function(t,e){return kt.everyTest((n=>!!x(n,t)||ut(n,e)))}(t,e))}function ot(t,e){return!w(t,e)&&ne(e)}function ut(t,e){return!!w(t,e)||(function(t){var e;return(null===(e=te())||void 0===e?void 0:e.getOptionalField(t.fieldName).type)===D.Delayed&&t.awaitsResolution()}(t)||t.isTested()||t.isOmitted())}function ct(){const t=new rt;return kt.walkTests((e=>{t.tests=function(t,e){const{fieldName:n}=e,r=Object.assign({},t);return r[n]=lt(r[n],e),r[n].valid=!1!==r[n].valid&&st(n),r}(t.tests,e),t.groups=function(t,e){const{groupName:n,fieldName:r}=e;if(!n)return t;const s=Object.assign({},t);return s[n]=s[n]||{},s[n][r]=lt(s[n][r],e),s[n][r].valid=!1!==s[n][r].valid&&it(n,r),s}(t.groups,e),t.errors=at(y.ERRORS,t.errors,e),t.warnings=at(y.WARNINGS,t.warnings,e)})),t.valid=st(),function(t){for(const e in t.tests)t.errorCount+=t.tests[e].errorCount,t.warnCount+=t.tests[e].warnCount,t.testCount+=t.tests[e].testCount;return t}(t)}function at(t,e,n){return(t===y.WARNINGS?n.isWarning():n.isFailing())?e.concat({fieldName:n.fieldName,groupName:n.groupName,message:n.message}):e}function lt(t,e){const{message:n}=e,r=a(t?Object.assign({},t):null,Et);return e.isNonActionable()||(r.testCount++,e.isFailing()?s(y.ERRORS):e.isWarning()&&s(y.WARNINGS)),r;function s(t){const e=K(t);r[e]++,n&&(r[t]=(r[t]||[]).concat(n))}}function Et(){return o(new nt,{errors:[],warnings:[],valid:!0})}function dt(t,e,n){return n?function(t,e,n){var r;return(null===(r=null==t?void 0:t[n])||void 0===r?void 0:r[e])||[]}(t,e,n):function(t,e){const n={},r=K(e);for(const s in t)l(t[s][r])&&(n[s]=t[s][e]||[]);return n}(t,e)}function ft(t){const e={getError:function(e){return St(y.ERRORS,t,e)},getErrors:function(e){return Nt(t,y.ERRORS,e)},getErrorsByGroup:function(e,n){return Tt(t,y.ERRORS,e,n)},getWarning:function(e){return St(y.WARNINGS,t,e)},getWarnings:function(e){return Nt(t,y.WARNINGS,e)},getWarningsByGroup:function(e,n){return Tt(t,y.WARNINGS,e,n)},hasErrors:function(e){return It(t,U.ERROR_COUNT,e)},hasErrorsByGroup:function(e,n){return Rt(t,U.ERROR_COUNT,e,n)},hasWarnings:function(e){return It(t,U.WARN_COUNT,e)},hasWarningsByGroup:function(e,n){return Rt(t,U.WARN_COUNT,e,n)},isValid:function(e){var n;return e?Boolean(null===(n=t.tests[e])||void 0===n?void 0:n.valid):t.valid},isValidByGroup:function(e,n){const r=t.groups[e];if(!r)return!1;if(n)return ht(r,n);for(const t in r)if(!ht(r,t))return!1;return!0}};return e}function Nt(t,e,n){return dt(t.tests,e,n)}function Tt(t,e,n,r){return dt(t.groups[n],e,r)}function ht(t,e){var n;return!!(null===(n=t[e])||void 0===n?void 0:n.valid)}function Rt(t,e,n,r){var s,i;const o=t.groups[n];if(!o)return!1;if(r)return l(null===(s=o[r])||void 0===s?void 0:s[e]);for(const t in o)if(l(null===(i=o[t])||void 0===i?void 0:i[e]))return!0;return!1}function It(t,e,n){var r;const s=n?null===(r=t.tests[n])||void 0===r?void 0:r[e]:t[e]||0;return l(s)}function St(t,e,n){var r;const s=e[t];return n?null===(r=s.find((t=>M(t,n))))||void 0===r?void 0:r.message:s[0]}function _t(){const t=ct(),e=Bt().suiteName;return function(t){const e=Bt().suiteResultCache;return e([Qt()],t)}((()=>o(t,ft(t),{suiteName:e})))}function mt(t,n){k.create((()=>{q.run({skipped:pt()||e(t,e(_t))},n)}))}function pt(){return function(){var t;return null!==(t=q.useX().skipped)&&void 0!==t&&t}()}function vt(t){return Dt(0,"tests",t)}function At(t){return Dt(1,"tests",t)}function gt(t){const{fieldName:n,groupName:r}=t;if(pt())return!0;const s=Y(),i=J(),o=s.tests,u=o[n];if(!1===u)return!0;const c=!0===u;if(r){if(function(t){const e=Y(),n=e.groups,r=f(n,t);if(r)return!1===n[t];return Ct()}(r))return!0;if(!0===s.groups[r])return!c&&(!!Ot(o)||!1===o[n])}return!!function(t){if(!Ct())return!1;return!t}(r)||!c&&(!!Ot(o)&&!e(i[n]))}function Dt(t,e,n){const r=Y(O.HOOK_CALLED_OUTSIDE);n&&E(n).forEach((n=>{d(n)&&(r[e][n]=0===t)}))}function Ot(t){for(const e in t)if(!0===t[e])return!0;return!1}function Ct(){const t=Y();for(const e in t.groups)if(t.groups[e])return!0;return!1}function yt(t,n){k.create((()=>{q.run({omitted:Ut()||e(t,e(_t))},n)}))}function Ut(){return function(){var t;return null!==(t=q.useX().omitted)&&void 0!==t&&t}()}function Lt(t,e=t){return function(t){return j()&&B(t.fieldName)}(t)?((n=t).skip(),n):function(t){return Ut()||ne(t.fieldName)}(t)?function(t){return t.omit(),t}(t):gt(t)?function(t){return t.skip(pt()),t}(e):t;var n}z=y.ERRORS,$=y.WARNINGS,vt.group=function(t){return Dt(0,"groups",t)},At.group=function(t){return Dt(1,"groups",t)};function Pt(){return function(t){let e=t.initial;return{getState:function(){return e},transition:function(n,r){let s=t.states[e][n];if(Array.isArray(s)){const[,t]=s;if(!t(r))return;s=s[0]}s&&s!==e&&(e=s)}}}(Ft)}!function(t){t.UNTESTED="UNTESTED",t.SKIPPED="SKIPPED",t.FAILED="FAILED",t.WARNING="WARNING",t.PASSING="PASSING",t.PENDING="PENDING",t.CANCELED="CANCELED",t.OMITTED="OMITTED"}(tt||(tt={})),function(t){t.RESET="RESET"}(et||(et={}));const Ft={initial:tt.UNTESTED,states:{[tt.UNTESTED]:{[tt.CANCELED]:tt.CANCELED,[tt.FAILED]:tt.FAILED,[tt.OMITTED]:tt.OMITTED,[tt.PASSING]:tt.PASSING,[tt.PENDING]:tt.PENDING,[tt.SKIPPED]:tt.SKIPPED,[tt.WARNING]:tt.WARNING},[tt.SKIPPED]:{[et.RESET]:tt.UNTESTED},[tt.FAILED]:{[et.RESET]:tt.UNTESTED},[tt.WARNING]:{[et.RESET]:tt.UNTESTED},[tt.PASSING]:{[et.RESET]:tt.UNTESTED},[tt.PENDING]:{[et.RESET]:tt.UNTESTED,[tt.CANCELED]:tt.CANCELED,[tt.FAILED]:tt.FAILED,[tt.OMITTED]:tt.OMITTED,[tt.PASSING]:tt.PASSING,[tt.SKIPPED]:[tt.SKIPPED,t=>!0===t],[tt.WARNING]:tt.WARNING},[tt.CANCELED]:{[et.RESET]:tt.UNTESTED},[tt.OMITTED]:{[et.RESET]:tt.UNTESTED}}};class Gt extends k{constructor({fieldName:t,testFn:e,message:n,groupName:r,key:s=null}){super(),this.children=null,this.id=R(),this.severity=Wt.Error,this.stateMachine=Pt(),this.fieldName=t,this.testFn=e,r&&(this.groupName=r),n&&(this.message=n),this.setKey(s)}static create(t,e){return Gt.cast(super.create(t,e))}static cast(t){return Gt.isX(t),t}get status(){return this.stateMachine.getState()}setStatus(t,e){this.stateMachine.transition(t,e)}run(){let t;try{t=this.testFn()}catch(e){(function(t,e){return h(t)&&d(e)})(this.message,e)&&(this.message=e),t=!1}return!1===t&&this.fail(),t}warns(){return this.severity===Wt.Warning}isPending(){return this.statusEquals(tt.PENDING)}isOmitted(){return this.statusEquals(tt.OMITTED)}isUntested(){return this.statusEquals(tt.UNTESTED)}isFailing(){return this.statusEquals(tt.FAILED)}isCanceled(){return this.statusEquals(tt.CANCELED)}isSkipped(){return this.statusEquals(tt.SKIPPED)}isPassing(){return this.statusEquals(tt.PASSING)}isWarning(){return this.statusEquals(tt.WARNING)}hasFailures(){return this.isFailing()||this.isWarning()}isNonActionable(){return this.isSkipped()||this.isOmitted()||this.isCanceled()}isTested(){return this.hasFailures()||this.isPassing()}awaitsResolution(){return this.isSkipped()||this.isUntested()||this.isPending()}statusEquals(t){return this.status===t}setPending(){this.setStatus(tt.PENDING)}fail(){this.setStatus(this.warns()?tt.WARNING:tt.FAILED)}pass(){this.setStatus(tt.PASSING)}warn(){this.severity=Wt.Warning}skip(t){this.setStatus(tt.SKIPPED,t)}cancel(){this.setStatus(tt.CANCELED)}reset(){this.stateMachine.transition(et.RESET)}omit(){this.setStatus(tt.OMITTED)}valueOf(){return!this.isFailing()}isAsyncTest(){return I(this.asyncTest)}static is(t){return t instanceof Gt}static isX(t){n(this.is(t))}}var Wt;Gt.reconciler=class extends G{static reconciler(e,n){if(!Gt.is(e))return e;if(t(n))return this.handleNoHistoryNode(e);if(!Gt.is(n))return e;const r=this.pickNode(n,e);return function(t,e,n){t===e&&Gt.is(e)&&(s=e)!==(r=n)&&b(r,s)&&r.isPending()&&r.cancel();var r,s}(r,e,n),r}static nodeReorderDetected(t,e){return!!Gt.is(e)&&!b(e,t)}static handleCollision(t,e){return t.usesKey()?Gt.cast(this.handleIsolateNodeWithKey(t)):this.nodeReorderDetected(t,e)?this.onNodeReorder(t,e):Gt.cast(e||t)}static onNodeReorder(t,e){return function(t,e){if(t.shouldAllowReorder())return;N(T(O.TESTS_CALLED_IN_DIFFERENT_ORDER,{fieldName:t.fieldName,prevName:Gt.is(e)?e.fieldName:void 0}))}(t,e),this.removeAllNextNodesInIsolate(),t}static pickNode(t,e){return Lt(e,this.handleCollision(e,t))}static handleNoHistoryNode(t){return t.usesKey()?Gt.cast(this.handleIsolateNodeWithKey(t)):t}},function(t){t.Error="error",t.Warning="warning"}(Wt||(Wt={}));class kt{static defaultRoot(){return te()}static hasNoTests(t=kt.defaultRoot()){return!t||(e=t,n=Gt.is,!P(e,(()=>!0),n));var e,n}static someIncompleteTests(t,e=kt.defaultRoot()){return!!e&&P(e,(e=>(Gt.isX(e),e.isPending()&&t(e))),Gt.is)}static someTests(t,e=kt.defaultRoot()){return!!e&&P(e,(e=>(Gt.isX(e),t(e))),Gt.is)}static everyTest(t,e=kt.defaultRoot()){return!!e&&function(t,e,n){let r=!0;return L(t,((t,n)=>{e(t)||(n(),r=!1)}),n),r}(e,(e=>(Gt.isX(e),t(e))),Gt.is)}static walkTests(t,e=kt.defaultRoot()){e&&L(e,((e,n)=>{t(Gt.cast(e),n)}),Gt.is)}static hasRemainingTests(t){return kt.someIncompleteTests((e=>!t||M(e,t)))}static pluckTests(t,e=kt.defaultRoot()){e&&function(t,e,n){L(t,(t=>{e(t)&&t.parent&&t.parent.removeChild(t)}),n)}(e,(e=>(Gt.isX(e),t(e))),Gt.is)}static resetField(t){kt.walkTests((e=>{M(e,t)&&e.reset()}),kt.defaultRoot())}static removeTestByFieldName(t,e=kt.defaultRoot()){kt.pluckTests((e=>M(e,t)),e)}}function wt(){const t=m.createBus();return e(C.TEST_COMPLETED,(e=>{e.isCanceled()||(!function(t){const[e]=qt();t&&!kt.hasRemainingTests(t)&&S(e[t])&&_(e[t])}(e.fieldName),kt.hasRemainingTests()||t.emit(C.ALL_RUNNING_TESTS_FINISHED))})),e(C.TEST_RUN_STARTED,(()=>{})),e(C.ALL_RUNNING_TESTS_FINISHED,(()=>{!function(){const[t]=jt();_(t)}()})),e(C.RESET_FIELD,(t=>{kt.resetField(t)})),e(C.SUITE_RUN_STARTED,(()=>{xt()})),e(C.REMOVE_FIELD,(t=>{kt.removeTestByFieldName(t)})),e(C.RESET_SUITE,(()=>{!function(){xt();const[,,t]=Yt();t()}()})),t;function e(e,n){t.on(e,((...t)=>{!function(){const t=Bt().suiteResultCache;t.invalidate([Qt()])}(),n(...t)}))}}const Mt=c(),bt=g(((t,e)=>{if(e)return null;n(t.historyRoot);const[r]=t.historyRoot(),s={};return o(s,{historyNode:r,runtimeNode:null,runtimeRoot:null},t),s}));function Kt(t){const e=bt.useX();return function(...n){var r;const s=null!==(r=bt.use())&&void 0!==r?r:e;return bt.run(s,(()=>t(...n)))}}function xt(){const[,,t]=jt(),[,,e]=qt();t(),e()}function Bt(){return bt.useX()}function Xt(){return Bt().VestBus}function Vt(){return Kt(Xt().emit)}function Ht(t){const e=Vt();return n=>e(t,n)}function jt(){return Bt().doneCallbacks()}function qt(){return Bt().fieldCallbacks()}function Yt(){return Bt().historyRoot()}function Jt(){return Bt().historyNode}function Qt(){return Bt().suiteId}function Zt(){var t;return null!==(t=Bt().runtimeNode)&&void 0!==t?t:null}function zt(){var t,e;return null!==(e=null===(t=Zt())||void 0===t?void 0:t.cursor())&&void 0!==e?e:0}function $t(){return Bt().runtimeRoot}function te(){const t=$t();if(t)return t;const[e]=Yt();return e}function ee(t){const n=$t();if(S(t)||d(t))E(t).forEach((t=>{n.setOptionalField(t,(()=>({type:D.Delayed,applied:!1,rule:null})))}));else for(const r in t){const s=t[r];n.setOptionalField(r,(()=>({type:D.Immediate,rule:s,applied:e(s)})))}}function ne(t){var e,n,r;return!!t&&(null!==(r=null===(n=null===(e=te())||void 0===e?void 0:e.getOptionalField(t))||void 0===n?void 0:n.applied)&&void 0!==r&&r)}class re extends k{constructor(){super(...arguments),this.optional={}}setOptionalField(t,e){const n=this.optional,r=n[t];Object.assign(n,{[t]:Object.assign({},r,e(r))})}getOptionalField(t){var e;return null!==(e=this.optional[t])&&void 0!==e?e:{}}}function se(t){const r=J(),s=Y();return n(d(t)),r[t]=a(s.tests[t],!0),{when:function(n){const r=J(),s=Y();r[t]=()=>f(s.tests,t)?a(s.tests[t],!0):d(n)?Boolean(s.tests[n]):e(n,e(_t))}}}function ie(t){Lt(t),t.isNonActionable()||(t.isUntested()?function(t){const e=Xt(),n=function(t){return q.run({currentTest:t},(()=>t.run()))}(t);try{I(n)?(t.asyncTest=n,t.setPending(),oe(t)):ue(e,t)}catch(e){throw new Error(T(O.UNEXPECTED_TEST_REGISTRATION_ERROR,{testObject:JSON.stringify(t),error:e}))}}(t):t.isAsyncTest()&&(t.setPending(),oe(t)))}function oe(t){const{asyncTest:e,message:n}=t;if(!I(e))return;const r=Xt(),s=Kt((()=>{ue(r,t)})),i=Kt((e=>{t.isCanceled()||(t.message=d(e)?e:n,t.fail(),s())}));e.then(s,i)}function ue(t,e){e.pass(),t.emit(C.TEST_COMPLETED,e)}function ce(t,...e){const[r,s,i]=v(e[1])?e:[void 0,...e];!function(t,e){const r="test";n(d(t),T(O.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:r,param:"fieldName",expected:"string"})),n(v(e),T(O.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:r,param:"callback",expected:"function"}))}(t,s);const o={fieldName:t,groupName:q.useX().groupName,key:i,message:r,testFn:s};return Vt()(C.TEST_RUN_STARTED),Gt.create(ie,o)}const ae=o(ce,{memo:function(t){return function(e,...n){const[r,s,i]=n.reverse();return function(t,e){const n=q.useX().testMemoCache,r=n.get(t);if(p(r))return n(t,e);const[,s]=r;if(s.isCanceled())return n.invalidate(t),n(t,e);return Gt.setNode(s),s}([Qt(),e,zt()].concat(r),(function(){return t(e,i,s)}))}}(ce)});function le(){return{group:he,include:se,omitWhen:yt,only:vt,optional:ee,skip:At,skipWhen:mt,test:ae}}function Ee(){return o({},_t(),{done:Kt(de)})}function de(...t){const[e,n]=t.reverse(),r=Ee();if(function(t,e,n){var r;return!!(!v(t)||e&&A(null===(r=n.tests[e])||void 0===r?void 0:r.testCount,0))}(e,n,r))return r;const s=()=>e(_t());return kt.hasRemainingTests(n)?(function(t,e){const[,n]=qt(),[,r]=jt();e?n((n=>o(n,{[e]:(n[e]||[]).concat(t)}))):r((e=>e.concat(t)))}(s,n),r):(s(),r)}function fe(...t){const[e,r]=t.reverse();!function(t){n(v(t),O.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION)}(e);const s=function({suiteName:t}={}){return{VestBus:wt(),doneCallbacks:u.createTinyState((()=>[])),fieldCallbacks:u.createTinyState((()=>({}))),historyRoot:u.createTinyState(null),suiteId:R(),suiteName:t,suiteResultCache:Mt}}({suiteName:r});function i(...t){return q.run({},(()=>(Vt()(C.SUITE_RUN_STARTED),re.create(function(t,...e){return()=>(t(...e),Ee())}(e,...t))))).output}return bt.run(s,(()=>o(bt.bind(s,i),Object.assign({get:Kt(_t),remove:Ht(C.REMOVE_FIELD),reset:Ht(C.RESET_SUITE),resetField:Ht(C.RESET_FIELD)},le()))))}class Ne extends k{constructor(){super(...arguments),this.allowReorder=!0}}function Te(t,e){n(v(e),O.EACH_CALLBACK_MUST_BE_A_FUNCTION),Ne.create((()=>{t.forEach(((t,n)=>{e(t,n)}))}))}function he(t,e){return k.create((()=>{q.run({groupName:t},e)}))}function Re(t){return o(((...e)=>fe(t)(...e)),Object.assign({},le()))}const Ie=O.WARN_MUST_BE_CALLED_FROM_TEST;function Se(){const t=(e=O.HOOK_CALLED_OUTSIDE,q.useX(e).currentTest);var e;n(t,Ie),t.warn()}export{V as Modes,fe as create,Te as each,he as group,se as include,H as mode,yt as omitWhen,vt as only,ee as optional,At as skip,mt as skipWhen,Re as staticSuite,ft as suiteSelectors,ae as test,Se as warn};
|
|
@@ -1,33 +1,55 @@
|
|
|
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["NO_ACTIVE_ISOLATE"] = "Not within an active isolate";
|
|
14
|
+
ErrorStrings["PROMISIFY_REQUIRE_FUNCTION"] = "Vest.Promisify must be called with a function";
|
|
15
|
+
ErrorStrings["PARSER_EXPECT_RESULT_OBJECT"] = "Vest parser: expected argument at position 0 to be Vest's result object.";
|
|
16
|
+
ErrorStrings["WARN_MUST_BE_CALLED_FROM_TEST"] = "Warn must be called from within the body of a test function";
|
|
17
|
+
ErrorStrings["EACH_CALLBACK_MUST_BE_A_FUNCTION"] = "Each must be called with a function";
|
|
18
|
+
ErrorStrings["INVALID_PARAM_PASSED_TO_FUNCTION"] = "Incompatible params passed to {fn_name} function. \"{param}\" must be of type {expected}";
|
|
19
|
+
ErrorStrings["ENCOUNTERED_THE_SAME_KEY_TWICE"] = "Encountered the same test key \"{key}\" twice. This may lead to tests overriding each other's results, or to tests being unexpectedly omitted.";
|
|
20
|
+
ErrorStrings["TESTS_CALLED_IN_DIFFERENT_ORDER"] = "Vest Critical Error: Tests called in different order than previous run.\n expected: {fieldName}\n received: {prevName}\n This can happen on one of two reasons:\n 1. You're using if/else statements to conditionally select tests. Instead, use \"skipWhen\".\n 2. You are iterating over a list of tests, and their order changed. Use \"each\" and a custom key prop so that Vest retains their state.";
|
|
21
|
+
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}.";
|
|
22
|
+
})(ErrorStrings || (ErrorStrings = {}));
|
|
23
|
+
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
25
|
+
// @ts-ignore - Need to understand why Vest is not being recognized
|
|
8
26
|
function parse(summary) {
|
|
9
|
-
vestUtils.invariant(summary && vestUtils.hasOwnProperty(summary, 'valid'),
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
27
|
+
vestUtils.invariant(summary && vestUtils.hasOwnProperty(summary, 'valid'), ErrorStrings.PARSER_EXPECT_RESULT_OBJECT);
|
|
28
|
+
const sel = vest.suiteSelectors(summary);
|
|
29
|
+
const testedStorage = {};
|
|
30
|
+
const selectors = {
|
|
13
31
|
invalid: sel.hasErrors,
|
|
14
32
|
tested: isTested,
|
|
15
33
|
untested: isUntested,
|
|
16
34
|
valid: sel.isValid,
|
|
17
|
-
warning: sel.hasWarnings
|
|
35
|
+
warning: sel.hasWarnings,
|
|
18
36
|
};
|
|
19
37
|
return selectors;
|
|
20
38
|
// Booleans
|
|
21
39
|
function isTested(fieldName) {
|
|
22
|
-
if (
|
|
40
|
+
if (vestUtils.isNullish(fieldName)) {
|
|
23
41
|
return vestUtils.isPositive(summary.testCount);
|
|
24
42
|
}
|
|
25
|
-
if (vestUtils.hasOwnProperty(testedStorage, fieldName))
|
|
43
|
+
if (vestUtils.hasOwnProperty(testedStorage, fieldName)) {
|
|
26
44
|
return testedStorage[fieldName];
|
|
45
|
+
}
|
|
46
|
+
addFieldToTestedStorage(fieldName);
|
|
47
|
+
return selectors.tested(fieldName);
|
|
48
|
+
}
|
|
49
|
+
function addFieldToTestedStorage(fieldName) {
|
|
27
50
|
testedStorage[fieldName] =
|
|
28
51
|
vestUtils.hasOwnProperty(summary.tests, fieldName) &&
|
|
29
52
|
vestUtils.isPositive(summary.tests[fieldName].testCount);
|
|
30
|
-
return selectors.tested(fieldName);
|
|
31
53
|
}
|
|
32
54
|
function isUntested(fieldName) {
|
|
33
55
|
return !(vestUtils.isPositive(summary.testCount) && selectors.tested(fieldName));
|
|
@@ -37,14 +59,13 @@
|
|
|
37
59
|
/**
|
|
38
60
|
* Creates a function that returns class names that match the validation result
|
|
39
61
|
*/
|
|
40
|
-
function classnames(res, classes) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (vestUtils.isFunction(selectors[sel]) && selectors[sel](key)) {
|
|
62
|
+
function classnames(res, classes = {}) {
|
|
63
|
+
const selectors = parse(res);
|
|
64
|
+
return function cn(fieldName) {
|
|
65
|
+
const classesArray = [];
|
|
66
|
+
for (const selector in classes) {
|
|
67
|
+
const sel = selector;
|
|
68
|
+
if (vestUtils.isFunction(selectors[sel]) && selectors[sel](fieldName)) {
|
|
48
69
|
classesArray.push(classes[sel]);
|
|
49
70
|
}
|
|
50
71
|
}
|
|
@@ -54,4 +75,4 @@
|
|
|
54
75
|
|
|
55
76
|
return classnames;
|
|
56
77
|
|
|
57
|
-
}))
|
|
78
|
+
}));
|
|
@@ -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.NO_ACTIVE_ISOLATE="Not within an active isolate",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.ENCOUNTERED_THE_SAME_KEY_TWICE='Encountered the same test key "{key}" twice. This may lead to tests overriding each other\'s results, or to tests being unexpectedly omitted.',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}."}(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,15 @@
|
|
|
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
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
8
|
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
return lazyRule.run(currentValue);
|
|
27
|
-
}
|
|
28
|
-
catch (_a) {
|
|
29
|
-
return failing();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
9
|
+
var compose__default = /*#__PURE__*/_interopDefaultLegacy(compose);
|
|
32
10
|
|
|
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
11
|
|
|
61
|
-
return compose;
|
|
62
12
|
|
|
63
|
-
|
|
13
|
+
return compose__default["default"];
|
|
14
|
+
|
|
15
|
+
}));
|
|
@@ -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";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}return o(e).default}));
|
|
@@ -1,95 +1,33 @@
|
|
|
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
|
-
|
|
32
|
-
|
|
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 _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n["default"] = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var compounds__namespace = /*#__PURE__*/_interopNamespace(compounds);
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
exports.compounds = compounds__namespace;
|
|
30
|
+
|
|
31
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
32
|
+
|
|
33
|
+
}));
|
|
@@ -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){if(e&&e.__esModule)return 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,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
@@ -1,95 +1,33 @@
|
|
|
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
|
-
|
|
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 _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n["default"] = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var schema__namespace = /*#__PURE__*/_interopNamespace(schema);
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
exports.schema = schema__namespace;
|
|
30
|
+
|
|
31
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
32
|
+
|
|
33
|
+
}));
|
|
@@ -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){if(e&&e.__esModule)return 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,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
@@ -1,33 +1,55 @@
|
|
|
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["NO_ACTIVE_ISOLATE"] = "Not within an active isolate";
|
|
14
|
+
ErrorStrings["PROMISIFY_REQUIRE_FUNCTION"] = "Vest.Promisify must be called with a function";
|
|
15
|
+
ErrorStrings["PARSER_EXPECT_RESULT_OBJECT"] = "Vest parser: expected argument at position 0 to be Vest's result object.";
|
|
16
|
+
ErrorStrings["WARN_MUST_BE_CALLED_FROM_TEST"] = "Warn must be called from within the body of a test function";
|
|
17
|
+
ErrorStrings["EACH_CALLBACK_MUST_BE_A_FUNCTION"] = "Each must be called with a function";
|
|
18
|
+
ErrorStrings["INVALID_PARAM_PASSED_TO_FUNCTION"] = "Incompatible params passed to {fn_name} function. \"{param}\" must be of type {expected}";
|
|
19
|
+
ErrorStrings["ENCOUNTERED_THE_SAME_KEY_TWICE"] = "Encountered the same test key \"{key}\" twice. This may lead to tests overriding each other's results, or to tests being unexpectedly omitted.";
|
|
20
|
+
ErrorStrings["TESTS_CALLED_IN_DIFFERENT_ORDER"] = "Vest Critical Error: Tests called in different order than previous run.\n expected: {fieldName}\n received: {prevName}\n This can happen on one of two reasons:\n 1. You're using if/else statements to conditionally select tests. Instead, use \"skipWhen\".\n 2. You are iterating over a list of tests, and their order changed. Use \"each\" and a custom key prop so that Vest retains their state.";
|
|
21
|
+
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}.";
|
|
22
|
+
})(ErrorStrings || (ErrorStrings = {}));
|
|
23
|
+
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
25
|
+
// @ts-ignore - Need to understand why Vest is not being recognized
|
|
8
26
|
function parse(summary) {
|
|
9
|
-
vestUtils.invariant(summary && vestUtils.hasOwnProperty(summary, 'valid'),
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
27
|
+
vestUtils.invariant(summary && vestUtils.hasOwnProperty(summary, 'valid'), ErrorStrings.PARSER_EXPECT_RESULT_OBJECT);
|
|
28
|
+
const sel = vest.suiteSelectors(summary);
|
|
29
|
+
const testedStorage = {};
|
|
30
|
+
const selectors = {
|
|
13
31
|
invalid: sel.hasErrors,
|
|
14
32
|
tested: isTested,
|
|
15
33
|
untested: isUntested,
|
|
16
34
|
valid: sel.isValid,
|
|
17
|
-
warning: sel.hasWarnings
|
|
35
|
+
warning: sel.hasWarnings,
|
|
18
36
|
};
|
|
19
37
|
return selectors;
|
|
20
38
|
// Booleans
|
|
21
39
|
function isTested(fieldName) {
|
|
22
|
-
if (
|
|
40
|
+
if (vestUtils.isNullish(fieldName)) {
|
|
23
41
|
return vestUtils.isPositive(summary.testCount);
|
|
24
42
|
}
|
|
25
|
-
if (vestUtils.hasOwnProperty(testedStorage, fieldName))
|
|
43
|
+
if (vestUtils.hasOwnProperty(testedStorage, fieldName)) {
|
|
26
44
|
return testedStorage[fieldName];
|
|
45
|
+
}
|
|
46
|
+
addFieldToTestedStorage(fieldName);
|
|
47
|
+
return selectors.tested(fieldName);
|
|
48
|
+
}
|
|
49
|
+
function addFieldToTestedStorage(fieldName) {
|
|
27
50
|
testedStorage[fieldName] =
|
|
28
51
|
vestUtils.hasOwnProperty(summary.tests, fieldName) &&
|
|
29
52
|
vestUtils.isPositive(summary.tests[fieldName].testCount);
|
|
30
|
-
return selectors.tested(fieldName);
|
|
31
53
|
}
|
|
32
54
|
function isUntested(fieldName) {
|
|
33
55
|
return !(vestUtils.isPositive(summary.testCount) && selectors.tested(fieldName));
|
|
@@ -38,4 +60,4 @@
|
|
|
38
60
|
|
|
39
61
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
40
62
|
|
|
41
|
-
}))
|
|
63
|
+
}));
|