vest 4.3.4 → 4.4.1

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.
@@ -7,16 +7,14 @@ type SuiteSummary = {
7
7
  tests: Tests;
8
8
  valid: boolean;
9
9
  } & SummaryBase;
10
- type GroupTestSummary = BaseTestSummary;
10
+ type GroupTestSummary = SingleTestSummary;
11
11
  type Groups = Record<string, Group>;
12
12
  type Group = Record<string, GroupTestSummary>;
13
13
  type Tests = Record<string, SingleTestSummary>;
14
- type SingleTestSummary = BaseTestSummary & {
15
- valid: boolean;
16
- };
17
- type BaseTestSummary = SummaryBase & {
14
+ type SingleTestSummary = SummaryBase & {
18
15
  errors: string[];
19
16
  warnings: string[];
17
+ valid: boolean;
20
18
  };
21
19
  type SummaryBase = {
22
20
  errorCount: number;
@@ -36,13 +34,16 @@ declare function hasErrors(fieldName?: string): boolean;
36
34
  declare function hasWarnings(fieldName?: string): boolean;
37
35
  declare function hasErrorsByGroup(groupName: string, fieldName?: string): boolean;
38
36
  declare function hasWarningsByGroup(groupName: string, fieldName?: string): boolean;
37
+ declare function isValid(fieldName?: string): boolean;
38
+ declare function isValidByGroup(groupName: string, fieldName?: string): boolean;
39
39
  type SuiteResult = ReturnType<typeof genTestsSummary> & {
40
40
  /**
41
41
  * Returns whether the suite as a whole is valid.
42
42
  * Determined if there are no errors, and if no
43
43
  * required fields are skipped.
44
44
  */
45
- isValid: (fieldName?: string) => boolean;
45
+ isValid: typeof isValid;
46
+ isValidByGroup: typeof isValidByGroup;
46
47
  hasErrors: typeof hasErrors;
47
48
  hasWarnings: typeof hasWarnings;
48
49
  getErrors: typeof getErrors;
package/types/vest.d.ts CHANGED
@@ -58,16 +58,14 @@ type SuiteSummary = {
58
58
  tests: Tests;
59
59
  valid: boolean;
60
60
  } & SummaryBase;
61
- type GroupTestSummary = BaseTestSummary;
61
+ type GroupTestSummary = SingleTestSummary;
62
62
  type Groups = Record<string, Group>;
63
63
  type Group = Record<string, GroupTestSummary>;
64
64
  type Tests = Record<string, SingleTestSummary>;
65
- type SingleTestSummary = BaseTestSummary & {
66
- valid: boolean;
67
- };
68
- type BaseTestSummary = SummaryBase & {
65
+ type SingleTestSummary = SummaryBase & {
69
66
  errors: string[];
70
67
  warnings: string[];
68
+ valid: boolean;
71
69
  };
72
70
  type SummaryBase = {
73
71
  errorCount: number;
@@ -87,13 +85,16 @@ declare function hasErrors(fieldName?: string): boolean;
87
85
  declare function hasWarnings(fieldName?: string): boolean;
88
86
  declare function hasErrorsByGroup(groupName: string, fieldName?: string): boolean;
89
87
  declare function hasWarningsByGroup(groupName: string, fieldName?: string): boolean;
88
+ declare function isValid(fieldName?: string): boolean;
89
+ declare function isValidByGroup(groupName: string, fieldName?: string): boolean;
90
90
  type SuiteResult = ReturnType<typeof genTestsSummary> & {
91
91
  /**
92
92
  * Returns whether the suite as a whole is valid.
93
93
  * Determined if there are no errors, and if no
94
94
  * required fields are skipped.
95
95
  */
96
- isValid: (fieldName?: string) => boolean;
96
+ isValid: typeof isValid;
97
+ isValidByGroup: typeof isValidByGroup;
97
98
  hasErrors: typeof hasErrors;
98
99
  hasWarnings: typeof hasWarnings;
99
100
  getErrors: typeof getErrors;
@@ -137,13 +138,9 @@ type Suite<T extends CB> = {
137
138
  */
138
139
  declare function create<T extends CB>(suiteName: string, suiteCallback: T): Suite<T>;
139
140
  declare function create<T extends CB>(suiteCallback: T): Suite<T>;
140
- declare function createCursor(): {
141
- addLevel: () => void;
142
- cursorAt: () => number;
143
- getCursor: () => number[];
144
- next: () => number;
145
- removeLevel: () => void;
146
- reset: () => void;
141
+ type IsolateCursor = {
142
+ current: () => number;
143
+ next: () => void;
147
144
  };
148
145
  declare enum IsolateTypes {
149
146
  DEFAULT = 0,
@@ -157,44 +154,43 @@ type IsolateKeys = {
157
154
  current: Record<string, VestTest>;
158
155
  prev: Record<string, VestTest>;
159
156
  };
157
+ type Isolate = {
158
+ type: IsolateTypes;
159
+ keys: IsolateKeys;
160
+ path: number[];
161
+ cursor: IsolateCursor;
162
+ };
160
163
  declare enum Modes {
161
164
  ALL = 0,
162
165
  EAGER = 1
163
166
  }
164
167
  type NestedArray<T> = Array<NestedArray<T> | T>;
165
- // eslint-disable-next-line max-lines-per-function
166
- declare function createState(onStateChange?: (...args: unknown[]) => unknown): CreateStateReturn;
167
- type StateInput<S> = S | ((prevState?: S) => S);
168
168
  type SetStateInput<S> = S | ((prevState: S) => S);
169
- type State = ReturnType<typeof createState>;
170
169
  type StateHandlerReturn<S> = [
171
170
  S,
172
171
  (nextState: SetStateInput<S>) => void
173
172
  ];
174
- type CreateStateReturn = {
175
- reset: () => void;
176
- registerStateKey: <S>(initialState?: StateInput<S> | undefined, onUpdate?: (() => void) | undefined) => () => StateHandlerReturn<S>;
173
+ type UseState<S> = () => StateHandlerReturn<S>;
174
+ type StateRef = {
175
+ optionalFields: UseState<OptionalFields>;
176
+ suiteId: UseState<string>;
177
+ suiteName: UseState<SuiteName>;
178
+ testCallbacks: UseState<TestCallbacks>;
179
+ testObjects: UseState<TestObjects>;
177
180
  };
178
- declare function createStateRef(state: State, { suiteId, suiteName }: {
179
- suiteId: string;
180
- suiteName?: void | string;
181
- }): {
182
- optionalFields: () => StateHandlerReturn<Record<string, [
183
- rule: boolean | (() => boolean),
184
- isApplied: boolean
185
- ]>>;
186
- suiteId: () => StateHandlerReturn<string>;
187
- suiteName: () => StateHandlerReturn<string | void>;
188
- testCallbacks: () => StateHandlerReturn<{
189
- fieldCallbacks: Record<string, ((res: SuiteResult) => void)[]>;
190
- doneCallbacks: ((res: SuiteResult) => void)[];
191
- }>;
192
- testObjects: () => StateHandlerReturn<{
193
- prev: NestedArray<VestTest>;
194
- current: NestedArray<VestTest>;
195
- }>;
181
+ type OptionalFields = Record<string, [
182
+ rule: (() => boolean) | boolean,
183
+ isApplied: boolean
184
+ ]>;
185
+ type SuiteName = string | void;
186
+ type TestCallbacks = {
187
+ fieldCallbacks: Record<string, Array<(res: SuiteResult) => void>>;
188
+ doneCallbacks: Array<(res: SuiteResult) => void>;
189
+ };
190
+ type TestObjects = {
191
+ prev: NestedArray<VestTest>;
192
+ current: NestedArray<VestTest>;
196
193
  };
197
- type StateRef = ReturnType<typeof createStateRef>;
198
194
  declare const _default: {
199
195
  run: <R>(ctxRef: Partial<CTXType>, fn: (context: CTXType) => R) => R;
200
196
  bind: <Fn extends (...args: any[]) => any>(ctxRef: Partial<CTXType>, fn: Fn) => Fn;
@@ -202,11 +198,7 @@ declare const _default: {
202
198
  useX: (errorMessage?: string | undefined) => CTXType;
203
199
  };
204
200
  type CTXType = {
205
- isolate: {
206
- type: IsolateTypes;
207
- keys: IsolateKeys;
208
- };
209
- testCursor: ReturnType<typeof createCursor>;
201
+ isolate: Isolate;
210
202
  stateRef?: StateRef;
211
203
  exclusion: {
212
204
  tests: Record<string, boolean>;
@@ -356,6 +348,6 @@ declare const test: typeof testBase & {
356
348
  * Sets a running test to warn only mode.
357
349
  */
358
350
  declare function warn(): void;
359
- declare const VERSION = "4.3.4";
351
+ declare const VERSION = "4.4.1";
360
352
  export { test, create, each, only, skip, warn, group, optional, skipWhen, omitWhen, enforce, VERSION, context, include, eager };
361
353
  export type { SuiteResult, SuiteRunResult, SuiteSummary, VestTest, Suite };