@testing-library/react-native 9.0.0 → 10.0.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.
Files changed (121) hide show
  1. package/README.md +2 -2
  2. package/build/act.d.ts +3 -0
  3. package/build/act.js +2 -1
  4. package/build/act.js.map +1 -0
  5. package/build/cleanup.d.ts +5 -0
  6. package/build/cleanup.js +3 -2
  7. package/build/cleanup.js.map +1 -0
  8. package/build/fireEvent.d.ts +8 -0
  9. package/build/fireEvent.js +2 -1
  10. package/build/fireEvent.js.map +1 -0
  11. package/build/flushMicroTasks.d.ts +5 -0
  12. package/build/flushMicroTasks.js +2 -12
  13. package/build/flushMicroTasks.js.map +1 -0
  14. package/build/helpers/debugDeep.d.ts +5 -0
  15. package/build/helpers/debugDeep.js +4 -1
  16. package/build/helpers/debugDeep.js.map +1 -0
  17. package/build/helpers/debugShallow.d.ts +6 -0
  18. package/build/helpers/debugShallow.js +4 -7
  19. package/build/helpers/debugShallow.js.map +1 -0
  20. package/build/helpers/errors.d.ts +10 -0
  21. package/build/helpers/errors.js +29 -9
  22. package/build/helpers/errors.js.map +1 -0
  23. package/build/helpers/filterNodeByType.d.ts +3 -0
  24. package/build/helpers/filterNodeByType.js +2 -1
  25. package/build/helpers/filterNodeByType.js.map +1 -0
  26. package/build/helpers/format.d.ts +3 -0
  27. package/build/helpers/format.js +4 -3
  28. package/build/helpers/format.js.map +1 -0
  29. package/build/helpers/timers.d.ts +6 -0
  30. package/build/helpers/timers.js +9 -6
  31. package/build/helpers/timers.js.map +1 -0
  32. package/build/index.d.ts +1 -0
  33. package/build/index.flow.js +394 -0
  34. package/build/index.js +2 -1
  35. package/build/index.js.map +1 -0
  36. package/build/matches.d.ts +9 -0
  37. package/build/matches.js +3 -2
  38. package/build/matches.js.map +1 -0
  39. package/build/{pure.js.flow → pure.d.ts} +4 -8
  40. package/build/pure.js +14 -31
  41. package/build/pure.js.map +1 -0
  42. package/build/queries/a11yAPI.d.ts +66 -0
  43. package/build/{helpers → queries}/a11yAPI.js +16 -15
  44. package/build/queries/a11yAPI.js.map +1 -0
  45. package/build/queries/displayValue.d.ts +13 -0
  46. package/build/{helpers/byDisplayValue.js → queries/displayValue.js} +23 -17
  47. package/build/queries/displayValue.js.map +1 -0
  48. package/build/queries/makeA11yQuery.d.ts +13 -0
  49. package/build/{helpers → queries}/makeA11yQuery.js +3 -2
  50. package/build/queries/makeA11yQuery.js.map +1 -0
  51. package/build/queries/makeQueries.d.ts +19 -0
  52. package/build/{helpers → queries}/makeQueries.js +23 -19
  53. package/build/queries/makeQueries.js.map +1 -0
  54. package/build/queries/placeholderText.d.ts +13 -0
  55. package/build/{helpers/byPlaceholderText.js → queries/placeholderText.js} +23 -17
  56. package/build/queries/placeholderText.js.map +1 -0
  57. package/build/queries/testId.d.ts +13 -0
  58. package/build/{helpers/byTestId.js → queries/testId.js} +19 -13
  59. package/build/queries/testId.js.map +1 -0
  60. package/build/queries/text.d.ts +17 -0
  61. package/build/{helpers/byText.js → queries/text.js} +31 -23
  62. package/build/queries/text.js.map +1 -0
  63. package/build/queries/unsafeProps.d.ts +16 -0
  64. package/build/queries/unsafeProps.js +58 -0
  65. package/build/queries/unsafeProps.js.map +1 -0
  66. package/build/queries/unsafeType.d.ts +9 -0
  67. package/build/queries/unsafeType.js +54 -0
  68. package/build/queries/unsafeType.js.map +1 -0
  69. package/build/render.d.ts +135 -0
  70. package/build/render.js +16 -21
  71. package/build/render.js.map +1 -0
  72. package/build/renderHook.d.ts +17 -0
  73. package/build/renderHook.js +57 -0
  74. package/build/renderHook.js.map +1 -0
  75. package/build/shallow.d.ts +8 -0
  76. package/build/shallow.js +3 -9
  77. package/build/shallow.js.map +1 -0
  78. package/build/waitFor.d.ts +8 -0
  79. package/build/waitFor.js +32 -23
  80. package/build/waitFor.js.map +1 -0
  81. package/build/waitForElementToBeRemoved.d.ts +2 -0
  82. package/build/waitForElementToBeRemoved.js +2 -1
  83. package/build/waitForElementToBeRemoved.js.map +1 -0
  84. package/build/within.d.ts +117 -0
  85. package/build/within.js +19 -9
  86. package/build/within.js.map +1 -0
  87. package/package.json +24 -14
  88. package/typings/index.flow.js +394 -0
  89. package/build/act.js.flow +0 -9
  90. package/build/cleanup.js.flow +0 -13
  91. package/build/fireEvent.js.flow +0 -127
  92. package/build/flushMicroTasks.js.flow +0 -23
  93. package/build/helpers/a11yAPI.js.flow +0 -241
  94. package/build/helpers/byDisplayValue.js.flow +0 -66
  95. package/build/helpers/byPlaceholderText.js.flow +0 -62
  96. package/build/helpers/byTestId.js.flow +0 -50
  97. package/build/helpers/byText.js.flow +0 -104
  98. package/build/helpers/debugDeep.js.flow +0 -16
  99. package/build/helpers/debugShallow.js.flow +0 -20
  100. package/build/helpers/errors.js.flow +0 -82
  101. package/build/helpers/filterNodeByType.js.flow +0 -1
  102. package/build/helpers/findByAPI.js +0 -32
  103. package/build/helpers/findByAPI.js.flow +0 -76
  104. package/build/helpers/format.js.flow +0 -10
  105. package/build/helpers/getByAPI.js +0 -98
  106. package/build/helpers/getByAPI.js.flow +0 -157
  107. package/build/helpers/makeA11yQuery.js.flow +0 -98
  108. package/build/helpers/makeQueries.js.flow +0 -165
  109. package/build/helpers/queryByAPI.js +0 -92
  110. package/build/helpers/queryByAPI.js.flow +0 -166
  111. package/build/helpers/timers.js.flow +0 -88
  112. package/build/index.js.flow +0 -18
  113. package/build/matches.js.flow +0 -41
  114. package/build/render.js.flow +0 -109
  115. package/build/shallow.js.flow +0 -26
  116. package/build/types.flow.js +0 -1
  117. package/build/types.flow.js.flow +0 -59
  118. package/build/waitFor.js.flow +0 -221
  119. package/build/waitForElementToBeRemoved.js.flow +0 -42
  120. package/build/within.js.flow +0 -18
  121. package/typings/index.d.ts +0 -432
