forked from avajs/ava
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js.flow
205 lines (171 loc) · 8.38 KB
/
index.js.flow
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// @flow
export interface PromiseLike<R> {
then<U>(onFulfill?: (value: R) => Promise<U> | U, onReject?: (error: any) => Promise<U> | U): Promise<U>;
}
export interface ObservableLike {
subscribe(observer: (value: any) => void): void;
}
export type ThrowsErrorValidator = Class<{constructor(...args: Array<any>): any}> | RegExp | string | ((error: any) => boolean);
export interface SnapshotOptions {
id?: string;
}
export interface Assertions {
deepEqual(actual: any, expected: any, message?: string): void;
fail(message?: string): void;
false(actual: any, message?: string): void;
falsy(actual: any, message?: string): void;
ifError(error: any, message?: string): void;
is(actual: any, expected: any, message?: string): void;
not(actual: any, expected: any, message?: string): void;
notDeepEqual(actual: any, expected: any, message?: string): void;
notRegex(string: string, regex: RegExp, message?: string): void;
notThrows(value: () => ObservableLike, message?: string): Promise<void>;
notThrows(value: () => PromiseLike<any>, message?: string): Promise<void>;
notThrows(value: () => any, message?: string): void;
notThrows(value: ObservableLike, message?: string): Promise<void>;
notThrows(value: PromiseLike<any>, message?: string): Promise<void>;
pass(message?: string): void;
regex(string: string, regex: RegExp, message?: string): void;
snapshot(expected: any, message?: string): void;
snapshot(expected: any, options: SnapshotOptions, message?: string): void;
throws(value: () => ObservableLike, error?: ThrowsErrorValidator, message?: string): Promise<any>;
throws(value: () => PromiseLike<any>, error?: ThrowsErrorValidator, message?: string): Promise<any>;
throws(value: () => any, error?: ThrowsErrorValidator, message?: string): any;
throws(value: ObservableLike, error?: ThrowsErrorValidator, message?: string): Promise<any>;
throws(value: PromiseLike<any>, error?: ThrowsErrorValidator, message?: string): Promise<any>;
true(actual: any, message?: string): void;
truthy(actual: any, message?: string): void;
}
export interface ExecutionContext<Context = {}> extends Assertions {
context: Context;
skip: Assertions;
title: string;
log(...values: Array<any>): void;
plan(count: number): void;
}
export interface CbExecutionContext<Context = {}> extends ExecutionContext<Context> {
end(): void;
}
export type ImplementationResult = PromiseLike<void> | ObservableLike | Iterator<any> | void;
export type Implementation<Context = {}> = {(t: ExecutionContext<Context>): ImplementationResult};
export type CbImplementation<Context = {}> = {(t: CbExecutionContext<Context>): ImplementationResult};
export interface Macro<Context = {}> {
(t: ExecutionContext<Context>, ...args: Array<any>): ImplementationResult;
title?: (providedTitle: string, ...args: Array<any>) => string;
}
export interface CbMacro<Context = {}> {
(t: CbExecutionContext<Context>, ...args: Array<any>): ImplementationResult;
title?: (providedTitle: string, ...args: Array<any>) => string;
}
export interface TestInterface<Context = {}> {
(title: string, implementation: Implementation<Context> | Macro<Context>): void;
(title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void;
(macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void;
after: AfterInterface<Context>;
afterEach: AfterInterface<Context>;
before: BeforeInterface<Context>;
beforeEach: BeforeInterface<Context>;
cb: CbInterface<Context>;
failing: FailingInterface<Context>;
only: OnlyInterface<Context>;
serial: SerialInterface<Context>;
skip: SkipInterface<Context>;
todo: TodoDeclaration;
}
export interface AfterInterface<Context = {}> {
(title: string, implementation: Implementation<Context> | Macro<Context>): void;
(title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void;
(macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void;
always: AlwaysInterface<Context>;
cb: HookCbInterface<Context>;
skip: SkipInterface<Context>;
}
export interface AlwaysInterface<Context = {}> {
(title: string, implementation: Implementation<Context> | Macro<Context>): void;
(title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void;
(macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void;
cb: HookCbInterface<Context>;
skip: SkipInterface<Context>;
}
export interface BeforeInterface<Context = {}> {
(title: string, implementation: Implementation<Context> | Macro<Context>): void;
(title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void;
(macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void;
cb: HookCbInterface<Context>;
skip: SkipInterface<Context>;
}
export interface CbInterface<Context = {}> {
(title: string, implementation: CbImplementation<Context> | CbMacro<Context>): void;
(title: string, macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void;
(macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void;
failing: CbFailingInterface<Context>;
only: CbOnlyInterface<Context>;
skip: CbSkipInterface<Context>;
}
export interface CbFailingInterface<Context = {}> {
(title: string, implementation: CbImplementation<Context> | CbMacro<Context>): void;
(title: string, macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void;
(macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void;
only: CbOnlyInterface<Context>;
skip: CbSkipInterface<Context>;
}
export interface CbOnlyInterface<Context = {}> {
(title: string, implementation: CbImplementation<Context> | CbMacro<Context>): void;
(title: string, macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void;
(macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void;
}
export interface CbSkipInterface<Context = {}> {
(title: string, implementation: CbImplementation<Context> | CbMacro<Context>): void;
(title: string, macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void;
(macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void;
}
export interface FailingInterface<Context = {}> {
(title: string, implementation: Implementation<Context> | Macro<Context>): void;
(title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void;
(macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void;
only: OnlyInterface<Context>;
skip: SkipInterface<Context>;
}
export interface HookCbInterface<Context = {}> {
(title: string, implementation: CbImplementation<Context> | CbMacro<Context>): void;
(title: string, macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void;
(macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void;
skip: CbSkipInterface<Context>;
}
export interface OnlyInterface<Context = {}> {
(title: string, implementation: Implementation<Context> | Macro<Context>): void;
(title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void;
(macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void;
}
export interface SerialInterface<Context = {}> {
(title: string, implementation: Implementation<Context> | Macro<Context>): void;
(title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void;
(macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void;
after: AfterInterface<Context>;
afterEach: AfterInterface<Context>;
before: BeforeInterface<Context>;
beforeEach: BeforeInterface<Context>;
cb: CbInterface<Context>;
failing: FailingInterface<Context>;
only: OnlyInterface<Context>;
skip: SkipInterface<Context>;
todo: TodoDeclaration;
}
export interface SkipInterface<Context = {}> {
(title: string, implementation: Implementation<Context> | Macro<Context>): void;
(title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void;
(macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void;
}
export type TodoDeclaration = {(title: string): void};
declare export default TestInterface<>;
declare export var test: TestInterface<>;
declare export var after: AfterInterface<>;
declare export var afterEach: AfterInterface<>;
declare export var before: BeforeInterface<>;
declare export var beforeEach: BeforeInterface<>;
declare export var cb: CbInterface<>;
declare export var failing: FailingInterface<>;
declare export var only: OnlyInterface<>;
declare export var serial: SerialInterface<>;
declare export var skip: SkipInterface<>;
declare export var todo: TodoDeclaration;