@testing-library/react-native 9.0.0-alpha.0 → 9.2.0
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/README.md +2 -2
- package/build/act.d.ts +3 -0
- package/build/act.js +2 -1
- package/build/act.js.map +1 -0
- package/build/cleanup.d.ts +5 -0
- package/build/cleanup.js +3 -2
- package/build/cleanup.js.map +1 -0
- package/build/fireEvent.d.ts +8 -0
- package/build/fireEvent.js +2 -1
- package/build/fireEvent.js.map +1 -0
- package/build/flushMicroTasks.d.ts +5 -0
- package/build/flushMicroTasks.js +2 -12
- package/build/flushMicroTasks.js.map +1 -0
- package/build/helpers/a11yAPI.d.ts +66 -0
- package/build/helpers/a11yAPI.js +16 -15
- package/build/helpers/a11yAPI.js.map +1 -0
- package/build/helpers/byDisplayValue.d.ts +6 -0
- package/build/helpers/byDisplayValue.js +2 -1
- package/build/helpers/byDisplayValue.js.map +1 -0
- package/build/helpers/byPlaceholderText.d.ts +6 -0
- package/build/helpers/byPlaceholderText.js +2 -1
- package/build/helpers/byPlaceholderText.js.map +1 -0
- package/build/helpers/byTestId.d.ts +6 -0
- package/build/helpers/byTestId.js +2 -1
- package/build/helpers/byTestId.js.map +1 -0
- package/build/helpers/byText.d.ts +10 -0
- package/build/helpers/byText.js +8 -5
- package/build/helpers/byText.js.map +1 -0
- package/build/helpers/debugDeep.d.ts +5 -0
- package/build/helpers/debugDeep.js +4 -1
- package/build/helpers/debugDeep.js.map +1 -0
- package/build/helpers/debugShallow.d.ts +6 -0
- package/build/helpers/debugShallow.js +4 -7
- package/build/helpers/debugShallow.js.map +1 -0
- package/build/helpers/errors.d.ts +10 -0
- package/build/helpers/errors.js +29 -9
- package/build/helpers/errors.js.map +1 -0
- package/build/helpers/filterNodeByType.d.ts +3 -0
- package/build/helpers/filterNodeByType.js +2 -1
- package/build/helpers/filterNodeByType.js.map +1 -0
- package/build/helpers/findByAPI.d.ts +17 -0
- package/build/helpers/findByAPI.js +2 -1
- package/build/helpers/findByAPI.js.map +1 -0
- package/build/helpers/format.d.ts +3 -0
- package/build/helpers/format.js +4 -3
- package/build/helpers/format.js.map +1 -0
- package/build/helpers/getByAPI.d.ts +31 -0
- package/build/helpers/getByAPI.js +4 -19
- package/build/helpers/getByAPI.js.map +1 -0
- package/build/helpers/makeA11yQuery.d.ts +13 -0
- package/build/helpers/makeA11yQuery.js +2 -1
- package/build/helpers/makeA11yQuery.js.map +1 -0
- package/build/helpers/makeQueries.d.ts +20 -0
- package/build/helpers/makeQueries.js +6 -3
- package/build/helpers/makeQueries.js.map +1 -0
- package/build/helpers/queryByAPI.d.ts +39 -0
- package/build/helpers/queryByAPI.js +3 -8
- package/build/helpers/queryByAPI.js.map +1 -0
- package/build/helpers/timers.d.ts +6 -0
- package/build/helpers/timers.js +9 -6
- package/build/helpers/timers.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.flow.js +384 -0
- package/build/index.js +2 -1
- package/build/index.js.map +1 -0
- package/build/matches.d.ts +9 -0
- package/build/matches.js +3 -2
- package/build/matches.js.map +1 -0
- package/build/{pure.js.flow → pure.d.ts} +4 -8
- package/build/pure.js +14 -31
- package/build/pure.js.map +1 -0
- package/build/render.d.ts +145 -0
- package/build/render.js +14 -10
- package/build/render.js.map +1 -0
- package/build/renderHook.d.ts +17 -0
- package/build/renderHook.js +57 -0
- package/build/renderHook.js.map +1 -0
- package/build/shallow.d.ts +8 -0
- package/build/shallow.js +3 -9
- package/build/shallow.js.map +1 -0
- package/build/waitFor.d.ts +8 -0
- package/build/waitFor.js +32 -23
- package/build/waitFor.js.map +1 -0
- package/build/waitForElementToBeRemoved.d.ts +2 -0
- package/build/waitForElementToBeRemoved.js +2 -1
- package/build/waitForElementToBeRemoved.js.map +1 -0
- package/build/within.d.ts +127 -0
- package/build/within.js +3 -2
- package/build/within.js.map +1 -0
- package/package.json +25 -15
- package/typings/index.flow.js +384 -0
- package/build/act.js.flow +0 -9
- package/build/cleanup.js.flow +0 -13
- package/build/fireEvent.js.flow +0 -127
- package/build/flushMicroTasks.js.flow +0 -23
- package/build/helpers/a11yAPI.js.flow +0 -241
- package/build/helpers/byDisplayValue.js.flow +0 -66
- package/build/helpers/byPlaceholderText.js.flow +0 -62
- package/build/helpers/byTestId.js.flow +0 -50
- package/build/helpers/byText.js.flow +0 -104
- package/build/helpers/debugDeep.js.flow +0 -16
- package/build/helpers/debugShallow.js.flow +0 -20
- package/build/helpers/errors.js.flow +0 -82
- package/build/helpers/filterNodeByType.js.flow +0 -1
- package/build/helpers/findByAPI.js.flow +0 -76
- package/build/helpers/format.js.flow +0 -10
- package/build/helpers/getByAPI.js.flow +0 -157
- package/build/helpers/makeA11yQuery.js.flow +0 -98
- package/build/helpers/makeQueries.js.flow +0 -165
- package/build/helpers/queryByAPI.js.flow +0 -166
- package/build/helpers/timers.js.flow +0 -88
- package/build/index.js.flow +0 -18
- package/build/matches.js.flow +0 -41
- package/build/render.js.flow +0 -109
- package/build/shallow.js.flow +0 -26
- package/build/types.flow.js +0 -1
- package/build/types.flow.js.flow +0 -59
- package/build/waitFor.js.flow +0 -221
- package/build/waitForElementToBeRemoved.js.flow +0 -42
- package/build/within.js.flow +0 -18
- package/typings/index.d.ts +0 -432
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
type GetReturn = ReactTestInstance;
|
|
5
|
+
type GetAllReturn = Array<ReactTestInstance>;
|
|
6
|
+
type QueryReturn = ReactTestInstance | null;
|
|
7
|
+
type QueryAllReturn = Array<ReactTestInstance> | [];
|
|
8
|
+
type FindReturn = Promise<ReactTestInstance>;
|
|
9
|
+
type FindAllReturn = Promise<ReactTestInstance[]>;
|
|
10
|
+
|
|
11
|
+
type TextMatch = string | RegExp;
|
|
12
|
+
|
|
13
|
+
declare type NormalizerFn = (textToNormalize: string) => string;
|
|
14
|
+
declare type NormalizerConfig = {
|
|
15
|
+
trim?: boolean,
|
|
16
|
+
collapseWhitespace?: boolean,
|
|
17
|
+
};
|
|
18
|
+
declare type TextMatchOptions = {
|
|
19
|
+
exact?: boolean,
|
|
20
|
+
normalizer?: NormalizerFn,
|
|
21
|
+
};
|
|
22
|
+
declare type A11yRole =
|
|
23
|
+
| 'none'
|
|
24
|
+
| 'button'
|
|
25
|
+
| 'link'
|
|
26
|
+
| 'search'
|
|
27
|
+
| 'image'
|
|
28
|
+
| 'keyboardkey'
|
|
29
|
+
| 'text'
|
|
30
|
+
| 'adjustable'
|
|
31
|
+
| 'imagebutton'
|
|
32
|
+
| 'header'
|
|
33
|
+
| 'summary'
|
|
34
|
+
| 'alert'
|
|
35
|
+
| 'checkbox'
|
|
36
|
+
| 'combobox'
|
|
37
|
+
| 'menu'
|
|
38
|
+
| 'menubar'
|
|
39
|
+
| 'menuitem'
|
|
40
|
+
| 'progressbar'
|
|
41
|
+
| 'radio'
|
|
42
|
+
| 'radiogroup'
|
|
43
|
+
| 'scrollbar'
|
|
44
|
+
| 'spinbutton'
|
|
45
|
+
| 'switch'
|
|
46
|
+
| 'tab'
|
|
47
|
+
| 'tablist'
|
|
48
|
+
| 'timer'
|
|
49
|
+
| 'toolbar';
|
|
50
|
+
|
|
51
|
+
declare type A11yState = {|
|
|
52
|
+
disabled?: boolean,
|
|
53
|
+
selected?: boolean,
|
|
54
|
+
checked?: boolean | 'mixed',
|
|
55
|
+
busy?: boolean,
|
|
56
|
+
expanded?: boolean,
|
|
57
|
+
|};
|
|
58
|
+
|
|
59
|
+
declare type A11yStates =
|
|
60
|
+
| 'disabled'
|
|
61
|
+
| 'selected'
|
|
62
|
+
| 'checked'
|
|
63
|
+
| 'unchecked'
|
|
64
|
+
| 'busy'
|
|
65
|
+
| 'expanded'
|
|
66
|
+
| 'collapsed'
|
|
67
|
+
| 'hasPopup';
|
|
68
|
+
|
|
69
|
+
declare type A11yValue = {
|
|
70
|
+
min?: number,
|
|
71
|
+
max?: number,
|
|
72
|
+
now?: number,
|
|
73
|
+
text?: string,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
interface GetByAPI {
|
|
77
|
+
getByText: (text: TextMatch, options?: TextMatchOptions) => ReactTestInstance;
|
|
78
|
+
getByPlaceholderText: (
|
|
79
|
+
placeholder: TextMatch,
|
|
80
|
+
options?: TextMatchOptions
|
|
81
|
+
) => ReactTestInstance;
|
|
82
|
+
getByDisplayValue: (
|
|
83
|
+
value: TextMatch,
|
|
84
|
+
options?: TextMatchOptions
|
|
85
|
+
) => ReactTestInstance;
|
|
86
|
+
getByTestId: (
|
|
87
|
+
testID: TextMatch,
|
|
88
|
+
options?: TextMatchOptions
|
|
89
|
+
) => ReactTestInstance;
|
|
90
|
+
getAllByTestId: (
|
|
91
|
+
testID: TextMatch,
|
|
92
|
+
options?: TextMatchOptions
|
|
93
|
+
) => Array<ReactTestInstance>;
|
|
94
|
+
getAllByText: (
|
|
95
|
+
text: TextMatch,
|
|
96
|
+
options?: TextMatchOptions
|
|
97
|
+
) => Array<ReactTestInstance>;
|
|
98
|
+
getAllByPlaceholderText: (
|
|
99
|
+
placeholder: TextMatch,
|
|
100
|
+
options?: TextMatchOptions
|
|
101
|
+
) => Array<ReactTestInstance>;
|
|
102
|
+
getAllByDisplayValue: (
|
|
103
|
+
value: TextMatch,
|
|
104
|
+
options?: TextMatchOptions
|
|
105
|
+
) => Array<ReactTestInstance>;
|
|
106
|
+
|
|
107
|
+
// Unsafe aliases
|
|
108
|
+
UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;
|
|
109
|
+
UNSAFE_getAllByType: <P>(
|
|
110
|
+
type: React.ComponentType<P>
|
|
111
|
+
) => Array<ReactTestInstance>;
|
|
112
|
+
UNSAFE_getByProps: (props: { [string]: any }) => ReactTestInstance;
|
|
113
|
+
UNSAFE_getAllByProps: (props: { [string]: any }) => Array<ReactTestInstance>;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
interface QueryByAPI {
|
|
117
|
+
queryByText: (
|
|
118
|
+
name: TextMatch,
|
|
119
|
+
options?: TextMatchOptions
|
|
120
|
+
) => ReactTestInstance | null;
|
|
121
|
+
queryByPlaceholderText: (
|
|
122
|
+
placeholder: TextMatch,
|
|
123
|
+
options?: TextMatchOptions
|
|
124
|
+
) => ReactTestInstance | null;
|
|
125
|
+
queryByDisplayValue: (
|
|
126
|
+
value: TextMatch,
|
|
127
|
+
options?: TextMatchOptions
|
|
128
|
+
) => ReactTestInstance | null;
|
|
129
|
+
queryByTestId: (testID: TextMatch) => ReactTestInstance | null;
|
|
130
|
+
queryAllByTestId: (testID: TextMatch) => Array<ReactTestInstance> | [];
|
|
131
|
+
queryAllByText: (
|
|
132
|
+
text: TextMatch,
|
|
133
|
+
options?: TextMatchOptions
|
|
134
|
+
) => Array<ReactTestInstance> | [];
|
|
135
|
+
queryAllByPlaceholderText: (
|
|
136
|
+
placeholder: TextMatch,
|
|
137
|
+
options?: TextMatchOptions
|
|
138
|
+
) => Array<ReactTestInstance> | [];
|
|
139
|
+
queryAllByDisplayValue: (
|
|
140
|
+
value: TextMatch,
|
|
141
|
+
options?: TextMatchOptions
|
|
142
|
+
) => Array<ReactTestInstance> | [];
|
|
143
|
+
|
|
144
|
+
// Unsafe aliases
|
|
145
|
+
UNSAFE_queryByType: <P>(
|
|
146
|
+
type: React.ComponentType<P>
|
|
147
|
+
) => ReactTestInstance | null;
|
|
148
|
+
UNSAFE_queryAllByType: <P>(
|
|
149
|
+
type: React.ComponentType<P>
|
|
150
|
+
) => Array<ReactTestInstance> | [];
|
|
151
|
+
UNSAFE_queryByProps: (props: { [string]: any }) => ReactTestInstance | null;
|
|
152
|
+
UNSAFE_queryAllByProps: (props: { [string]: any }) =>
|
|
153
|
+
| Array<ReactTestInstance>
|
|
154
|
+
| [];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
type WaitForOptions = {
|
|
158
|
+
timeout?: number,
|
|
159
|
+
interval?: number,
|
|
160
|
+
onTimeout?: (error: mixed) => Error,
|
|
161
|
+
};
|
|
162
|
+
type WaitForFunction = <T = any>(
|
|
163
|
+
expectation: () => T,
|
|
164
|
+
options?: WaitForOptions
|
|
165
|
+
) => Promise<T>;
|
|
166
|
+
|
|
167
|
+
interface FindByAPI {
|
|
168
|
+
findByText: (
|
|
169
|
+
text: TextMatch,
|
|
170
|
+
queryOptions?: TextMatchOptions,
|
|
171
|
+
waitForOptions?: WaitForOptions
|
|
172
|
+
) => FindReturn;
|
|
173
|
+
findByPlaceholderText: (
|
|
174
|
+
placeholder: TextMatch,
|
|
175
|
+
queryOptions?: TextMatchOptions,
|
|
176
|
+
waitForOptions?: WaitForOptions
|
|
177
|
+
) => FindReturn;
|
|
178
|
+
findByDisplayValue: (
|
|
179
|
+
value: TextMatch,
|
|
180
|
+
queryOptions?: TextMatchOptions,
|
|
181
|
+
waitForOptions?: WaitForOptions
|
|
182
|
+
) => FindReturn;
|
|
183
|
+
findByTestId: (
|
|
184
|
+
testID: TextMatch,
|
|
185
|
+
queryOptions?: TextMatchOptions,
|
|
186
|
+
waitForOptions?: WaitForOptions
|
|
187
|
+
) => FindReturn;
|
|
188
|
+
findAllByText: (
|
|
189
|
+
text: TextMatch,
|
|
190
|
+
queryOptions?: TextMatchOptions,
|
|
191
|
+
waitForOptions?: WaitForOptions
|
|
192
|
+
) => FindAllReturn;
|
|
193
|
+
findAllByPlaceholderText: (
|
|
194
|
+
placeholder: TextMatch,
|
|
195
|
+
queryOptions?: TextMatchOptions,
|
|
196
|
+
waitForOptions?: WaitForOptions
|
|
197
|
+
) => FindAllReturn;
|
|
198
|
+
findAllByDisplayValue: (
|
|
199
|
+
value: TextMatch,
|
|
200
|
+
queryOptions?: TextMatchOptions,
|
|
201
|
+
waitForOptions?: WaitForOptions
|
|
202
|
+
) => FindAllReturn;
|
|
203
|
+
findAllByTestId: (
|
|
204
|
+
testID: TextMatch,
|
|
205
|
+
queryOptions?: TextMatchOptions,
|
|
206
|
+
waitForOptions?: WaitForOptions
|
|
207
|
+
) => FindAllReturn;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
interface A11yAPI {
|
|
211
|
+
// Label
|
|
212
|
+
getByLabelText: (matcher: TextMatch) => GetReturn;
|
|
213
|
+
getAllByLabelText: (matcher: TextMatch) => GetAllReturn;
|
|
214
|
+
queryByLabelText: (matcher: TextMatch) => QueryReturn;
|
|
215
|
+
queryAllByLabelText: (matcher: TextMatch) => QueryAllReturn;
|
|
216
|
+
findByLabelText: (
|
|
217
|
+
matcher: TextMatch,
|
|
218
|
+
waitForOptions?: WaitForOptions
|
|
219
|
+
) => FindReturn;
|
|
220
|
+
findAllByLabelText: (
|
|
221
|
+
matcher: TextMatch,
|
|
222
|
+
waitForOptions?: WaitForOptions
|
|
223
|
+
) => FindAllReturn;
|
|
224
|
+
|
|
225
|
+
// Hint
|
|
226
|
+
getByA11yHint: (matcher: TextMatch) => GetReturn;
|
|
227
|
+
getByHintText: (matcher: TextMatch) => GetReturn;
|
|
228
|
+
getAllByA11yHint: (matcher: TextMatch) => GetAllReturn;
|
|
229
|
+
getAllByHintText: (matcher: TextMatch) => GetAllReturn;
|
|
230
|
+
queryByA11yHint: (matcher: TextMatch) => QueryReturn;
|
|
231
|
+
queryByHintText: (matcher: TextMatch) => QueryReturn;
|
|
232
|
+
queryAllByA11yHint: (matcher: TextMatch) => QueryAllReturn;
|
|
233
|
+
queryAllByHintText: (matcher: TextMatch) => QueryAllReturn;
|
|
234
|
+
findByA11yHint: (
|
|
235
|
+
matcher: TextMatch,
|
|
236
|
+
waitForOptions?: WaitForOptions
|
|
237
|
+
) => FindReturn;
|
|
238
|
+
findByHintText: (
|
|
239
|
+
matcher: TextMatch,
|
|
240
|
+
waitForOptions?: WaitForOptions
|
|
241
|
+
) => FindReturn;
|
|
242
|
+
findAllByA11yHint: (
|
|
243
|
+
matcher: TextMatch,
|
|
244
|
+
waitForOptions?: WaitForOptions
|
|
245
|
+
) => FindAllReturn;
|
|
246
|
+
findAllByHintText: (
|
|
247
|
+
matcher: TextMatch,
|
|
248
|
+
waitForOptions?: WaitForOptions
|
|
249
|
+
) => FindAllReturn;
|
|
250
|
+
|
|
251
|
+
// Role
|
|
252
|
+
getByRole: (matcher: A11yRole | RegExp) => GetReturn;
|
|
253
|
+
getAllByRole: (matcher: A11yRole | RegExp) => GetAllReturn;
|
|
254
|
+
queryByRole: (matcher: A11yRole | RegExp) => QueryReturn;
|
|
255
|
+
queryAllByRole: (matcher: A11yRole | RegExp) => QueryAllReturn;
|
|
256
|
+
findByRole: (
|
|
257
|
+
matcher: A11yRole | RegExp,
|
|
258
|
+
waitForOptions?: WaitForOptions
|
|
259
|
+
) => FindReturn;
|
|
260
|
+
findAllByRole: (
|
|
261
|
+
matcher: A11yRole | RegExp,
|
|
262
|
+
waitForOptions?: WaitForOptions
|
|
263
|
+
) => FindAllReturn;
|
|
264
|
+
|
|
265
|
+
// States
|
|
266
|
+
getByA11yStates: (matcher: A11yStates | Array<A11yStates>) => GetReturn;
|
|
267
|
+
getAllByA11yStates: (matcher: A11yStates | Array<A11yStates>) => GetAllReturn;
|
|
268
|
+
queryByA11yStates: (matcher: A11yStates | Array<A11yStates>) => QueryReturn;
|
|
269
|
+
queryAllByA11yStates: (
|
|
270
|
+
matcher: A11yStates | Array<A11yStates>
|
|
271
|
+
) => QueryAllReturn;
|
|
272
|
+
|
|
273
|
+
// State
|
|
274
|
+
getByA11yState: (matcher: A11yStates) => GetReturn;
|
|
275
|
+
getAllByA11yState: (matcher: A11yStates) => GetAllReturn;
|
|
276
|
+
queryByA11yState: (matcher: A11yStates) => QueryReturn;
|
|
277
|
+
queryAllByA11yState: (matcher: A11yStates) => QueryAllReturn;
|
|
278
|
+
findByA11yState: (
|
|
279
|
+
matcher: A11yStates,
|
|
280
|
+
waitForOptions?: WaitForOptions
|
|
281
|
+
) => FindReturn;
|
|
282
|
+
findAllByA11yState: (
|
|
283
|
+
matcher: A11yStates,
|
|
284
|
+
waitForOptions?: WaitForOptions
|
|
285
|
+
) => FindAllReturn;
|
|
286
|
+
|
|
287
|
+
// Value
|
|
288
|
+
getByA11yValue: (matcher: A11yValue) => GetReturn;
|
|
289
|
+
getAllByA11yValue: (matcher: A11yValue) => GetAllReturn;
|
|
290
|
+
queryByA11yValue: (matcher: A11yValue) => QueryReturn;
|
|
291
|
+
queryAllByA11yValue: (matcher: A11yValue) => QueryAllReturn;
|
|
292
|
+
findByA11yValue: (
|
|
293
|
+
matcher: A11yValue,
|
|
294
|
+
waitForOptions?: WaitForOptions
|
|
295
|
+
) => FindReturn;
|
|
296
|
+
findAllByA11yValue: (
|
|
297
|
+
matcher: A11yValue,
|
|
298
|
+
waitForOptions?: WaitForOptions
|
|
299
|
+
) => FindAllReturn;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
interface Thenable {
|
|
303
|
+
then: (resolve: () => any, reject?: () => any) => any;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
interface RenderOptions {
|
|
307
|
+
wrapper?: React.ComponentType<any>;
|
|
308
|
+
createNodeMock?: (element: React.Element<any>) => any;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
type Debug = {
|
|
312
|
+
(message?: string): void,
|
|
313
|
+
shallow: (message?: string) => void,
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
type Queries = GetByAPI & QueryByAPI & FindByAPI & A11yAPI;
|
|
317
|
+
|
|
318
|
+
interface RenderAPI extends Queries {
|
|
319
|
+
update(nextElement: React.Element<any>): void;
|
|
320
|
+
rerender(nextElement: React.Element<any>): void;
|
|
321
|
+
unmount(nextElement?: React.Element<any>): void;
|
|
322
|
+
toJSON(): ReactTestRendererJSON[] | ReactTestRendererJSON | null;
|
|
323
|
+
debug: Debug;
|
|
324
|
+
container: ReactTestInstance;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
type FireEventFunction = (
|
|
328
|
+
element: ReactTestInstance,
|
|
329
|
+
eventName: string,
|
|
330
|
+
...data: Array<any>
|
|
331
|
+
) => any;
|
|
332
|
+
|
|
333
|
+
type FireEventAPI = FireEventFunction & {
|
|
334
|
+
press: (element: ReactTestInstance, ...data: Array<any>) => any,
|
|
335
|
+
changeText: (element: ReactTestInstance, ...data: Array<any>) => any,
|
|
336
|
+
scroll: (element: ReactTestInstance, ...data: Array<any>) => any,
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
type RenderHookResult<Result, Props> = {
|
|
340
|
+
rerender: (props: Props) => void,
|
|
341
|
+
result: { current: Result },
|
|
342
|
+
unmount: () => void,
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
type RenderHookOptions<Props> = {
|
|
346
|
+
initialProps?: Props,
|
|
347
|
+
wrapper?: React.ComponentType<any>,
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
declare module '@testing-library/react-native' {
|
|
351
|
+
declare export var render: (
|
|
352
|
+
component: React.Element<any>,
|
|
353
|
+
options?: RenderOptions
|
|
354
|
+
) => RenderAPI;
|
|
355
|
+
|
|
356
|
+
declare export var cleanup: () => void;
|
|
357
|
+
declare export var fireEvent: FireEventAPI;
|
|
358
|
+
|
|
359
|
+
declare export var waitFor: WaitForFunction;
|
|
360
|
+
|
|
361
|
+
declare type WaitForElementToBeRemovedFunction = <T = any>(
|
|
362
|
+
expectation: () => T,
|
|
363
|
+
options?: WaitForOptions
|
|
364
|
+
) => Promise<T>;
|
|
365
|
+
|
|
366
|
+
declare export var waitForElementToBeRemoved: WaitForElementToBeRemovedFunction;
|
|
367
|
+
|
|
368
|
+
declare export var act: (callback: () => void) => Thenable;
|
|
369
|
+
declare export var within: (instance: ReactTestInstance) => Queries;
|
|
370
|
+
declare export var getQueriesForElement: (
|
|
371
|
+
instance: ReactTestInstance
|
|
372
|
+
) => Queries;
|
|
373
|
+
|
|
374
|
+
declare export var getDefaultNormalizer: (
|
|
375
|
+
normalizerConfig?: NormalizerConfig
|
|
376
|
+
) => NormalizerFn;
|
|
377
|
+
|
|
378
|
+
declare type RenderHookFunction = <Result, Props>(
|
|
379
|
+
renderCallback: (props: Props) => Result,
|
|
380
|
+
options?: RenderHookOptions<Props>
|
|
381
|
+
) => RenderHookResult<Result, Props>;
|
|
382
|
+
|
|
383
|
+
declare export var renderHook: RenderHookFunction;
|
|
384
|
+
}
|
package/build/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["afterEach","process","env","RNTL_SKIP_AUTO_CLEANUP"],"mappings":";;;;;;AAAA;;AAgBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAfA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAOA,SAAP,KAAqB,UAArB,IAAmC,CAACC,OAAO,CAACC,GAAR,CAAYC,sBAApD,EAA4E;AAC1E;AACAH,EAAAA,SAAS,CAAC,YAAY;AACpB,UAAM,uCAAN;AACA;AACD,GAHQ,CAAT;AAID","sourcesContent":["import { cleanup } from './pure';\nimport { flushMicroTasks } from './flushMicroTasks';\n\n// If we're running in a test runner that supports afterEach\n// then we'll automatically run cleanup afterEach test\n// this ensures that tests run in isolation from each other\n// if you don't like this then either import the `pure` module\n// or set the RNTL_SKIP_AUTO_CLEANUP env variable to 'true'.\nif (typeof afterEach === 'function' && !process.env.RNTL_SKIP_AUTO_CLEANUP) {\n // eslint-disable-next-line no-undef\n afterEach(async () => {\n await flushMicroTasks();\n cleanup();\n });\n}\n\nexport * from './pure';\n"],"file":"index.js"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare type NormalizerFn = (textToNormalize: string) => string;
|
|
2
|
+
export declare type TextMatch = string | RegExp;
|
|
3
|
+
export declare function matches(matcher: TextMatch, text: string, normalizer?: NormalizerFn, exact?: boolean): boolean;
|
|
4
|
+
declare type NormalizerConfig = {
|
|
5
|
+
trim?: boolean;
|
|
6
|
+
collapseWhitespace?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function getDefaultNormalizer({ trim, collapseWhitespace, }?: NormalizerConfig): NormalizerFn;
|
|
9
|
+
export {};
|
package/build/matches.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.matches = matches;
|
|
7
6
|
exports.getDefaultNormalizer = getDefaultNormalizer;
|
|
7
|
+
exports.matches = matches;
|
|
8
8
|
|
|
9
9
|
function matches(matcher, text, normalizer = getDefaultNormalizer(), exact = true) {
|
|
10
10
|
if (typeof text !== 'string') {
|
|
@@ -30,4 +30,5 @@ function getDefaultNormalizer({
|
|
|
30
30
|
normalizedText = collapseWhitespace ? normalizedText.replace(/\s+/g, ' ') : normalizedText;
|
|
31
31
|
return normalizedText;
|
|
32
32
|
};
|
|
33
|
-
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=matches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/matches.ts"],"names":["matches","matcher","text","normalizer","getDefaultNormalizer","exact","normalizedText","toLowerCase","includes","test","trim","collapseWhitespace","replace"],"mappings":";;;;;;;;AAGO,SAASA,OAAT,CACLC,OADK,EAELC,IAFK,EAGLC,UAAwB,GAAGC,oBAAoB,EAH1C,EAILC,KAAc,GAAG,IAJZ,EAKI;AACT,MAAI,OAAOH,IAAP,KAAgB,QAApB,EAA8B;AAC5B,WAAO,KAAP;AACD;;AAED,QAAMI,cAAc,GAAGH,UAAU,CAACD,IAAD,CAAjC;;AACA,MAAI,OAAOD,OAAP,KAAmB,QAAvB,EAAiC;AAC/B,WAAOI,KAAK,GACRC,cAAc,KAAKL,OADX,GAERK,cAAc,CAACC,WAAf,GAA6BC,QAA7B,CAAsCP,OAAO,CAACM,WAAR,EAAtC,CAFJ;AAGD,GAJD,MAIO;AACL,WAAON,OAAO,CAACQ,IAAR,CAAaH,cAAb,CAAP;AACD;AACF;;AAOM,SAASF,oBAAT,CAA8B;AACnCM,EAAAA,IAAI,GAAG,IAD4B;AAEnCC,EAAAA,kBAAkB,GAAG;AAFc,IAGf,EAHf,EAGiC;AACtC,SAAQT,IAAD,IAAkB;AACvB,QAAII,cAAc,GAAGJ,IAArB;AACAI,IAAAA,cAAc,GAAGI,IAAI,GAAGJ,cAAc,CAACI,IAAf,EAAH,GAA2BJ,cAAhD;AACAA,IAAAA,cAAc,GAAGK,kBAAkB,GAC/BL,cAAc,CAACM,OAAf,CAAuB,MAAvB,EAA+B,GAA/B,CAD+B,GAE/BN,cAFJ;AAGA,WAAOA,cAAP;AACD,GAPD;AAQD","sourcesContent":["export type NormalizerFn = (textToNormalize: string) => string;\nexport type TextMatch = string | RegExp;\n\nexport function matches(\n matcher: TextMatch,\n text: string,\n normalizer: NormalizerFn = getDefaultNormalizer(),\n exact: boolean = true\n): boolean {\n if (typeof text !== 'string') {\n return false;\n }\n\n const normalizedText = normalizer(text);\n if (typeof matcher === 'string') {\n return exact\n ? normalizedText === matcher\n : normalizedText.toLowerCase().includes(matcher.toLowerCase());\n } else {\n return matcher.test(normalizedText);\n }\n}\n\ntype NormalizerConfig = {\n trim?: boolean;\n collapseWhitespace?: boolean;\n};\n\nexport function getDefaultNormalizer({\n trim = true,\n collapseWhitespace = true,\n}: NormalizerConfig = {}): NormalizerFn {\n return (text: string) => {\n let normalizedText = text;\n normalizedText = trim ? normalizedText.trim() : normalizedText;\n normalizedText = collapseWhitespace\n ? normalizedText.replace(/\\s+/g, ' ')\n : normalizedText;\n return normalizedText;\n };\n}\n"],"file":"matches.js"}
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import act from './act';
|
|
3
2
|
import cleanup from './cleanup';
|
|
4
3
|
import fireEvent from './fireEvent';
|
|
5
|
-
import flushMicrotasksQueue from './flushMicroTasks';
|
|
6
4
|
import render from './render';
|
|
7
|
-
import
|
|
8
|
-
import waitFor, { waitForElement } from './waitFor';
|
|
5
|
+
import waitFor from './waitFor';
|
|
9
6
|
import waitForElementToBeRemoved from './waitForElementToBeRemoved';
|
|
10
7
|
import { within, getQueriesForElement } from './within';
|
|
11
8
|
import { getDefaultNormalizer } from './matches';
|
|
12
|
-
|
|
9
|
+
import { renderHook } from './renderHook';
|
|
13
10
|
export { act };
|
|
14
11
|
export { cleanup };
|
|
15
12
|
export { fireEvent };
|
|
16
|
-
export { flushMicrotasksQueue };
|
|
17
13
|
export { render };
|
|
18
|
-
export {
|
|
19
|
-
export { waitFor, waitForElement };
|
|
14
|
+
export { waitFor };
|
|
20
15
|
export { waitForElementToBeRemoved };
|
|
21
16
|
export { within, getQueriesForElement };
|
|
22
17
|
export { getDefaultNormalizer };
|
|
18
|
+
export { renderHook };
|
package/build/pure.js
CHANGED
|
@@ -21,34 +21,34 @@ Object.defineProperty(exports, "fireEvent", {
|
|
|
21
21
|
return _fireEvent.default;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(exports, "
|
|
24
|
+
Object.defineProperty(exports, "getDefaultNormalizer", {
|
|
25
25
|
enumerable: true,
|
|
26
26
|
get: function () {
|
|
27
|
-
return
|
|
27
|
+
return _matches.getDefaultNormalizer;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
Object.defineProperty(exports, "
|
|
30
|
+
Object.defineProperty(exports, "getQueriesForElement", {
|
|
31
31
|
enumerable: true,
|
|
32
32
|
get: function () {
|
|
33
|
-
return
|
|
33
|
+
return _within.getQueriesForElement;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
Object.defineProperty(exports, "
|
|
36
|
+
Object.defineProperty(exports, "render", {
|
|
37
37
|
enumerable: true,
|
|
38
38
|
get: function () {
|
|
39
|
-
return
|
|
39
|
+
return _render.default;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
Object.defineProperty(exports, "
|
|
42
|
+
Object.defineProperty(exports, "renderHook", {
|
|
43
43
|
enumerable: true,
|
|
44
44
|
get: function () {
|
|
45
|
-
return
|
|
45
|
+
return _renderHook.renderHook;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
Object.defineProperty(exports, "
|
|
48
|
+
Object.defineProperty(exports, "waitFor", {
|
|
49
49
|
enumerable: true,
|
|
50
50
|
get: function () {
|
|
51
|
-
return _waitFor.
|
|
51
|
+
return _waitFor.default;
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
Object.defineProperty(exports, "waitForElementToBeRemoved", {
|
|
@@ -63,18 +63,6 @@ Object.defineProperty(exports, "within", {
|
|
|
63
63
|
return _within.within;
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
-
Object.defineProperty(exports, "getQueriesForElement", {
|
|
67
|
-
enumerable: true,
|
|
68
|
-
get: function () {
|
|
69
|
-
return _within.getQueriesForElement;
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
Object.defineProperty(exports, "getDefaultNormalizer", {
|
|
73
|
-
enumerable: true,
|
|
74
|
-
get: function () {
|
|
75
|
-
return _matches.getDefaultNormalizer;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
66
|
|
|
79
67
|
var _act = _interopRequireDefault(require("./act"));
|
|
80
68
|
|
|
@@ -82,13 +70,9 @@ var _cleanup = _interopRequireDefault(require("./cleanup"));
|
|
|
82
70
|
|
|
83
71
|
var _fireEvent = _interopRequireDefault(require("./fireEvent"));
|
|
84
72
|
|
|
85
|
-
var _flushMicroTasks = _interopRequireDefault(require("./flushMicroTasks"));
|
|
86
|
-
|
|
87
73
|
var _render = _interopRequireDefault(require("./render"));
|
|
88
74
|
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
var _waitFor = _interopRequireWildcard(require("./waitFor"));
|
|
75
|
+
var _waitFor = _interopRequireDefault(require("./waitFor"));
|
|
92
76
|
|
|
93
77
|
var _waitForElementToBeRemoved = _interopRequireDefault(require("./waitForElementToBeRemoved"));
|
|
94
78
|
|
|
@@ -96,8 +80,7 @@ var _within = require("./within");
|
|
|
96
80
|
|
|
97
81
|
var _matches = require("./matches");
|
|
98
82
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
83
|
+
var _renderHook = require("./renderHook");
|
|
102
84
|
|
|
103
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
85
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
86
|
+
//# sourceMappingURL=pure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pure.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["import act from './act';\nimport cleanup from './cleanup';\nimport fireEvent from './fireEvent';\nimport render from './render';\nimport waitFor from './waitFor';\nimport waitForElementToBeRemoved from './waitForElementToBeRemoved';\nimport { within, getQueriesForElement } from './within';\nimport { getDefaultNormalizer } from './matches';\nimport { renderHook } from './renderHook';\n\nexport { act };\nexport { cleanup };\nexport { fireEvent };\nexport { render };\nexport { waitFor };\nexport { waitForElementToBeRemoved };\nexport { within, getQueriesForElement };\nexport { getDefaultNormalizer };\nexport { renderHook };\n"],"file":"pure.js"}
|