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.
Files changed (71) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +2 -57
  3. package/dist/cjs/classnames.development.js +37 -17
  4. package/dist/cjs/classnames.production.js +1 -1
  5. package/dist/cjs/enforce/compose.development.js +1 -54
  6. package/dist/cjs/enforce/compose.production.js +1 -1
  7. package/dist/cjs/enforce/compounds.development.js +18 -84
  8. package/dist/cjs/enforce/compounds.production.js +1 -1
  9. package/dist/cjs/enforce/schema.development.js +18 -84
  10. package/dist/cjs/enforce/schema.production.js +1 -1
  11. package/dist/cjs/parser.development.js +30 -11
  12. package/dist/cjs/parser.production.js +1 -1
  13. package/dist/cjs/promisify.development.js +21 -9
  14. package/dist/cjs/promisify.production.js +1 -1
  15. package/dist/cjs/vest.development.js +1324 -1294
  16. package/dist/cjs/vest.production.js +1 -1
  17. package/dist/es/classnames.development.js +39 -19
  18. package/dist/es/classnames.production.js +1 -1
  19. package/dist/es/enforce/compose.development.js +1 -58
  20. package/dist/es/enforce/compose.production.js +1 -1
  21. package/dist/es/enforce/compounds.development.js +2 -90
  22. package/dist/es/enforce/compounds.production.js +1 -1
  23. package/dist/es/enforce/schema.development.js +2 -88
  24. package/dist/es/enforce/schema.production.js +1 -1
  25. package/dist/es/parser.development.js +31 -10
  26. package/dist/es/parser.production.js +1 -1
  27. package/dist/es/promisify.development.js +22 -10
  28. package/dist/es/promisify.production.js +1 -1
  29. package/dist/es/vest.development.js +1321 -1286
  30. package/dist/es/vest.production.js +1 -1
  31. package/dist/umd/classnames.development.js +40 -20
  32. package/dist/umd/classnames.production.js +1 -1
  33. package/dist/umd/enforce/compose.development.js +6 -60
  34. package/dist/umd/enforce/compose.production.js +1 -1
  35. package/dist/umd/enforce/compounds.development.js +29 -94
  36. package/dist/umd/enforce/compounds.production.js +1 -1
  37. package/dist/umd/enforce/schema.development.js +29 -94
  38. package/dist/umd/enforce/schema.production.js +1 -1
  39. package/dist/umd/parser.development.js +33 -14
  40. package/dist/umd/parser.production.js +1 -1
  41. package/dist/umd/promisify.development.js +24 -12
  42. package/dist/umd/promisify.production.js +1 -1
  43. package/dist/umd/vest.development.js +1327 -1298
  44. package/dist/umd/vest.production.js +1 -1
  45. package/package.json +144 -147
  46. package/testUtils/TVestMock.ts +7 -0
  47. package/testUtils/__tests__/partition.test.ts +4 -4
  48. package/testUtils/asVestTest.ts +9 -0
  49. package/testUtils/mockThrowError.ts +4 -2
  50. package/testUtils/suiteDummy.ts +4 -1
  51. package/testUtils/testDummy.ts +12 -10
  52. package/testUtils/testPromise.ts +3 -0
  53. package/types/classnames.d.ts +141 -12
  54. package/types/classnames.d.ts.map +1 -0
  55. package/types/enforce/compose.d.ts +2 -126
  56. package/types/enforce/compose.d.ts.map +1 -0
  57. package/types/enforce/compounds.d.ts +2 -136
  58. package/types/enforce/compounds.d.ts.map +1 -0
  59. package/types/enforce/schema.d.ts +2 -144
  60. package/types/enforce/schema.d.ts.map +1 -0
  61. package/types/parser.d.ts +147 -18
  62. package/types/parser.d.ts.map +1 -0
  63. package/types/promisify.d.ts +139 -43
  64. package/types/promisify.d.ts.map +1 -0
  65. package/types/vest.d.ts +257 -242
  66. package/types/vest.d.ts.map +1 -0
  67. package/CHANGELOG.md +0 -87
  68. package/testUtils/expandStateRef.ts +0 -8
  69. package/testUtils/runCreateRef.ts +0 -10
  70. package/testUtils/testObjects.ts +0 -6
  71. package/tsconfig.json +0 -8
