vest 4.0.0 → 4.0.2-dev-72921c

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/CHANGELOG.md CHANGED
@@ -4,99 +4,6 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## 4.0.0 - 2021-12-24
8
- ### Changed or removed
9
- - b5a0108 breaking(vest): remove test.each (ealush)
10
- - 7c43eab major(context): used named export in context (ealush)
11
- - e8652bc breaking(vest, enforce): prepare next major (ealush)
12
- - dab8e00 breaking(vest, enforce): prepare next major (ealush)
13
-
14
- ### Added
15
- - 0842334 feat(vest): expose Vest's context for future plugin support (ealush)
16
- - b0a9a14 feat(vest): use key prop to retain test state after reorder (#732) (Evyatar)
17
- - d3e7613 feat(vest): support custom optional logic (ealush)
18
- - be1cbf6 feat(vest): Add a parser export (ealush)
19
- - 2553748 feat(vest): isValid with field name (ealush)
20
- - ec5ceb9 feat(vest): handle execution order state refill with memoized tests (ealush)
21
- - 4032bd8 feat(vest): Make the state rely on execution order. Make skipWhen set skipped context. (undefined)
22
- - 220127b added(n4s): partial rule modifier (undefined)
23
- - b5ce72d feat(n4s): context propagation within enforce (undefined)
24
-
25
- ### Fixed and improved
26
- - 8f006ce types(n4s): extract shape object type (ealush)
27
- - 37dfaaf types(vest): fix redeclaration of _default (ealush)
28
- - packages/vest/src/core/isolate/isolates/each.ts
29
- - 8ba9895 add(vest): omitWhen (#738) (Evyatar)
30
- - 1384c08 fix(vest): only.group works in conjunction with only (#734) (Evyatar)
31
- - README.md
32
- - 7daf6d2 rule(n4s): add isNullish rule, improve isBlank (ealush)
33
- - c4a4140 chore: organize imports (ealush)
34
- - 9f9b970 vx: improve package.json generation (ealush)
35
- - 0370fc1 n4s: extract non-required modules (ealush)
36
- - 03ba92c vx: support namespaced exports (ealush)
37
- - 38a54ae vx: support installing of local packages (ealush)
38
- - 7baedf2 n4s: use named export in entry (ealush)
39
- - 366001b patch(vest): better handling of skipped async tests (ealush)
40
- - 2380679 types(vest): allow unprovided suite name in tests (ealush)
41
- - f721b2d patch(vest): replace warns boolean flag with enum (ealush)
42
- - 0acb24d patch(vest): Pass draft result to skipWhen conditional (ealush)
43
- - e84cd9d patch(vest): add back optional suite name argument (ealush)
44
- - 8b30b66 patch(vest): make compose an external export (ealush)
45
- - ddfa9fd patch(vest): move creation functions to event bus (ealush)
46
- - fe83e88 patch: Some cleanups (ealush)
47
- - 9275707 fix(vest): prevent pending tests from being marked as skipped (ealush)
48
- - 94e00a8 patch(vest): Add isolate module for containing re-orders (ealush)
49
- - 5bcc14a patch(vest): refresh tests after cancel (ealush)
50
- - fd049e8 patch: add cursor util (ealush)
51
- - 9380c09 patch(vest): move cursor into context (ealush)
52
- - 49b72f4 patch(vest): automatically purge not-found test results (ealush)
53
- - 2dfedaf vx: correctly pass cli options to build script (ealush)
54
- - aae250a patch(vest): Throw error when tests are called in the wrong order (ealush)
55
- - a87824b vx: add types to exports (ealush)
56
- - cc9b4b0 organize vest state hooks (ealush)
57
- - df84261 patch(vest): infer omitted optional fields (ealush)
58
- - 2534cf6 vx: add dev bundle to exports (ealush)
59
- - 4d450aa fix(vest): prevent changing test status once it was finalized (ealush)
60
- - 8730e25 patch(vest): add cache invalidation for canceled tests (ealush)
61
- - 4cb2c6c types(vest): add safeguard around shouldUseErrorAsMessage (ealush)
62
- - c214a12 patch(vest): some cleanups (ealush)
63
- - 858458d patch(vest): remove duplicate code handling perv test registration (ealush)
64
- - ec69173 vx: use context directly from published package (ealush)
65
- - 962bc06 patch: run done callbacks via event (ealush)
66
- - d96f428 patch(vest): removed state subscription (ealush)
67
- - package.json
68
- - packages/anyone/package.json
69
- - packages/anyone/package.json
70
- - packages/vast/types/vast.d.ts
71
- - e4e1746 patch(vest): remove pending and lagging state (ealush)
72
- - 9d8fd21 patch(vest): convert boolean flags to a single status key (ealush)
73
- - dbb836e patch: simplify fieldname comparison (ealush)
74
- - 5a78179 patch(vest): add useAllIncomplete hook (ealush)
75
- - b5ae658 patch(vest): invalid accounts for warning tests as well (ealush)
76
- - 4563b8d patch(vest): isValid counts all required tests per field (ealush)
77
- - 3fe2f21 chore: cleanups (ealush)
78
- - .eslintrc.js
79
- - 149aab3 add(n4s): enforce.condition (ealush)
80
- - package.json
81
- - packages/anyone/package.json
82
- - 40ef071 chore: cleanup residue (undefined)
83
- - eeac20e chore: remove duplicate types (undefined)
84
- - packages/anyone/package.json
85
- - 4d88c04 patch: add nodejs exports (undefined)
86
- - 6e57aa1 patch: remove unused exports (undefined)
87
- - packages/anyone/package.json
88
- - 26af06b chore: reduce complexity, remove all lint errors (undefined)
89
- - packages/anyone/.npmignore
90
- - .github/PULL_REQUEST_TEMPLATE.md
91
- - 5be986d chore: cleanup unused code (ealush)
92
- - ba68539 lint: handling lint of all packages (ealush)
93
- - .gitignore
94
- - cca5130 patch(n4s): add ruleReturn default values (ealush)
95
- - 75306ff fix(n4s): make enforce compound runners fall back to correct response (ealush)
96
- - 4751584 fix(n4s): make enforce chaining work (ealush)
97
- - 73b28a1 chore: some lint fixes (ealush)
98
- - 4135ce3 add cli options support (ealush)
99
-
100
7
  ## 3.2.7 - 2021-07-17
101
8
 
102
9
  ### Fixed and improved
package/README.md CHANGED
@@ -1,3 +1,58 @@
1
- # Vest
1
+ # Vest - Declarative validations framework
2
2
 
3
- Home of the Vest source code.
3
+ [Vest Documentation](https://vestjs.dev)
4
+
5
+ [![Join Discord](https://badgen.net/discord/online-members/WmADZpJnSe?icon=discord&label=Discord)](https://discord.gg/WmADZpJnSe) [![Github Stars](https://badgen.net/github/stars/ealush/vest?color=yellow&label=Github%20🌟)](https://github.com/ealush/vest) [![Version](https://badgen.net/npm/v/vest?&icon=npm)](https://www.npmjs.com/package/vest) [![Downloads](https://badgen.net/npm/dt/vest?label=Downloads)](https://www.npmjs.com/package/vest) [![bundlephobia](https://badgen.net/bundlephobia/minzip/vest)](https://bundlephobia.com/package/vest) [![Status](https://badgen.net/github/status/ealush/vest)](https://github.com/ealush/vest/actions)
6
+
7
+ ![Vest](https://cdn.jsdelivr.net/gh/ealush/vest@assets/logo_250.png 'Vest')
8
+
9
+ Vest is a form-validation framework inspired by unit testing libraries like Mocha or Jest; It is designed to be easy to use and easy to learn by introducing their declarative syntax.
10
+
11
+ The idea behind Vest is that your validations can be described as a suite - a contract that reflects your form or feature structure. Vest is framework agnostic, meaning it can be used with any UI framework, or without any framework at all.
12
+
13
+ Using Vest for form validation can reduce bloat, improve feature readability and maintainability.
14
+
15
+ ```js
16
+ test('username', 'Username is required', () => {
17
+ enforce(data.username).isNotBlank();
18
+ });
19
+
20
+ test('username', 'Username must be at least 3 chars', () => {
21
+ enforce(data.username).longerThanOrEquals(3);
22
+ });
23
+ ```
24
+
25
+ ## Installation
26
+
27
+ ```
28
+ npm i vest
29
+ ```
30
+
31
+ ## Motivation
32
+
33
+ Writing forms is an integral part of building web apps, and even though it may seem trivial at first - as your feature grows over time, so does your validation logic grows in complexity.
34
+
35
+ Vest tries to remediate this by separating validation logic from feature logic, so it's easier to maintain over time and refactor when needed.
36
+
37
+ # Why Vest?
38
+
39
+ 💡 Vest is easy to Learn. Vest adopts the syntax and style of unit testing frameworks, so you can leverage the knowledge you already have to write your form validations.
40
+
41
+ 🎨 Vest is framework agnostic. You can use Vest with any UI framework out there.
42
+
43
+ 🧠 Vest takes care of all the annoying parts for you. It manages its validation state, handles async validations, and much more.
44
+
45
+ 🧩 Vest is extendable. You can easily add new kinds of validations to Vest according to your needs.
46
+
47
+ ♻️ Validation logic in Vest can be shared across multiple features in your app.
48
+
49
+ # Getting Started
50
+
51
+ [Vest Documentation](https://vestjs.dev)
52
+
53
+ Here are some code sandboxes to get you started:
54
+
55
+ - [React](https://codesandbox.io/s/react-28jwx)
56
+ - [Vue](https://codesandbox.io/s/vue-hsyt8)
57
+ - [Svelte](https://codesandbox.io/s/svelte-tsfhx)
58
+ - [Vanilla](https://codesandbox.io/s/vest-vanilla-js-35u8e)
@@ -187,6 +187,7 @@ var context = context$1.createContext(function (ctxRef, parentContext) {
187
187
  tests: {},
188
188
  groups: {}
189
189
  },
190
+ inclusion: {},
190
191
  isolate: {
191
192
  type: IsolateTypes.DEFAULT,
192
193
  keys: {
@@ -753,7 +754,7 @@ function __spreadArray(to, from, pack) {
753
754
  ar[i] = from[i];
754
755
  }
755
756
  }
756
- return to.concat(ar || from);
757
+ return to.concat(ar || Array.prototype.slice.call(from));
757
758
  }
758
759
 
759
760
  function either(a, b) {
@@ -1264,13 +1265,14 @@ function isExcludedIndividually() {
1264
1265
  return !!context.useX().skipped;
1265
1266
  }
1266
1267
  //Checks whether a certain test profile excluded by any of the exclusion groups.
1267
- // eslint-disable-next-line complexity, max-statements
1268
+ // eslint-disable-next-line complexity, max-statements, max-lines-per-function
1268
1269
  function isExcluded(testObject) {
1269
1270
  var fieldName = testObject.fieldName, groupName = testObject.groupName;
1270
1271
  if (isExcludedIndividually())
1271
1272
  return true;
1272
1273
  var context$1 = context.useX();
1273
1274
  var exclusion = context$1.exclusion;
1275
+ var inclusion = context$1.inclusion;
1274
1276
  var keyTests = exclusion.tests;
1275
1277
  var testValue = keyTests[fieldName];
1276
1278
  // if test is skipped
@@ -1300,8 +1302,12 @@ function isExcluded(testObject) {
1300
1302
  if (isTestIncluded)
1301
1303
  return false;
1302
1304
  // If there is _ANY_ `only`ed test (and we already know this one isn't) return true
1303
- // Otherwise return false
1304
- return hasIncludedTests(keyTests);
1305
+ if (hasIncludedTests(keyTests)) {
1306
+ // Check if inclusion rules for this field (`include` hook)
1307
+ return !optionalFunctionValue(inclusion[fieldName]);
1308
+ }
1309
+ // We're done here. This field is not excluded
1310
+ return false;
1305
1311
  }
1306
1312
  // eslint-disable-next-line max-statements
1307
1313
  function isMissingFromIncludedGroup(groupName) {
@@ -1406,6 +1412,29 @@ function throwGroupError(error) {
1406
1412
  throwError("Wrong arguments passed to group. Group " + error + ".");
1407
1413
  }
1408
1414
 
1415
+ function include(fieldName) {
1416
+ var context$1 = context.useX();
1417
+ var inclusion = context$1.inclusion, exclusion = context$1.exclusion;
1418
+ if (!fieldName) {
1419
+ return { when: when };
1420
+ }
1421
+ inclusion[fieldName] = defaultTo(exclusion.tests[fieldName], true);
1422
+ return { when: when };
1423
+ function when(condition) {
1424
+ var context$1 = context.useX();
1425
+ var inclusion = context$1.inclusion, exclusion = context$1.exclusion;
1426
+ inclusion[fieldName] = function () {
1427
+ if (hasOwnProperty(exclusion.tests, fieldName)) {
1428
+ return defaultTo(exclusion.tests[fieldName], true);
1429
+ }
1430
+ if (isStringValue(condition)) {
1431
+ return Boolean(exclusion.tests[condition]);
1432
+ }
1433
+ return optionalFunctionValue(condition, optionalFunctionValue(produceDraft));
1434
+ };
1435
+ }
1436
+ }
1437
+
1409
1438
  /**
1410
1439
  * Conditionally omits tests from the suite.
1411
1440
  *
@@ -1684,6 +1713,7 @@ function registerTestObjectByTier(testObject) {
1684
1713
  }
1685
1714
  }
1686
1715
 
1716
+ /* eslint-disable jest/valid-title */
1687
1717
  // eslint-disable-next-line max-lines-per-function
1688
1718
  function bindTestMemo(test) {
1689
1719
  var cache = createCache(100); // arbitrary cache size
@@ -1761,7 +1791,7 @@ function warn() {
1761
1791
  ctx.currentTest.warn();
1762
1792
  }
1763
1793
 
1764
- var VERSION = "3.3.0";
1794
+ var VERSION = "4.0.2-dev-72921c";
1765
1795
 
1766
1796
  Object.defineProperty(exports, 'enforce', {
1767
1797
  enumerable: true,
@@ -1774,6 +1804,7 @@ exports.context = context;
1774
1804
  exports.create = create;
1775
1805
  exports.each = each;
1776
1806
  exports.group = group;
1807
+ exports.include = include;
1777
1808
  exports.omitWhen = omitWhen;
1778
1809
  exports.only = only;
1779
1810
  exports.optional = optional;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n,t,r=require("n4s"),e=require("context"),u=Object.assign,i=(n=0,function(){return""+n++});function o(n){return"function"==typeof n}function s(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return o(n)?n.apply(void 0,t):n}function c(n,t){var r;return null!==(r=s(n))&&void 0!==r?r:t}function a(n,t){throw Error(c(t,n))}function f(n,t){setTimeout((function(){a(n,t)}),0)}function l(n){function t(n,t,u){return e.references.push(),r(n,s(t,u)),function(){return[e.references[n],function(t){return r(n,s(t,e.references[n]))}]}}function r(t,r){var i=e.references[t];e.references[t]=r,o(t=u[t][1])&&t(r,i),o(n)&&n()}var e={references:[]},u=[];return{registerStateKey:function(n,r){var e=u.length;return u.push([n,r]),t(e,n)},reset:function(){var n=e.references;e.references=[],u.forEach((function(r,e){return t(e,r[0],n[e])}))}}}function p(n,t){var r=t.suiteId;return t=t.suiteName,{optionalFields:n.registerStateKey((function(){return{}})),suiteId:n.registerStateKey(r),suiteName:n.registerStateKey(t),testCallbacks:n.registerStateKey((function(){return{fieldCallbacks:{},doneCallbacks:[]}})),testObjects:n.registerStateKey((function(n){return{prev:n?n.current:[],current:[]}}))}}function v(n){return[].concat(n)}function d(n){return(n=v(n))[n.length-1]}function g(){function n(){t=[0]}var t=[];return n(),{addLevel:function(){t.push(0)},cursorAt:function(){return d(t)},getCursor:function(){return v(t)},next:function(){return t[t.length-1]++,d(t)},removeLevel:function(){t.pop()},reset:n}}!function(n){n[n.DEFAULT=0]="DEFAULT",n[n.SUITE=1]="SUITE",n[n.EACH=2]="EACH",n[n.SKIP_WHEN=3]="SKIP_WHEN",n[n.OMIT_WHEN=4]="OMIT_WHEN",n[n.GROUP=5]="GROUP"}(t||(t={}));var h=e.createContext((function(n,r){return r?null:u({},{exclusion:{tests:{},groups:{}},isolate:{type:t.DEFAULT,keys:{current:{},prev:{}}},testCursor:g()},n)}));function m(n){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return!n.apply(void 0,t)}}function y(n){return!!Array.isArray(n)}function E(n){return null===n}var N=m(E);function b(n,t){for(var r=[],e=0;e<n.length;e++){var u=n[e];y(u)?r.push(b(u,t)):(u=t(u),N(u)&&r.push(u))}return r}function C(n,t,r){return k(n,t)[d(t)]=r,n}function T(n){return v(n).reduce((function(n,t){return y(t)?n.concat(T(t)):v(n).concat(t)}),[])}function k(n,t){var r=0;for(t=t.slice(0,-1);r<t.length;r++){var e=t[r];n[e]=c(n[e],[]),n=n[e]}return n}function S(n){return void 0===n}function O(n){return E(n)||S(n)}function P(n){return String(n)===n}function x(n,t){return S(n)&&P(t)}function I(n,t){return n.length===Number(t)}function w(n){void 0===n&&(n=1);var t=[],r=function(e,u){var i=r.get(e);return i?i[1]:(u=u(),t.unshift([e.concat(),u]),function(n,t){return n.length>Number(t)}(t,n)&&(t.length=n),u)};return r.invalidate=function(n){var r=t.findIndex((function(t){var r=t[0];return I(n,r.length)&&n.every((function(n,t){return n===r[t]}))}));-1<r&&t.splice(r,1)},r.get=function(n){return t[t.findIndex((function(t){var r=t[0];return I(n,r.length)&&n.every((function(n,t){return n===r[t]}))}))]||null},r}function F(){return h.useX().stateRef}function W(){return F().suiteId()[0]}function _(){return F().testCallbacks()}function D(){return F().optionalFields()}function L(){return F().testObjects()}function A(){(0,L()[1])((function(n){return{prev:n.prev,current:v(n.current)}}))}function X(n){(0,L()[1])((function(t){return{prev:t.prev,current:v(n(t.current))}}))}function U(){return T(b(L()[0].current,(function(n){return n.isPending()?n:null})))}var M,R=w();function G(){var n=L()[0].current;return R([n],(function(){return T(n)}))}!function(n){n.Error="error",n.Warning="warning"}(M||(M={}));var j=function(){function n(n,t,r){var e=void 0===r?{}:r;r=e.message;var u=e.groupName;e=e.key,this.key=null,this.id=i(),this.severity=M.Error,this.status=H,this.fieldName=n,this.testFn=t,u&&(this.groupName=u),r&&(this.message=r),e&&(this.key=e)}return n.prototype.run=function(){try{var n=this.testFn()}catch(t){x(this.message,t)&&(this.message=t),n=!1}return!1===n&&this.fail(),n},n.prototype.setStatus=function(n){this.isFinalStatus()&&n!==J||(this.status=n)},n.prototype.warns=function(){return this.severity===M.Warning},n.prototype.setPending=function(){this.setStatus(Y)},n.prototype.fail=function(){this.setStatus(this.warns()?B:V)},n.prototype.done=function(){this.isFinalStatus()||this.setStatus(q)},n.prototype.warn=function(){this.severity=M.Warning},n.prototype.isFinalStatus=function(){return this.hasFailures()||this.isCanceled()||this.isPassing()},n.prototype.skip=function(n){this.isPending()&&!n||this.setStatus(K)},n.prototype.cancel=function(){this.setStatus(z),A()},n.prototype.omit=function(){this.setStatus(J)},n.prototype.valueOf=function(){return!this.isFailing()},n.prototype.hasFailures=function(){return this.isFailing()||this.isWarning()},n.prototype.isNonActionable=function(){return this.isSkipped()||this.isOmitted()||this.isCanceled()},n.prototype.isPending=function(){return this.status===Y},n.prototype.isTested=function(){return this.hasFailures()||this.isPassing()},n.prototype.isOmitted=function(){return this.status===J},n.prototype.isUntested=function(){return this.status===H},n.prototype.isFailing=function(){return this.status===V},n.prototype.isCanceled=function(){return this.status===z},n.prototype.isSkipped=function(){return this.status===K},n.prototype.isPassing=function(){return this.status===q},n.prototype.isWarning=function(){return this.status===B},n}(),H="UNTESTED",K="SKIPPED",V="FAILED",B="WARNING",q="PASSING",Y="PENDING",z="CANCELED",J="OMITTED";function Q(){return h.useX().testCursor.getCursor()}function Z(){return h.useX().testCursor.cursorAt()}function $(){return h.useX().testCursor.next()}function nn(n,r){if(n=void 0===(n=n.type)?t.DEFAULT:n,o(r)){var e={current:{},prev:{}},u=Q();return h.run({isolate:{type:n,keys:e}},(function(){h.useX().testCursor.addLevel(),e.prev=v(k(L()[0].prev,Q())).reduce((function(n,t){return t instanceof j&&!O(t.key)?(n[t.key]=t,n):n}),{}),X((function(n){return C(n,u,[])}));var n=r();return h.useX().testCursor.removeLevel(),$(),n}))}}function tn(n,t){return Object.prototype.hasOwnProperty.call(n,t)}function rn(n){if(n){if(function(n){return"number"==typeof n}(n))return 0===n;if(tn(n,"length"))return I(n,0);if("object"==typeof n)return I(Object.keys(n),0)}return!0}var en=m(rn);function un(n,t){return!!t&&!on(n,t)}function on(n,t){return!(!t||n.fieldName!==t)}function sn(n){var t=U();return!rn(t)&&(n?t.some((function(t){return on(t,n)})):en(t))}function cn(n,t){function r(n,t){i[n]++,u&&(i[t]=(i[t]||[]).concat(u))}var e=t.fieldName,u=t.message;n[e]=n[e]||{errorCount:0,warnCount:0,testCount:0};var i=n[e];return t.isNonActionable()||(n[e].testCount++,t.isFailing()?r("errorCount","errors"):t.isWarning()&&r("warnCount","warnings")),i}var an=function(){return(an=Object.assign||function(n){for(var t,r=1,e=arguments.length;r<e;r++)for(var u in t=arguments[r])Object.prototype.hasOwnProperty.call(t,u)&&(n[u]=t[u]);return n}).apply(this,arguments)};function fn(n,t,r){if(r||2===arguments.length)for(var e,u=0,i=t.length;u<i;u++)!e&&u in t||(e||(e=Array.prototype.slice.call(t,0,u)),e[u]=t[u]);return n.concat(e||t)}function ln(n,t){return function(n,t){return!!n!=!!t}("warnings"===n,t.warns())}function pn(n,t,r){var e;void 0===r&&(r={});var u=(r=r||{}).group,i=r.fieldName;return t.reduce((function(t,r){return function(n,t,r,e){return!!(function(n,t){return!(!t||n.groupName===t)}(n,r)||un(n,e)||ln(t,n))}(r,n,u,i)||!r.hasFailures()||(t[r.fieldName]=(t[r.fieldName]||[]).concat(r.message||[])),t}),an({},i&&((e={})[i]=[],e)))}function vn(n,t){return t?n[t]:n}function dn(n){return hn("errors",n)}function gn(n){return hn("warnings",n)}function hn(n,t){return vn(n=pn(n,G(),{fieldName:t}),t)}function mn(n,t){return vn(n=En("errors",n,t),t)}function yn(n,t){return vn(n=En("warnings",n,t),t)}function En(n,t,r){return t||a("get"+n[0].toUpperCase()+n.slice(1)+"ByGroup requires a group name. Received `"+t+"` instead."),pn(n,G(),{group:t,fieldName:r})}function Nn(n,t,r){return!(!n.hasFailures()||un(n,r)||ln(t,n))}function bn(n){return Tn("errors",n)}function Cn(n){return Tn("warnings",n)}function Tn(n,t){return G().some((function(r){return Nn(r,n,t)}))}function kn(n,t){return On("errors",n,t)}function Sn(n,t){return On("warnings",n,t)}function On(n,t,r){return G().some((function(e){return t===e.groupName&&Nn(e,n,r)}))}function Pn(n,t){return!!function(n){var t=G().reduce((function(n,t){return n[t.fieldName]||t.isOmitted()&&(n[t.fieldName]=!0),n}),{});return!!n&&!!t[n]}(t)||!n.hasErrors(t)&&(!(rn(G())||function(n,t){return!!t&&rn(n.tests[t])}(n,t)||function(n){var t=D()[0];return en(U().filter((function(r){return!un(r,n)&&!0!==t[r.fieldName]})))}(t))&&function(n){var t=G(),r=D()[0];return t.every((function(t){return!!un(t,n)||(!0===r[t.fieldName]||t.isTested()||t.isOmitted())}))}(t))}var xn=w(20);function In(){var n=G(),t={stateRef:F()};return xn([n],h.bind(t,(function(){var n=F().suiteName()[0];return u(function(){var n={errorCount:0,groups:{},testCount:0,tests:{},warnCount:0};return G().forEach((function(t){var r=t.fieldName,e=t.groupName;n.tests[r]=cn(n.tests,t),e&&(n.groups[e]=n.groups[e]||{},n.groups[e][r]=cn(n.groups[e],t))})),function(n){for(var t in n.tests)n.errorCount+=n.tests[t].errorCount,n.warnCount+=n.tests[t].warnCount,n.testCount+=n.tests[t].testCount;return n}(n)}(),{getErrors:h.bind(t,dn),getErrorsByGroup:h.bind(t,mn),getWarnings:h.bind(t,gn),getWarningsByGroup:h.bind(t,yn),hasErrors:h.bind(t,bn),hasErrorsByGroup:h.bind(t,kn),hasWarnings:h.bind(t,Cn),hasWarningsByGroup:h.bind(t,Sn),isValid:h.bind(t,(function(n){return Pn(In(),n)})),suiteName:n})})))}var wn=w(20);function Fn(){var n=G(),t={stateRef:F()};return wn([n],h.bind(t,(function(){return u({},In(),{done:h.bind(t,Ln)})})))}function Wn(n,t,r){return!(o(n)&&(!t||r.tests[t]&&!rn(r.tests[t].testCount)))}function _n(n){return!(sn()&&(!n||sn(n)))}var Dn,Ln=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var r=(n=n.reverse())[0];if(n=n[1],t=Fn(),Wn(r,n,t))return t;var e=function(){return r(In())};return _n(n)?(e(),t):(An(e,n),t)};function An(n,t){var r=h.bind({},n);(0,_()[1])((function(n){return t?n.fieldCallbacks[t]=(n.fieldCallbacks[t]||[]).concat(r):n.doneCallbacks.push(r),n}))}function Xn(n){return n.forEach((function(n){return n()}))}function Un(){var n=function(){var n={};return{emit:function(t,r){n[t]&&n[t].forEach((function(n){n(r)}))},on:function(t,r){return n[t]||(n[t]=[]),n[t].push(r),{off:function(){n[t]=n[t].filter((function(n){return n!==r}))}}}}}();return n.on(Dn.TEST_COMPLETED,(function(n){n.isCanceled()||(n.done(),function(n){var t=_()[0].fieldCallbacks;n&&!sn(n)&&y(t[n])&&Xn(t[n])}(n.fieldName),function(){var n=_()[0].doneCallbacks;sn()||Xn(n)}())})),n.on(Dn.SUITE_COMPLETED,(function(){!function(){var n=D()[0];if(!rn(n)){var t={};X((function(r){return b(r,(function(r){var e=r.fieldName;if(t.hasOwnProperty(e))t[r.fieldName]&&r.omit();else{var u=n[e];o(u)&&(t[e]=u(),t[r.fieldName]&&r.omit())}return r}))}))}}()})),n.on(Dn.REMOVE_FIELD,(function(n){G().forEach((function(t){on(t,n)&&(t.cancel(),function(n){X((function(t){return b(t,(function(t){return n!==t?t:null}))}))}(t))}))})),n}function Mn(){var n=h.useX();return n.bus||a(),n.bus}!function(n){n.TEST_COMPLETED="test_completed",n.REMOVE_FIELD="remove_field",n.SUITE_COMPLETED="suite_completed"}(Dn||(Dn={}));function Rn(n){return Kn(0,"tests",n)}function Gn(n){return Kn(1,"tests",n)}function jn(){return!!h.useX().skipped}function Hn(n){var t=n.fieldName;if(n=n.groupName,jn())return!0;var r=h.useX().exclusion,e=r.tests,u=e[t];if(!1===u)return!0;if(u=!0===u,n){if(function(n){var t=h.useX().exclusion.groups;if(tn(t,n))return!1===t[n];for(var r in t)if(!0===t[r])return!0;return!1}(n))return!0;if(!0===r.groups[n])return!u&&(!!Vn(e)||!1===e[t])}return!!function(n){var t=h.useX().exclusion;return!!function(){var n,t=h.useX().exclusion;for(n in t.groups)if(t.groups[n])return!0;return!1}()&&(!n||(!(n in t.groups)||!t.groups[n]))}(n)||!u&&Vn(e)}function Kn(n,t,r){var e=h.useX("hook called outside of a running suite.");r&&v(r).forEach((function(r){P(r)&&(e.exclusion[t][r]=0===n)}))}function Vn(n){for(var t in n)if(!0===n[t])return!0;return!1}function Bn(n){a("Wrong arguments passed to group. Group "+n+".")}Rn.group=function(n){return Kn(0,"groups",n)},Gn.group=function(n){return Kn(1,"groups",n)};var qn=m(P);function Yn(n){return n&&o(n.then)}function zn(n,t){return n.fieldName===t.fieldName&&n.groupName===t.groupName}function Jn(n){var t=n.asyncTest,r=n.message;if(Yn(t)){var e=Mn().emit,u=F(),i=h.bind({stateRef:u},(function(){A(),e(Dn.TEST_COMPLETED,n)}));u=h.bind({stateRef:u},(function(t){n.isCanceled()||(n.message=P(t)?t:r,n.fail(),i())}));try{t.then(i,u)}catch(n){u()}}}function Qn(n){var t=Mn(),r=function(n){return h.run({currentTest:n},(function(){try{var t=n.testFn()}catch(r){x(n.message,r)&&(n.message=r),t=!1}return!1===t&&n.fail(),t}))}(n);try{Yn(r)?(n.asyncTest=r,n.setPending(),Jn(n)):t.emit(Dn.TEST_COMPLETED,n)}catch(t){a("Your test function "+n.fieldName+' returned a value. Only "false" or Promise returns are supported.')}}function Zn(n){var r=L()[0].prev;return rn(r)?($n(n),n):(r=function(n){var t=Q();return function(n,t){return k(n,t)[d(t)]}(n,t)}(r),O(n.key)?(function(n,t){return en(n)&&!zn(n,t)}(r,n)&&(function(n,r){h.useX().isolate.type===t.EACH||f("Vest Critical Error: Tests called in different order than previous run.\n expected: "+n.fieldName+"\n received: "+r.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.')}(r,n),function(){var n=L(),t=n[1],r=n[0].prev;n=k(r,Q());var e=Z();n.splice(e),t((function(n){return{prev:r,current:n.current}}))}(),r=null),$n(n=c(r,n)),n):($n(n=function(n,t){var r=function(n){return h.useX().isolate.keys.prev[n]}(n);return r&&(t=r),function(n,t){var r=h.useX().isolate.keys.current;O(r[n])?r[n]=t:f('Encountered the same test key "'+n+"\" twice. This may lead to tests overriding each other's results, or to tests being unexpectedly omitted.")}(n,t),t}(n.key,n)),n))}function $n(n){var t=Q();X((function(r){return C(r,t,n)}))}function nt(n){var t=Zn(n);return h.useX().omitted?(t.omit(),$(),t):Hn(n)?(t.skip(jn()),$(),t):(function(n,t){t!==n&&zn(n,t)&&n.isPending()&&n.cancel()}(t,n),$n(n),$(),function(n){n.isUntested()?Qn(n):Yn(n.asyncTest)&&(n.setPending(),Jn(n))}(n),n)}function tt(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var e=o(t[1])?t:fn([void 0],t);t=e[0],r=e[1],e=e[2],qn(n)&&et("fieldName","string"),o(r)||et("Test callback","function");var u=h.useX();return nt(t=new j(n,r,{message:t,groupName:u.groupName,key:e}))}var rt=u(tt,{memo:function(n){var t=w(100);return function(r){for(var e=[],u=1;u<arguments.length;u++)e[u-1]=arguments[u];u=Z();var i=(e=e.reverse())[0],o=e[1],s=e[2];return u=[W(),r,u].concat(i),E(e=t.get(u))?t(u,(function(){return n(r,s,o)})):e[1].isCanceled()?(t.invalidate(u),t(u,(function(){return n(r,s,o)}))):nt(e[1])}}(tt)});function et(n,t){a("Incompatible params passed to test function. "+n+" must be a "+t)}Object.defineProperty(exports,"enforce",{enumerable:!0,get:function(){return r.enforce}}),exports.VERSION="3.3.0",exports.context=h,exports.create=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var e=(n=n.reverse())[0];n=n[1],o(e)||a("vest.create: Expected callback to be a function.");var s=Un(),c=l();return n={stateRef:p(c,{suiteId:i(),suiteName:n}),bus:s},u(h.bind(n,(function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return c.reset(),nn({type:t.SUITE},(function(){e.apply(void 0,n)})),s.emit(Dn.SUITE_COMPLETED),Fn()})),{get:h.bind(n,In),reset:c.reset,remove:h.bind(n,(function(n){s.emit(Dn.REMOVE_FIELD,n)}))})},exports.each=function(n,r){o(r)||a("callback must be a function"),nn({type:t.EACH},(function(){n.forEach((function(n,t){r(n,t)}))}))},exports.group=function(n,r){P(n)||Bn("name must be a string"),o(r)||Bn("callback must be a function"),nn({type:t.GROUP},(function(){h.run({groupName:n},r)}))},exports.omitWhen=function(n,r){nn({type:t.OMIT_WHEN},(function(){h.run({omitted:s(n,s(In))},(function(){return r()}))}))},exports.only=Rn,exports.optional=function(n){(0,D()[1])((function(t){if(y(n)||P(n))v(n).forEach((function(n){t[n]=!0}));else for(var r in n)t[r]=n[r];return t}))},exports.skip=Gn,exports.skipWhen=function(n,r){nn({type:t.SKIP_WHEN},(function(){h.run({skipped:s(n,s(In))},(function(){return r()}))}))},exports.test=rt,exports.warn=function(){var n=h.useX("warn hook called outside of a running suite.");n.currentTest||a("warn called outside of a test."),n.currentTest.warn()};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n,t,e=require("n4s"),r=require("context"),u=Object.assign,i=(n=0,function(){return""+n++});function o(n){return"function"==typeof n}function s(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return o(n)?n.apply(void 0,t):n}function c(n,t){var e;return null!==(e=s(n))&&void 0!==e?e:t}function a(n,t){throw Error(c(t,n))}function f(n,t){setTimeout((function(){a(n,t)}),0)}function l(n){function t(n,t,u){return r.references.push(),e(n,s(t,u)),function(){return[r.references[n],function(t){return e(n,s(t,r.references[n]))}]}}function e(t,e){var i=r.references[t];r.references[t]=e,o(t=u[t][1])&&t(e,i),o(n)&&n()}var r={references:[]},u=[];return{registerStateKey:function(n,e){var r=u.length;return u.push([n,e]),t(r,n)},reset:function(){var n=r.references;r.references=[],u.forEach((function(e,r){return t(r,e[0],n[r])}))}}}function p(n,t){var e=t.suiteId;return t=t.suiteName,{optionalFields:n.registerStateKey((function(){return{}})),suiteId:n.registerStateKey(e),suiteName:n.registerStateKey(t),testCallbacks:n.registerStateKey((function(){return{fieldCallbacks:{},doneCallbacks:[]}})),testObjects:n.registerStateKey((function(n){return{prev:n?n.current:[],current:[]}}))}}function v(n){return[].concat(n)}function d(n){return(n=v(n))[n.length-1]}function g(){function n(){t=[0]}var t=[];return n(),{addLevel:function(){t.push(0)},cursorAt:function(){return d(t)},getCursor:function(){return v(t)},next:function(){return t[t.length-1]++,d(t)},removeLevel:function(){t.pop()},reset:n}}!function(n){n[n.DEFAULT=0]="DEFAULT",n[n.SUITE=1]="SUITE",n[n.EACH=2]="EACH",n[n.SKIP_WHEN=3]="SKIP_WHEN",n[n.OMIT_WHEN=4]="OMIT_WHEN",n[n.GROUP=5]="GROUP"}(t||(t={}));var h=r.createContext((function(n,e){return e?null:u({},{exclusion:{tests:{},groups:{}},inclusion:{},isolate:{type:t.DEFAULT,keys:{current:{},prev:{}}},testCursor:g()},n)}));function m(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return!n.apply(void 0,t)}}function y(n){return!!Array.isArray(n)}function E(n){return null===n}var N=m(E);function b(n,t){for(var e=[],r=0;r<n.length;r++){var u=n[r];y(u)?e.push(b(u,t)):(u=t(u),N(u)&&e.push(u))}return e}function C(n,t,e){return k(n,t)[d(t)]=e,n}function T(n){return v(n).reduce((function(n,t){return y(t)?n.concat(T(t)):v(n).concat(t)}),[])}function k(n,t){var e=0;for(t=t.slice(0,-1);e<t.length;e++){var r=t[e];n[r]=c(n[r],[]),n=n[r]}return n}function S(n){return void 0===n}function O(n){return E(n)||S(n)}function x(n){return String(n)===n}function P(n,t){return S(n)&&x(t)}function I(n,t){return n.length===Number(t)}function w(n){void 0===n&&(n=1);var t=[],e=function(r,u){var i=e.get(r);return i?i[1]:(u=u(),t.unshift([r.concat(),u]),function(n,t){return n.length>Number(t)}(t,n)&&(t.length=n),u)};return e.invalidate=function(n){var e=t.findIndex((function(t){var e=t[0];return I(n,e.length)&&n.every((function(n,t){return n===e[t]}))}));-1<e&&t.splice(e,1)},e.get=function(n){return t[t.findIndex((function(t){var e=t[0];return I(n,e.length)&&n.every((function(n,t){return n===e[t]}))}))]||null},e}function F(){return h.useX().stateRef}function W(){return F().suiteId()[0]}function X(){return F().testCallbacks()}function _(){return F().optionalFields()}function A(){return F().testObjects()}function D(){(0,A()[1])((function(n){return{prev:n.prev,current:v(n.current)}}))}function L(n){(0,A()[1])((function(t){return{prev:t.prev,current:v(n(t.current))}}))}function U(){return T(b(A()[0].current,(function(n){return n.isPending()?n:null})))}var M,R=w();function G(){var n=A()[0].current;return R([n],(function(){return T(n)}))}!function(n){n.Error="error",n.Warning="warning"}(M||(M={}));var j=function(){function n(n,t,e){var r=void 0===e?{}:e;e=r.message;var u=r.groupName;r=r.key,this.key=null,this.id=i(),this.severity=M.Error,this.status=H,this.fieldName=n,this.testFn=t,u&&(this.groupName=u),e&&(this.message=e),r&&(this.key=r)}return n.prototype.run=function(){try{var n=this.testFn()}catch(t){P(this.message,t)&&(this.message=t),n=!1}return!1===n&&this.fail(),n},n.prototype.setStatus=function(n){this.isFinalStatus()&&n!==J||(this.status=n)},n.prototype.warns=function(){return this.severity===M.Warning},n.prototype.setPending=function(){this.setStatus(Y)},n.prototype.fail=function(){this.setStatus(this.warns()?B:V)},n.prototype.done=function(){this.isFinalStatus()||this.setStatus(q)},n.prototype.warn=function(){this.severity=M.Warning},n.prototype.isFinalStatus=function(){return this.hasFailures()||this.isCanceled()||this.isPassing()},n.prototype.skip=function(n){this.isPending()&&!n||this.setStatus(K)},n.prototype.cancel=function(){this.setStatus(z),D()},n.prototype.omit=function(){this.setStatus(J)},n.prototype.valueOf=function(){return!this.isFailing()},n.prototype.hasFailures=function(){return this.isFailing()||this.isWarning()},n.prototype.isNonActionable=function(){return this.isSkipped()||this.isOmitted()||this.isCanceled()},n.prototype.isPending=function(){return this.status===Y},n.prototype.isTested=function(){return this.hasFailures()||this.isPassing()},n.prototype.isOmitted=function(){return this.status===J},n.prototype.isUntested=function(){return this.status===H},n.prototype.isFailing=function(){return this.status===V},n.prototype.isCanceled=function(){return this.status===z},n.prototype.isSkipped=function(){return this.status===K},n.prototype.isPassing=function(){return this.status===q},n.prototype.isWarning=function(){return this.status===B},n}(),H="UNTESTED",K="SKIPPED",V="FAILED",B="WARNING",q="PASSING",Y="PENDING",z="CANCELED",J="OMITTED";function Q(){return h.useX().testCursor.getCursor()}function Z(){return h.useX().testCursor.cursorAt()}function $(){return h.useX().testCursor.next()}function nn(n,e){if(n=void 0===(n=n.type)?t.DEFAULT:n,o(e)){var r={current:{},prev:{}},u=Q();return h.run({isolate:{type:n,keys:r}},(function(){h.useX().testCursor.addLevel(),r.prev=v(k(A()[0].prev,Q())).reduce((function(n,t){return t instanceof j&&!O(t.key)?(n[t.key]=t,n):n}),{}),L((function(n){return C(n,u,[])}));var n=e();return h.useX().testCursor.removeLevel(),$(),n}))}}function tn(n,t){return Object.prototype.hasOwnProperty.call(n,t)}function en(n){if(n){if(function(n){return"number"==typeof n}(n))return 0===n;if(tn(n,"length"))return I(n,0);if("object"==typeof n)return I(Object.keys(n),0)}return!0}var rn=m(en);function un(n,t){return!!t&&!on(n,t)}function on(n,t){return!(!t||n.fieldName!==t)}function sn(n){var t=U();return!en(t)&&(n?t.some((function(t){return on(t,n)})):rn(t))}function cn(n,t){function e(n,t){i[n]++,u&&(i[t]=(i[t]||[]).concat(u))}var r=t.fieldName,u=t.message;n[r]=n[r]||{errorCount:0,warnCount:0,testCount:0};var i=n[r];return t.isNonActionable()||(n[r].testCount++,t.isFailing()?e("errorCount","errors"):t.isWarning()&&e("warnCount","warnings")),i}var an=function(){return(an=Object.assign||function(n){for(var t,e=1,r=arguments.length;e<r;e++)for(var u in t=arguments[e])Object.prototype.hasOwnProperty.call(t,u)&&(n[u]=t[u]);return n}).apply(this,arguments)};function fn(n,t,e){if(e||2===arguments.length)for(var r,u=0,i=t.length;u<i;u++)!r&&u in t||(r||(r=Array.prototype.slice.call(t,0,u)),r[u]=t[u]);return n.concat(r||Array.prototype.slice.call(t))}function ln(n,t){return function(n,t){return!!n!=!!t}("warnings"===n,t.warns())}function pn(n,t,e){var r;void 0===e&&(e={});var u=(e=e||{}).group,i=e.fieldName;return t.reduce((function(t,e){return function(n,t,e,r){return!!(function(n,t){return!(!t||n.groupName===t)}(n,e)||un(n,r)||ln(t,n))}(e,n,u,i)||!e.hasFailures()||(t[e.fieldName]=(t[e.fieldName]||[]).concat(e.message||[])),t}),an({},i&&((r={})[i]=[],r)))}function vn(n,t){return t?n[t]:n}function dn(n){return hn("errors",n)}function gn(n){return hn("warnings",n)}function hn(n,t){return vn(n=pn(n,G(),{fieldName:t}),t)}function mn(n,t){return vn(n=En("errors",n,t),t)}function yn(n,t){return vn(n=En("warnings",n,t),t)}function En(n,t,e){return t||a("get"+n[0].toUpperCase()+n.slice(1)+"ByGroup requires a group name. Received `"+t+"` instead."),pn(n,G(),{group:t,fieldName:e})}function Nn(n,t,e){return!(!n.hasFailures()||un(n,e)||ln(t,n))}function bn(n){return Tn("errors",n)}function Cn(n){return Tn("warnings",n)}function Tn(n,t){return G().some((function(e){return Nn(e,n,t)}))}function kn(n,t){return On("errors",n,t)}function Sn(n,t){return On("warnings",n,t)}function On(n,t,e){return G().some((function(r){return t===r.groupName&&Nn(r,n,e)}))}function xn(n,t){return!!function(n){var t=G().reduce((function(n,t){return n[t.fieldName]||t.isOmitted()&&(n[t.fieldName]=!0),n}),{});return!!n&&!!t[n]}(t)||!n.hasErrors(t)&&(!(en(G())||function(n,t){return!!t&&en(n.tests[t])}(n,t)||function(n){var t=_()[0];return rn(U().filter((function(e){return!un(e,n)&&!0!==t[e.fieldName]})))}(t))&&function(n){var t=G(),e=_()[0];return t.every((function(t){return!!un(t,n)||(!0===e[t.fieldName]||t.isTested()||t.isOmitted())}))}(t))}var Pn=w(20);function In(){var n=G(),t={stateRef:F()};return Pn([n],h.bind(t,(function(){var n=F().suiteName()[0];return u(function(){var n={errorCount:0,groups:{},testCount:0,tests:{},warnCount:0};return G().forEach((function(t){var e=t.fieldName,r=t.groupName;n.tests[e]=cn(n.tests,t),r&&(n.groups[r]=n.groups[r]||{},n.groups[r][e]=cn(n.groups[r],t))})),function(n){for(var t in n.tests)n.errorCount+=n.tests[t].errorCount,n.warnCount+=n.tests[t].warnCount,n.testCount+=n.tests[t].testCount;return n}(n)}(),{getErrors:h.bind(t,dn),getErrorsByGroup:h.bind(t,mn),getWarnings:h.bind(t,gn),getWarningsByGroup:h.bind(t,yn),hasErrors:h.bind(t,bn),hasErrorsByGroup:h.bind(t,kn),hasWarnings:h.bind(t,Cn),hasWarningsByGroup:h.bind(t,Sn),isValid:h.bind(t,(function(n){return xn(In(),n)})),suiteName:n})})))}var wn=w(20);function Fn(){var n=G(),t={stateRef:F()};return wn([n],h.bind(t,(function(){return u({},In(),{done:h.bind(t,An)})})))}function Wn(n,t,e){return!(o(n)&&(!t||e.tests[t]&&!en(e.tests[t].testCount)))}function Xn(n){return!(sn()&&(!n||sn(n)))}var _n,An=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=(n=n.reverse())[0];if(n=n[1],t=Fn(),Wn(e,n,t))return t;var r=function(){return e(In())};return Xn(n)?(r(),t):(Dn(r,n),t)};function Dn(n,t){var e=h.bind({},n);(0,X()[1])((function(n){return t?n.fieldCallbacks[t]=(n.fieldCallbacks[t]||[]).concat(e):n.doneCallbacks.push(e),n}))}function Ln(n){return n.forEach((function(n){return n()}))}function Un(){var n=function(){var n={};return{emit:function(t,e){n[t]&&n[t].forEach((function(n){n(e)}))},on:function(t,e){return n[t]||(n[t]=[]),n[t].push(e),{off:function(){n[t]=n[t].filter((function(n){return n!==e}))}}}}}();return n.on(_n.TEST_COMPLETED,(function(n){n.isCanceled()||(n.done(),function(n){var t=X()[0].fieldCallbacks;n&&!sn(n)&&y(t[n])&&Ln(t[n])}(n.fieldName),function(){var n=X()[0].doneCallbacks;sn()||Ln(n)}())})),n.on(_n.SUITE_COMPLETED,(function(){!function(){var n=_()[0];if(!en(n)){var t={};L((function(e){return b(e,(function(e){var r=e.fieldName;if(t.hasOwnProperty(r))t[e.fieldName]&&e.omit();else{var u=n[r];o(u)&&(t[r]=u(),t[e.fieldName]&&e.omit())}return e}))}))}}()})),n.on(_n.REMOVE_FIELD,(function(n){G().forEach((function(t){on(t,n)&&(t.cancel(),function(n){L((function(t){return b(t,(function(t){return n!==t?t:null}))}))}(t))}))})),n}function Mn(){var n=h.useX();return n.bus||a(),n.bus}!function(n){n.TEST_COMPLETED="test_completed",n.REMOVE_FIELD="remove_field",n.SUITE_COMPLETED="suite_completed"}(_n||(_n={}));function Rn(n){return Kn(0,"tests",n)}function Gn(n){return Kn(1,"tests",n)}function jn(){return!!h.useX().skipped}function Hn(n){var t=n.fieldName;if(n=n.groupName,jn())return!0;var e=h.useX(),r=e.exclusion;e=e.inclusion;var u=r.tests,i=u[t];if(!1===i)return!0;if(i=!0===i,n){if(function(n){var t=h.useX().exclusion.groups;if(tn(t,n))return!1===t[n];for(var e in t)if(!0===t[e])return!0;return!1}(n))return!0;if(!0===r.groups[n])return!i&&(!!Vn(u)||!1===u[t])}return!!function(n){var t=h.useX().exclusion;return!!function(){var n,t=h.useX().exclusion;for(n in t.groups)if(t.groups[n])return!0;return!1}()&&(!n||(!(n in t.groups)||!t.groups[n]))}(n)||!i&&(!!Vn(u)&&!s(e[t]))}function Kn(n,t,e){var r=h.useX("hook called outside of a running suite.");e&&v(e).forEach((function(e){x(e)&&(r.exclusion[t][e]=0===n)}))}function Vn(n){for(var t in n)if(!0===n[t])return!0;return!1}function Bn(n){a("Wrong arguments passed to group. Group "+n+".")}Rn.group=function(n){return Kn(0,"groups",n)},Gn.group=function(n){return Kn(1,"groups",n)};var qn=m(x);function Yn(n){return n&&o(n.then)}function zn(n,t){return n.fieldName===t.fieldName&&n.groupName===t.groupName}function Jn(n){var t=n.asyncTest,e=n.message;if(Yn(t)){var r=Mn().emit,u=F(),i=h.bind({stateRef:u},(function(){D(),r(_n.TEST_COMPLETED,n)}));u=h.bind({stateRef:u},(function(t){n.isCanceled()||(n.message=x(t)?t:e,n.fail(),i())}));try{t.then(i,u)}catch(n){u()}}}function Qn(n){var t=Mn(),e=function(n){return h.run({currentTest:n},(function(){try{var t=n.testFn()}catch(e){P(n.message,e)&&(n.message=e),t=!1}return!1===t&&n.fail(),t}))}(n);try{Yn(e)?(n.asyncTest=e,n.setPending(),Jn(n)):t.emit(_n.TEST_COMPLETED,n)}catch(t){a("Your test function "+n.fieldName+' returned a value. Only "false" or Promise returns are supported.')}}function Zn(n){var e=A()[0].prev;return en(e)?($n(n),n):(e=function(n){var t=Q();return function(n,t){return k(n,t)[d(t)]}(n,t)}(e),O(n.key)?(function(n,t){return rn(n)&&!zn(n,t)}(e,n)&&(function(n,e){h.useX().isolate.type===t.EACH||f("Vest Critical Error: Tests called in different order than previous run.\n expected: "+n.fieldName+"\n received: "+e.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.')}(e,n),function(){var n=A(),t=n[1],e=n[0].prev;n=k(e,Q());var r=Z();n.splice(r),t((function(n){return{prev:e,current:n.current}}))}(),e=null),$n(n=c(e,n)),n):($n(n=function(n,t){var e=function(n){return h.useX().isolate.keys.prev[n]}(n);return e&&(t=e),function(n,t){var e=h.useX().isolate.keys.current;O(e[n])?e[n]=t:f('Encountered the same test key "'+n+"\" twice. This may lead to tests overriding each other's results, or to tests being unexpectedly omitted.")}(n,t),t}(n.key,n)),n))}function $n(n){var t=Q();L((function(e){return C(e,t,n)}))}function nt(n){var t=Zn(n);return h.useX().omitted?(t.omit(),$(),t):Hn(n)?(t.skip(jn()),$(),t):(function(n,t){t!==n&&zn(n,t)&&n.isPending()&&n.cancel()}(t,n),$n(n),$(),function(n){n.isUntested()?Qn(n):Yn(n.asyncTest)&&(n.setPending(),Jn(n))}(n),n)}function tt(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];var r=o(t[1])?t:fn([void 0],t);t=r[0],e=r[1],r=r[2],qn(n)&&rt("fieldName","string"),o(e)||rt("Test callback","function");var u=h.useX();return nt(t=new j(n,e,{message:t,groupName:u.groupName,key:r}))}var et=u(tt,{memo:function(n){var t=w(100);return function(e){for(var r=[],u=1;u<arguments.length;u++)r[u-1]=arguments[u];u=Z();var i=(r=r.reverse())[0],o=r[1],s=r[2];return u=[W(),e,u].concat(i),E(r=t.get(u))?t(u,(function(){return n(e,s,o)})):r[1].isCanceled()?(t.invalidate(u),t(u,(function(){return n(e,s,o)}))):nt(r[1])}}(tt)});function rt(n,t){a("Incompatible params passed to test function. "+n+" must be a "+t)}Object.defineProperty(exports,"enforce",{enumerable:!0,get:function(){return e.enforce}}),exports.VERSION="4.0.2-dev-72921c",exports.context=h,exports.create=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var r=(n=n.reverse())[0];n=n[1],o(r)||a("vest.create: Expected callback to be a function.");var s=Un(),c=l();return n={stateRef:p(c,{suiteId:i(),suiteName:n}),bus:s},u(h.bind(n,(function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return c.reset(),nn({type:t.SUITE},(function(){r.apply(void 0,n)})),s.emit(_n.SUITE_COMPLETED),Fn()})),{get:h.bind(n,In),reset:c.reset,remove:h.bind(n,(function(n){s.emit(_n.REMOVE_FIELD,n)}))})},exports.each=function(n,e){o(e)||a("callback must be a function"),nn({type:t.EACH},(function(){n.forEach((function(n,t){e(n,t)}))}))},exports.group=function(n,e){x(n)||Bn("name must be a string"),o(e)||Bn("callback must be a function"),nn({type:t.GROUP},(function(){h.run({groupName:n},e)}))},exports.include=function(n){function t(t){var e=h.useX(),r=e.exclusion;e.inclusion[n]=function(){return tn(r.tests,n)?c(r.tests[n],!0):x(t)?!!r.tests[t]:s(t,s(In))}}var e=h.useX();return n?(e.inclusion[n]=c(e.exclusion.tests[n],!0),{when:t}):{when:t}},exports.omitWhen=function(n,e){nn({type:t.OMIT_WHEN},(function(){h.run({omitted:s(n,s(In))},(function(){return e()}))}))},exports.only=Rn,exports.optional=function(n){(0,_()[1])((function(t){if(y(n)||x(n))v(n).forEach((function(n){t[n]=!0}));else for(var e in n)t[e]=n[e];return t}))},exports.skip=Gn,exports.skipWhen=function(n,e){nn({type:t.SKIP_WHEN},(function(){h.run({skipped:s(n,s(In))},(function(){return e()}))}))},exports.test=et,exports.warn=function(){var n=h.useX("warn hook called outside of a running suite.");n.currentTest||a("warn called outside of a test."),n.currentTest.warn()};
@@ -183,6 +183,7 @@ var context = createContext(function (ctxRef, parentContext) {
183
183
  tests: {},
184
184
  groups: {}
185
185
  },
186
+ inclusion: {},
186
187
  isolate: {
187
188
  type: IsolateTypes.DEFAULT,
188
189
  keys: {
@@ -749,7 +750,7 @@ function __spreadArray(to, from, pack) {
749
750
  ar[i] = from[i];
750
751
  }
751
752
  }
752
- return to.concat(ar || from);
753
+ return to.concat(ar || Array.prototype.slice.call(from));
753
754
  }
754
755
 
755
756
  function either(a, b) {
@@ -1260,13 +1261,14 @@ function isExcludedIndividually() {
1260
1261
  return !!context.useX().skipped;
1261
1262
  }
1262
1263
  //Checks whether a certain test profile excluded by any of the exclusion groups.
1263
- // eslint-disable-next-line complexity, max-statements
1264
+ // eslint-disable-next-line complexity, max-statements, max-lines-per-function
1264
1265
  function isExcluded(testObject) {
1265
1266
  var fieldName = testObject.fieldName, groupName = testObject.groupName;
1266
1267
  if (isExcludedIndividually())
1267
1268
  return true;
1268
1269
  var context$1 = context.useX();
1269
1270
  var exclusion = context$1.exclusion;
1271
+ var inclusion = context$1.inclusion;
1270
1272
  var keyTests = exclusion.tests;
1271
1273
  var testValue = keyTests[fieldName];
1272
1274
  // if test is skipped
@@ -1296,8 +1298,12 @@ function isExcluded(testObject) {
1296
1298
  if (isTestIncluded)
1297
1299
  return false;
1298
1300
  // If there is _ANY_ `only`ed test (and we already know this one isn't) return true
1299
- // Otherwise return false
1300
- return hasIncludedTests(keyTests);
1301
+ if (hasIncludedTests(keyTests)) {
1302
+ // Check if inclusion rules for this field (`include` hook)
1303
+ return !optionalFunctionValue(inclusion[fieldName]);
1304
+ }
1305
+ // We're done here. This field is not excluded
1306
+ return false;
1301
1307
  }
1302
1308
  // eslint-disable-next-line max-statements
1303
1309
  function isMissingFromIncludedGroup(groupName) {
@@ -1402,6 +1408,29 @@ function throwGroupError(error) {
1402
1408
  throwError("Wrong arguments passed to group. Group " + error + ".");
1403
1409
  }
1404
1410
 
1411
+ function include(fieldName) {
1412
+ var context$1 = context.useX();
1413
+ var inclusion = context$1.inclusion, exclusion = context$1.exclusion;
1414
+ if (!fieldName) {
1415
+ return { when: when };
1416
+ }
1417
+ inclusion[fieldName] = defaultTo(exclusion.tests[fieldName], true);
1418
+ return { when: when };
1419
+ function when(condition) {
1420
+ var context$1 = context.useX();
1421
+ var inclusion = context$1.inclusion, exclusion = context$1.exclusion;
1422
+ inclusion[fieldName] = function () {
1423
+ if (hasOwnProperty(exclusion.tests, fieldName)) {
1424
+ return defaultTo(exclusion.tests[fieldName], true);
1425
+ }
1426
+ if (isStringValue(condition)) {
1427
+ return Boolean(exclusion.tests[condition]);
1428
+ }
1429
+ return optionalFunctionValue(condition, optionalFunctionValue(produceDraft));
1430
+ };
1431
+ }
1432
+ }
1433
+
1405
1434
  /**
1406
1435
  * Conditionally omits tests from the suite.
1407
1436
  *
@@ -1680,6 +1709,7 @@ function registerTestObjectByTier(testObject) {
1680
1709
  }
1681
1710
  }
1682
1711
 
1712
+ /* eslint-disable jest/valid-title */
1683
1713
  // eslint-disable-next-line max-lines-per-function
1684
1714
  function bindTestMemo(test) {
1685
1715
  var cache = createCache(100); // arbitrary cache size
@@ -1757,6 +1787,6 @@ function warn() {
1757
1787
  ctx.currentTest.warn();
1758
1788
  }
1759
1789
 
1760
- var VERSION = "3.3.0";
1790
+ var VERSION = "4.0.2-dev-72921c";
1761
1791
 
1762
- export { VERSION, context, create, each, group, omitWhen, only, optional, skip, skipWhen, test, warn };
1792
+ export { VERSION, context, create, each, group, include, omitWhen, only, optional, skip, skipWhen, test, warn };
@@ -1 +1 @@
1
- import{createContext as t}from"context";export{enforce}from"n4s";var n,e=Object.assign,r=(n=0,function(){return""+n++});function u(t){return"function"==typeof t}function i(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return u(t)?t.apply(void 0,n):t}function o(t,n){var e;return null!==(e=i(t))&&void 0!==e?e:n}function s(t,n){throw Error(o(n,t))}function a(t,n){setTimeout((function(){s(t,n)}),0)}function c(t){function n(t,n,u){return r.references.push(),e(t,i(n,u)),function(){return[r.references[t],function(n){return e(t,i(n,r.references[t]))}]}}function e(n,e){var i=r.references[n];r.references[n]=e,u(n=o[n][1])&&n(e,i),u(t)&&t()}var r={references:[]},o=[];return{registerStateKey:function(t,e){var r=o.length;return o.push([t,e]),n(r,t)},reset:function(){var t=r.references;r.references=[],o.forEach((function(e,r){return n(r,e[0],t[r])}))}}}var f,l=f||(f={});function p(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 d(t){return(t=[].concat(t))[t.length-1]}function v(){function t(){n=[0]}var n=[];return t(),{addLevel:function(){n.push(0)},cursorAt:function(){return d(n)},getCursor:function(){return[].concat(n)},next:function(){return n[n.length-1]++,d(n)},removeLevel:function(){n.pop()},reset:t}}l[l.DEFAULT=0]="DEFAULT",l[l.SUITE=1]="SUITE",l[l.EACH=2]="EACH",l[l.SKIP_WHEN=3]="SKIP_WHEN",l[l.OMIT_WHEN=4]="OMIT_WHEN",l[l.GROUP=5]="GROUP";var g=t((function(t,n){return n?null:e({},{exclusion:{tests:{},groups:{}},isolate:{type:f.DEFAULT,keys:{current:{},prev:{}}},testCursor:v()},t)}));function h(t){return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return!t.apply(void 0,n)}}var m=h((function(t){return null===t}));function y(t,n){for(var e=[],r=0;r<t.length;r++){var u=t[r];Array.isArray(u)?e.push(y(u,n)):(u=n(u),m(u)&&e.push(u))}return e}function E(t){return[].concat(t).reduce((function(t,n){return Array.isArray(n)?t.concat(E(n)):[].concat(t).concat(n)}),[])}function N(t,n){var e=0;for(n=n.slice(0,-1);e<n.length;e++){var r=n[e];t[r]=o(t[r],[]),t=t[r]}return t}function b(t){return null==t}function C(t){return String(t)===t}function T(t){function n(r,u){var i=n.get(r);return i?i[1]:(u=u(),e.unshift([r.concat(),u]),e.length>Number(t)&&(e.length=t),u)}void 0===t&&(t=1);var e=[];return n.invalidate=function(t){var n=e.findIndex((function(n){var e=n[0];return t.length===Number(e.length)&&t.every((function(t,n){return t===e[n]}))}));-1<n&&e.splice(n,1)},n.get=function(t){return e[e.findIndex((function(n){var e=n[0];return t.length===Number(e.length)&&t.every((function(t,n){return t===e[n]}))}))]||null},n}function k(){return g.useX().stateRef}function S(){return k().testObjects()}function O(){(0,S()[1])((function(t){return{prev:t.prev,current:[].concat(t.current)}}))}function P(t){(0,S()[1])((function(n){return{prev:n.prev,current:[].concat(t(n.current))}}))}function w(){return E(y(S()[0].current,(function(t){return t.isPending()?t:null})))}var I=T();function F(){var t=S()[0].current;return I([t],(function(){return E(t)}))}var A,X=A||(A={});X.Error="error",X.Warning="warning";var D=function(){function t(t,n,e){var u=void 0===e?{}:e;e=u.message;var i=u.groupName;u=u.key,this.key=null,this.id=r(),this.severity=A.Error,this.status=L,this.fieldName=t,this.testFn=n,i&&(this.groupName=i),e&&(this.message=e),u&&(this.key=u)}return t.prototype.run=function(){try{var t=this.testFn()}catch(n){t=n,void 0===this.message&&C(t)&&(this.message=n),t=!1}return!1===t&&this.fail(),t},t.prototype.setStatus=function(t){this.isFinalStatus()&&t!==G||(this.status=t)},t.prototype.warns=function(){return this.severity===A.Warning},t.prototype.setPending=function(){this.setStatus(M)},t.prototype.fail=function(){this.setStatus(this.warns()?U:_)},t.prototype.done=function(){this.isFinalStatus()||this.setStatus(x)},t.prototype.warn=function(){this.severity=A.Warning},t.prototype.isFinalStatus=function(){return this.hasFailures()||this.isCanceled()||this.isPassing()},t.prototype.skip=function(t){this.isPending()&&!t||this.setStatus(W)},t.prototype.cancel=function(){this.setStatus(R),O()},t.prototype.omit=function(){this.setStatus(G)},t.prototype.valueOf=function(){return!this.isFailing()},t.prototype.hasFailures=function(){return this.isFailing()||this.isWarning()},t.prototype.isNonActionable=function(){return this.isSkipped()||this.isOmitted()||this.isCanceled()},t.prototype.isPending=function(){return this.status===M},t.prototype.isTested=function(){return this.hasFailures()||this.isPassing()},t.prototype.isOmitted=function(){return this.status===G},t.prototype.isUntested=function(){return this.status===L},t.prototype.isFailing=function(){return this.status===_},t.prototype.isCanceled=function(){return this.status===R},t.prototype.isSkipped=function(){return this.status===W},t.prototype.isPassing=function(){return this.status===x},t.prototype.isWarning=function(){return this.status===U},t}(),L="UNTESTED",W="SKIPPED",_="FAILED",U="WARNING",x="PASSING",M="PENDING",R="CANCELED",G="OMITTED";function H(){return g.useX().testCursor.getCursor()}function K(){return g.useX().testCursor.next()}function j(t,n){if(t=void 0===(t=t.type)?f.DEFAULT:t,u(n)){var e={current:{},prev:{}},r=H();return g.run({isolate:{type:t,keys:e}},(function(){g.useX().testCursor.addLevel(),e.prev=function(){var t=S()[0].prev;return[].concat(N(t,H())).reduce((function(t,n){return n instanceof D&&!b(n.key)?(t[n.key]=n,t):t}),{})}(),P((function(t){return N(t,r)[d(r)]=[],t}));var t=n();return g.useX().testCursor.removeLevel(),K(),t}))}}function V(t){if(t){if("number"==typeof t)return 0===t;if(Object.prototype.hasOwnProperty.call(t,"length"))return t.length===Number(0);if("object"==typeof t)return Object.keys(t).length===Number(0)}return!0}var B=h(V);function Y(t,n){return!(!n||t.fieldName!==n)}function q(t){var n=w();return!V(n)&&(t?n.some((function(n){return Y(n,t)})):B(n))}function z(t,n){function e(t,n){i[t]++,u&&(i[n]=(i[n]||[]).concat(u))}var r=n.fieldName,u=n.message;t[r]=t[r]||{errorCount:0,warnCount:0,testCount:0};var i=t[r];return n.isNonActionable()||(t[r].testCount++,n.isFailing()?e("errorCount","errors"):n.isWarning()&&e("warnCount","warnings")),i}function J(){return(J=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var u in n=arguments[e])Object.prototype.hasOwnProperty.call(n,u)&&(t[u]=n[u]);return t}).apply(this,arguments)}function Q(t,n,e){if(e||2===arguments.length)for(var r,u=0,i=n.length;u<i;u++)!r&&u in n||(r||(r=Array.prototype.slice.call(n,0,u)),r[u]=n[u]);return t.concat(r||n)}function Z(t,n,e){var r;void 0===e&&(e={});var u=(e=e||{}).group,i=e.fieldName;return n.reduce((function(n,e){if(u&&e.groupName!==u)var r=!0;else i&&!Y(e,i)?r=!0:(r=e.warns(),r="warnings"===t!=!!r);return r||!e.hasFailures()||(n[e.fieldName]=(n[e.fieldName]||[]).concat(e.message||[])),n}),J({},i&&((r={})[i]=[],r)))}function $(t){return nt("errors",t)}function tt(t){return nt("warnings",t)}function nt(t,n){return t=Z(t,F(),{fieldName:n}),n?t[n]:t}function et(t,n){return t=ut("errors",t,n),n?t[n]:t}function rt(t,n){return t=ut("warnings",t,n),n?t[n]:t}function ut(t,n,e){return n||s("get"+t[0].toUpperCase()+t.slice(1)+"ByGroup requires a group name. Received `"+n+"` instead."),Z(t,F(),{group:n,fieldName:e})}function it(t,n,e){return(e=!t.hasFailures()||e&&!Y(t,e))||(e="warnings"===n!=!!(t=t.warns())),!e}function ot(t){return at("errors",t)}function st(t){return at("warnings",t)}function at(t,n){return F().some((function(e){return it(e,t,n)}))}function ct(t,n){return lt("errors",t,n)}function ft(t,n){return lt("warnings",t,n)}function lt(t,n,e){return F().some((function(r){return n===r.groupName&&it(r,t,e)}))}var pt=T(20);function dt(){var t=F(),n={stateRef:k()};return pt([t],g.bind(n,(function(){var t=k().suiteName()[0];return e(function(){var t={errorCount:0,groups:{},testCount:0,tests:{},warnCount:0};return F().forEach((function(n){var e=n.fieldName,r=n.groupName;t.tests[e]=z(t.tests,n),r&&(t.groups[r]=t.groups[r]||{},t.groups[r][e]=z(t.groups[r],n))})),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}(t)}(),{getErrors:g.bind(n,$),getErrorsByGroup:g.bind(n,et),getWarnings:g.bind(n,tt),getWarningsByGroup:g.bind(n,rt),hasErrors:g.bind(n,ot),hasErrorsByGroup:g.bind(n,ct),hasWarnings:g.bind(n,st),hasWarningsByGroup:g.bind(n,ft),isValid:g.bind(n,(function(t){var n=dt(),e=F().reduce((function(t,n){return t[n.fieldName]||n.isOmitted()&&(t[n.fieldName]=!0),t}),{});return(e=!!t&&!!e[t])?t=!0:n.hasErrors(t)?t=!1:t=!(V(e=F())||t&&V(n.tests[t])||function(t){var n=k().optionalFields()[0];return B(w().filter((function(e){return!(t&&!Y(e,t))&&!0!==n[e.fieldName]})))}(t))&&function(t){var n=F(),e=k().optionalFields()[0];return n.every((function(n){return!(!t||Y(n,t))||!0===e[n.fieldName]||n.isTested()||n.isOmitted()}))}(t),t})),suiteName:t})})))}var vt=T(20);function gt(){var t=F(),n={stateRef:k()};return vt([t],g.bind(n,(function(){return e({},dt(),{done:g.bind(n,yt)})})))}function ht(t,n,e){return!(u(t)&&(!n||e.tests[n]&&!V(e.tests[n].testCount)))}function mt(t){return!(q()&&(!t||q(t)))}function yt(){function t(){return r(dt())}for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var r=(n=n.reverse())[0];return n=n[1],e=gt(),ht(r,n,e)?e:mt(n)?(t(),e):(Et(t,n),e)}function Et(t,n){var e=g.bind({},t);(0,k().testCallbacks()[1])((function(t){return n?t.fieldCallbacks[n]=(t.fieldCallbacks[n]||[]).concat(e):t.doneCallbacks.push(e),t}))}function Nt(t){return t.forEach((function(t){return t()}))}function bt(){var t=function(){var t={};return{emit:function(n,e){t[n]&&t[n].forEach((function(t){t(e)}))},on:function(n,e){return t[n]||(t[n]=[]),t[n].push(e),{off:function(){t[n]=t[n].filter((function(t){return t!==e}))}}}}}();return t.on(Tt.TEST_COMPLETED,(function(t){if(!t.isCanceled()){t.done(),t=t.fieldName;var n=k().testCallbacks()[0].fieldCallbacks;t&&!q(t)&&Array.isArray(n[t])&&Nt(n[t]),t=k().testCallbacks()[0].doneCallbacks,q()||Nt(t)}})),t.on(Tt.SUITE_COMPLETED,(function(){!function(){var t=k().optionalFields()[0];if(!V(t)){var n={};P((function(e){return y(e,(function(e){var r=e.fieldName;if(n.hasOwnProperty(r))n[e.fieldName]&&e.omit();else{var i=t[r];u(i)&&(n[r]=i(),n[e.fieldName]&&e.omit())}return e}))}))}}()})),t.on(Tt.REMOVE_FIELD,(function(t){F().forEach((function(n){Y(n,t)&&(n.cancel(),function(t){P((function(n){return y(n,(function(n){return t!==n?n:null}))}))}(n))}))})),t}function Ct(){var t=g.useX();return t.bus||s(),t.bus}var Tt,kt=Tt||(Tt={});function St(t){return Pt(0,"tests",t)}function Ot(t){return Pt(1,"tests",t)}function Pt(t,n,e){var r=g.useX("hook called outside of a running suite.");e&&[].concat(e).forEach((function(e){C(e)&&(r.exclusion[n][e]=0===t)}))}function wt(t){for(var n in t)if(!0===t[n])return!0;return!1}function It(t){s("Wrong arguments passed to group. Group "+t+".")}kt.TEST_COMPLETED="test_completed",kt.REMOVE_FIELD="remove_field",kt.SUITE_COMPLETED="suite_completed",St.group=function(t){return Pt(0,"groups",t)},Ot.group=function(t){return Pt(1,"groups",t)};var Ft=h(C);function At(t){var n=t.asyncTest,e=t.message;if(n&&u(n.then)){var r=Ct().emit,i=k(),o=g.bind({stateRef:i},(function(){O(),r(Tt.TEST_COMPLETED,t)}));i=g.bind({stateRef:i},(function(n){t.isCanceled()||(t.message=C(n)?n:e,t.fail(),o())}));try{n.then(o,i)}catch(t){i()}}}function Xt(t){var n=H();P((function(e){return N(e,n)[d(n)]=t,e}))}function Dt(t){var n=S()[0].prev;if(V(n))Xt(t),n=t;else{var e=H();if(n=N(n,e)[d(e)],b(t.key))!B(e=n)||e.fieldName===t.fieldName&&e.groupName===t.groupName||(g.useX().isolate.type!==f.EACH&&a("Vest Critical Error: Tests called in different order than previous run.\n expected: "+n.fieldName+"\n received: "+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=S(),n=t[1],e=t[0].prev;t=N(e,H());var r=g.useX().testCursor.cursorAt();t.splice(r),n((function(t){return{prev:e,current:t.current}}))}(),n=null),Xt(n=o(n,t));else{n=t.key;var r=g.useX().isolate.keys.prev[n];e=t,r&&(e=r),r=e;var i=g.useX().isolate.keys.current;b(i[n])?i[n]=r:a('Encountered the same test key "'+n+"\" twice. This may lead to tests overriding each other's results, or to tests being unexpectedly omitted."),Xt(n=e)}}if(g.useX().omitted)return n.omit(),K(),n;if(function(t){var n=t.fieldName;if(t=t.groupName,g.useX().skipped)return!0;var e=g.useX().exclusion,r=e.tests,u=r[n];if(!1===u)return!0;if(u=!0===u,t){t:{var i=g.useX().exclusion.groups;if(Object.prototype.hasOwnProperty.call(i,t))var o=!1===i[t];else{for(o in i)if(!0===i[o]){o=!0;break t}o=!1}}if(o)return!0;if(!0===e.groups[t])return!(u||!wt(r)&&!1!==r[n])}n=g.useX().exclusion;t:{for(s in(e=g.useX().exclusion).groups)if(e.groups[s]){var s=!0;break t}s=!1}return!(!s||t&&t in n.groups&&n.groups[t])||!u&&wt(r)}(t))return n.skip(!!g.useX().skipped),K(),n;if(t!==n&&n.fieldName===t.fieldName&&n.groupName===t.groupName&&n.isPending()&&n.cancel(),Xt(t),K(),t.isUntested()){n=Ct(),e=function(t){return g.run({currentTest:t},(function(){try{var n=t.testFn()}catch(e){n=e,void 0===t.message&&C(n)&&(t.message=e),n=!1}return!1===n&&t.fail(),n}))}(t);try{e&&u(e.then)?(t.asyncTest=e,t.setPending(),At(t)):n.emit(Tt.TEST_COMPLETED,t)}catch(n){s("Your test function "+t.fieldName+' returned a value. Only "false" or Promise returns are supported.')}}else(n=t.asyncTest)&&u(n.then)&&(t.setPending(),At(t));return t}function Lt(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var r=u(n[1])?n:Q([void 0],n);n=r[0],e=r[1],r=r[2],Ft(t)&&_t("fieldName","string"),u(e)||_t("Test callback","function");var i=g.useX();return Dt(n=new D(t,e,{message:n,groupName:i.groupName,key:r}))}var Wt=e(Lt,{memo:function(t){var n=T(100);return function(e){for(var r=[],u=1;u<arguments.length;u++)r[u-1]=arguments[u];u=g.useX().testCursor.cursorAt();var i=(r=r.reverse())[0],o=r[1],s=r[2];return u=[k().suiteId()[0],e,u].concat(i),null===(r=n.get(u))?n(u,(function(){return t(e,s,o)})):r[1].isCanceled()?(n.invalidate(u),n(u,(function(){return t(e,s,o)}))):Dt(r[1])}}(Lt)});function _t(t,n){s("Incompatible params passed to test function. "+t+" must be a "+n)}var Ut="3.3.0";function xt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var i=(t=t.reverse())[0];t=t[1],u(i)||s("vest.create: Expected callback to be a function.");var o=bt(),a=c();return t={stateRef:p(a,{suiteId:r(),suiteName:t}),bus:o},e(g.bind(t,(function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return a.reset(),j({type:f.SUITE},(function(){i.apply(void 0,t)})),o.emit(Tt.SUITE_COMPLETED),gt()})),{get:g.bind(t,dt),reset:a.reset,remove:g.bind(t,(function(t){o.emit(Tt.REMOVE_FIELD,t)}))})}function Mt(t,n){u(n)||s("callback must be a function"),j({type:f.EACH},(function(){t.forEach((function(t,e){n(t,e)}))}))}function Rt(t,n){C(t)||It("name must be a string"),u(n)||It("callback must be a function"),j({type:f.GROUP},(function(){g.run({groupName:t},n)}))}function Gt(t,n){j({type:f.OMIT_WHEN},(function(){g.run({omitted:i(t,i(dt))},(function(){return n()}))}))}function Ht(t){(0,k().optionalFields()[1])((function(n){if(Array.isArray(t)||C(t))[].concat(t).forEach((function(t){n[t]=!0}));else for(var e in t)n[e]=t[e];return n}))}function Kt(t,n){j({type:f.SKIP_WHEN},(function(){g.run({skipped:i(t,i(dt))},(function(){return n()}))}))}function jt(){var t=g.useX("warn hook called outside of a running suite.");t.currentTest||s("warn called outside of a test."),t.currentTest.warn()}export{Ut as VERSION,g as context,xt as create,Mt as each,Rt as group,Gt as omitWhen,St as only,Ht as optional,Ot as skip,Kt as skipWhen,Wt as test,jt as warn};
1
+ import{createContext as t}from"context";export{enforce}from"n4s";var n,e=Object.assign,r=(n=0,function(){return""+n++});function u(t){return"function"==typeof t}function i(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return u(t)?t.apply(void 0,n):t}function o(t,n){var e;return null!==(e=i(t))&&void 0!==e?e:n}function s(t,n){throw Error(o(n,t))}function a(t,n){setTimeout((function(){s(t,n)}),0)}function c(t){function n(t,n,u){return r.references.push(),e(t,i(n,u)),function(){return[r.references[t],function(n){return e(t,i(n,r.references[t]))}]}}function e(n,e){var i=r.references[n];r.references[n]=e,u(n=o[n][1])&&n(e,i),u(t)&&t()}var r={references:[]},o=[];return{registerStateKey:function(t,e){var r=o.length;return o.push([t,e]),n(r,t)},reset:function(){var t=r.references;r.references=[],o.forEach((function(e,r){return n(r,e[0],t[r])}))}}}var f,l=f||(f={});function p(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 v(t){return(t=[].concat(t))[t.length-1]}function d(){function t(){n=[0]}var n=[];return t(),{addLevel:function(){n.push(0)},cursorAt:function(){return v(n)},getCursor:function(){return[].concat(n)},next:function(){return n[n.length-1]++,v(n)},removeLevel:function(){n.pop()},reset:t}}l[l.DEFAULT=0]="DEFAULT",l[l.SUITE=1]="SUITE",l[l.EACH=2]="EACH",l[l.SKIP_WHEN=3]="SKIP_WHEN",l[l.OMIT_WHEN=4]="OMIT_WHEN",l[l.GROUP=5]="GROUP";var g=t((function(t,n){return n?null:e({},{exclusion:{tests:{},groups:{}},inclusion:{},isolate:{type:f.DEFAULT,keys:{current:{},prev:{}}},testCursor:d()},t)}));function h(t){return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return!t.apply(void 0,n)}}var m=h((function(t){return null===t}));function y(t,n){for(var e=[],r=0;r<t.length;r++){var u=t[r];Array.isArray(u)?e.push(y(u,n)):(u=n(u),m(u)&&e.push(u))}return e}function E(t){return[].concat(t).reduce((function(t,n){return Array.isArray(n)?t.concat(E(n)):[].concat(t).concat(n)}),[])}function N(t,n){var e=0;for(n=n.slice(0,-1);e<n.length;e++){var r=n[e];t[r]=o(t[r],[]),t=t[r]}return t}function b(t){return null==t}function C(t){return String(t)===t}function T(t){function n(r,u){var i=n.get(r);return i?i[1]:(u=u(),e.unshift([r.concat(),u]),e.length>Number(t)&&(e.length=t),u)}void 0===t&&(t=1);var e=[];return n.invalidate=function(t){var n=e.findIndex((function(n){var e=n[0];return t.length===Number(e.length)&&t.every((function(t,n){return t===e[n]}))}));-1<n&&e.splice(n,1)},n.get=function(t){return e[e.findIndex((function(n){var e=n[0];return t.length===Number(e.length)&&t.every((function(t,n){return t===e[n]}))}))]||null},n}function k(){return g.useX().stateRef}function O(){return k().testObjects()}function S(){(0,O()[1])((function(t){return{prev:t.prev,current:[].concat(t.current)}}))}function P(t){(0,O()[1])((function(n){return{prev:n.prev,current:[].concat(t(n.current))}}))}function w(){return E(y(O()[0].current,(function(t){return t.isPending()?t:null})))}var I=T();function F(){var t=O()[0].current;return I([t],(function(){return E(t)}))}var A,X=A||(A={});X.Error="error",X.Warning="warning";var D=function(){function t(t,n,e){var u=void 0===e?{}:e;e=u.message;var i=u.groupName;u=u.key,this.key=null,this.id=r(),this.severity=A.Error,this.status=L,this.fieldName=t,this.testFn=n,i&&(this.groupName=i),e&&(this.message=e),u&&(this.key=u)}return t.prototype.run=function(){try{var t=this.testFn()}catch(n){t=n,void 0===this.message&&C(t)&&(this.message=n),t=!1}return!1===t&&this.fail(),t},t.prototype.setStatus=function(t){this.isFinalStatus()&&t!==G||(this.status=t)},t.prototype.warns=function(){return this.severity===A.Warning},t.prototype.setPending=function(){this.setStatus(M)},t.prototype.fail=function(){this.setStatus(this.warns()?_:W)},t.prototype.done=function(){this.isFinalStatus()||this.setStatus(U)},t.prototype.warn=function(){this.severity=A.Warning},t.prototype.isFinalStatus=function(){return this.hasFailures()||this.isCanceled()||this.isPassing()},t.prototype.skip=function(t){this.isPending()&&!t||this.setStatus(x)},t.prototype.cancel=function(){this.setStatus(R),S()},t.prototype.omit=function(){this.setStatus(G)},t.prototype.valueOf=function(){return!this.isFailing()},t.prototype.hasFailures=function(){return this.isFailing()||this.isWarning()},t.prototype.isNonActionable=function(){return this.isSkipped()||this.isOmitted()||this.isCanceled()},t.prototype.isPending=function(){return this.status===M},t.prototype.isTested=function(){return this.hasFailures()||this.isPassing()},t.prototype.isOmitted=function(){return this.status===G},t.prototype.isUntested=function(){return this.status===L},t.prototype.isFailing=function(){return this.status===W},t.prototype.isCanceled=function(){return this.status===R},t.prototype.isSkipped=function(){return this.status===x},t.prototype.isPassing=function(){return this.status===U},t.prototype.isWarning=function(){return this.status===_},t}(),L="UNTESTED",x="SKIPPED",W="FAILED",_="WARNING",U="PASSING",M="PENDING",R="CANCELED",G="OMITTED";function j(){return g.useX().testCursor.getCursor()}function H(){return g.useX().testCursor.next()}function K(t,n){if(t=void 0===(t=t.type)?f.DEFAULT:t,u(n)){var e={current:{},prev:{}},r=j();return g.run({isolate:{type:t,keys:e}},(function(){g.useX().testCursor.addLevel(),e.prev=function(){var t=O()[0].prev;return[].concat(N(t,j())).reduce((function(t,n){return n instanceof D&&!b(n.key)?(t[n.key]=n,t):t}),{})}(),P((function(t){return N(t,r)[v(r)]=[],t}));var t=n();return g.useX().testCursor.removeLevel(),H(),t}))}}function V(t){if(t){if("number"==typeof t)return 0===t;if(Object.prototype.hasOwnProperty.call(t,"length"))return t.length===Number(0);if("object"==typeof t)return Object.keys(t).length===Number(0)}return!0}var B=h(V);function Y(t,n){return!(!n||t.fieldName!==n)}function q(t){var n=w();return!V(n)&&(t?n.some((function(n){return Y(n,t)})):B(n))}function z(t,n){function e(t,n){i[t]++,u&&(i[n]=(i[n]||[]).concat(u))}var r=n.fieldName,u=n.message;t[r]=t[r]||{errorCount:0,warnCount:0,testCount:0};var i=t[r];return n.isNonActionable()||(t[r].testCount++,n.isFailing()?e("errorCount","errors"):n.isWarning()&&e("warnCount","warnings")),i}function J(){return(J=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var u in n=arguments[e])Object.prototype.hasOwnProperty.call(n,u)&&(t[u]=n[u]);return t}).apply(this,arguments)}function Q(t,n,e){if(e||2===arguments.length)for(var r,u=0,i=n.length;u<i;u++)!r&&u in n||(r||(r=Array.prototype.slice.call(n,0,u)),r[u]=n[u]);return t.concat(r||Array.prototype.slice.call(n))}function Z(t,n,e){var r;void 0===e&&(e={});var u=(e=e||{}).group,i=e.fieldName;return n.reduce((function(n,e){if(u&&e.groupName!==u)var r=!0;else i&&!Y(e,i)?r=!0:(r=e.warns(),r="warnings"===t!=!!r);return r||!e.hasFailures()||(n[e.fieldName]=(n[e.fieldName]||[]).concat(e.message||[])),n}),J({},i&&((r={})[i]=[],r)))}function $(t){return nt("errors",t)}function tt(t){return nt("warnings",t)}function nt(t,n){return t=Z(t,F(),{fieldName:n}),n?t[n]:t}function et(t,n){return t=ut("errors",t,n),n?t[n]:t}function rt(t,n){return t=ut("warnings",t,n),n?t[n]:t}function ut(t,n,e){return n||s("get"+t[0].toUpperCase()+t.slice(1)+"ByGroup requires a group name. Received `"+n+"` instead."),Z(t,F(),{group:n,fieldName:e})}function it(t,n,e){return(e=!t.hasFailures()||e&&!Y(t,e))||(e="warnings"===n!=!!(t=t.warns())),!e}function ot(t){return at("errors",t)}function st(t){return at("warnings",t)}function at(t,n){return F().some((function(e){return it(e,t,n)}))}function ct(t,n){return lt("errors",t,n)}function ft(t,n){return lt("warnings",t,n)}function lt(t,n,e){return F().some((function(r){return n===r.groupName&&it(r,t,e)}))}var pt=T(20);function vt(){var t=F(),n={stateRef:k()};return pt([t],g.bind(n,(function(){var t=k().suiteName()[0];return e(function(){var t={errorCount:0,groups:{},testCount:0,tests:{},warnCount:0};return F().forEach((function(n){var e=n.fieldName,r=n.groupName;t.tests[e]=z(t.tests,n),r&&(t.groups[r]=t.groups[r]||{},t.groups[r][e]=z(t.groups[r],n))})),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}(t)}(),{getErrors:g.bind(n,$),getErrorsByGroup:g.bind(n,et),getWarnings:g.bind(n,tt),getWarningsByGroup:g.bind(n,rt),hasErrors:g.bind(n,ot),hasErrorsByGroup:g.bind(n,ct),hasWarnings:g.bind(n,st),hasWarningsByGroup:g.bind(n,ft),isValid:g.bind(n,(function(t){var n=vt(),e=F().reduce((function(t,n){return t[n.fieldName]||n.isOmitted()&&(t[n.fieldName]=!0),t}),{});return(e=!!t&&!!e[t])?t=!0:n.hasErrors(t)?t=!1:t=!(V(e=F())||t&&V(n.tests[t])||function(t){var n=k().optionalFields()[0];return B(w().filter((function(e){return!(t&&!Y(e,t))&&!0!==n[e.fieldName]})))}(t))&&function(t){var n=F(),e=k().optionalFields()[0];return n.every((function(n){return!(!t||Y(n,t))||!0===e[n.fieldName]||n.isTested()||n.isOmitted()}))}(t),t})),suiteName:t})})))}var dt=T(20);function gt(){var t=F(),n={stateRef:k()};return dt([t],g.bind(n,(function(){return e({},vt(),{done:g.bind(n,yt)})})))}function ht(t,n,e){return!(u(t)&&(!n||e.tests[n]&&!V(e.tests[n].testCount)))}function mt(t){return!(q()&&(!t||q(t)))}function yt(){function t(){return r(vt())}for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var r=(n=n.reverse())[0];return n=n[1],e=gt(),ht(r,n,e)?e:mt(n)?(t(),e):(Et(t,n),e)}function Et(t,n){var e=g.bind({},t);(0,k().testCallbacks()[1])((function(t){return n?t.fieldCallbacks[n]=(t.fieldCallbacks[n]||[]).concat(e):t.doneCallbacks.push(e),t}))}function Nt(t){return t.forEach((function(t){return t()}))}function bt(){var t=function(){var t={};return{emit:function(n,e){t[n]&&t[n].forEach((function(t){t(e)}))},on:function(n,e){return t[n]||(t[n]=[]),t[n].push(e),{off:function(){t[n]=t[n].filter((function(t){return t!==e}))}}}}}();return t.on(Tt.TEST_COMPLETED,(function(t){if(!t.isCanceled()){t.done(),t=t.fieldName;var n=k().testCallbacks()[0].fieldCallbacks;t&&!q(t)&&Array.isArray(n[t])&&Nt(n[t]),t=k().testCallbacks()[0].doneCallbacks,q()||Nt(t)}})),t.on(Tt.SUITE_COMPLETED,(function(){!function(){var t=k().optionalFields()[0];if(!V(t)){var n={};P((function(e){return y(e,(function(e){var r=e.fieldName;if(n.hasOwnProperty(r))n[e.fieldName]&&e.omit();else{var i=t[r];u(i)&&(n[r]=i(),n[e.fieldName]&&e.omit())}return e}))}))}}()})),t.on(Tt.REMOVE_FIELD,(function(t){F().forEach((function(n){Y(n,t)&&(n.cancel(),function(t){P((function(n){return y(n,(function(n){return t!==n?n:null}))}))}(n))}))})),t}function Ct(){var t=g.useX();return t.bus||s(),t.bus}var Tt,kt=Tt||(Tt={});function Ot(t){return Pt(0,"tests",t)}function St(t){return Pt(1,"tests",t)}function Pt(t,n,e){var r=g.useX("hook called outside of a running suite.");e&&[].concat(e).forEach((function(e){C(e)&&(r.exclusion[n][e]=0===t)}))}function wt(t){for(var n in t)if(!0===t[n])return!0;return!1}function It(t){s("Wrong arguments passed to group. Group "+t+".")}kt.TEST_COMPLETED="test_completed",kt.REMOVE_FIELD="remove_field",kt.SUITE_COMPLETED="suite_completed",Ot.group=function(t){return Pt(0,"groups",t)},St.group=function(t){return Pt(1,"groups",t)};var Ft=h(C);function At(t){var n=t.asyncTest,e=t.message;if(n&&u(n.then)){var r=Ct().emit,i=k(),o=g.bind({stateRef:i},(function(){S(),r(Tt.TEST_COMPLETED,t)}));i=g.bind({stateRef:i},(function(n){t.isCanceled()||(t.message=C(n)?n:e,t.fail(),o())}));try{n.then(o,i)}catch(t){i()}}}function Xt(t){var n=j();P((function(e){return N(e,n)[v(n)]=t,e}))}function Dt(t){var n=O()[0].prev;if(V(n))Xt(t),n=t;else{var e=j();if(n=N(n,e)[v(e)],b(t.key))!B(e=n)||e.fieldName===t.fieldName&&e.groupName===t.groupName||(g.useX().isolate.type!==f.EACH&&a("Vest Critical Error: Tests called in different order than previous run.\n expected: "+n.fieldName+"\n received: "+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=O(),n=t[1],e=t[0].prev;t=N(e,j());var r=g.useX().testCursor.cursorAt();t.splice(r),n((function(t){return{prev:e,current:t.current}}))}(),n=null),Xt(n=o(n,t));else{n=t.key;var r=g.useX().isolate.keys.prev[n];e=t,r&&(e=r),r=e;var c=g.useX().isolate.keys.current;b(c[n])?c[n]=r:a('Encountered the same test key "'+n+"\" twice. This may lead to tests overriding each other's results, or to tests being unexpectedly omitted."),Xt(n=e)}}if(g.useX().omitted)return n.omit(),H(),n;if(function(t){var n=t.fieldName;if(t=t.groupName,g.useX().skipped)return!0;var e=g.useX(),r=e.exclusion;e=e.inclusion;var u=r.tests,o=u[n];if(!1===o)return!0;if(o=!0===o,t){t:{var s=g.useX().exclusion.groups;if(Object.prototype.hasOwnProperty.call(s,t))var a=!1===s[t];else{for(a in s)if(!0===s[a]){a=!0;break t}a=!1}}if(a)return!0;if(!0===r.groups[t])return!(o||!wt(u)&&!1!==u[n])}r=g.useX().exclusion;t:{for(c in(a=g.useX().exclusion).groups)if(a.groups[c]){var c=!0;break t}c=!1}return!(!c||t&&t in r.groups&&r.groups[t])||!o&&!!wt(u)&&!i(e[n])}(t))return n.skip(!!g.useX().skipped),H(),n;if(t!==n&&n.fieldName===t.fieldName&&n.groupName===t.groupName&&n.isPending()&&n.cancel(),Xt(t),H(),t.isUntested()){n=Ct(),e=function(t){return g.run({currentTest:t},(function(){try{var n=t.testFn()}catch(e){n=e,void 0===t.message&&C(n)&&(t.message=e),n=!1}return!1===n&&t.fail(),n}))}(t);try{e&&u(e.then)?(t.asyncTest=e,t.setPending(),At(t)):n.emit(Tt.TEST_COMPLETED,t)}catch(n){s("Your test function "+t.fieldName+' returned a value. Only "false" or Promise returns are supported.')}}else(n=t.asyncTest)&&u(n.then)&&(t.setPending(),At(t));return t}function Lt(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var r=u(n[1])?n:Q([void 0],n);n=r[0],e=r[1],r=r[2],Ft(t)&&Wt("fieldName","string"),u(e)||Wt("Test callback","function");var i=g.useX();return Dt(n=new D(t,e,{message:n,groupName:i.groupName,key:r}))}var xt=e(Lt,{memo:function(t){var n=T(100);return function(e){for(var r=[],u=1;u<arguments.length;u++)r[u-1]=arguments[u];u=g.useX().testCursor.cursorAt();var i=(r=r.reverse())[0],o=r[1],s=r[2];return u=[k().suiteId()[0],e,u].concat(i),null===(r=n.get(u))?n(u,(function(){return t(e,s,o)})):r[1].isCanceled()?(n.invalidate(u),n(u,(function(){return t(e,s,o)}))):Dt(r[1])}}(Lt)});function Wt(t,n){s("Incompatible params passed to test function. "+t+" must be a "+n)}var _t="4.0.2-dev-72921c";function Ut(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var i=(t=t.reverse())[0];t=t[1],u(i)||s("vest.create: Expected callback to be a function.");var o=bt(),a=c();return t={stateRef:p(a,{suiteId:r(),suiteName:t}),bus:o},e(g.bind(t,(function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return a.reset(),K({type:f.SUITE},(function(){i.apply(void 0,t)})),o.emit(Tt.SUITE_COMPLETED),gt()})),{get:g.bind(t,vt),reset:a.reset,remove:g.bind(t,(function(t){o.emit(Tt.REMOVE_FIELD,t)}))})}function Mt(t,n){u(n)||s("callback must be a function"),K({type:f.EACH},(function(){t.forEach((function(t,e){n(t,e)}))}))}function Rt(t,n){C(t)||It("name must be a string"),u(n)||It("callback must be a function"),K({type:f.GROUP},(function(){g.run({groupName:t},n)}))}function Gt(t){function n(n){var e=g.useX(),r=e.exclusion;e.inclusion[t]=function(){return Object.prototype.hasOwnProperty.call(r.tests,t)?o(r.tests[t],!0):C(n)?!!r.tests[n]:i(n,i(vt))}}var e=g.useX();return t?(e.inclusion[t]=o(e.exclusion.tests[t],!0),{when:n}):{when:n}}function jt(t,n){K({type:f.OMIT_WHEN},(function(){g.run({omitted:i(t,i(vt))},(function(){return n()}))}))}function Ht(t){(0,k().optionalFields()[1])((function(n){if(Array.isArray(t)||C(t))[].concat(t).forEach((function(t){n[t]=!0}));else for(var e in t)n[e]=t[e];return n}))}function Kt(t,n){K({type:f.SKIP_WHEN},(function(){g.run({skipped:i(t,i(vt))},(function(){return n()}))}))}function Vt(){var t=g.useX("warn hook called outside of a running suite.");t.currentTest||s("warn called outside of a test."),t.currentTest.warn()}export{_t as VERSION,g as context,Ut as create,Mt as each,Rt as group,Gt as include,jt as omitWhen,Ot as only,Ht as optional,St as skip,Kt as skipWhen,xt as test,Vt as warn};