vest 5.0.0-dev-781e21 → 5.0.0-dev-9c596e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +2 -57
  3. package/dist/cjs/classnames.development.js +38 -17
  4. package/dist/cjs/classnames.production.js +1 -1
  5. package/dist/cjs/enforce/compose.development.js +5 -54
  6. package/dist/cjs/enforce/compose.production.js +1 -1
  7. package/dist/cjs/enforce/compounds.development.js +20 -83
  8. package/dist/cjs/enforce/compounds.production.js +1 -1
  9. package/dist/cjs/enforce/schema.development.js +19 -82
  10. package/dist/cjs/enforce/schema.production.js +1 -1
  11. package/dist/cjs/parser.development.js +31 -9
  12. package/dist/cjs/parser.production.js +1 -1
  13. package/dist/cjs/promisify.development.js +22 -9
  14. package/dist/cjs/promisify.production.js +1 -1
  15. package/dist/cjs/vest.development.js +1421 -1223
  16. package/dist/cjs/vest.production.js +1 -1
  17. package/dist/es/classnames.development.js +40 -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 +32 -10
  26. package/dist/es/parser.production.js +1 -1
  27. package/dist/es/promisify.development.js +23 -10
  28. package/dist/es/promisify.production.js +1 -1
  29. package/dist/es/vest.development.js +1415 -1214
  30. package/dist/es/vest.production.js +1 -1
  31. package/dist/umd/classnames.development.js +41 -20
  32. package/dist/umd/classnames.production.js +1 -1
  33. package/dist/umd/enforce/compose.development.js +9 -57
  34. package/dist/umd/enforce/compose.production.js +1 -1
  35. package/dist/umd/enforce/compounds.development.js +32 -94
  36. package/dist/umd/enforce/compounds.production.js +1 -1
  37. package/dist/umd/enforce/schema.development.js +32 -94
  38. package/dist/umd/enforce/schema.production.js +1 -1
  39. package/dist/umd/parser.development.js +34 -12
  40. package/dist/umd/parser.production.js +1 -1
  41. package/dist/umd/promisify.development.js +25 -12
  42. package/dist/umd/promisify.production.js +1 -1
  43. package/dist/umd/vest.development.js +1423 -1225
  44. package/dist/umd/vest.production.js +1 -1
  45. package/package.json +12 -16
  46. package/testUtils/TVestMock.ts +7 -0
  47. package/testUtils/__tests__/partition.test.ts +4 -4
  48. package/testUtils/mockThrowError.ts +4 -2
  49. package/testUtils/suiteDummy.ts +4 -1
  50. package/testUtils/testDummy.ts +12 -10
  51. package/testUtils/testPromise.ts +3 -0
  52. package/types/classnames.d.ts +63 -12
  53. package/types/classnames.d.ts.map +1 -0
  54. package/types/enforce/compose.d.ts +2 -126
  55. package/types/enforce/compose.d.ts.map +1 -0
  56. package/types/enforce/compounds.d.ts +2 -136
  57. package/types/enforce/compounds.d.ts.map +1 -0
  58. package/types/enforce/schema.d.ts +2 -144
  59. package/types/enforce/schema.d.ts.map +1 -0
  60. package/types/parser.d.ts +69 -18
  61. package/types/parser.d.ts.map +1 -0
  62. package/types/promisify.d.ts +60 -42
  63. package/types/promisify.d.ts.map +1 -0
  64. package/types/vest.d.ts +246 -243
  65. package/types/vest.d.ts.map +1 -0
  66. package/CHANGELOG.md +0 -87
  67. package/testUtils/expandStateRef.ts +0 -8
  68. package/testUtils/runCreateRef.ts +0 -10
  69. package/testUtils/testObjects.ts +0 -6
  70. package/tsconfig.json +0 -8
package/types/vest.d.ts CHANGED
@@ -1,56 +1,166 @@
1
1
  import { enforce } from 'n4s';