@@ -0,0 +1,394 @@
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
+ type WaitForOptions = {
77
+ timeout?: number,
78
+ interval?: number,
79
+ onTimeout?: (error: mixed) => Error,
80
+ };
81
+ type WaitForFunction = <T = any>(
82
+ expectation: () => T,
83
+ options?: WaitForOptions
84
+ ) => Promise<T>;
85
+
86
+ interface ByTextQueries {
87
+ getByText: (text: TextMatch, options?: TextMatchOptions) => ReactTestInstance;
88
+ getAllByText: (
89
+ text: TextMatch,
90
+ options?: TextMatchOptions
91
+ ) => Array<ReactTestInstance>;
92
+ queryByText: (
93
+ name: TextMatch,
94
+ options?: TextMatchOptions
95
+ ) => ReactTestInstance | null;
96
+ queryAllByText: (
97
+ text: TextMatch,
98
+ options?: TextMatchOptions
99
+ ) => Array<ReactTestInstance> | [];
100
+ findByText: (
101
+ text: TextMatch,
102
+ queryOptions?: TextMatchOptions,
103
+ waitForOptions?: WaitForOptions
104
+ ) => FindReturn;
105
+ findAllByText: (
106
+ text: TextMatch,
107
+ queryOptions?: TextMatchOptions,
108
+ waitForOptions?: WaitForOptions
109
+ ) => FindAllReturn;
110
+ }
111
+
112
+ interface ByTestIdQueries {
113
+ getByTestId: (
114
+ testID: TextMatch,
115
+ options?: TextMatchOptions
116
+ ) => ReactTestInstance;
117
+ getAllByTestId: (
118
+ testID: TextMatch,
119
+ options?: TextMatchOptions
120
+ ) => Array<ReactTestInstance>;
121
+ queryByTestId: (testID: TextMatch) => ReactTestInstance | null;
122
+ queryAllByTestId: (testID: TextMatch) => Array<ReactTestInstance> | [];
123
+ findByTestId: (
124
+ testID: TextMatch,
125
+ queryOptions?: TextMatchOptions,
126
+ waitForOptions?: WaitForOptions
127
+ ) => FindReturn;
128
+ findAllByTestId: (
129
+ testID: TextMatch,
130
+ queryOptions?: TextMatchOptions,
131
+ waitForOptions?: WaitForOptions
132
+ ) => FindAllReturn;
133
+ }
134
+
135
+ interface ByDisplayValueQueries {
136
+ getByDisplayValue: (
137
+ value: TextMatch,
138
+ options?: TextMatchOptions
139
+ ) => ReactTestInstance;
140
+ getAllByDisplayValue: (
141
+ value: TextMatch,
142
+ options?: TextMatchOptions
143
+ ) => Array<ReactTestInstance>;
144
+ queryByDisplayValue: (
145
+ value: TextMatch,
146
+ options?: TextMatchOptions
147
+ ) => ReactTestInstance | null;
148
+ queryAllByDisplayValue: (
149
+ value: TextMatch,
150
+ options?: TextMatchOptions
151
+ ) => Array<ReactTestInstance> | [];
152
+ findByDisplayValue: (
153
+ value: TextMatch,
154
+ queryOptions?: TextMatchOptions,
155
+ waitForOptions?: WaitForOptions
156
+ ) => FindReturn;
157
+ findAllByDisplayValue: (
158
+ value: TextMatch,
159
+ queryOptions?: TextMatchOptions,
160
+ waitForOptions?: WaitForOptions
161
+ ) => FindAllReturn;
162
+ }
163
+
164
+ interface ByPlaceholderTextQueries {
165
+ getByPlaceholderText: (
166
+ placeholder: TextMatch,
167
+ options?: TextMatchOptions
168
+ ) => ReactTestInstance;
169
+ getAllByPlaceholderText: (
170
+ placeholder: TextMatch,
171
+ options?: TextMatchOptions
172
+ ) => Array<ReactTestInstance>;
173
+ queryByPlaceholderText: (
174
+ placeholder: TextMatch,
175
+ options?: TextMatchOptions
176
+ ) => ReactTestInstance | null;
177
+ queryAllByPlaceholderText: (
178
+ placeholder: TextMatch,
179
+ options?: TextMatchOptions
180
+ ) => Array<ReactTestInstance> | [];
181
+ findByPlaceholderText: (
182
+ placeholder: TextMatch,
183
+ queryOptions?: TextMatchOptions,
184
+ waitForOptions?: WaitForOptions
185
+ ) => FindReturn;
186
+ findAllByPlaceholderText: (
187
+ placeholder: TextMatch,
188
+ queryOptions?: TextMatchOptions,
189
+ waitForOptions?: WaitForOptions
190
+ ) => FindAllReturn;
191
+ }
192
+
193
+ interface UnsafeByTypeQueries {
194
+ UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;
195
+ UNSAFE_getAllByType: <P>(
196
+ type: React.ComponentType<P>
197
+ ) => Array<ReactTestInstance>;
198
+ UNSAFE_queryByType: <P>(
199
+ type: React.ComponentType<P>
200
+ ) => ReactTestInstance | null;
201
+ UNSAFE_queryAllByType: <P>(
202
+ type: React.ComponentType<P>
203
+ ) => Array<ReactTestInstance> | [];
204
+ }
205
+
206
+ interface UnsafeByPropsQueries {
207
+ UNSAFE_getByProps: (props: { [string]: any }) => ReactTestInstance;
208
+ UNSAFE_getAllByProps: (props: { [string]: any }) => Array<ReactTestInstance>;
209
+ UNSAFE_queryByProps: (props: { [string]: any }) => ReactTestInstance | null;
210
+ UNSAFE_queryAllByProps: (props: { [string]: any }) =>
211
+ | Array<ReactTestInstance>
212
+ | [];
213
+ }
214
+ interface A11yAPI {
215
+ // Label
216
+ getByLabelText: (matcher: TextMatch) => GetReturn;
217
+ getAllByLabelText: (matcher: TextMatch) => GetAllReturn;
218
+ queryByLabelText: (matcher: TextMatch) => QueryReturn;
219
+ queryAllByLabelText: (matcher: TextMatch) => QueryAllReturn;
220
+ findByLabelText: (
221
+ matcher: TextMatch,
222
+ waitForOptions?: WaitForOptions
223
+ ) => FindReturn;
224
+ findAllByLabelText: (
225
+ matcher: TextMatch,
226
+ waitForOptions?: WaitForOptions
227
+ ) => FindAllReturn;
228
+
229
+ // Hint
230
+ getByA11yHint: (matcher: TextMatch) => GetReturn;
231
+ getByHintText: (matcher: TextMatch) => GetReturn;
232
+ getAllByA11yHint: (matcher: TextMatch) => GetAllReturn;
233
+ getAllByHintText: (matcher: TextMatch) => GetAllReturn;
234
+ queryByA11yHint: (matcher: TextMatch) => QueryReturn;
235
+ queryByHintText: (matcher: TextMatch) => QueryReturn;
236
+ queryAllByA11yHint: (matcher: TextMatch) => QueryAllReturn;
237
+ queryAllByHintText: (matcher: TextMatch) => QueryAllReturn;
238
+ findByA11yHint: (
239
+ matcher: TextMatch,
240
+ waitForOptions?: WaitForOptions
241
+ ) => FindReturn;
242
+ findByHintText: (
243
+ matcher: TextMatch,
244
+ waitForOptions?: WaitForOptions
245
+ ) => FindReturn;
246
+ findAllByA11yHint: (
247
+ matcher: TextMatch,
248
+ waitForOptions?: WaitForOptions
249
+ ) => FindAllReturn;
250
+ findAllByHintText: (
251
+ matcher: TextMatch,
252
+ waitForOptions?: WaitForOptions
253
+ ) => FindAllReturn;
254
+
255
+ // Role
256
+ getByRole: (matcher: A11yRole | RegExp) => GetReturn;
257
+ getAllByRole: (matcher: A11yRole | RegExp) => GetAllReturn;
258
+ queryByRole: (matcher: A11yRole | RegExp) => QueryReturn;
259
+ queryAllByRole: (matcher: A11yRole | RegExp) => QueryAllReturn;
260
+ findByRole: (
261
+ matcher: A11yRole | RegExp,
262
+ waitForOptions?: WaitForOptions
263
+ ) => FindReturn;
264
+ findAllByRole: (
265
+ matcher: A11yRole | RegExp,
266
+ waitForOptions?: WaitForOptions
267
+ ) => FindAllReturn;
268
+
269
+ // States
270
+ getByA11yStates: (matcher: A11yStates | Array<A11yStates>) => GetReturn;
271
+ getAllByA11yStates: (matcher: A11yStates | Array<A11yStates>) => GetAllReturn;
272
+ queryByA11yStates: (matcher: A11yStates | Array<A11yStates>) => QueryReturn;
273
+ queryAllByA11yStates: (
274
+ matcher: A11yStates | Array<A11yStates>
275
+ ) => QueryAllReturn;
276
+
277
+ // State
278
+ getByA11yState: (matcher: A11yStates) => GetReturn;
279
+ getAllByA11yState: (matcher: A11yStates) => GetAllReturn;
280
+ queryByA11yState: (matcher: A11yStates) => QueryReturn;
281
+ queryAllByA11yState: (matcher: A11yStates) => QueryAllReturn;
282
+ findByA11yState: (
283
+ matcher: A11yStates,
284
+ waitForOptions?: WaitForOptions
285
+ ) => FindReturn;
286
+ findAllByA11yState: (
287
+ matcher: A11yStates,
288
+ waitForOptions?: WaitForOptions
289
+ ) => FindAllReturn;
290
+
291
+ // Value
292
+ getByA11yValue: (matcher: A11yValue) => GetReturn;
293
+ getAllByA11yValue: (matcher: A11yValue) => GetAllReturn;
294
+ queryByA11yValue: (matcher: A11yValue) => QueryReturn;
295
+ queryAllByA11yValue: (matcher: A11yValue) => QueryAllReturn;
296
+ findByA11yValue: (
297
+ matcher: A11yValue,
298
+ waitForOptions?: WaitForOptions
299
+ ) => FindReturn;
300
+ findAllByA11yValue: (
301
+ matcher: A11yValue,
302
+ waitForOptions?: WaitForOptions
303
+ ) => FindAllReturn;
304
+ }
305
+
306
+ interface Thenable {
307
+ then: (resolve: () => any, reject?: () => any) => any;
308
+ }
309
+
310
+ interface RenderOptions {
311
+ wrapper?: React.ComponentType<any>;
312
+ createNodeMock?: (element: React.Element<any>) => any;
313
+ }
314
+
315
+ type Debug = {
316
+ (message?: string): void,
317
+ shallow: (message?: string) => void,
318
+ };
319
+
320
+ type Queries = ByTextQueries &
321
+ ByTestIdQueries &
322
+ ByDisplayValueQueries &
323
+ ByPlaceholderTextQueries &
324
+ UnsafeByTypeQueries &
325
+ UnsafeByPropsQueries &
326
+ A11yAPI;
327
+
328
+ interface RenderAPI extends Queries {
329
+ update(nextElement: React.Element<any>): void;
330
+ rerender(nextElement: React.Element<any>): void;
331
+ unmount(nextElement?: React.Element<any>): void;
332
+ toJSON(): ReactTestRendererJSON[] | ReactTestRendererJSON | null;
333
+ debug: Debug;
334
+ container: ReactTestInstance;
335
+ }
336
+
337
+ type FireEventFunction = (
338
+ element: ReactTestInstance,
339
+ eventName: string,
340
+ ...data: Array<any>
341
+ ) => any;
342
+
343
+ type FireEventAPI = FireEventFunction & {
344
+ press: (element: ReactTestInstance, ...data: Array<any>) => any,
345
+ changeText: (element: ReactTestInstance, ...data: Array<any>) => any,
346
+ scroll: (element: ReactTestInstance, ...data: Array<any>) => any,
347
+ };
348
+
349
+ type RenderHookResult<Result, Props> = {
350
+ rerender: (props: Props) => void,
351
+ result: { current: Result },
352
+ unmount: () => void,
353
+ };
354
+
355
+ type RenderHookOptions<Props> = {
356
+ initialProps?: Props,
357
+ wrapper?: React.ComponentType<any>,
358
+ };
359
+
360
+ declare module '@testing-library/react-native' {
361
+ declare export var render: (
362
+ component: React.Element<any>,
363
+ options?: RenderOptions
364
+ ) => RenderAPI;
365
+
366
+ declare export var cleanup: () => void;
367
+ declare export var fireEvent: FireEventAPI;
368
+
369
+ declare export var waitFor: WaitForFunction;
370
+
371
+ declare type WaitForElementToBeRemovedFunction = <T = any>(
372
+ expectation: () => T,
373
+ options?: WaitForOptions
374
+ ) => Promise<T>;
375
+
376
+ declare export var waitForElementToBeRemoved: WaitForElementToBeRemovedFunction;
377
+
378
+ declare export var act: (callback: () => void) => Thenable;
379
+ declare export var within: (instance: ReactTestInstance) => Queries;
380
+ declare export var getQueriesForElement: (
381
+ instance: ReactTestInstance
382
+ ) => Queries;
383
+
384
+ declare export var getDefaultNormalizer: (
385
+ normalizerConfig?: NormalizerConfig
386
+ ) => NormalizerFn;
387
+
388
+ declare type RenderHookFunction = <Result, Props>(
389
+ renderCallback: (props: Props) => Result,
390
+ options?: RenderHookOptions<Props>
391
+ ) => RenderHookResult<Result, Props>;
392
+
393
+ declare export var renderHook: RenderHookFunction;
394
+ }
package/build/index.js CHANGED
@@ -30,4 +30,5 @@ if (typeof afterEach === 'function' && !process.env.RNTL_SKIP_AUTO_CLEANUP) {
30
30
  await (0, _flushMicroTasks.flushMicroTasks)();
31
31
  (0, _pure.cleanup)();
32
32
  });