@@ -1 +1 @@
1
- "use strict";!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("n4s"),require("vest-utils"),require("context")):"function"==typeof define&&define.amd?define(["exports","n4s","vest-utils","context"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).vest={},t.n4s,t["vest-utils"],t.context)}(this,(function(t,n,e,r){function i(){var t=0;return{current:function(){return t},next:function(){t++}}}function u(t,n){return void 0===n&&(n=[]),{cursor:i(),keys:{current:{},prev:{}},path:n,type:t}}function s(){return rt.useX().stateRef}function o(t,n){(0,s().optionalFields()[1])((function(r){var i;return e.assign(r,((i={})[t]=e.assign({},r[t],n(r[t])),i))}))}function a(t){var n;return null!==(n=s().optionalFields()[0][t])&&void 0!==n?n:{}}function c(){f((function(t){return t}))}function f(t){(0,s().testObjects()[1])((function(n){return{prev:n.prev,current:e.asArray(t(n.current))}}))}function l(){return d().filter((function(t){return t.isPending()}))}function d(){var t=s().testObjects()[0].current;return it([t],(function(){return e.nestedArray.flatten(t)}))}function p(t){function n(t,n,u){return i.references.push(),r(t,e.optionalFunctionValue(n,u)),function(){return[i.references[t],function(n){return r(t,e.optionalFunctionValue(n,i.references[t]))}]}}function r(n,r){var s=i.references[n];i.references[n]=r,n=u[n][1],e.isFunction(n)&&n(r,s),e.isFunction(t)&&t()}var i={references:[]},u=[];return{registerStateKey:function(t,e){var r=u.length;return u.push([t,e]),n(r,t)},reset:function(){var t=i.references;i.references=[],u.forEach((function(e,r){return n(r,e[0],t[r])}))}}}function v(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 E(){return rt.useX().isolate}function h(){var t=E();return t.path.concat(t.cursor.current())}function g(t,n){t=void 0===(t=t.type)?$.DEFAULT:t,e.invariant(e.isFunction(n));var r=u(t,h());return t=rt.run({isolate:r},(function(){return r.keys.prev=function(){var t=s().testObjects()[0].prev;return e.asArray(e.nestedArray.getCurrent(t,h())).reduce((function(t,n){return n instanceof ot&&!e.isNullish(n.key)?(t[n.key]=n,t):t}),{})}(),f((function(t){return e.nestedArray.setValueAtPath(t,r.path,[])})),n()})),E().cursor.next(),t}function N(t,n){return!(!n||t.fieldName!==n)}function m(t,n){return d().some((function(e){return y(e,t,n)}))}function y(t,n,r){return!(!t.hasFailures()||r&&!N(t,r)||e.either(n===ut.WARNINGS,t.warns()))}function R(t){return!!t&&a(t).applied}function S(t){if(R(t))return!0;var n=d();return!(e.isEmpty(n)||m(ut.ERRORS,t)||function(t){return e.isNotEmpty(l().filter((function(n){return T(n,t)})))}(t))&&function(t){return d().every((function(n){return C(n,t)}))}(t)}function T(t,n){return!(n&&!N(t,n))&&R(n)}function C(t,n){return!(!n||N(t,n))||(a(t.fieldName).type===ht.Delayed&&t.awaitsResolution()||t.isTested()||t.isOmitted())}function O(){var t=d(),n=e.assign({errorCount:0,warnCount:0,testCount:0},{groups:{},tests:{},valid:!1});return t.reduce((function(t,n){var r=t.tests;r[n.fieldName]=A(r,n),r[n.fieldName].valid=!1!==r[n.fieldName].valid&&S(n.fieldName);var i=t.groups,u=n.groupName;return u&&(i[u]=i[u]||{},i[u][n.fieldName]=A(i[u],n),r=i[u][n.fieldName],!1===i[u][n.fieldName].valid?n=!1:n=!!R(n=n.fieldName)||!function(t,n,e){return d().some((function(r){return!gt(r,n)&&y(r,t,e)}))}(ut.ERRORS,u,n)&&!function(t,n){return e.isNotEmpty(l().filter((function(e){return!gt(e,t)&&T(e,n)})))}(u,n)&&function(t,n){return d().every((function(e){return!!gt(e,t)||C(e,n)}))}(u,n),r.valid=n),t}),n),n.valid=S(),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 A(t,n){function r(t){s[t===ut.ERRORS?st.ERROR_COUNT:st.WARN_COUNT]++,u&&(s[t]=(s[t]||[]).concat(u))}var i=n.fieldName,u=n.message;t[i]=t[i]||e.assign({errorCount:0,warnCount:0,testCount:0},{errors:[],warnings:[]});var s=t[i];return n.isNonActionable()||(t[i].testCount++,n.isFailing()?r(ut.ERRORS):n.isWarning()&&r(ut.WARNINGS)),s}function _(t,n,r){if(r){var i;t=(null===(i=null==t?void 0:t[r])||void 0===i?void 0:i[n])||[]}else{for(var u in i={},r=n===ut.ERRORS?st.ERROR_COUNT:st.WARN_COUNT,t)e.isPositive(t[u][r])&&(i[u]=t[u][n]||[]);t=i}return t}function b(t){return{getErrors:function(n){return _(t.tests,ut.ERRORS,n)},getErrorsByGroup:function(n,e){return _(t.groups[n],ut.ERRORS,e)},getWarnings:function(n){return _(t.tests,ut.WARNINGS,n)},getWarningsByGroup:function(n,e){return _(t.groups[n],ut.WARNINGS,e)},hasErrors:function(n){return k(t,st.ERROR_COUNT,n)},hasErrorsByGroup:function(n,e){return I(t,st.ERROR_COUNT,n,e)},hasWarnings:function(n){return k(t,st.WARN_COUNT,n)},hasWarningsByGroup:function(n,e){return I(t,st.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 F(n,e);for(var r in n)if(!F(n,r))return!1;return!0}}}function F(t,n){var e;return!(null===(e=t[n])||void 0===e||!e.valid)}function I(t,n,r,i){var u,s;if(!(t=t.groups[r]))return!1;if(i)return e.isPositive(null===(u=t[i])||void 0===u?void 0:u[n]);for(var o in t)if(e.isPositive(null===(s=t[o])||void 0===s?void 0:s[n]))return!0;return!1}function k(t,n,r){var i;return t=r?null===(i=t.tests[r])||void 0===i?void 0:i[n]:t[n]||0,e.isPositive(t)}function P(){var t=d(),n={stateRef:s()};return mt([t],rt.bind(n,(function(){var t=O(),n=s().suiteName()[0];return e.assign(t,b(t),{suiteName:n})})))}function U(t){var n=l();return!e.isEmpty(n)&&(!t||n.some((function(n){return N(n,t)})))}function L(){var t=d(),n={stateRef:s()};return yt([t],rt.bind(n,(function(){return e.assign({},P(),{done:rt.bind(n,Rt)})})))}function W(t,n,r){var i;return!!(!e.isFunction(t)||n&&e.numberEquals(null===(i=r.tests[n])||void 0===i?void 0:i.testCount,0))}function D(t){return!(U()&&(!t||U(t)))}function V(t,n){(0,s().testCallbacks()[1])((function(e){return n?e.fieldCallbacks[n]=(e.fieldCallbacks[n]||[]).concat(t):e.doneCallbacks.push(t),e}))}function w(){var t=e.bus.createBus();return t.on(Nt.TEST_COMPLETED,(function(n){if(!n.isCanceled()){n.done(),n=n.fieldName;var r=s().testCallbacks()[0].fieldCallbacks;n&&!U(n)&&e.isArray(r[n])&&e.callEach(r[n]),U()||t.emit(Nt.ALL_RUNNING_TESTS_FINISHED)}})),t.on(Nt.SUITE_CALLBACK_DONE_RUNNING,(function(){!function(){function t(t){r[t.fieldName]&&(t.omit(),o(t.fieldName,(function(){return{applied:!0}})))}var n=s().optionalFields()[0];if(!e.isEmpty(n)){var r={};d().forEach((function(n){if(e.hasOwnProperty(r,n.fieldName))t(n);else{var i=a(n.fieldName);i.type===ht.Immediate&&(r[n.fieldName]=e.optionalFunctionValue(i.rule),t(n))}})),c()}}()})),t.on(Nt.ALL_RUNNING_TESTS_FINISHED,(function(){var t=s().testCallbacks()[0].doneCallbacks;e.callEach(t)})),t.on(Nt.REMOVE_FIELD,(function(t){d().forEach((function(n){N(n,t)&&(n.cancel(),function(t){f((function(n){return e.nestedArray.transform(n,(function(n){return t!==n?n:null}))}))}(n))}))})),t.on(Nt.RESET_FIELD,(function(t){d().forEach((function(n){N(n,t)&&n.reset()}))})),t}function G(){var t=rt.useX();return e.invariant(t.bus),t.bus}function x(t){return q(0,"tests",t)}function X(t){return q(1,"tests",t)}function q(t,n,r){var i=rt.useX("hook called outside of a running suite.");r&&e.asArray(r).forEach((function(r){e.isStringValue(r)&&(i.exclusion[n][r]=0===t)}))}function H(t){for(var n in t)if(!0===t[n])return!0;return!1}function K(){var t,n=rt.useX().exclusion;for(t in n.groups)if(n.groups[t])return!0;return!1}function M(t){return"Wrong arguments passed to group. Group ".concat(t,".")}function j(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 B(t){var n=t.asyncTest,r=t.message;if(e.isPromise(n)){var i=G().emit,u=s(),o=rt.bind({stateRef:u},(function(){c(),i(Nt.TEST_COMPLETED,t)}));u=rt.bind({stateRef:u},(function(n){t.isCanceled()||(t.message=e.isStringValue(n)?n:r,t.fail(),o())}));try{n.then(o,u)}catch(t){u()}}}function Y(t){var n=s().testObjects()[0].prev;if(e.isEmpty(n))return J(t),t;var r=h();if(n=e.nestedArray.valueAtPath(n,r),!e.isNullish(t.key)){n=t.key,(r=E().keys.prev[n])&&(t=r),r=t;var i=E().keys.current;return e.isNullish(i[n])?i[n]=r:e.deferThrow('Encountered the same test key "'.concat(n,"\" twice. This may lead to tests overriding each other's results, or to tests being unexpectedly omitted.")),J(t),t}return r=n,!e.isNotEmpty(r)||r.fieldName===t.fieldName&&r.groupName===t.groupName||(E().type===$.EACH||e.deferThrow("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=E().cursor.current();f((function(n){return n.splice(t),n}))}(),n=null),J(t=e.defaultTo(n,t)),t}function J(t){var n=h();f((function(r){return e.nestedArray.setValueAtPath(r,n,t)}))}function z(t){var n=E().cursor,r=nt.EAGER;if(rt.useX().mode[0]===r&&m(ut.ERRORS,t.fieldName))return t.skip(),Y(t),n.next(),t;if(r=Y(t),rt.useX().omitted||R(t.fieldName))return r.omit(),n.next(),r;if(function(t){var n=t.fieldName;if(t=t.groupName,rt.useX().skipped)return!0;var r=rt.useX(),i=r.exclusion;r=r.inclusion;var u=i.tests,s=u[n];if(!1===s)return!0;if(s=!0===s,t){var o=rt.useX().exclusion.groups;if(o=e.hasOwnProperty(o,t)?!1===o[t]:K())return!0;if(!0===i.groups[t])return!(s||!H(u)&&!1!==u[n])}return!!(t=!!K()&&!t)||!s&&!!H(u)&&!e.optionalFunctionValue(r[n])}(t))return r.skip(!!rt.useX().skipped),n.next(),r;if(t!==r&&r.fieldName===t.fieldName&&r.groupName===t.groupName&&r.isPending()&&r.cancel(),J(t),t.isUntested()){r=G();var i=function(t){return rt.run({currentTest:t},(function(){return t.run()}))}(t);try{e.isPromise(i)?(t.asyncTest=i,t.setPending(),B(t)):r.emit(Nt.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 e.isPromise(t.asyncTest)&&(t.setPending(),B(t));return n.next(),t}function Q(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=e.isFunction(n[1])?n:j([void 0],n,!0);n=i[0],r=i[1],i=i[2],e.invariant(e.isStringValue(t),Z("fieldName","string")),e.invariant(e.isFunction(r),Z("Test callback","function"));var u=rt.useX();return z(n=new ot(t,r,{message:n,groupName:u.groupName,key:i}))}function Z(t,n){return"Incompatible params passed to test function. ".concat(t," must be a ").concat(n)}var $,tt,nt;(tt=$||($={}))[tt.DEFAULT=0]="DEFAULT",tt[tt.SUITE=1]="SUITE",tt[tt.EACH=2]="EACH",tt[tt.SKIP_WHEN=3]="SKIP_WHEN",tt[tt.OMIT_WHEN=4]="OMIT_WHEN",tt[tt.GROUP=5]="GROUP",function(t){t[t.ALL=0]="ALL",t[t.EAGER=1]="EAGER"}(nt||(nt={}));var et,rt=r.createCascade((function(t,n){return n?null:e.assign({exclusion:{tests:{},groups:{}},inclusion:{},isolate:u($.DEFAULT),mode:[nt.ALL]},t)})),it=e.cache();!function(t){t.Error="error",t.Warning="warning"}(et||(et={}));var ut,st,ot=function(){function t(t,n,r){var i=void 0===r?{}:r;r=i.message;var u=i.groupName;i=i.key,this.key=null,this.id=e.seq(),this.severity=et.Error,this.status=at,this.fieldName=t,this.testFn=n,u&&(this.groupName=u),r&&(this.message=r),i&&(this.key=i)}return t.prototype.run=function(){try{var t=this.testFn()}catch(n){t=n,e.isUndefined(this.message)&&e.isStringValue(t)&&(this.message=n),t=!1}return!1===t&&this.fail(),t},t.prototype.setStatus=function(t){this.isFinalStatus()&&t!==Et||(this.status=t)},t.prototype.warns=function(){return this.severity===et.Warning},t.prototype.setPending=function(){this.setStatus(pt)},t.prototype.fail=function(){this.setStatus(this.warns()?lt:ft)},t.prototype.done=function(){this.isFinalStatus()||this.setStatus(dt)},t.prototype.warn=function(){this.severity=et.Warning},t.prototype.isFinalStatus=function(){return this.hasFailures()||this.isCanceled()||this.isPassing()},t.prototype.skip=function(t){this.isPending()&&!t||this.setStatus(ct)},t.prototype.cancel=function(){this.setStatus(vt),c()},t.prototype.reset=function(){this.status=at,c()},t.prototype.omit=function(){this.setStatus(Et)},t.prototype.valueOf=function(){return!this.isFailing()},t.prototype.isPending=function(){return this.statusEquals(pt)},t.prototype.isOmitted=function(){return this.statusEquals(Et)},t.prototype.isUntested=function(){return this.statusEquals(at)},t.prototype.isFailing=function(){return this.statusEquals(ft)},t.prototype.isCanceled=function(){return this.statusEquals(vt)},t.prototype.isSkipped=function(){return this.statusEquals(ct)},t.prototype.isPassing=function(){return this.statusEquals(dt)},t.prototype.isWarning=function(){return this.statusEquals(lt)},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}(),at="UNTESTED",ct="SKIPPED",ft="FAILED",lt="WARNING",dt="PASSING",pt="PENDING",vt="CANCELED",Et="OMITTED";!function(t){t.WARNINGS="warnings",t.ERRORS="errors"}(ut||(ut={})),function(t){t.ERROR_COUNT="errorCount",t.WARN_COUNT="warnCount"}(st||(st={}));var ht,gt=e.bindNot((function(t,n){return t.groupName===n}));!function(t){t[t.Immediate=0]="Immediate",t[t.Delayed=1]="Delayed"}(ht||(ht={}));var Nt,mt=e.cache(1),yt=e.cache(20),Rt=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=(t=t.reverse())[0];if(t=t[1],n=L(),W(e,t,n))return n;var r=function(){return e(P())};return D(t)?(r(),n):(V(r,t),n)};!function(t){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.SUITE_CALLBACK_DONE_RUNNING="suite_callback_done_running"}(Nt||(Nt={})),x.group=function(t){return q(0,"groups",t)},X.group=function(t){return q(1,"groups",t)},r=e.assign(Q,{memo:function(t){var n=e.cache(10);return function(r){for(var i=[],u=1;u<arguments.length;u++)i[u-1]=arguments[u];u=E().cursor.current();var o=(i=i.reverse())[0],a=i[1],c=i[2];return u=[s().suiteId()[0],r,u].concat(o),i=n.get(u),e.isNull(i)?n(u,(function(){return t(r,c,a)})):i[1].isCanceled()?(n.invalidate(u),n(u,(function(){return t(r,c,a)}))):z(i[1])}}(Q)}),Object.defineProperty(t,"enforce",{enumerable:!0,get:function(){return n.enforce}}),t.VERSION="5.0.0-dev-781e21",t.context=rt,t.create=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=(t=t.reverse())[0];t=t[1],e.invariant(e.isFunction(r),"vest.create: Expected callback to be a function.");var i=w(),u=p();return t={stateRef:v(u,{suiteId:e.seq(),suiteName:t}),bus:i},e.assign(rt.bind(t,(function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return u.reset(),g({type:$.SUITE},(function(){r.apply(void 0,t)})),i.emit(Nt.SUITE_CALLBACK_DONE_RUNNING),L()})),{get:rt.bind(t,P),remove:rt.bind(t,(function(t){i.emit(Nt.REMOVE_FIELD,t)})),reset:u.reset,resetField:rt.bind(t,(function(t){i.emit(Nt.RESET_FIELD,t)}))})},t.each=function(t,n){e.invariant(e.isFunction(n),"each callback must be a function"),g({type:$.EACH},(function(){t.forEach((function(t,e){n(t,e)}))}))},t.eager=function(){var t=nt.EAGER;rt.useX().mode[0]=t},t.group=function(t,n){e.invariant(e.isStringValue(t),M("name must be a string")),e.invariant(e.isFunction(n),M("callback must be a function")),g({type:$.GROUP},(function(){rt.run({groupName:t},n)}))},t.include=function(t){var n=rt.useX(),r=n.inclusion;return n=n.exclusion,e.invariant(e.isStringValue(t)),r[t]=e.defaultTo(n.tests[t],!0),{when:function(n){var r=rt.useX(),i=r.exclusion;r.inclusion[t]=function(){return e.hasOwnProperty(i.tests,t)?e.defaultTo(i.tests[t],!0):e.isStringValue(n)?!!i.tests[n]:e.optionalFunctionValue(n,e.optionalFunctionValue(P))}}}},t.omitWhen=function(t,n){g({type:$.OMIT_WHEN},(function(){rt.run({omitted:!!rt.useX().omitted||e.optionalFunctionValue(t,e.optionalFunctionValue(P))},(function(){return n()}))}))},t.only=x,t.optional=function(t){if(e.isArray(t)||e.isStringValue(t))e.asArray(t).forEach((function(t){o(t,(function(){return{type:ht.Delayed,applied:!1,rule:null}}))}));else{var n,r=function(n){var r=t[n];o(n,(function(){return{type:ht.Immediate,rule:r,applied:e.optionalFunctionValue(r)}}))};for(n in t)r(n)}},t.skip=X,t.skipWhen=function(t,n){g({type:$.SKIP_WHEN},(function(){rt.run({skipped:!!rt.useX().skipped||e.optionalFunctionValue(t,e.optionalFunctionValue(P))},(function(){return n()}))}))},t.suiteSelectors=b,t.test=r,t.warn=function(){var t=rt.useX("warn hook called outside of a running suite.");e.invariant(t.currentTest,"warn called outside of a test."),t.currentTest.warn()},Object.defineProperty(t,"__esModule",{value:!0})}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("n4s"),require("vest-runtime"),require("vest-utils"),require("context")):"function"==typeof define&&define.amd?define(["exports","n4s","vest-runtime","vest-utils","context"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).vest={},t.n4s,t["vest-runtime"],t["vest-utils"],t.context)}(this,(function(t,e,n,s,i){"use strict";var r,u;function o(t){const e=n.VestRuntime.useAvailableRoot();if(s.isArray(t)||s.isStringValue(t))s.asArray(t).forEach((t=>{e.setOptionalField(t,(()=>({type:r.AUTO,applied:!1,rule:null})))}));else for(const n in t){const s=t[n];e.setOptionalField(n,(()=>({type:r.CUSTOM_LOGIC,rule:s,applied:!0===s})))}}function a(t){var e,s,i;return!!t&&(null!==(i=null===(s=null===(e=n.VestRuntime.useAvailableRoot())||void 0===e?void 0:e.getOptionalField(t))||void 0===s?void 0:s.applied)&&void 0!==i&&i)}!function(t){t[t.CUSTOM_LOGIC=0]="CUSTOM_LOGIC",t[t.AUTO=1]="AUTO"}(r||(r={})),function(t){t.TEST_RUN_STARTED="test_run_started",t.TEST_COMPLETED="test_completed",t.ALL_RUNNING_TESTS_FINISHED="all_running_tests_finished",t.REMOVE_FIELD="remove_field",t.RESET_FIELD="reset_field",t.RESET_SUITE="reset_suite",t.SUITE_RUN_STARTED="suite_run_started",t.SUITE_CALLBACK_RUN_FINISHED="SUITE_CALLBACK_RUN_FINISHED",t.DONE_TEST_OMISSION_PASS="DONE_TEST_OMISSION_PASS"}(u||(u={}));class c extends n.Isolate{constructor(){super(...arguments),this.optional={}}setOptionalField(t,e){const n=this.optional,s=n[t];Object.assign(n,{[t]:Object.assign({},s,e(s))})}getOptionalField(t){var e;return null!==(e=this.optional[t])&&void 0!==e?e:{}}getOptionalFields(){return this.optional}}const l=s.cache();function E(){return n.VestRuntime.useXAppData()}function f(){return E().doneCallbacks()}function d(){return E().fieldCallbacks()}function N(){return E().suiteId}function T(){const[,,t]=f(),[,,e]=d();t(),e()}var R,S,m,I,p,_;function g(t){return t===R.ERRORS?S.ERROR_COUNT:S.WARN_COUNT}function h(t,e){return!!e&&!O(t,e)}function O(t,e){return!(!e||t.fieldName!==e)}function A(t,e){return O(t,e.fieldName)&&t.groupName===e.groupName&&t.key===e.key}!function(t){t.WARNINGS="warnings",t.ERRORS="errors"}(R||(R={})),function(t){t.ERROR_COUNT="errorCount",t.WARN_COUNT="warnCount"}(S||(S={})),function(t){t.Error="error",t.Warning="warning"}(m||(m={})),function(t){t.HOOK_CALLED_OUTSIDE="hook called outside of a running suite.",t.EXPECTED_VEST_TEST="Expected value to be an instance of IsolateTest",t.FIELD_NAME_REQUIRED="Field name must be passed",t.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION="Suite must be initialized with a function",t.PROMISIFY_REQUIRE_FUNCTION="Vest.Promisify must be called with a function",t.PARSER_EXPECT_RESULT_OBJECT="Vest parser: expected argument at position 0 to be Vest's result object.",t.WARN_MUST_BE_CALLED_FROM_TEST="Warn must be called from within the body of a test function",t.EACH_CALLBACK_MUST_BE_A_FUNCTION="Each must be called with a function",t.INVALID_PARAM_PASSED_TO_FUNCTION='Incompatible params passed to {fn_name} function. "{param}" must be of type {expected}',t.TESTS_CALLED_IN_DIFFERENT_ORDER='Vest Critical Error: Tests called in different order than previous run.\n expected: {fieldName}\n received: {prevName}\n This can happen on one of two reasons:\n 1. You\'re using if/else statements to conditionally select tests. Instead, use "skipWhen".\n 2. You are iterating over a list of tests, and their order changed. Use "each" and a custom key prop so that Vest retains their state.',t.UNEXPECTED_TEST_REGISTRATION_ERROR="Unexpected error encountered during test registration.\n Please report this issue to Vest's Github repository.\n Test Object: {testObject}.\n Error: {error}.",t.UNEXPECTED_TEST_RUN_ERROR="Unexpected error encountered during test run. Please report this issue to Vest's Github repository.\n Test Object: {testObject}."}(I||(I={}));class v{constructor(){this.errorCount=0,this.warnCount=0,this.testCount=0}}class D extends v{constructor(){super(...arguments),this[p]=[],this[_]=[],this.groups={},this.tests={},this.valid=!1}}p=R.ERRORS,_=R.WARNINGS;class C{constructor(t,e,n){this.fieldName=t,this.message=e,this.groupName=n}static fromTestObject(t){return new C(t.fieldName,t.message,t.groupName)}toString(){return this.message||""}}const P=s.bindNot((function(t,e){return t.groupName===e}));function F(t){return!!a(t)||!ot.hasNoTests()&&(!at(t)&&(!function(t){return ot.someIncompleteTests((e=>!h(e,t)&&!a(t)))}(t)&&function(t){return ot.everyTest((e=>y(e,t)))}(t)))}function U(t,e){return!!a(e)||!function(t,e,n){return ot.someTests((s=>!P(s,e)&&ct(s,t,n)))}(R.ERRORS,t,e)&&(!function(t,e){return ot.someIncompleteTests((n=>!P(n,t)&&(!h(n,e)&&!a(e))))}(t,e)&&function(t,e){return ot.everyTest((n=>!!P(n,t)||y(n,e)))}(t,e))}function y(t,e){return!!h(t,e)||(t.isOmitted()||t.isTested()||function(t){var e;return(null===(e=n.VestRuntime.useAvailableRoot())||void 0===e?void 0:e.getOptionalField(t.fieldName).type)===r.AUTO&&t.awaitsResolution()}(t))}function L(){const t=new D;return ot.walkTests((e=>{t.tests=function(t,e){const{fieldName:n}=e,s=Object.assign({},t);return s[n]=W(s[n],e),s[n].valid=!1!==s[n].valid&&F(n),s}(t.tests,e),t.groups=function(t,e){const{groupName:n,fieldName:s}=e;if(!n)return t;const i=Object.assign({},t);return i[n]=i[n]||{},i[n][s]=W(i[n][s],e),i[n][s].valid=!1!==i[n][s].valid&&U(n,s),i}(t.groups,e),t.errors=G(R.ERRORS,t.errors,e),t.warnings=G(R.WARNINGS,t.warnings,e)})),t.valid=F(),function(t){for(const e in t.tests)t.errorCount+=t.tests[e].errorCount,t.warnCount+=t.tests[e].warnCount,t.testCount+=t.tests[e].testCount;return t}(t)}function G(t,e,n){if(n.isOmitted())return e;return(t===R.WARNINGS?n.isWarning():n.isFailing())?e.concat(C.fromTestObject(n)):e}function W(t,e){const{message:n}=e,i=s.defaultTo(t?Object.assign({},t):null,V);return e.isNonActionable()||(i.testCount++,e.isFailing()?r(R.ERRORS):e.isWarning()&&r(R.WARNINGS)),i;function r(t){const e=g(t);i[e]++,n&&(i[t]=(i[t]||[]).concat(n))}}function V(){return s.assign(new v,{errors:[],warnings:[],valid:!0})}function b(t,e,n){return n?function(t,e,n){var s;return(null===(s=null==t?void 0:t[n])||void 0===s?void 0:s[e])||[]}(t,e,n):function(t,e){const n={},i=g(e);for(const r in t)s.isPositive(t[r][i])&&(n[r]=t[r][e]||[]);return n}(t,e)}function M(t){const e={getError:function(e){return K(R.ERRORS,t,e)},getErrors:function(e){return w(t,R.ERRORS,e)},getErrorsByGroup:function(e,n){return k(t,R.ERRORS,e,n)},getWarning:function(e){return K(R.WARNINGS,t,e)},getWarnings:function(e){return w(t,R.WARNINGS,e)},getWarningsByGroup:function(e,n){return k(t,R.WARNINGS,e,n)},hasErrors:function(e){return j(t,S.ERROR_COUNT,e)},hasErrorsByGroup:function(e,n){return x(t,S.ERROR_COUNT,e,n)},hasWarnings:function(e){return j(t,S.WARN_COUNT,e)},hasWarningsByGroup:function(e,n){return x(t,S.WARN_COUNT,e,n)},isValid:function(e){var n;return e?Boolean(null===(n=t.tests[e])||void 0===n?void 0:n.valid):t.valid},isValidByGroup:function(e,n){const s=t.groups[e];if(!s)return!1;if(n)return B(s,n);for(const t in s)if(!B(s,t))return!1;return!0}};return e}function w(t,e,n){return b(t.tests,e,n)}function k(t,e,n,s){return b(t.groups[n],e,s)}function B(t,e){var n;return!!(null===(n=t[e])||void 0===n?void 0:n.valid)}function x(t,e,n,i){var r,u;const o=t.groups[n];if(!o)return!1;if(i)return s.isPositive(null===(r=o[i])||void 0===r?void 0:r[e]);for(const t in o)if(s.isPositive(null===(u=o[t])||void 0===u?void 0:u[e]))return!0;return!1}function j(t,e,n){var i;const r=n?null===(i=t.tests[n])||void 0===i?void 0:i[e]:t[e]||0;return s.isPositive(r)}function K(t,e,n){var s;const i=e[t];return n?null===(s=i.find((t=>O(t,n))))||void 0===s?void 0:s.message:i[0]}function X(){return t=()=>{const t=L(),e=E().suiteName;return Object.freeze(s.assign(t,M(t),{suiteName:e}))},(0,E().suiteResultCache)([N()],t);var t}function q(t,e){n.Isolate.create((()=>{ft.run({skipped:H()||s.optionalFunctionValue(t,s.optionalFunctionValue(X))},e)}))}function H(){return function(){var t;return null!==(t=ft.useX().skipped)&&void 0!==t&&t}()}function z(t){return Q(0,"tests",t)}function J(t){return Q(1,"tests",t)}function Y(t){const{fieldName:e,groupName:n}=t;if(H())return!0;const i=dt(),r=Nt(),u=i.tests,o=u[e];if(!1===o)return!0;const a=!0===o;if(n){if(function(t){const e=dt().groups;if(s.hasOwnProperty(e,t))return!1===e[t];return $()}(n))return!0;if(!0===i.groups[n])return!a&&(!!Z(u)||!1===u[e])}return!!function(t){if(!$())return!1;return!t}(n)||!a&&(!!Z(u)&&!s.optionalFunctionValue(r[e]))}function Q(t,e,n){const i=dt(I.HOOK_CALLED_OUTSIDE);n&&s.asArray(n).forEach((n=>{s.isStringValue(n)&&(i[e][n]=0===t)}))}function Z(t){for(const e in t)if(!0===t[e])return!0;return!1}function $(){const t=dt();for(const e in t.groups)if(t.groups[e])return!0;return!1}function tt(t,e){n.Isolate.create((()=>{ft.run({omitted:et()||s.optionalFunctionValue(t,s.optionalFunctionValue(X))},e)}))}function et(){return function(){var t;return null!==(t=ft.useX().omitted)&&void 0!==t&&t}()}function nt(e,n=e){return function(e){if(Et(t.Modes.ONE))return at();if(Et(t.Modes.EAGER))return at(e.fieldName);return!1}(e)?((s=e).skip(),s):function(t){return et()||a(t.fieldName)}(e)?function(t){return t.omit(),t}(e):Y(e)?function(t){return t.skip(H()),t}(n):e;var s}var st,it;z.group=function(t){return Q(0,"groups",t)},J.group=function(t){return Q(1,"groups",t)},function(t){t.UNTESTED="UNTESTED",t.SKIPPED="SKIPPED",t.FAILED="FAILED",t.WARNING="WARNING",t.PASSING="PASSING",t.PENDING="PENDING",t.CANCELED="CANCELED",t.OMITTED="OMITTED"}(st||(st={})),function(t){t.RESET="RESET"}(it||(it={}));const rt={initial:st.UNTESTED,states:{"*":{[st.OMITTED]:st.OMITTED,[it.RESET]:st.UNTESTED},[st.UNTESTED]:{[st.CANCELED]:st.CANCELED,[st.FAILED]:st.FAILED,[st.PASSING]:st.PASSING,[st.PENDING]:st.PENDING,[st.SKIPPED]:st.SKIPPED,[st.WARNING]:st.WARNING},[st.PENDING]:{[st.CANCELED]:st.CANCELED,[st.FAILED]:st.FAILED,[st.PASSING]:st.PASSING,[st.SKIPPED]:[st.SKIPPED,t=>!0===t],[st.WARNING]:st.WARNING},[st.SKIPPED]:{},[st.FAILED]:{},[st.WARNING]:{},[st.PASSING]:{},[st.CANCELED]:{},[st.OMITTED]:{}}};class ut extends n.Isolate{constructor({fieldName:t,testFn:e,message:n,groupName:i,key:r=null}){super(),this.children=null,this.id=s.seq(),this.severity=m.Error,this.stateMachine=s.StateMachine(rt),this.fieldName=t,this.testFn=e,i&&(this.groupName=i),n&&(this.message=n),this.setKey(r)}static create(t,e){return ut.cast(super.create(t,e))}static cast(t){return ut.isX(t),t}get status(){return this.stateMachine.getState()}setStatus(t,e){this.stateMachine.transition(t,e)}run(){let t;try{t=this.testFn()}catch(e){(function(t,e){return s.isUndefined(t)&&s.isStringValue(e)})(this.message,e)&&(this.message=e),t=!1}return!1===t&&this.fail(),t}warns(){return this.severity===m.Warning}isPending(){return this.statusEquals(st.PENDING)}isOmitted(){return this.statusEquals(st.OMITTED)}isUntested(){return this.statusEquals(st.UNTESTED)}isFailing(){return this.statusEquals(st.FAILED)}isCanceled(){return this.statusEquals(st.CANCELED)}isSkipped(){return this.statusEquals(st.SKIPPED)}isPassing(){return this.statusEquals(st.PASSING)}isWarning(){return this.statusEquals(st.WARNING)}hasFailures(){return this.isFailing()||this.isWarning()}isNonActionable(){return this.isSkipped()||this.isOmitted()||this.isCanceled()}isTested(){return this.hasFailures()||this.isPassing()}awaitsResolution(){return this.isSkipped()||this.isUntested()||this.isPending()}statusEquals(t){return this.status===t}setPending(){this.setStatus(st.PENDING)}fail(){this.setStatus(this.warns()?st.WARNING:st.FAILED)}pass(){this.setStatus(st.PASSING)}warn(){this.severity=m.Warning}skip(t){this.setStatus(st.SKIPPED,t)}cancel(){this.setStatus(st.CANCELED)}reset(){this.stateMachine.transition(it.RESET)}omit(){this.setStatus(st.OMITTED)}valueOf(){return!this.isFailing()}isAsyncTest(){return s.isPromise(this.asyncTest)}static is(t){return t instanceof ut}static isX(t){s.invariant(this.is(t))}}ut.reconciler=function(t,e){if(!ut.is(t))return t;if(s.isNullish(e))return function(t){if(t.usesKey())return ut.cast(n.Reconciler.handleIsolateNodeWithKey(t));return t}(t);if(!ut.is(e))return t;const i=function(t,e){const i=function(t,e){if(t.usesKey())return ut.cast(n.Reconciler.handleIsolateNodeWithKey(t));if(function(t,e){return!!ut.is(e)&&!A(e,t)}(t,e))return function(t,e){return function(t,e){if(t.shouldAllowReorder())return;s.deferThrow(s.text(I.TESTS_CALLED_IN_DIFFERENT_ORDER,{fieldName:t.fieldName,prevName:ut.is(e)?e.fieldName:void 0}))}(t,e),n.Reconciler.removeAllNextNodesInIsolate(),t}(t,e);if(!ut.is(e))return t;if(e.isOmitted())return t;return e}(e,t);return nt(e,i)}(e,t);return function(t,e,n){t===e&&ut.is(e)&&(i=e)!==(s=n)&&A(s,i)&&s.isPending()&&s.cancel();var s,i}(i,t,e),i};class ot{static defaultRoot(){return n.VestRuntime.useAvailableRoot()}static hasNoTests(t=ot.defaultRoot()){return!t||!n.Walker.has(t,ut.is)}static someIncompleteTests(t,e=ot.defaultRoot()){return!!e&&n.Walker.some(e,(e=>(ut.isX(e),e.isPending()&&t(e))),ut.is)}static someTests(t,e=ot.defaultRoot()){return!!e&&n.Walker.some(e,(e=>(ut.isX(e),t(e))),ut.is)}static everyTest(t,e=ot.defaultRoot()){return!!e&&n.Walker.every(e,(e=>(ut.isX(e),t(e))),ut.is)}static walkTests(t,e=ot.defaultRoot()){e&&n.Walker.walk(e,((e,n)=>{t(ut.cast(e),n)}),ut.is)}static hasRemainingTests(t){return ot.someIncompleteTests((e=>!t||O(e,t)))}static pluckTests(t,e=ot.defaultRoot()){e&&n.Walker.pluck(e,(e=>(ut.isX(e),t(e))),ut.is)}static resetField(t){ot.walkTests((e=>{O(e,t)&&e.reset()}),ot.defaultRoot())}static removeTestByFieldName(t,e=ot.defaultRoot()){ot.pluckTests((e=>O(e,t)),e)}}function at(t){return function(t,e){return ot.someTests((n=>ct(n,t,e)))}(R.ERRORS,t)}function ct(t,e,n){return!!t.hasFailures()&&(!h(t,n)&&!function(t,e){return s.either(t===R.WARNINGS,e.warns())}(e,t))}var lt;function Et(t){const[e]=Tt();return e===t}t.Modes=void 0,(lt=t.Modes||(t.Modes={})).EAGER="EAGER",lt.ALL="ALL",lt.ONE="ONE";const ft=i.createCascade(((e,n)=>n?null:s.assign({exclusion:{tests:{},groups:{}},inclusion:{},mode:s.tinyState.createTinyState(t.Modes.EAGER),testMemoCache:Rt},e)));function dt(t){return ft.useX(t).exclusion}function Nt(){return ft.useX().inclusion}function Tt(){return ft.useX().mode()}const Rt=s.cache(10);function St(){const t=n.VestRuntime.useAvailableRoot(),e=n.VestRuntime.useEmit(),i=null==t?void 0:t.getOptionalFields();if(s.isEmpty(i))return;const r=new Set;function o(e){r.has(e.fieldName)&&(e.omit(),null==t||t.setOptionalField(e.fieldName,(t=>Object.assign(Object.assign({},t),{applied:!0}))))}ot.walkTests((e=>{e.isPending()||(s.hasOwnProperty(r,e.fieldName)?o(e):function(e){const n=null==t?void 0:t.getOptionalField(e.fieldName);if(s.isNullish(n))return;!0===s.optionalFunctionValue(n.rule)&&r.add(e.fieldName);o(e)}(e))})),e(u.DONE_TEST_OMISSION_PASS)}function mt(){const t=n.VestRuntime.useBus();return e(u.TEST_COMPLETED,(e=>{e.isCanceled()||(!function(t){const[e]=d();t&&!ot.hasRemainingTests(t)&&s.isArray(e[t])&&s.callEach(e[t])}(e.fieldName),ot.hasRemainingTests()||t.emit(u.ALL_RUNNING_TESTS_FINISHED))})),e(u.TEST_RUN_STARTED,(()=>{})),e(u.DONE_TEST_OMISSION_PASS,(()=>{})),e(u.ALL_RUNNING_TESTS_FINISHED,(()=>{ot.someTests((t=>t.isAsyncTest()))&&St(),function(){const[t]=f();s.callEach(t)}()})),e(u.RESET_FIELD,(t=>{ot.resetField(t)})),e(u.SUITE_RUN_STARTED,(()=>{T()})),e(u.SUITE_CALLBACK_RUN_FINISHED,(()=>{St()})),e(u.REMOVE_FIELD,(t=>{ot.removeTestByFieldName(t)})),e(u.RESET_SUITE,(()=>{T(),n.VestRuntime.reset()})),t;function e(e,n){t.on(e,((...t)=>{E().suiteResultCache.invalidate([N()]),n(...t)}))}}function It(t){const e=Nt(),n=dt();return s.invariant(s.isStringValue(t)),e[t]=s.defaultTo(n.tests[t],!0),{when:function(e){const n=Nt(),i=dt();n[t]=()=>s.hasOwnProperty(i.tests,t)?s.defaultTo(i.tests[t],!0):s.isStringValue(e)?Boolean(i.tests[e]):s.optionalFunctionValue(e,s.optionalFunctionValue(X))}}}function pt(t){if(nt(t),t.isUntested())return function(t){const e=n.VestRuntime.useBus(),i=function(t){return ft.run({currentTest:t},(()=>t.run()))}(t);try{s.isPromise(i)?(t.asyncTest=i,function(t){const{asyncTest:e,message:i}=t;if(!s.isPromise(e))return;t.setPending();const r=n.VestRuntime.useBus(),u=n.VestRuntime.persist((()=>{_t(r,t)})),o=n.VestRuntime.persist((e=>{t.isCanceled()||(t.message=s.isStringValue(e)?e:i,t.fail(),u())}));e.then(u,o)}(t)):_t(e,t)}catch(e){throw new Error(s.text(I.UNEXPECTED_TEST_REGISTRATION_ERROR,{testObject:JSON.stringify(t),error:e}))}}(t);t.isNonActionable()||s.deferThrow(s.text(I.UNEXPECTED_TEST_REGISTRATION_ERROR,{testObject:JSON.stringify(t)}))}function _t(t,e){e.pass(),t.emit(u.TEST_COMPLETED,e)}function gt(t,...e){const[i,r,o]=s.isFunction(e[1])?e:[void 0,...e];!function(t,e){const n="test";s.invariant(s.isStringValue(t),s.text(I.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:n,param:"fieldName",expected:"string"})),s.invariant(s.isFunction(e),s.text(I.INVALID_PARAM_PASSED_TO_FUNCTION,{fn_name:n,param:"callback",expected:"function"}))}(t,r);const a={fieldName:t,groupName:ft.useX().groupName,key:o,message:i,testFn:r};return n.VestRuntime.useEmit()(u.TEST_RUN_STARTED),ut.create(pt,a)}const ht=s.assign(gt,{memo:function(t){return function(e,...i){const[r,u,o]=i.reverse();return function(t,e){const n=ft.useX().testMemoCache,i=n.get(t);if(s.isNull(i))return n(t,e);const[,r]=i;if(r.isCanceled())return n.invalidate(t),n(t,e);return ut.setNode(r),r}([N(),e,n.VestRuntime.useCurrentCursor()].concat(r),(function(){return t(e,o,u)}))}}(gt)});function Ot(){return{group:Pt,include:It,omitWhen:tt,only:z,optional:o,skip:J,skipWhen:q,test:ht}}function At(){return Object.freeze(s.assign({done:n.VestRuntime.persist(vt)},X()))}function vt(...t){const[e,n]=t.reverse(),i=At();if(function(t,e,n){var i;return!!(!s.isFunction(t)||e&&s.numberEquals(null===(i=n.tests[e])||void 0===i?void 0:i.testCount,0))}(e,n,i))return i;const r=()=>e(X());return ot.hasRemainingTests(n)?(function(t,e){const[,n]=d(),[,i]=f();e?n((n=>s.assign(n,{[e]:(n[e]||[]).concat(t)}))):i((e=>e.concat(t)))}(r,n),i):(r(),i)}function Dt(...t){const[e,i]=t.reverse();!function(t){s.invariant(s.isFunction(t),I.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION)}(e);const r=function({suiteName:t}={}){const e={doneCallbacks:s.tinyState.createTinyState((()=>[])),fieldCallbacks:s.tinyState.createTinyState((()=>({}))),suiteId:s.seq(),suiteName:t,suiteResultCache:l};return n.VestRuntime.createRef(e)}({suiteName:i});function o(...t){return ft.run({},(()=>(n.VestRuntime.useEmit()(u.SUITE_RUN_STARTED),c.create(function(t,...e){const s=n.VestRuntime.useEmit();return()=>(t(...e),s(u.SUITE_CALLBACK_RUN_FINISHED),At())}(e,...t))))).output}return n.VestRuntime.Run(r,(()=>{return mt(),s.assign(n.VestRuntime.persist(o),Object.assign(Object.assign({get:n.VestRuntime.persist(X),remove:n.VestRuntime.usePrepareEmitter(u.REMOVE_FIELD),reset:n.VestRuntime.usePrepareEmitter(u.RESET_SUITE),resetField:n.VestRuntime.usePrepareEmitter(u.RESET_FIELD)},(t=n.VestRuntime.persist(X),{getError:(...e)=>t().getError(...e),getErrors:(...e)=>t().getErrors(...e),getErrorsByGroup:(...e)=>t().getErrorsByGroup(...e),getWarning:(...e)=>t().getWarning(...e),getWarnings:(...e)=>t().getWarnings(...e),getWarningsByGroup:(...e)=>t().getWarningsByGroup(...e),hasErrors:(...e)=>t().hasErrors(...e),hasErrorsByGroup:(...e)=>t().hasErrorsByGroup(...e),hasWarnings:(...e)=>t().hasWarnings(...e),hasWarningsByGroup:(...e)=>t().hasWarningsByGroup(...e),isValid:(...e)=>t().isValid(...e),isValidByGroup:(...e)=>t().isValidByGroup(...e)})),Ot()));var t}))}class Ct extends n.Isolate{constructor(){super(...arguments),this.allowReorder=!0}}function Pt(t,e){return n.Isolate.create((()=>{ft.run({groupName:t},e)}))}const Ft=I.WARN_MUST_BE_CALLED_FROM_TEST;Object.defineProperty(t,"enforce",{enumerable:!0,get:function(){return e.enforce}}),t.create=Dt,t.each=function(t,e){s.invariant(s.isFunction(e),I.EACH_CALLBACK_MUST_BE_A_FUNCTION),Ct.create((()=>{t.forEach(((t,n)=>{e(t,n)}))}))},t.group=Pt,t.include=It,t.mode=function(t){const[,e]=Tt();e(t)},t.omitWhen=tt,t.only=z,t.optional=o,t.skip=J,t.skipWhen=q,t.staticSuite=function(t){return s.assign(((...e)=>Dt(t)(...e)),Object.assign({},Ot()))},t.suiteSelectors=M,t.test=ht,t.warn=function(){const t=(e=I.HOOK_CALLED_OUTSIDE,ft.useX(e).currentTest);var e;s.invariant(t,Ft),t.warn()}}));
package/package.json CHANGED
@@ -1,16 +1,14 @@
1
1
  {
2
- "version": "5.0.0-dev-781e21",
3
- "license": "MIT",
4
2
  "name": "vest",
3
+ "version": "5.0.0-dev-ec989a",
4
+ "description": "Declarative Form Validations Framework",
5
+ "license": "MIT",
5
6
  "author": "ealush",
6
- "scripts": {
7
- "test": "vx test",
8
- "build": "vx build",
9
- "release": "vx release"
10
- },
11
7
  "main": "./dist/cjs/vest.js",
12
- "types": "./types/vest.d.ts",
13
8
  "module": "./dist/es/vest.production.js",
9
+ "unpkg": "./dist/umd/vest.production.js",
10
+ "jsdelivr": "./dist/umd/vest.production.js",
11
+ "types": "./types/vest.d.ts",
14
12
  "repository": {
15
13
  "type": "git",
16
14
  "url": "https://github.com/ealush/vest.git",
@@ -20,101 +18,72 @@
20
18
  "url": "https://github.com/ealush/vest.git/issues"
21
19
  },
22
20
  "dependencies": {
23
- "context": "^3.0.0-dev-781e21",
24
- "n4s": "^5.0.0-dev-781e21",
25
- "vest-utils": "^0.0.2"
21
+ "context": "3.0.9-dev-ec989a",
22
+ "n4s": "5.0.0-dev-ec989a",
23
+ "vast": "1.0.18-dev-ec989a",
24
+ "vest-runtime": "0.0.2-dev-ec989a",
25
+ "vest-utils": "1.0.0-dev-ec989a"
26
26
  },
27
- "homepage": "https://vestjs.dev/",
28
27
  "exports": {
29
- "./classnames": {
30
- "production": {
31
- "types": "./types/classnames.d.ts",
32
- "browser": "./dist/es/classnames.production.js",
33
- "umd": "./dist/umd/classnames.production.js",
34
- "import": "./dist/es/classnames.production.js",
35
- "require": "./dist/cjs/classnames.production.js",
36
- "node": "./dist/cjs/classnames.production.js",
37
- "module": "./dist/es/classnames.production.js",
38
- "default": "./dist/cjs/classnames.production.js"
39
- },
40
- "development": {
41
- "types": "./types/classnames.d.ts",
42
- "browser": "./dist/es/classnames.development.js",
43
- "umd": "./dist/umd/classnames.development.js",
44
- "import": "./dist/es/classnames.development.js",
45
- "require": "./dist/cjs/classnames.development.js",
46
- "node": "./dist/cjs/classnames.development.js",
47
- "module": "./dist/es/classnames.development.js",
48
- "default": "./dist/cjs/classnames.development.js"
49
- },
50
- "types": "./types/classnames.d.ts",
51
- "browser": "./dist/es/classnames.production.js",
52
- "umd": "./dist/umd/classnames.production.js",
53
- "import": "./dist/es/classnames.production.js",
54
- "require": "./dist/cjs/classnames.production.js",
55
- "node": "./dist/cjs/classnames.production.js",
56
- "module": "./dist/es/classnames.production.js",
57
- "default": "./dist/cjs/classnames.production.js"
58
- },
59
- "./enforce/compose": {
28
+ "./promisify": {
60
29
  "production": {
61
- "types": "./types/enforce/compose.d.ts",
62
- "browser": "./dist/es/enforce/compose.production.js",
63
- "umd": "./dist/umd/enforce/compose.production.js",
64
- "import": "./dist/es/enforce/compose.production.js",
65
- "require": "./dist/cjs/enforce/compose.production.js",
66
- "node": "./dist/cjs/enforce/compose.production.js",
67
- "module": "./dist/es/enforce/compose.production.js",
68
- "default": "./dist/cjs/enforce/compose.production.js"
30
+ "types": "./types/promisify.d.ts",
31
+ "browser": "./dist/es/promisify.production.js",
32
+ "umd": "./dist/umd/promisify.production.js",
33
+ "import": "./dist/es/promisify.production.js",
34
+ "require": "./dist/cjs/promisify.production.js",
35
+ "node": "./dist/cjs/promisify.production.js",
36
+ "module": "./dist/es/promisify.production.js",
37
+ "default": "./dist/cjs/promisify.production.js"
69
38
  },
70
39
  "development": {
71
- "types": "./types/enforce/compose.d.ts",
72
- "browser": "./dist/es/enforce/compose.development.js",
73
- "umd": "./dist/umd/enforce/compose.development.js",
74
- "import": "./dist/es/enforce/compose.development.js",
75
- "require": "./dist/cjs/enforce/compose.development.js",
76
- "node": "./dist/cjs/enforce/compose.development.js",
77
- "module": "./dist/es/enforce/compose.development.js",
78
- "default": "./dist/cjs/enforce/compose.development.js"
40
+ "types": "./types/promisify.d.ts",
41
+ "browser": "./dist/es/promisify.development.js",
42
+ "umd": "./dist/umd/promisify.development.js",
43
+ "import": "./dist/es/promisify.development.js",
44
+ "require": "./dist/cjs/promisify.development.js",
45
+ "node": "./dist/cjs/promisify.development.js",
46
+ "module": "./dist/es/promisify.development.js",
47
+ "default": "./dist/cjs/promisify.development.js"
79
48
  },
80
- "types": "./types/enforce/compose.d.ts",
81
- "browser": "./dist/es/enforce/compose.production.js",
82
- "umd": "./dist/umd/enforce/compose.production.js",
83
- "import": "./dist/es/enforce/compose.production.js",
84
- "require": "./dist/cjs/enforce/compose.production.js",
85
- "node": "./dist/cjs/enforce/compose.production.js",
86
- "module": "./dist/es/enforce/compose.production.js",
87
- "default": "./dist/cjs/enforce/compose.production.js"
49
+ "types": "./types/promisify.d.ts",
50
+ "browser": "./dist/es/promisify.production.js",
51
+ "umd": "./dist/umd/promisify.production.js",
52
+ "import": "./dist/es/promisify.production.js",
53
+ "require": "./dist/cjs/promisify.production.js",
54
+ "node": "./dist/cjs/promisify.production.js",
55
+ "module": "./dist/es/promisify.production.js",
56
+ "default": "./dist/cjs/promisify.production.js"
88
57
  },
89
- "./enforce/compounds": {
58
+ "./parser": {
90
59
  "production": {
91
- "types": "./types/enforce/compounds.d.ts",
92
- "browser": "./dist/es/enforce/compounds.production.js",
93
- "umd": "./dist/umd/enforce/compounds.production.js",
94
- "import": "./dist/es/enforce/compounds.production.js",
95
- "require": "./dist/cjs/enforce/compounds.production.js",
96
- "node": "./dist/cjs/enforce/compounds.production.js",
97
- "module": "./dist/es/enforce/compounds.production.js",
98
- "default": "./dist/cjs/enforce/compounds.production.js"
60
+ "types": "./types/parser.d.ts",
61
+ "browser": "./dist/es/parser.production.js",
62
+ "umd": "./dist/umd/parser.production.js",
63
+ "import": "./dist/es/parser.production.js",
64
+ "require": "./dist/cjs/parser.production.js",
65
+ "node": "./dist/cjs/parser.production.js",
66
+ "module": "./dist/es/parser.production.js",
67
+ "default": "./dist/cjs/parser.production.js"
99
68
  },
100
69
  "development": {
101
- "types": "./types/enforce/compounds.d.ts",
102
- "browser": "./dist/es/enforce/compounds.development.js",
103
- "umd": "./dist/umd/enforce/compounds.development.js",
104
- "import": "./dist/es/enforce/compounds.development.js",
105
- "require": "./dist/cjs/enforce/compounds.development.js",
106
- "node": "./dist/cjs/enforce/compounds.development.js",
107
- "module": "./dist/es/enforce/compounds.development.js",
108
- "default": "./dist/cjs/enforce/compounds.development.js"
70
+ "types": "./types/parser.d.ts",
71
+ "browser": "./dist/es/parser.development.js",
72
+ "umd": "./dist/umd/parser.development.js",
73
+ "import": "./dist/es/parser.development.js",
74
+ "require": "./dist/cjs/parser.development.js",
75
+ "node": "./dist/cjs/parser.development.js",
76
+ "module": "./dist/es/parser.development.js",
77
+ "default": "./dist/cjs/parser.development.js"
109
78
  },
110
- "types": "./types/enforce/compounds.d.ts",
111
- "browser": "./dist/es/enforce/compounds.production.js",
112
- "umd": "./dist/umd/enforce/compounds.production.js",
113
- "import": "./dist/es/enforce/compounds.production.js",
114
- "require": "./dist/cjs/enforce/compounds.production.js",
115
- "node": "./dist/cjs/enforce/compounds.production.js",
116
- "module": "./dist/es/enforce/compounds.production.js",
117
- "default": "./dist/cjs/enforce/compounds.production.js"
79
+ "types": "./types/parser.d.ts",
80
+ "browser": "./dist/es/parser.production.js",
81
+ "umd": "./dist/umd/parser.production.js",
82
+ "import": "./dist/es/parser.production.js",
83
+ "require": "./dist/cjs/parser.production.js",
84
+ "node": "./dist/cjs/parser.production.js",
85
+ "module": "./dist/es/parser.production.js",
86
+ "default": "./dist/cjs/parser.production.js"
118
87
  },
119
88
  "./enforce/schema": {
120
89
  "production": {
@@ -146,65 +115,95 @@
146
115
  "module": "./dist/es/enforce/schema.production.js",
147
116
  "default": "./dist/cjs/enforce/schema.production.js"
148
117
  },
149
- "./parser": {
118
+ "./enforce/compounds": {
150
119
  "production": {
151
- "types": "./types/parser.d.ts",
152
- "browser": "./dist/es/parser.production.js",
153
- "umd": "./dist/umd/parser.production.js",
154
- "import": "./dist/es/parser.production.js",
155
- "require": "./dist/cjs/parser.production.js",
156
- "node": "./dist/cjs/parser.production.js",
157
- "module": "./dist/es/parser.production.js",
158
- "default": "./dist/cjs/parser.production.js"
120
+ "types": "./types/enforce/compounds.d.ts",
121
+ "browser": "./dist/es/enforce/compounds.production.js",
122
+ "umd": "./dist/umd/enforce/compounds.production.js",
123
+ "import": "./dist/es/enforce/compounds.production.js",
124
+ "require": "./dist/cjs/enforce/compounds.production.js",
125
+ "node": "./dist/cjs/enforce/compounds.production.js",
126
+ "module": "./dist/es/enforce/compounds.production.js",
127
+ "default": "./dist/cjs/enforce/compounds.production.js"
159
128
  },
160
129
  "development": {
161
- "types": "./types/parser.d.ts",
162
- "browser": "./dist/es/parser.development.js",
163
- "umd": "./dist/umd/parser.development.js",
164
- "import": "./dist/es/parser.development.js",
165
- "require": "./dist/cjs/parser.development.js",
166
- "node": "./dist/cjs/parser.development.js",
167
- "module": "./dist/es/parser.development.js",
168
- "default": "./dist/cjs/parser.development.js"
130
+ "types": "./types/enforce/compounds.d.ts",
131
+ "browser": "./dist/es/enforce/compounds.development.js",
132
+ "umd": "./dist/umd/enforce/compounds.development.js",
133
+ "import": "./dist/es/enforce/compounds.development.js",
134
+ "require": "./dist/cjs/enforce/compounds.development.js",
135
+ "node": "./dist/cjs/enforce/compounds.development.js",
136
+ "module": "./dist/es/enforce/compounds.development.js",
137
+ "default": "./dist/cjs/enforce/compounds.development.js"
169
138
  },
170
- "types": "./types/parser.d.ts",
171
- "browser": "./dist/es/parser.production.js",
172
- "umd": "./dist/umd/parser.production.js",
173
- "import": "./dist/es/parser.production.js",
174
- "require": "./dist/cjs/parser.production.js",
175
- "node": "./dist/cjs/parser.production.js",
176
- "module": "./dist/es/parser.production.js",
177
- "default": "./dist/cjs/parser.production.js"
139
+ "types": "./types/enforce/compounds.d.ts",
140
+ "browser": "./dist/es/enforce/compounds.production.js",
141
+ "umd": "./dist/umd/enforce/compounds.production.js",
142
+ "import": "./dist/es/enforce/compounds.production.js",
143
+ "require": "./dist/cjs/enforce/compounds.production.js",
144
+ "node": "./dist/cjs/enforce/compounds.production.js",
145
+ "module": "./dist/es/enforce/compounds.production.js",
146
+ "default": "./dist/cjs/enforce/compounds.production.js"
178
147
  },
179
- "./promisify": {
148
+ "./enforce/compose": {
180
149
  "production": {
181
- "types": "./types/promisify.d.ts",
182
- "browser": "./dist/es/promisify.production.js",
183
- "umd": "./dist/umd/promisify.production.js",
184
- "import": "./dist/es/promisify.production.js",
185
- "require": "./dist/cjs/promisify.production.js",
186
- "node": "./dist/cjs/promisify.production.js",
187
- "module": "./dist/es/promisify.production.js",
188
- "default": "./dist/cjs/promisify.production.js"
150
+ "types": "./types/enforce/compose.d.ts",
151
+ "browser": "./dist/es/enforce/compose.production.js",
152
+ "umd": "./dist/umd/enforce/compose.production.js",
153
+ "import": "./dist/es/enforce/compose.production.js",
154
+ "require": "./dist/cjs/enforce/compose.production.js",
155
+ "node": "./dist/cjs/enforce/compose.production.js",
156
+ "module": "./dist/es/enforce/compose.production.js",
157
+ "default": "./dist/cjs/enforce/compose.production.js"
189
158
  },
190
159
  "development": {
191
- "types": "./types/promisify.d.ts",
192
- "browser": "./dist/es/promisify.development.js",
193
- "umd": "./dist/umd/promisify.development.js",
194
- "import": "./dist/es/promisify.development.js",
195
- "require": "./dist/cjs/promisify.development.js",
196
- "node": "./dist/cjs/promisify.development.js",
197
- "module": "./dist/es/promisify.development.js",
198
- "default": "./dist/cjs/promisify.development.js"
160
+ "types": "./types/enforce/compose.d.ts",
161
+ "browser": "./dist/es/enforce/compose.development.js",
162
+ "umd": "./dist/umd/enforce/compose.development.js",
163
+ "import": "./dist/es/enforce/compose.development.js",
164
+ "require": "./dist/cjs/enforce/compose.development.js",
165
+ "node": "./dist/cjs/enforce/compose.development.js",
166
+ "module": "./dist/es/enforce/compose.development.js",
167
+ "default": "./dist/cjs/enforce/compose.development.js"
199
168
  },
200
- "types": "./types/promisify.d.ts",
201
- "browser": "./dist/es/promisify.production.js",
202
- "umd": "./dist/umd/promisify.production.js",
203
- "import": "./dist/es/promisify.production.js",
204
- "require": "./dist/cjs/promisify.production.js",
205
- "node": "./dist/cjs/promisify.production.js",
206
- "module": "./dist/es/promisify.production.js",
207
- "default": "./dist/cjs/promisify.production.js"
169
+ "types": "./types/enforce/compose.d.ts",
170
+ "browser": "./dist/es/enforce/compose.production.js",
171
+ "umd": "./dist/umd/enforce/compose.production.js",
172
+ "import": "./dist/es/enforce/compose.production.js",
173
+ "require": "./dist/cjs/enforce/compose.production.js",
174
+ "node": "./dist/cjs/enforce/compose.production.js",
175
+ "module": "./dist/es/enforce/compose.production.js",
176
+ "default": "./dist/cjs/enforce/compose.production.js"
177
+ },
178
+ "./classnames": {
179
+ "production": {
180
+ "types": "./types/classnames.d.ts",
181
+ "browser": "./dist/es/classnames.production.js",
182
+ "umd": "./dist/umd/classnames.production.js",
183
+ "import": "./dist/es/classnames.production.js",
184
+ "require": "./dist/cjs/classnames.production.js",
185
+ "node": "./dist/cjs/classnames.production.js",
186
+ "module": "./dist/es/classnames.production.js",
187
+ "default": "./dist/cjs/classnames.production.js"
188
+ },
189
+ "development": {
190
+ "types": "./types/classnames.d.ts",
191
+ "browser": "./dist/es/classnames.development.js",
192
+ "umd": "./dist/umd/classnames.development.js",
193
+ "import": "./dist/es/classnames.development.js",
194
+ "require": "./dist/cjs/classnames.development.js",
195
+ "node": "./dist/cjs/classnames.development.js",
196
+ "module": "./dist/es/classnames.development.js",
197
+ "default": "./dist/cjs/classnames.development.js"
198
+ },
199
+ "types": "./types/classnames.d.ts",
200
+ "browser": "./dist/es/classnames.production.js",
201
+ "umd": "./dist/umd/classnames.production.js",
202
+ "import": "./dist/es/classnames.production.js",
203
+ "require": "./dist/cjs/classnames.production.js",
204
+ "node": "./dist/cjs/classnames.production.js",
205
+ "module": "./dist/es/classnames.production.js",
206
+ "default": "./dist/cjs/classnames.production.js"
208
207
  },
209
208
  ".": {
210
209
  "development": {
@@ -227,8 +226,6 @@
227
226
  "default": "./dist/cjs/vest.production.js"
228
227
  },
229
228
  "./package.json": "./package.json",
230
- "./": "./"
231
- },
232
- "unpkg": "./dist/umd/vest.production.js",
233
- "jsdelivr": "./dist/umd/vest.production.js"
234
- }
229
+ "./*": "./*"
230
+ }
231
+ }
@@ -0,0 +1,7 @@
1
+ import { TFieldName, TGroupName } from 'SuiteResultTypes';
2
+ import * as vest from 'vest';
3
+
4
+ export type TVestMock = typeof vest;
5
+
6
+ export type TTestSuiteCallback = (...args: any[]) => void;
7
+ export type TTestSuite = vest.Suite<TFieldName, TGroupName, TTestSuiteCallback>;
@@ -1,17 +1,17 @@
1
- import { partition } from 'vest-utils';
1
+ import partition from '../partition';
2
2
 
3
3
  describe('partition', () => {
4
4
  it('Should correctly partition array', () => {
5
5
  expect(partition([300, 200, 10, 50, 0, -500], v => v <= 100))
6
6
  .toMatchInlineSnapshot(`
7
- Array [
8
- Array [
7
+ [
8
+ [
9
9
  10,
10
10
  50,
11
11
  0,
12
12
  -500,
13
13
  ],
14
- Array [
14
+ [
15
15
  300,
16
16
  200,
17
17
  ],
@@ -0,0 +1,9 @@
1
+ import { ErrorStrings } from 'ErrorStrings';
2
+ import { invariant } from 'vest-utils';
3
+
4
+ import { IsolateTest } from 'IsolateTest';
5
+
6
+ export function asVestTest(value: any): IsolateTest {
7
+ invariant(value instanceof IsolateTest, ErrorStrings.EXPECTED_VEST_TEST);
8
+ return value;
9
+ }
@@ -1,11 +1,13 @@
1
+ import { TVestMock } from './TVestMock';
2
+
1
3
  export default function mockThrowError() {
2
- const deferThrow = jest.fn();
4
+ const deferThrow = jest.fn<string, any>();
3
5
  jest.resetModules();
4
6
  jest.mock('vest-utils', () => ({
5
7
  ...jest.requireActual('vest-utils'),
6
8
  deferThrow,
7
9
  }));
8
- const vest = require('vest');
10
+ const vest = require('vest') as TVestMock;
9
11
 
10
12
  return {
11
13
  deferThrow,
@@ -2,6 +2,7 @@ import { asArray } from 'vest-utils';
2
2
 
3
3
  import { dummyTest } from './testDummy';
4
4
 
5
+ import { TFieldName, TGroupName } from 'SuiteResultTypes';
5
6
  import { optional, create, skip, SuiteResult } from 'vest';
6
7
 
7
8
  export function failing(failingFields?: string | string[]) {
@@ -103,6 +104,8 @@ function createSuite(
103
104
  });
104
105
  }
105
106
 
106
- export function ser(res: SuiteResult) {
107
+ export function ser<F extends TFieldName, G extends TGroupName>(
108
+ res: SuiteResult<F, G>
109
+ ) {
107
110
  return JSON.parse(JSON.stringify(res));
108
111
  }
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable jest/valid-title */
2
- import faker from 'faker';
2
+ import { faker } from '@faker-js/faker';
3
3
 
4
- import { test, warn } from 'vest';
4
+ import { test as vestTest, warn } from 'vest';
5
5
 
6
6
  /**
7
7
  * Generates dummy vest tests.
@@ -12,7 +12,7 @@ const testDummy = () => {
12
12
  message: string = faker.random.words(),
13
13
  groupName?: string
14
14
  ) => {
15
- const to = test(
15
+ const to = vestTest(
16
16
  name,
17
17
  message,
18
18
  jest.fn(() => {
@@ -32,7 +32,7 @@ const testDummy = () => {
32
32
  message = faker.random.words(),
33
33
  groupName?: string
34
34
  ) => {
35
- const to = test(
35
+ const to = vestTest(
36
36
  name,
37
37
  message,
38
38
  jest.fn(() => {
@@ -53,7 +53,7 @@ const testDummy = () => {
53
53
  message = faker.random.words(),
54
54
  groupName?: string
55
55
  ) => {
56
- const to = test(name, message, jest.fn());
56
+ const to = vestTest(name, message, jest.fn());
57
57
 
58
58
  if (groupName) {
59
59
  to.groupName = groupName;
@@ -67,7 +67,7 @@ const testDummy = () => {
67
67
  message = faker.random.words(),
68
68
  groupName?: string
69
69
  ) => {
70
- const to = test(
70
+ const to = vestTest(
71
71
  name,
72
72
  message,
73
73
  jest.fn(() => {
@@ -84,7 +84,7 @@ const testDummy = () => {
84
84
  name = faker.random.word(),
85
85
  { message = faker.random.words(), time = 0 } = {}
86
86
  ) =>
87
- test(
87
+ vestTest(
88
88
  name,
89
89
  message,
90
90
  jest.fn(
@@ -99,7 +99,7 @@ const testDummy = () => {
99
99
  name = faker.random.word(),
100
100
  { message = faker.random.words(), time = 0 } = {}
101
101
  ) =>
102
- test(
102
+ vestTest(
103
103
  name,
104
104
  message,
105
105
  jest.fn(() => {
@@ -114,7 +114,7 @@ const testDummy = () => {
114
114
  name = faker.random.word(),
115
115
  { message = faker.random.words(), time = 0 } = {}
116
116
  ) =>
117
- test(
117
+ vestTest(
118
118
  name,
119
119
  message,
120
120
  jest.fn(
@@ -129,7 +129,7 @@ const testDummy = () => {
129
129
  name = faker.random.word(),
130
130
  { message = faker.random.words(), time = 0 } = {}
131
131
  ) =>
132
- test(
132
+ vestTest(
133
133
  name,
134
134
  message,
135
135
  jest.fn(() => {
@@ -153,3 +153,5 @@ const testDummy = () => {
153
153
  };
154
154
 
155
155
  export const dummyTest = testDummy();
156
+
157
+ export type TDummyTest = typeof dummyTest;
@@ -0,0 +1,3 @@
1
+ export function TestPromise(cb: (done: () => void) => void): Promise<void> {
2
+ return new Promise<void>(done => cb(done));
3
+ }