vest 5.0.0-dev-781e21 → 5.0.0-dev-9c596e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +2 -57
- package/dist/cjs/classnames.development.js +38 -17
- package/dist/cjs/classnames.production.js +1 -1
- package/dist/cjs/enforce/compose.development.js +5 -54
- package/dist/cjs/enforce/compose.production.js +1 -1
- package/dist/cjs/enforce/compounds.development.js +20 -83
- package/dist/cjs/enforce/compounds.production.js +1 -1
- package/dist/cjs/enforce/schema.development.js +19 -82
- package/dist/cjs/enforce/schema.production.js +1 -1
- package/dist/cjs/parser.development.js +31 -9
- package/dist/cjs/parser.production.js +1 -1
- package/dist/cjs/promisify.development.js +22 -9
- package/dist/cjs/promisify.production.js +1 -1
- package/dist/cjs/vest.development.js +1421 -1223
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/classnames.development.js +40 -19
- package/dist/es/classnames.production.js +1 -1
- package/dist/es/enforce/compose.development.js +1 -58
- package/dist/es/enforce/compose.production.js +1 -1
- package/dist/es/enforce/compounds.development.js +2 -90
- package/dist/es/enforce/compounds.production.js +1 -1
- package/dist/es/enforce/schema.development.js +2 -88
- package/dist/es/enforce/schema.production.js +1 -1
- package/dist/es/parser.development.js +32 -10
- package/dist/es/parser.production.js +1 -1
- package/dist/es/promisify.development.js +23 -10
- package/dist/es/promisify.production.js +1 -1
- package/dist/es/vest.development.js +1415 -1214
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/classnames.development.js +41 -20
- package/dist/umd/classnames.production.js +1 -1
- package/dist/umd/enforce/compose.development.js +9 -57
- package/dist/umd/enforce/compose.production.js +1 -1
- package/dist/umd/enforce/compounds.development.js +32 -94
- package/dist/umd/enforce/compounds.production.js +1 -1
- package/dist/umd/enforce/schema.development.js +32 -94
- package/dist/umd/enforce/schema.production.js +1 -1
- package/dist/umd/parser.development.js +34 -12
- package/dist/umd/parser.production.js +1 -1
- package/dist/umd/promisify.development.js +25 -12
- package/dist/umd/promisify.production.js +1 -1
- package/dist/umd/vest.development.js +1423 -1225
- package/dist/umd/vest.production.js +1 -1
- package/package.json +12 -16
- package/testUtils/TVestMock.ts +7 -0
- package/testUtils/__tests__/partition.test.ts +4 -4
- package/testUtils/mockThrowError.ts +4 -2
- package/testUtils/suiteDummy.ts +4 -1
- package/testUtils/testDummy.ts +12 -10
- package/testUtils/testPromise.ts +3 -0
- package/types/classnames.d.ts +63 -12
- package/types/classnames.d.ts.map +1 -0
- package/types/enforce/compose.d.ts +2 -126
- package/types/enforce/compose.d.ts.map +1 -0
- package/types/enforce/compounds.d.ts +2 -136
- package/types/enforce/compounds.d.ts.map +1 -0
- package/types/enforce/schema.d.ts +2 -144
- package/types/enforce/schema.d.ts.map +1 -0
- package/types/parser.d.ts +69 -18
- package/types/parser.d.ts.map +1 -0
- package/types/promisify.d.ts +60 -42
- package/types/promisify.d.ts.map +1 -0
- package/types/vest.d.ts +246 -243
- package/types/vest.d.ts.map +1 -0
- package/CHANGELOG.md +0 -87
- package/testUtils/expandStateRef.ts +0 -8
- package/testUtils/runCreateRef.ts +0 -10
- package/testUtils/testObjects.ts +0 -6
- package/tsconfig.json +0 -8
package/types/vest.d.ts
CHANGED
|
@@ -1,56 +1,166 @@
|
|
|
1
1
|
import { enforce } from 'n4s';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
}
|
|
53
|
+
}
|
|
7
54
|
type GroupTestSummary = SingleTestSummary;
|
|
8
|
-
type Groups = Record<
|
|
9
|
-
type Group = Record<
|
|
10
|
-
type Tests = Record<
|
|
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
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
151
|
+
asyncTest?: AsyncTest;
|
|
33
152
|
id: string;
|
|
34
153
|
severity: TestSeverity;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
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:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
92
|
-
|
|
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
|
|
107
|
-
|
|
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
|
-
*
|
|
198
|
+
* Adds a field or a list of fields into the inclusion list
|
|
117
199
|
*
|
|
118
200
|
* @example
|
|
119
201
|
*
|
|
120
|
-
*
|
|
121
|
-
* test("username", "Username is required", () => {
|
|
122
|
-
* enforce(data.username).isNotBlank();
|
|
123
|
-
* });
|
|
124
|
-
* });
|
|
202
|
+
* only('username');
|
|
125
203
|
*/
|
|
126
|
-
|
|
127
|
-
declare function
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
*
|
|
210
|
+
* Adds a field or a list of fields into the exclusion list
|
|
164
211
|
*
|
|
165
212
|
* @example
|
|
166
213
|
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* optional({
|
|
170
|
-
* username: () => allowUsernameEmpty,
|
|
171
|
-
* });
|
|
214
|
+
* skip('username');
|
|
172
215
|
*/
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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
|
|
199
|
-
|
|
200
|
-
|
|
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
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
type
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
|
|
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
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
322
|
-
declare function
|
|
323
|
-
declare function
|
|
324
|
-
|
|
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
|
-
|
|
346
|
-
export {
|
|
347
|
-
|
|
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)
|