33
- }
33
+ }
34
+ //# sourceMappingURL=index.js.map
@@ -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 shallow from './shallow';
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 { shallow };
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, "flushMicrotasksQueue", {
24
+ Object.defineProperty(exports, "getDefaultNormalizer", {
25
25
  enumerable: true,
26
26
  get: function () {
27
- return _flushMicroTasks.default;
27
+ return _matches.getDefaultNormalizer;
28
28
  }
29
29
  });
30
- Object.defineProperty(exports, "render", {
30
+ Object.defineProperty(exports, "getQueriesForElement", {
31
31
  enumerable: true,
32
32
  get: function () {
33
- return _render.default;
33
+ return _within.getQueriesForElement;
34
34
  }
35
35
  });
36
- Object.defineProperty(exports, "shallow", {
36
+ Object.defineProperty(exports, "render", {
37
37
  enumerable: true,
38
38
  get: function () {
39
- return _shallow.default;
39
+ return _render.default;
40
40
  }
41
41
  });
42
- Object.defineProperty(exports, "waitFor", {
42
+ Object.defineProperty(exports, "renderHook", {
43
43
  enumerable: true,
44
44
  get: function () {
45
- return _waitFor.default;
45
+ return _renderHook.renderHook;
46
46
  }
47
47
  });
48
- Object.defineProperty(exports, "waitForElement", {
48
+ Object.defineProperty(exports, "waitFor", {
49
49
  enumerable: true,
50
50
  get: function () {
51
- return _waitFor.waitForElement;
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 _shallow = _interopRequireDefault(require("./shallow"));
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
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
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"}
@@ -0,0 +1,66 @@
1
+ import type { ReactTestInstance } from 'react-test-renderer';
2
+ import type { AccessibilityRole, AccessibilityState } from 'react-native';
3
+ import type { WaitForOptions } from '../waitFor';
4
+ import type { TextMatch } from '../matches';
5
+ declare type AccessibilityStateKey = keyof AccessibilityState;
6
+ declare type A11yValue = {
7
+ min?: number;
8
+ max?: number;
9
+ now?: number;
10
+ text?: string;
11
+ };
12
+ declare type GetReturn = ReactTestInstance;
13
+ declare type GetAllReturn = Array<ReactTestInstance>;
14
+ declare type QueryReturn = ReactTestInstance | null;
15
+ declare type QueryAllReturn = Array<ReactTestInstance>;
16
+ declare type FindReturn = Promise<GetReturn>;
17
+ declare type FindAllReturn = Promise<GetAllReturn>;
18
+ export declare type A11yAPI = {
19
+ getByLabelText: (label: TextMatch) => GetReturn;
20
+ getAllByLabelText: (label: TextMatch) => GetAllReturn;
21
+ queryByLabelText: (label: TextMatch) => QueryReturn;
22
+ queryAllByLabelText: (label: TextMatch) => QueryAllReturn;
23
+ findByLabelText: (label: TextMatch, waitForOptions?: WaitForOptions) => FindReturn;
24
+ findAllByLabelText: (label: TextMatch, waitForOptions?: WaitForOptions) => FindAllReturn;
25
+ getByA11yHint: (a11yHint: TextMatch) => GetReturn;
26
+ getByHintText: (a11yHint: TextMatch) => GetReturn;
27
+ getAllByA11yHint: (a11yHint: TextMatch) => GetAllReturn;
28
+ getAllByHintText: (a11yHint: TextMatch) => GetAllReturn;
29
+ queryByA11yHint: (a11yHint: TextMatch) => QueryReturn;
30
+ queryByHintText: (a11yHint: TextMatch) => QueryReturn;
31
+ queryAllByA11yHint: (a11yHint: TextMatch) => QueryAllReturn;
32
+ queryAllByHintText: (a11yHint: TextMatch) => QueryAllReturn;
33
+ findByA11yHint: (a11yHint: TextMatch, waitForOptions?: WaitForOptions) => FindReturn;
34
+ findByHintText: (a11yHint: TextMatch, waitForOptions?: WaitForOptions) => FindReturn;
35
+ findAllByA11yHint: (a11yHint: TextMatch, waitForOptions?: WaitForOptions) => FindAllReturn;
36
+ findAllByHintText: (a11yHint: TextMatch, waitForOptions?: WaitForOptions) => FindAllReturn;
37
+ getByRole: (role: AccessibilityRole | RegExp) => GetReturn;
38
+ getAllByRole: (role: AccessibilityRole | RegExp) => GetAllReturn;
39
+ queryByRole: (role: AccessibilityRole | RegExp) => QueryReturn;
40
+ queryAllByRole: (role: AccessibilityRole | RegExp) => QueryAllReturn;
41
+ findByRole: (role: AccessibilityRole, waitForOptions?: WaitForOptions) => FindReturn;
42
+ findAllByRole: (role: AccessibilityRole, waitForOptions?: WaitForOptions) => FindAllReturn;
43
+ getByA11yStates: (accessibilityStateKey: AccessibilityStateKey | Array<AccessibilityStateKey>) => GetReturn;
44
+ getAllByA11yStates: (accessibilityStateKey: AccessibilityStateKey | Array<AccessibilityStateKey>) => GetAllReturn;
45
+ queryByA11yStates: (accessibilityStateKey: AccessibilityStateKey | Array<AccessibilityStateKey>) => QueryReturn;
46
+ queryAllByA11yStates: (accessibilityStateKey: AccessibilityStateKey | Array<AccessibilityStateKey>) => QueryAllReturn;
47
+ findByA11yStates: (accessibilityStateKey: AccessibilityStateKey, waitForOptions?: WaitForOptions) => FindReturn;
48
+ findAllByA11yStates: (accessibilityStateKey: AccessibilityStateKey, waitForOptions?: WaitForOptions) => FindAllReturn;
49
+ getByA11yState: (accessibilityState: AccessibilityState) => GetReturn;
50
+ getAllByA11yState: (accessibilityState: AccessibilityState) => GetAllReturn;
51
+ queryByA11yState: (accessibilityState: AccessibilityState) => QueryReturn;
52
+ queryAllByA11yState: (accessibilityState: AccessibilityState) => QueryAllReturn;
53
+ findByA11yState: (accessibilityState: AccessibilityState, waitForOptions?: WaitForOptions) => FindReturn;
54
+ findAllByA11yState: (accessibilityState: AccessibilityState, waitForOptions?: WaitForOptions) => FindAllReturn;
55
+ getByA11yValue: (a11yValue: A11yValue) => GetReturn;
56
+ getAllByA11yValue: (a11yValue: A11yValue) => GetAllReturn;
57
+ queryByA11yValue: (a11yValue: A11yValue) => QueryReturn;
58
+ queryAllByA11yValue: (a11yValue: A11yValue) => QueryAllReturn;
59
+ findByA11yValue: (a11yValue: A11yValue, waitForOptions?: WaitForOptions) => FindReturn;
60
+ findAllByA11yValue: (a11yValue: A11yValue, waitForOptions?: WaitForOptions) => FindAllReturn;
61
+ };
62
+ export declare function matchStringValue(prop: string | undefined, matcher: TextMatch): boolean;
63
+ export declare function matchArrayValue(prop: Array<string> | undefined, matcher: string | Array<string>): boolean;
64
+ export declare function matchObject<T extends Record<string, unknown>>(prop: T | undefined, matcher: T): boolean;
65
+ export declare const a11yAPI: (instance: ReactTestInstance) => A11yAPI;
66
+ export {};