2
- type SuiteSummary = {
3
- groups: Groups;
4
- tests: Tests;
2
+ import { CB } from "vest-utils";
3
+ declare enum Severity {
4
+ WARNINGS = "warnings",
5
+ ERRORS = "errors"
6
+ }
7
+ type TestFn = () => TestResult;
8
+ type AsyncTest = Promise<string | void | false>;
9
+ type TestResult = AsyncTest | boolean | void;
10
+ type WithFieldName<F extends TFieldName = TFieldName> = {
11
+ fieldName: F;
12
+ };
13
+ interface Done<F extends TFieldName, G extends TGroupName> {
14
+ (...args: [
15
+ cb: (res: SuiteResult<F, G>) => void
16
+ ]): SuiteRunResult<F, G>;
17
+ (...args: [
18
+ fieldName: F,
19
+ cb: (res: SuiteResult<F, G>) => void
20
+ ]): SuiteRunResult<F, G>;
21
+ }
22
+ // eslint-disable-next-line max-lines-per-function, max-statements
23
+ declare function suiteSelectors<F extends TFieldName, G extends TGroupName>(summary: SuiteSummary<F, G>): SuiteSelectors<F, G>;
24
+ interface SuiteSelectors<F extends TFieldName, G extends TGroupName> {
25
+ getWarning(fieldName?: F): void | string | SummaryFailure<F, G>;
26
+ getError(fieldName?: F): void | string | SummaryFailure<F, G>;
27
+ getErrors(fieldName: F): string[];
28
+ getErrors(): FailureMessages;
29
+ getWarnings(): FailureMessages;
30
+ getWarnings(fieldName: F): string[];
31
+ getErrorsByGroup(groupName: G, fieldName: F): string[];
32
+ getErrorsByGroup(groupName: G): FailureMessages;
33
+ getWarningsByGroup(groupName: G): FailureMessages;
34
+ getWarningsByGroup(groupName: G, fieldName: F): string[];
35
+ hasErrors(fieldName?: F): boolean;
36
+ hasWarnings(fieldName?: F): boolean;
37
+ hasErrorsByGroup(groupName: G, fieldName?: F): boolean;
38
+ hasWarningsByGroup(groupName: G, fieldName?: F): boolean;
39
+ isValid(fieldName?: F): boolean;
40
+ isValidByGroup(groupName: G, fieldName?: F): boolean;
41
+ }
42
+ declare class SummaryBase {
43
+ errorCount: number;
44
+ warnCount: number;
45
+ testCount: number;
46
+ }
47
+ declare class SuiteSummary<F extends TFieldName, G extends TGroupName> extends SummaryBase {
48
+ [Severity.ERRORS]: SummaryFailure<F, G>[];
49
+ [Severity.WARNINGS]: SummaryFailure<F, G>[];
50
+ groups: Groups<G, F>;
51
+ tests: Tests<F>;
5
52
  valid: boolean;
6
- } & SummaryBase;
53
+ }
7
54
  type GroupTestSummary = SingleTestSummary;
8
- type Groups = Record<string, Group>;
9
- type Group = Record<string, GroupTestSummary>;
10
- type Tests = Record<string, SingleTestSummary>;
55
+ type Groups<G extends TGroupName, F extends TFieldName> = Record<G, Group<F>>;
56
+ type Group<F extends TFieldName> = Record<F, GroupTestSummary>;
57
+ type Tests<F extends TFieldName> = Record<F, SingleTestSummary>;
11
58
  type SingleTestSummary = SummaryBase & {
12
59
  errors: string[];
13
60
  warnings: string[];
14
61
  valid: boolean;
15
62
  };
16
- type SummaryBase = {
17
- errorCount: number;
18
- warnCount: number;
19
- testCount: number;
63
+ type SummaryFailure<F extends TFieldName, G extends TGroupName> = WithFieldName<F> & {
64
+ groupName: G | undefined;
65
+ message: string | undefined;
20
66
  };
21
67
  type FailureMessages = Record<string, string[]>;
22
- declare enum TestSeverity {
23
- Error = "error",
24
- Warning = "warning"
68
+ type SuiteResult<F extends TFieldName, G extends TGroupName> = SuiteSummary<F, G> & SuiteSelectors<F, G> & {
69
+ suiteName: SuiteName;
70
+ };
71
+ type SuiteRunResult<F extends TFieldName, G extends TGroupName> = SuiteResult<F, G> & {
72
+ done: Done<F, G>;
73
+ };
74
+ type SuiteName = string | undefined;
75
+ type TFieldName<T extends string = string> = T;
76
+ type TGroupName<G extends string = string> = G;
77
+ type OptionalsInput<F extends TFieldName> = F | F[] | OptionalsObject<F>;
78
+ type OptionalsObject<F extends TFieldName> = Record<F, (() => boolean) | boolean>;
79
+ // @vx-allow use-use
80
+ declare function optional<F extends TFieldName>(optionals: OptionalsInput<F>): void;
81
+ declare class Reconciler {
82
+ static reconciler(currentNode: Isolate, historicNode: Isolate | null): Isolate;
83
+ static reconcile<Callback extends CB = CB>(node: Isolate, callback: Callback): [
84
+ Isolate,
85
+ ReturnType<Callback>
86
+ ];
87
+ static removeAllNextNodesInIsolate(): void;
88
+ static handleCollision(newNode: Isolate, prevNode: Isolate): Isolate;
89
+ static nodeReorderDetected(newNode: Isolate, prevNode: Isolate): boolean;
90
+ static onNodeReorder(newNode: Isolate, prevNode: Isolate): Isolate;
91
+ static handleIsolateNodeWithKey(node: Isolate): Isolate;
25
92
  }
26
- declare class VestTest {
27
- fieldName: string;
28
- testFn: TestFn;
29
- asyncTest?: AsyncTest;
93
+ type IsolateKey = null | string;
94
+ declare class Isolate<_D = any> {
95
+ children: Isolate[] | null;
96
+ keys: Record<string, Isolate>;
97
+ parent: Isolate | null;
98
+ output?: any;
99
+ key: IsolateKey;
100
+ allowReorder: boolean;
101
+ static reconciler: typeof Reconciler;
102
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
103
+ constructor(_data?: _D);
104
+ setParent(parent: Isolate | null): this;
105
+ saveOutput(output: any): this;
106
+ setKey(key: string | null): this;
107
+ usesKey(): boolean;
108
+ addChild(child: Isolate): void;
109
+ removeChild(node: Isolate): void;
110
+ slice(at: number): void;
111
+ at(at: number): Isolate | null;
112
+ cursor(): number;
113
+ shouldAllowReorder(): boolean;
114
+ get rootNode(): Isolate;
115
+ static create<Callback extends CB = CB>(callback: Callback, data?: any): Isolate;
116
+ private static createImplementation;
117
+ static setNode(node: Isolate): void;
118
+ static is(node: any): boolean;
119
+ }
120
+ declare class IsolateTestReconciler extends Reconciler {
121
+ static reconciler(currentNode: Isolate, historyNode: Isolate | null): Isolate;
122
+ static nodeReorderDetected(newNode: IsolateTest, prevNode?: Isolate): boolean;
123
+ static handleCollision(newNode: IsolateTest, prevNode?: Isolate): IsolateTest;
124
+ static onNodeReorder(newNode: IsolateTest, prevNode?: Isolate): IsolateTest;
125
+ static pickNode(historyNode: IsolateTest, currentNode: IsolateTest): Isolate;
126
+ static handleNoHistoryNode(testNode: IsolateTest): IsolateTest;
127
+ }
128
+ declare enum TestStatus {
129
+ UNTESTED = "UNTESTED",
130
+ SKIPPED = "SKIPPED",
131
+ FAILED = "FAILED",
132
+ WARNING = "WARNING",
133
+ PASSING = "PASSING",
134
+ PENDING = "PENDING",
135
+ CANCELED = "CANCELED",
136
+ OMITTED = "OMITTED"
137
+ }
138
+ type IsolateTestInput = {
139
+ message?: string;
30
140
  groupName?: string;
141
+ fieldName: TFieldName;
142
+ testFn: TestFn;
143
+ key?: IsolateKey;
144
+ };
145
+ declare class IsolateTest<F extends TFieldName = TFieldName, G extends TGroupName = TGroupName> extends Isolate {
146
+ children: null;
147
+ fieldName: F;
148
+ testFn: TestFn;
149
+ groupName?: G;
31
150
  message?: string;
32
- key?: null | string;
151
+ asyncTest?: AsyncTest;
33
152
  id: string;
34
153
  severity: TestSeverity;
35
- status: KStatus;
36
- constructor(fieldName: string, testFn: TestFn, { message, groupName, key }?: {
37
- message?: string;
38
- groupName?: string;
39
- key?: string;
40
- });
154
+ private stateMachine;
155
+ static reconciler: typeof IsolateTestReconciler;
156
+ constructor({ fieldName, testFn, message, groupName, key }: IsolateTestInput);
157
+ static create<Callback extends CB = CB>(callback: Callback, data: IsolateTestInput): IsolateTest;
158
+ static cast<F extends TFieldName = TFieldName, G extends TGroupName = TGroupName>(isolate: Isolate): IsolateTest<F, G>;
159
+ get status(): TestStatus;
160
+ setStatus(status: TestStatus, payload?: any): void;
41
161
  run(): TestResult;
42
- setStatus(status: KStatus): void;
162
+ // Selectors
43
163
  warns(): boolean;
44
- setPending(): void;
45
- fail(): void;
46
- done(): void;
47
- warn(): void;
48
- isFinalStatus(): boolean;
49
- skip(force?: boolean): void;
50
- cancel(): void;
51
- reset(): void;
52
- omit(): void;
53
- valueOf(): boolean;
54
164
  isPending(): boolean;
55
165
  isOmitted(): boolean;
56
166
  isUntested(): boolean;
@@ -63,172 +173,105 @@ declare class VestTest {
63
173
  isNonActionable(): boolean;
64
174
  isTested(): boolean;
65
175
  awaitsResolution(): boolean;
66
- statusEquals(status: KStatus): boolean;
67
- }
68
- type AsyncTest = Promise<string | void>;
69
- type TestResult = AsyncTest | boolean | void;
70
- type TestFn = () => TestResult;
71
- type KStatus = "UNTESTED" | "SKIPPED" | "FAILED" | "WARNING" | "PASSING" | "PENDING" | "CANCELED" | "OMITTED";
72
- type CB = (...args: any[]) => any;
73
- // eslint-disable-next-line max-lines-per-function, max-statements
74
- declare function suiteSelectors(summary: SuiteSummary): SuiteSelectors;
75
- interface SuiteSelectors {
76
- getErrors(fieldName: string): string[];
77
- getErrors(): FailureMessages;
78
- getWarnings(): FailureMessages;
79
- getWarnings(fieldName: string): string[];
80
- getErrorsByGroup(groupName: string, fieldName: string): string[];
81
- getErrorsByGroup(groupName: string): FailureMessages;
82
- getWarningsByGroup(groupName: string): FailureMessages;
83
- getWarningsByGroup(groupName: string, fieldName: string): string[];
84
- hasErrors(fieldName?: string): boolean;
85
- hasWarnings(fieldName?: string): boolean;
86
- hasErrorsByGroup(groupName: string, fieldName?: string): boolean;
87
- hasWarningsByGroup(groupName: string, fieldName?: string): boolean;
88
- isValid(fieldName?: string): boolean;
89
- isValidByGroup(groupName: string, fieldName?: string): boolean;
176
+ statusEquals(status: TestStatus): boolean;
177
+ // State modifiers
178
+ setPending(): void;
179
+ fail(): void;
180
+ pass(): void;
181
+ warn(): void;
182
+ skip(force?: boolean): void;
183
+ cancel(): void;
184
+ reset(): void;
185
+ omit(): void;
186
+ valueOf(): boolean;
187
+ isAsyncTest(): boolean;
188
+ static is(value: any): value is IsolateTest;
189
+ static isX(value: any): asserts value is IsolateTest;
90
190
  }
91
- type SuiteResult = SuiteSummary & SuiteSelectors & {
92
- suiteName: SuiteName;
93
- };
94
- type SuiteRunResult = SuiteResult & {
95
- done: Done;
96
- };
97
- interface Done {
98
- (...args: [
99
- cb: (res: SuiteResult) => void
100
- ]): SuiteRunResult;
101
- (...args: [
102
- fieldName: string,
103
- cb: (res: SuiteResult) => void
104
- ]): SuiteRunResult;
191
+ declare enum TestSeverity {
192
+ Error = "error",
193
+ Warning = "warning"
105
194
  }
106
- type CreateProperties = {
107
- get: () => SuiteResult;
108
- reset: () => void;
109
- resetField: (fieldName: string) => void;
110
- remove: (fieldName: string) => void;
111
- };
112
- type Suite<T extends CB> = {
113
- (...args: Parameters<T>): SuiteRunResult;
114
- } & CreateProperties;
195
+ type FieldExclusion<F extends TFieldName> = F | F[] | undefined;
196
+ type GroupExclusion<G extends TGroupName> = G | G[] | undefined;
115
197
  /**
116
- * Creates a new validation suite
198
+ * Adds a field or a list of fields into the inclusion list
117
199
  *
118
200
  * @example
119
201
  *
120
- * const suite = create((data = {}) => {
121
- * test("username", "Username is required", () => {
122
- * enforce(data.username).isNotBlank();
123
- * });
124
- * });
202
+ * only('username');
125
203
  */
126
- declare function create<T extends CB>(suiteName: SuiteName, suiteCallback: T): Suite<T>;
127
- declare function create<T extends CB>(suiteCallback: T): Suite<T>;
128
- type SuiteName = string | void;
129
- type IsolateCursor = {
130
- current: () => number;
131
- next: () => void;
132
- };
133
- declare enum IsolateTypes {
134
- DEFAULT = 0,
135
- SUITE = 1,
136
- EACH = 2,
137
- SKIP_WHEN = 3,
138
- OMIT_WHEN = 4,
139
- GROUP = 5
140
- }
141
- type IsolateKeys = {
142
- current: Record<string, VestTest>;
143
- prev: Record<string, VestTest>;
144
- };
145
- type Isolate = {
146
- type: IsolateTypes;
147
- keys: IsolateKeys;
148
- path: number[];
149
- cursor: IsolateCursor;
150
- };
151
- declare enum Modes {
152
- ALL = 0,
153
- EAGER = 1
204
+ // @vx-allow use-use
205
+ declare function only<F extends TFieldName>(item: FieldExclusion<F>): void;
206
+ declare namespace only {
207
+ var group: <G extends string>(item: GroupExclusion<G>) => void;
154
208
  }
155
- type NestedArray<T> = Array<NestedArray<T> | T>;
156
- type SetStateInput<S> = S | ((prevState: S) => S);
157
- type StateHandlerReturn<S> = [
158
- S,
159
- (nextState: SetStateInput<S>) => void
160
- ];
161
- type UseState<S> = () => StateHandlerReturn<S>;
162
209
  /**
163
- * Marks a field as optional, either just by name, or by a given condition.
210
+ * Adds a field or a list of fields into the exclusion list
164
211
  *
165
212
  * @example
166
213
  *
167
- * optional('field_name');
168
- *
169
- * optional({
170
- * username: () => allowUsernameEmpty,
171
- * });
214
+ * skip('username');
172
215
  */
173
- declare function optional(optionals: OptionalsInput): void;
174
- type OptionalsInput = string | string[] | OptionalsObject;
175
- type OptionalsObject = Record<string, (() => boolean) | boolean>;
176
- type ImmediateOptionalFieldDeclaration = {
177
- type: OptionalFieldTypes.Immediate;
178
- rule: boolean | (() => boolean);
179
- applied: boolean;
180
- };
181
- type DelayedOptionalFieldDeclaration = {
182
- type: OptionalFieldTypes.Delayed;
183
- applied: boolean;
184
- rule: null;
185
- };
186
- type OptionalFieldDeclaration = ImmediateOptionalFieldDeclaration | DelayedOptionalFieldDeclaration;
187
- declare enum OptionalFieldTypes {
188
- Immediate = 0,
189
- Delayed = 1
216
+ // @vx-allow use-use
217
+ declare function skip<F extends TFieldName>(item: FieldExclusion<F>): void;
218
+ declare namespace skip {
219
+ var group: <G extends string>(item: GroupExclusion<G>) => void;
190
220
  }
191
- type StateRef = {
192
- optionalFields: UseState<OptionalFields>;
193
- suiteId: UseState<string>;
194
- suiteName: UseState<SuiteName>;
195
- testCallbacks: UseState<TestCallbacks>;
196
- testObjects: UseState<TestObjects>;
221
+ declare function vestTest<F extends TFieldName>(fieldName: F, message: string, cb: TestFn): IsolateTest;
222
+ declare function vestTest<F extends TFieldName>(fieldName: F, cb: TestFn): IsolateTest;
223
+ declare function vestTest<F extends TFieldName>(fieldName: F, message: string, cb: TestFn, key: IsolateKey): IsolateTest;
224
+ declare function vestTest<F extends TFieldName>(fieldName: F, cb: TestFn, key: IsolateKey): IsolateTest;
225
+ declare const test: typeof vestTest & {
226
+ memo: TestMemo<string>;
197
227
  };
198
- type OptionalFields = Record<string, OptionalFieldDeclaration>;
199
- type TestCallbacks = {
200
- fieldCallbacks: Record<string, Array<(res: SuiteResult) => void>>;
201
- doneCallbacks: Array<(res: SuiteResult) => void>;
228
+ type TestMemo<F extends TFieldName> = {
229
+ (fieldName: F, ...args: ParametersWithoutMessage): IsolateTest;
230
+ (fieldName: F, ...args: ParametersWithMessage): IsolateTest;
202
231
  };
203
- type TestObjects = {
204
- prev: VestTests;
205
- current: VestTests;
206
- };
207
- type VestTests = NestedArray<VestTest>;
208
- declare const _default: import("context").CtxCascadeApi<CTXType>;
209
- type CTXType = {
210
- isolate: Isolate;
211
- stateRef?: StateRef;
212
- exclusion: {
213
- tests: Record<string, boolean>;
214
- groups: Record<string, boolean>;
232
+ type ParametersWithoutMessage = [
233
+ test: TestFn,
234
+ dependencies: unknown[]
235
+ ];
236
+ type ParametersWithMessage = [
237
+ message: string,
238
+ test: TestFn,
239
+ dependencies: unknown[]
240
+ ];
241
+ type TTypedMethods<F extends TFieldName, G extends TGroupName> = {
242
+ include: (fieldName: F) => {
243
+ when: (condition: boolean | F | ((draft: SuiteResult<F, G>) => boolean)) => void;
215
244
  };
216
- inclusion: Record<string, boolean | (() => boolean)>;
217
- currentTest?: VestTest;
218
- groupName?: string;
219
- skipped?: boolean;
220
- omitted?: boolean;
221
- mode: [
222
- Modes
223
- ];
224
- bus?: {
225
- on: (event: string, handler: CB) => {
226
- off: () => void;
227
- };
228
- emit: (event: string, ...args: any[]) => void;
245
+ omitWhen: (conditional: boolean | ((draft: SuiteResult<F, G>) => boolean), callback: CB) => void;
246
+ only: {
247
+ (item: FieldExclusion<F>): void;
248
+ group(item: GroupExclusion<G>): void;
249
+ };
250
+ optional: (optionals: OptionalsInput<F>) => void;
251
+ skip: {
252
+ (item: FieldExclusion<F>): void;
253
+ group(item: GroupExclusion<G>): void;
229
254
  };
255
+ skipWhen: (condition: boolean | ((draft: SuiteResult<F, G>) => boolean), callback: CB) => void;
256
+ test: {
257
+ (fieldName: F, message: string, cb: TestFn): IsolateTest;
258
+ (fieldName: F, cb: TestFn): IsolateTest;
259
+ (fieldName: F, message: string, cb: TestFn, key: IsolateKey): IsolateTest;
260
+ (fieldName: F, cb: TestFn, key: IsolateKey): IsolateTest;
261
+ } & {
262
+ memo: TestMemo<F>;
263
+ };
264
+ group: (groupName: G, callback: () => void) => Isolate;
230
265
  };
231
- declare const context: typeof _default;
266
+ type Suite<T extends CB, F extends TFieldName, G extends TGroupName> = ((...args: Parameters<T>) => SuiteRunResult<F, G>) & SuiteMethods<F, G>;
267
+ type SuiteMethods<F extends TFieldName, G extends TGroupName> = {
268
+ get: () => SuiteResult<F, G>;
269
+ reset: () => void;
270
+ remove: (fieldName: F) => void;
271
+ resetField: (fieldName: F) => void;
272
+ } & TTypedMethods<F, G>;
273
+ declare function createSuite<T extends CB, F extends TFieldName = string, G extends TGroupName = string>(suiteName: SuiteName, suiteCallback: T): Suite<T, F, G>;
274
+ declare function createSuite<T extends CB, F extends TFieldName = string, G extends TGroupName = string>(suiteCallback: T): Suite<T, F, G>;
232
275
  /**
233
276
  * Iterates over an array of items, allowing to run tests individually per item.
234
277
  *
@@ -243,42 +286,15 @@ declare const context: typeof _default;
243
286
  * })
244
287
  */
245
288
  declare function each<T>(list: T[], callback: (arg: T, index: number) => void): void;
246
- type ExclusionItem = string | string[] | undefined;
247
- /**
248
- * Adds a field or a list of fields into the inclusion list
249
- *
250
- * @example
251
- *
252
- * only('username');
253
- */
254
- declare function only(item: ExclusionItem): void;
255
- declare namespace only {
256
- var group: (item: ExclusionItem) => void;
257
- }
258
- /**
259
- * Adds a field or a list of fields into the exclusion list
260
- *
261
- * @example
262
- *
263
- * skip('username');
264
- */
265
- declare function skip(item: ExclusionItem): void;
266
- declare namespace skip {
267
- var group: (item: ExclusionItem) => void;
268
- }
269
- /**
270
- * Runs tests within a group so that they can be controlled or queried separately.
271
- *
272
- * @example
273
- *
274
- * group('group_name', () => {
275
- * // Tests go here
276
- * });
277
- */
278
- declare function group(groupName: string, tests: () => void): void;
279
- declare function include(fieldName: string): {
280
- when: (condition: string | boolean | ((draft: SuiteResult) => boolean)) => void;
289
+ declare function group<G extends TGroupName>(groupName: G, callback: () => void): Isolate;
290
+ // @vx-allow use-use
291
+ declare function include<F extends TFieldName, G extends TGroupName>(fieldName: F): {
292
+ when: (condition: F | TFieldName | boolean | ((draft: SuiteResult<F, G>) => boolean)) => void;
281
293
  };
294
+ declare enum Modes {
295
+ ALL = "ALL",
296
+ EAGER = "EAGER"
297
+ }
282
298
  /**
283
299
  * Sets the suite to "eager" (fail fast) mode.
284
300
  * Eager mode will skip running subsequent tests of a failing fields.
@@ -298,7 +314,8 @@ declare function include(fieldName: string): {
298
314
  * });
299
315
  * });
300
316
  */
301
- declare function eager(): void;
317
+ // @vx-allow use-use
318
+ declare function mode(mode: Modes): void;
302
319
  /**
303
320
  * Conditionally omits tests from the suite.
304
321
  *
@@ -308,7 +325,8 @@ declare function eager(): void;
308
325
  * test('username', 'User already taken', async () => await doesUserExist(username)
309
326
  * });
310
327
  */
311
- declare function omitWhen(conditional: boolean | ((draft: SuiteResult) => boolean), callback: CB): void;
328
+ // @vx-allow use-use
329
+ declare function omitWhen<F extends TFieldName, G extends TGroupName>(conditional: boolean | ((draft: SuiteResult<F, G>) => boolean), callback: CB): void;
312
330
  /**
313
331
  * Conditionally skips running tests within the callback.
314
332
  *
@@ -318,30 +336,15 @@ declare function omitWhen(conditional: boolean | ((draft: SuiteResult) => boolea
318
336
  * test('username', 'User already taken', async () => await doesUserExist(username)
319
337
  * });
320
338
  */
321
- declare function skipWhen(conditional: boolean | ((draft: SuiteResult) => boolean), callback: CB): void;
322
- declare function testBase(fieldName: string, message: string, cb: TestFn): VestTest;
323
- declare function testBase(fieldName: string, cb: TestFn): VestTest;
324
- declare function testBase(fieldName: string, message: string, cb: TestFn, key: string): VestTest;
325
- declare function testBase(fieldName: string, cb: TestFn, key: string): VestTest;
326
- /**
327
- * Represents a single case in a validation suite.
328
- *
329
- * @example
330
- *
331
- * test("username", "Username is required", () => {
332
- * enforce(data.username).isNotBlank();
333
- * });
334
- */
335
- declare const test: typeof testBase & {
336
- memo: {
337
- (fieldName: string, test: TestFn, deps: unknown[]): VestTest;
338
- (fieldName: string, message: string, test: TestFn, deps: unknown[]): VestTest;
339
- };
340
- };
339
+ // @vx-allow use-use
340
+ declare function skipWhen<F extends TFieldName, G extends TGroupName>(condition: boolean | ((draft: SuiteResult<F, G>) => boolean), callback: CB): void;
341
+ declare function staticSuite<T extends CB, F extends TFieldName = string, G extends TGroupName = string>(suiteCallback: T): StaticSuite<T, F, G>;
342
+ type StaticSuite<T extends CB, F extends TFieldName = string, G extends TGroupName = string> = ((...args: Parameters<T>) => SuiteRunResult<F, G>) & TTypedMethods<F, G>;
341
343
  /**
342
344
  * Sets a running test to warn only mode.
343
345
  */
346
+ // @vx-allow use-use
344
347
  declare function warn(): void;
345
- declare const VERSION = "5.0.0-dev-781e21";
346
- export { suiteSelectors, test, create, each, only, skip, warn, group, optional, skipWhen, omitWhen, enforce, VERSION, context, include, eager };
347
- export type { SuiteResult, SuiteRunResult, SuiteSummary, VestTest, Suite };
348
+ export { createSuite as create, test, group, optional, enforce, skip, skipWhen, omitWhen, only, warn, include, suiteSelectors, each, mode, staticSuite, Modes };
349
+ export type { SuiteResult, SuiteRunResult, SuiteSummary, IsolateTest, Suite };
350
+ //# sourceMappingURL=vest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vest.d.ts","sourceRoot":"","sources":["../src/vest.ts","../src/core/isolate/walker.ts","../src/core/VestBus/Events.ts","../src/errors/ErrorStrings.ts","../src/suiteResult/Severity.ts","../src/core/test/TestTypes.ts","../src/core/isolate/reconciler/Reconciler/Reconciler.ts","../src/core/test/helpers/matchingFieldName.ts","../src/core/isolate/reconciler/isSameProfileTest.ts","../src/core/isolate/reconciler/cancelOverriddenPendingTest.ts","../src/core/test/helpers/matchingGroupName.ts","../src/core/test/helpers/nonMatchingSeverityProfile.ts","../src/suiteResult/selectors/hasFailuresByTestObjects.ts","../src/hooks/mode.ts","../src/core/context/SuiteContext.ts","../src/hooks/optional/OptionalTypes.ts","../src/suiteResult/selectors/shouldAddValidProperty.ts","../src/suiteResult/selectors/produceSuiteSummary.ts","../src/suiteResult/selectors/collectFailures.ts","../src/suiteResult/selectors/suiteSelectors.ts","../src/suiteResult/suiteResult.ts","../src/isolates/skipWhen.ts","../src/hooks/exclusive.ts","../src/isolates/omitWhen.ts","../src/core/test/testLevelFlowControl/verifyTestRun.ts","../src/core/isolate/IsolateTest/IsolateTestReconciler.ts","../src/core/isolate/IsolateTest/SimpleStateMachine.ts","../src/core/isolate/IsolateTest/IsolateTestStateMachine.ts","../src/core/test/helpers/shouldUseErrorMessage.ts","../src/core/isolate/IsolateTest/IsolateTest.ts","../src/core/isolate/IsolateTest/TestWalker.ts","../src/suiteResult/done/deferDoneCallback.ts","../src/suiteResult/done/shouldSkipDoneRegistration.ts","../src/suiteResult/suiteRunResult.ts","../src/suiteResult/SuiteResultTypes.ts","../src/suite/runCallbacks.ts","../src/core/VestBus/VestBus.ts","../src/core/context/PersistedContext.ts","../src/core/isolate/Isolate.ts","../src/core/isolate/IsolateSuite/IsolateSuite.ts","../src/hooks/optional/optional.ts","../src/hooks/include.ts","../src/core/test/testLevelFlowControl/runTest.ts","../src/core/test/test.memo.ts","../src/core/test/test.ts","../src/suite/getTypedMethods.ts","../src/suite/SuiteTypes.ts","../src/suite/validateParams/validateSuiteParams.ts","../src/suite/createSuite.ts","../src/core/isolate/IsolateEach/IsolateEach.ts","../src/isolates/each.ts","../src/isolates/group.ts","../src/suite/staticSuite.ts","../src/hooks/warn.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuB9B,OAAO,wJAiBN,CAAC;AAEF,YAAY,iEAAiE,CAAC"}
package/CHANGELOG.md DELETED
@@ -1,87 +0,0 @@
1
- # vest - Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
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
-
7
- ## 3.2.7 - 2021-07-17
8
-
9
- ### Fixed and improved
10
-
11
- - .github/PULL_REQUEST_TEMPLATE.md
12
- - aec6cd6 chore: cleanup unused code (ealush)
13
- - 0103b38 lint: handling lint of all packages (ealush)
14
- - .gitignore
15
- - 03cf487 patch(n4s): add ruleReturn default values (ealush)
16
- - 76e8c98 fix(n4s): make enforce compound runners fall back to correct response (ealush)
17
- - ff91bd2 fix(n4s): make enforce chaining work (ealush)
18
- - c3fd912 chore: some lint fixes (ealush)
19
- - f6321cf add cli options support (ealush)
20
- - 49b6b84 Vest 4 Infra Setup (ealush)
21
- - ba6c296 patch: remove unused optional references from the state (ealush)
22
-
23
- ## 3.2.6 - 2021-07-17
24
-
25
- ### Fixed and improved
26
-
27
- - .github/PULL_REQUEST_TEMPLATE.md
28
- - aec6cd6 chore: cleanup unused code (ealush)
29
- - 0103b38 lint: handling lint of all packages (ealush)
30
- - .gitignore
31
- - 03cf487 patch(n4s): add ruleReturn default values (ealush)
32
- - 76e8c98 fix(n4s): make enforce compound runners fall back to correct response (ealush)
33
- - ff91bd2 fix(n4s): make enforce chaining work (ealush)
34
- - c3fd912 chore: some lint fixes (ealush)
35
- - f6321cf add cli options support (ealush)
36
- - 49b6b84 Vest 4 Infra Setup (ealush)
37
- - ba6c296 patch: remove unused optional references from the state (ealush)
38
-
39
- ## 3.2.5 - 2021-07-17
40
-
41
- ### Fixed and improved
42
-
43
- - .github/PULL_REQUEST_TEMPLATE.md
44
- - aec6cd6 chore: cleanup unused code (ealush)
45
- - 0103b38 lint: handling lint of all packages (ealush)
46
- - .gitignore
47
- - 03cf487 patch(n4s): add ruleReturn default values (ealush)
48
- - 76e8c98 fix(n4s): make enforce compound runners fall back to correct response (ealush)
49
- - ff91bd2 fix(n4s): make enforce chaining work (ealush)
50
- - c3fd912 chore: some lint fixes (ealush)
51
- - f6321cf add cli options support (ealush)
52
- - 49b6b84 Vest 4 Infra Setup (ealush)
53
- - ba6c296 patch: remove unused optional references from the state (ealush)
54
-
55
- ## 1.0.31 - 2021-07-02
56
-
57
- ### Fixed and improved
58
-
59
- - e6ea7d6 support global replaces (undefined)
60
- - 34e0414 improved conditions (undefined)
61
- - 26c28c6 all tests pass (undefined)
62
- - 33f4e46 release (undefined)
63
- - 6fe40c7 better bundle (undefined)
64
- - c2cfb65 better typing (undefined)
65
- - c6387ab before ts settings (undefined)
66
- - c0e9708 generate correct d.ts file (undefined)
67
- - packages/vest/types/vest.development.d.ts
68
- - 8e01b8e x (undefined)
69
- - afb3960 x (undefined)
70
- - e0a8463 add changelog support (undefined)
71
- - cc46c38 current (undefined)
72
- - 4a2073f patch(vest): changes (ealush)
73
- - c0a1705 patch(vest): changes (ealush)
74
- - 240386c better create generic (ealush)
75
- - b6db1c6 transform any to unknowns (ealush)
76
- - f2c20a7 add done integration tests (ealush)
77
- - ba56e33 produce methods (ealush)
78
- - 0638243 better produce integration tests (ealush)
79
- - 4098a11 getFailures as integration tests (ealush)
80
- - f56cf7f pd (ealush)
81
- - 2ea440e pd (ealush)
82
- - b3032ef relocate draftresult (ealush)
83
- - 962141f test getFailuresByGroup (ealush)
84
- - e163c56 test getFailures (ealush)
85
- - a92b6df test collectFailureMessages (ealush)
86
- - 81aad51 fix most tests (ealush)
87
- - c149e90 simplify collectFailureMessages (ealush)
@@ -1,8 +0,0 @@
1
- export default function expandStateRef(stateRef) {
2
- const state = {};
3
- for (const key in stateRef) {
4
- const [value] = stateRef[key]();
5
- state[key] = value;
6
- }
7
- return state;
8
- }