@testing-library/react-native 11.4.0 → 11.5.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 (69) hide show
  1. package/README.md +3 -3
  2. package/build/cleanup.d.ts +1 -1
  3. package/build/config.d.ts +10 -2
  4. package/build/config.js +12 -3
  5. package/build/config.js.map +1 -1
  6. package/build/flushMicroTasks.d.ts +1 -1
  7. package/build/helpers/accessiblity.d.ts +10 -4
  8. package/build/helpers/accessiblity.js +19 -9
  9. package/build/helpers/accessiblity.js.map +1 -1
  10. package/build/helpers/debugDeep.d.ts +1 -1
  11. package/build/helpers/findAll.d.ts +10 -0
  12. package/build/helpers/findAll.js +44 -0
  13. package/build/helpers/findAll.js.map +1 -0
  14. package/build/helpers/format.d.ts +2 -2
  15. package/build/helpers/getTextContent.d.ts +2 -0
  16. package/build/helpers/getTextContent.js +20 -0
  17. package/build/helpers/getTextContent.js.map +1 -0
  18. package/build/helpers/matchers/accessibilityValue.d.ts +9 -0
  19. package/build/helpers/matchers/accessibilityValue.js +12 -0
  20. package/build/helpers/matchers/accessibilityValue.js.map +1 -0
  21. package/build/helpers/matchers/matchTextContent.d.ts +3 -0
  22. package/build/helpers/matchers/matchTextContent.js +22 -0
  23. package/build/helpers/matchers/matchTextContent.js.map +1 -0
  24. package/build/helpers/timers.js.map +1 -1
  25. package/build/index.flow.js +122 -54
  26. package/build/matches.d.ts +7 -3
  27. package/build/matches.js.map +1 -1
  28. package/build/pure.d.ts +12 -23
  29. package/build/pure.js +8 -2
  30. package/build/pure.js.map +1 -1
  31. package/build/queries/a11yState.d.ts +15 -14
  32. package/build/queries/a11yState.js +3 -2
  33. package/build/queries/a11yState.js.map +1 -1
  34. package/build/queries/a11yValue.d.ts +15 -20
  35. package/build/queries/a11yValue.js +16 -5
  36. package/build/queries/a11yValue.js.map +1 -1
  37. package/build/queries/displayValue.d.ts +11 -9
  38. package/build/queries/displayValue.js +2 -1
  39. package/build/queries/displayValue.js.map +1 -1
  40. package/build/queries/hintText.d.ts +23 -21
  41. package/build/queries/hintText.js +2 -1
  42. package/build/queries/hintText.js.map +1 -1
  43. package/build/queries/labelText.d.ts +11 -9
  44. package/build/queries/labelText.js +2 -1
  45. package/build/queries/labelText.js.map +1 -1
  46. package/build/queries/makeQueries.d.ts +8 -8
  47. package/build/queries/options.d.ts +11 -0
  48. package/build/queries/options.js +2 -0
  49. package/build/queries/options.js.map +1 -0
  50. package/build/queries/placeholderText.d.ts +11 -9
  51. package/build/queries/placeholderText.js +2 -1
  52. package/build/queries/placeholderText.js.map +1 -1
  53. package/build/queries/role.d.ts +7 -4
  54. package/build/queries/role.js +19 -10
  55. package/build/queries/role.js.map +1 -1
  56. package/build/queries/testId.d.ts +11 -9
  57. package/build/queries/testId.js +3 -2
  58. package/build/queries/testId.js.map +1 -1
  59. package/build/queries/text.d.ts +11 -13
  60. package/build/queries/text.js +6 -47
  61. package/build/queries/text.js.map +1 -1
  62. package/build/queries/unsafeProps.d.ts +1 -1
  63. package/build/queries/unsafeType.d.ts +1 -1
  64. package/build/render.d.ts +92 -146
  65. package/build/renderHook.d.ts +2 -2
  66. package/build/waitFor.d.ts +1 -1
  67. package/build/within.d.ts +90 -144
  68. package/package.json +8 -8
  69. package/typings/index.flow.js +122 -54
@@ -8,6 +8,10 @@ type QueryAllReturn = Array<ReactTestInstance> | [];
8
8
  type FindReturn = Promise<ReactTestInstance>;
9
9
  type FindAllReturn = Promise<ReactTestInstance[]>;
10
10
 
11
+ type CommonQueryOptions = {
12
+ includeHiddenElements?: boolean,
13
+ hidden?: boolean,
14
+ };
11
15
  type TextMatch = string | RegExp;
12
16
 
13
17
  declare type NormalizerFn = (textToNormalize: string) => string;
@@ -60,7 +64,7 @@ declare type A11yValue = {
60
64
  min?: number,
61
65
  max?: number,
62
66
  now?: number,
63
- text?: string,
67
+ text?: TextMatch,
64
68
  };
65
69
 
66
70
  type WaitForOptions = {
@@ -74,109 +78,123 @@ type WaitForFunction = <T = any>(
74
78
  options?: WaitForOptions
75
79
  ) => Promise<T>;
76
80
 
81
+ type ByTextOptions = CommonQueryOptions & TextMatchOptions;
82
+
77
83
  interface ByTextQueries {
78
- getByText: (text: TextMatch, options?: TextMatchOptions) => ReactTestInstance;
84
+ getByText: (text: TextMatch, options?: ByTextOptions) => ReactTestInstance;
79
85
  getAllByText: (
80
86
  text: TextMatch,
81
- options?: TextMatchOptions
87
+ options?: ByTextOptions
82
88
  ) => Array<ReactTestInstance>;
83
89
  queryByText: (
84
90
  name: TextMatch,
85
- options?: TextMatchOptions
91
+ options?: ByTextOptions
86
92
  ) => ReactTestInstance | null;
87
93
  queryAllByText: (
88
94
  text: TextMatch,
89
- options?: TextMatchOptions
95
+ options?: ByTextOptions
90
96
  ) => Array<ReactTestInstance> | [];
91
97
  findByText: (
92
98
  text: TextMatch,
93
- queryOptions?: TextMatchOptions,
99
+ queryOptions?: ByTextOptions,
94
100
  waitForOptions?: WaitForOptions
95
101
  ) => FindReturn;
96
102
  findAllByText: (
97
103
  text: TextMatch,
98
- queryOptions?: TextMatchOptions,
104
+ queryOptions?: ByTextOptions,
99
105
  waitForOptions?: WaitForOptions
100
106
  ) => FindAllReturn;
101
107
  }
102
108
 
109
+ type ByTestIdOptions = CommonQueryOptions & TextMatchOptions;
110
+
103
111
  interface ByTestIdQueries {
104
112
  getByTestId: (
105
113
  testID: TextMatch,
106
- options?: TextMatchOptions
114
+ options?: ByTestIdOptions
107
115
  ) => ReactTestInstance;
108
116
  getAllByTestId: (
109
117
  testID: TextMatch,
110
- options?: TextMatchOptions
118
+ options?: ByTestIdOptions
111
119
  ) => Array<ReactTestInstance>;
112
- queryByTestId: (testID: TextMatch) => ReactTestInstance | null;
113
- queryAllByTestId: (testID: TextMatch) => Array<ReactTestInstance> | [];
120
+ queryByTestId: (
121
+ testID: TextMatch,
122
+ options?: ByTestIdOptions
123
+ ) => ReactTestInstance | null;
124
+ queryAllByTestId: (
125
+ testID: TextMatch,
126
+ options?: ByTestIdOptions
127
+ ) => Array<ReactTestInstance> | [];
114
128
  findByTestId: (
115
129
  testID: TextMatch,
116
- queryOptions?: TextMatchOptions,
130
+ queryOptions?: ByTestIdOptions,
117
131
  waitForOptions?: WaitForOptions
118
132
  ) => FindReturn;
119
133
  findAllByTestId: (
120
134
  testID: TextMatch,
121
- queryOptions?: TextMatchOptions,
135
+ queryOptions?: ByTestIdOptions,
122
136
  waitForOptions?: WaitForOptions
123
137
  ) => FindAllReturn;
124
138
  }
125
139
 
140
+ type ByDisplayValueOptions = CommonQueryOptions & TextMatchOptions;
141
+
126
142
  interface ByDisplayValueQueries {
127
143
  getByDisplayValue: (
128
144
  value: TextMatch,
129
- options?: TextMatchOptions
145
+ options?: ByDisplayValueOptions
130
146
  ) => ReactTestInstance;
131
147
  getAllByDisplayValue: (
132
148
  value: TextMatch,
133
- options?: TextMatchOptions
149
+ options?: ByDisplayValueOptions
134
150
  ) => Array<ReactTestInstance>;
135
151
  queryByDisplayValue: (
136
152
  value: TextMatch,
137
- options?: TextMatchOptions
153
+ options?: ByDisplayValueOptions
138
154
  ) => ReactTestInstance | null;
139
155
  queryAllByDisplayValue: (
140
156
  value: TextMatch,
141
- options?: TextMatchOptions
157
+ options?: ByDisplayValueOptions
142
158
  ) => Array<ReactTestInstance> | [];
143
159
  findByDisplayValue: (
144
160
  value: TextMatch,
145
- queryOptions?: TextMatchOptions,
161
+ queryOptions?: ByDisplayValueOptions,
146
162
  waitForOptions?: WaitForOptions
147
163
  ) => FindReturn;
148
164
  findAllByDisplayValue: (
149
165
  value: TextMatch,
150
- queryOptions?: TextMatchOptions,
166
+ queryOptions?: ByDisplayValueOptions,
151
167
  waitForOptions?: WaitForOptions
152
168
  ) => FindAllReturn;
153
169
  }
154
170
 
171
+ type ByPlaceholderTextOptions = CommonQueryOptions & TextMatchOptions;
172
+
155
173
  interface ByPlaceholderTextQueries {
156
174
  getByPlaceholderText: (
157
175
  placeholder: TextMatch,
158
- options?: TextMatchOptions
176
+ options?: ByPlaceholderTextOptions
159
177
  ) => ReactTestInstance;
160
178
  getAllByPlaceholderText: (
161
179
  placeholder: TextMatch,
162
- options?: TextMatchOptions
180
+ options?: ByPlaceholderTextOptions
163
181
  ) => Array<ReactTestInstance>;
164
182
  queryByPlaceholderText: (
165
183
  placeholder: TextMatch,
166
- options?: TextMatchOptions
184
+ options?: ByPlaceholderTextOptions
167
185
  ) => ReactTestInstance | null;
168
186
  queryAllByPlaceholderText: (
169
187
  placeholder: TextMatch,
170
- options?: TextMatchOptions
188
+ options?: ByPlaceholderTextOptions
171
189
  ) => Array<ReactTestInstance> | [];
172
190
  findByPlaceholderText: (
173
191
  placeholder: TextMatch,
174
- queryOptions?: TextMatchOptions,
192
+ queryOptions?: ByPlaceholderTextOptions,
175
193
  waitForOptions?: WaitForOptions
176
194
  ) => FindReturn;
177
195
  findAllByPlaceholderText: (
178
196
  placeholder: TextMatch,
179
- queryOptions?: TextMatchOptions,
197
+ queryOptions?: ByPlaceholderTextOptions,
180
198
  waitForOptions?: WaitForOptions
181
199
  ) => FindAllReturn;
182
200
  }
@@ -203,82 +221,89 @@ interface UnsafeByPropsQueries {
203
221
  | [];
204
222
  }
205
223
 
206
- type ByRoleOptions = {
224
+ type ByRoleOptions = CommonQueryOptions & {
207
225
  ...A11yState,
208
226
  name?: string,
227
+ value?: A11yValue,
209
228
  };
210
229
 
230
+ type ByLabelTextOptions = CommonQueryOptions & TextMatchOptions;
231
+ type ByHintTextOptions = CommonQueryOptions & TextMatchOptions;
232
+
211
233
  interface A11yAPI {
212
234
  // Label
213
- getByLabelText: (matcher: TextMatch, options?: TextMatchOptions) => GetReturn;
235
+ getByLabelText: (
236
+ matcher: TextMatch,
237
+ options?: ByLabelTextOptions
238
+ ) => GetReturn;
214
239
  getAllByLabelText: (
215
240
  matcher: TextMatch,
216
- options?: TextMatchOptions
241
+ options?: ByLabelTextOptions
217
242
  ) => GetAllReturn;
218
243
  queryByLabelText: (
219
244
  matcher: TextMatch,
220
- options?: TextMatchOptions
245
+ options?: ByLabelTextOptions
221
246
  ) => QueryReturn;
222
247
  queryAllByLabelText: (
223
248
  matcher: TextMatch,
224
- options?: TextMatchOptions
249
+ options?: ByLabelTextOptions
225
250
  ) => QueryAllReturn;
226
251
  findByLabelText: (
227
252
  matcher: TextMatch,
228
- queryOptions?: TextMatchOptions,
253
+ queryOptions?: ByLabelTextOptions,
229
254
  waitForOptions?: WaitForOptions
230
255
  ) => FindReturn;
231
256
  findAllByLabelText: (
232
257
  matcher: TextMatch,
233
- queryOptions?: TextMatchOptions,
258
+ queryOptions?: ByLabelTextOptions,
234
259
  waitForOptions?: WaitForOptions
235
260
  ) => FindAllReturn;
236
261
 
237
262
  // Hint
238
- getByA11yHint: (matcher: TextMatch, options?: TextMatchOptions) => GetReturn;
239
- getByHintText: (matcher: TextMatch, options?: TextMatchOptions) => GetReturn;
263
+ getByA11yHint: (matcher: TextMatch, options?: ByHintTextOptions) => GetReturn;
264
+ getByHintText: (matcher: TextMatch, options?: ByHintTextOptions) => GetReturn;
240
265
  getAllByA11yHint: (
241
266
  matcher: TextMatch,
242
- options?: TextMatchOptions
267
+ options?: ByHintTextOptions
243
268
  ) => GetAllReturn;
244
269
  getAllByHintText: (
245
270
  matcher: TextMatch,
246
- options?: TextMatchOptions
271
+ options?: ByHintTextOptions
247
272
  ) => GetAllReturn;
248
273
  queryByA11yHint: (
249
274
  matcher: TextMatch,
250
- options?: TextMatchOptions
275
+ options?: ByHintTextOptions
251
276
  ) => QueryReturn;
252
277
  queryByHintText: (
253
278
  matcher: TextMatch,
254
- options?: TextMatchOptions
279
+ options?: ByHintTextOptions
255
280
  ) => QueryReturn;
256
281
  queryAllByA11yHint: (
257
282
  matcher: TextMatch,
258
- options?: TextMatchOptions
283
+ options?: ByHintTextOptions
259
284
  ) => QueryAllReturn;
260
285
  queryAllByHintText: (
261
286
  matcher: TextMatch,
262
- options?: TextMatchOptions
287
+ options?: ByHintTextOptions
263
288
  ) => QueryAllReturn;
264
289
  findByA11yHint: (
265
290
  matcher: TextMatch,
266
- queryOptions?: TextMatchOptions,
291
+ queryOptions?: ByHintTextOptions,
267
292
  waitForOptions?: WaitForOptions
268
293
  ) => FindReturn;
269
294
  findByHintText: (
270
295
  matcher: TextMatch,
271
- queryOptions?: TextMatchOptions,
296
+ queryOptions?: ByHintTextOptions,
272
297
  waitForOptions?: WaitForOptions
273
298
  ) => FindReturn;
274
299
  findAllByA11yHint: (
275
300
  matcher: TextMatch,
276
- queryOptions?: TextMatchOptions,
301
+ queryOptions?: ByHintTextOptions,
277
302
  waitForOptions?: WaitForOptions
278
303
  ) => FindAllReturn;
279
304
  findAllByHintText: (
280
305
  matcher: TextMatch,
281
- queryOptions?: TextMatchOptions,
306
+ queryOptions?: ByHintTextOptions,
282
307
  waitForOptions?: WaitForOptions
283
308
  ) => FindAllReturn;
284
309
 
@@ -308,30 +333,58 @@ interface A11yAPI {
308
333
  ) => FindAllReturn;
309
334
 
310
335
  // State
311
- getByA11yState: (matcher: A11yState) => GetReturn;
312
- getAllByA11yState: (matcher: A11yState) => GetAllReturn;
313
- queryByA11yState: (matcher: A11yState) => QueryReturn;
314
- queryAllByA11yState: (matcher: A11yState) => QueryAllReturn;
336
+ getByA11yState: (
337
+ matcher: A11yState,
338
+ options?: CommonQueryOptions
339
+ ) => GetReturn;
340
+ getAllByA11yState: (
341
+ matcher: A11yState,
342
+ options?: CommonQueryOptions
343
+ ) => GetAllReturn;
344
+ queryByA11yState: (
345
+ matcher: A11yState,
346
+ options?: CommonQueryOptions
347
+ ) => QueryReturn;
348
+ queryAllByA11yState: (
349
+ matcher: A11yState,
350
+ options?: CommonQueryOptions
351
+ ) => QueryAllReturn;
315
352
  findByA11yState: (
316
353
  matcher: A11yState,
354
+ queryOptions?: CommonQueryOptions,
317
355
  waitForOptions?: WaitForOptions
318
356
  ) => FindReturn;
319
357
  findAllByA11yState: (
320
358
  matcher: A11yState,
359
+ queryOptions?: CommonQueryOptions,
321
360
  waitForOptions?: WaitForOptions
322
361
  ) => FindAllReturn;
323
362
 
324
363
  // Value
325
- getByA11yValue: (matcher: A11yValue) => GetReturn;
326
- getAllByA11yValue: (matcher: A11yValue) => GetAllReturn;
327
- queryByA11yValue: (matcher: A11yValue) => QueryReturn;
328
- queryAllByA11yValue: (matcher: A11yValue) => QueryAllReturn;
364
+ getByA11yValue: (
365
+ matcher: A11yValue,
366
+ options?: CommonQueryOptions
367
+ ) => GetReturn;
368
+ getAllByA11yValue: (
369
+ matcher: A11yValue,
370
+ options?: CommonQueryOptions
371
+ ) => GetAllReturn;
372
+ queryByA11yValue: (
373
+ matcher: A11yValue,
374
+ options?: CommonQueryOptions
375
+ ) => QueryReturn;
376
+ queryAllByA11yValue: (
377
+ matcher: A11yValue,
378
+ options?: CommonQueryOptions
379
+ ) => QueryAllReturn;
329
380
  findByA11yValue: (
330
381
  matcher: A11yValue,
382
+ queryOptions?: CommonQueryOptions,
331
383
  waitForOptions?: WaitForOptions
332
384
  ) => FindReturn;
333
385
  findAllByA11yValue: (
334
386
  matcher: A11yValue,
387
+ queryOptions?: CommonQueryOptions,
335
388
  waitForOptions?: WaitForOptions
336
389
  ) => FindAllReturn;
337
390
  }
@@ -414,22 +467,37 @@ declare module '@testing-library/react-native' {
414
467
 
415
468
  declare interface Config {
416
469
  asyncUtilTimeout: number;
470
+ defaultIncludeHiddenElements: boolean;
417
471
  defaultDebugOptions?: $Shape<DebugOptions>;
418
472
  }
419
473
 
420
- declare export var configure: (options: $Shape<Config>) => void;
474
+ declare interface ConfigAliasOptions {
475
+ /** Alias to `defaultIncludeHiddenElements` for RTL compatibility */
476
+ defaultHidden: boolean;
477
+ }
478
+
479
+ declare export var configure: (
480
+ options: $Shape<Config & ConfigAliasOptions>
481
+ ) => void;
421
482
  declare export var resetToDefaults: () => void;
422
483
 
423
484
  declare export var act: (callback: () => void) => Thenable;
424
485
  declare export var within: (instance: ReactTestInstance) => Queries;
425
486
  declare export var getQueriesForElement: (
426
- instance: ReactTestInstance
487
+ element: ReactTestInstance
427
488
  ) => Queries;
428
489
 
429
490
  declare export var getDefaultNormalizer: (
430
491
  normalizerConfig?: NormalizerConfig
431
492
  ) => NormalizerFn;
432
493
 
494
+ declare export var isHiddenFromAccessibility: (
495
+ element: ReactTestInstance | null
496
+ ) => boolean;
497
+ declare export var isInaccessible: (
498
+ element: ReactTestInstance | null
499
+ ) => boolean;
500
+
433
501
  declare type RenderHookResult<Result, Props> = {
434
502
  rerender: (props: Props) => void,
435
503
  result: { current: Result },
@@ -1,7 +1,11 @@
1
- export declare type NormalizerFn = (textToNormalize: string) => string;
2
- export declare type TextMatch = string | RegExp;
1
+ export type NormalizerFn = (textToNormalize: string) => string;
2
+ export type TextMatch = string | RegExp;
3
+ export type TextMatchOptions = {
4
+ exact?: boolean;
5
+ normalizer?: NormalizerFn;
6
+ };
3
7
  export declare function matches(matcher: TextMatch, text: string, normalizer?: NormalizerFn, exact?: boolean): boolean;
4
- declare type NormalizerConfig = {
8
+ type NormalizerConfig = {
5
9
  trim?: boolean;
6
10
  collapseWhitespace?: boolean;
7
11
  };
@@ -1 +1 @@
1
- {"version":3,"file":"matches.js","names":["matches","matcher","text","normalizer","getDefaultNormalizer","exact","normalizedText","normalizedMatcher","toLowerCase","includes","lastIndex","test","trim","collapseWhitespace","replace"],"sources":["../src/matches.ts"],"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 const normalizedMatcher = normalizer(matcher);\n return exact\n ? normalizedText === normalizedMatcher\n : normalizedText.toLowerCase().includes(normalizedMatcher.toLowerCase());\n } else {\n // Reset state for global regexes: https://stackoverflow.com/a/1520839/484499\n matcher.lastIndex = 0;\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"],"mappings":";;;;;;;AAGO,SAASA,OAAO,CACrBC,OAAkB,EAClBC,IAAY,EACZC,UAAwB,GAAGC,oBAAoB,EAAE,EACjDC,KAAc,GAAG,IAAI,EACZ;EACT,IAAI,OAAOH,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAO,KAAK;EACd;EAEA,MAAMI,cAAc,GAAGH,UAAU,CAACD,IAAI,CAAC;EACvC,IAAI,OAAOD,OAAO,KAAK,QAAQ,EAAE;IAC/B,MAAMM,iBAAiB,GAAGJ,UAAU,CAACF,OAAO,CAAC;IAC7C,OAAOI,KAAK,GACRC,cAAc,KAAKC,iBAAiB,GACpCD,cAAc,CAACE,WAAW,EAAE,CAACC,QAAQ,CAACF,iBAAiB,CAACC,WAAW,EAAE,CAAC;EAC5E,CAAC,MAAM;IACL;IACAP,OAAO,CAACS,SAAS,GAAG,CAAC;IACrB,OAAOT,OAAO,CAACU,IAAI,CAACL,cAAc,CAAC;EACrC;AACF;AAOO,SAASF,oBAAoB,CAAC;EACnCQ,IAAI,GAAG,IAAI;EACXC,kBAAkB,GAAG;AACL,CAAC,GAAG,CAAC,CAAC,EAAgB;EACtC,OAAQX,IAAY,IAAK;IACvB,IAAII,cAAc,GAAGJ,IAAI;IACzBI,cAAc,GAAGM,IAAI,GAAGN,cAAc,CAACM,IAAI,EAAE,GAAGN,cAAc;IAC9DA,cAAc,GAAGO,kBAAkB,GAC/BP,cAAc,CAACQ,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,GACnCR,cAAc;IAClB,OAAOA,cAAc;EACvB,CAAC;AACH"}
1
+ {"version":3,"file":"matches.js","names":["matches","matcher","text","normalizer","getDefaultNormalizer","exact","normalizedText","normalizedMatcher","toLowerCase","includes","lastIndex","test","trim","collapseWhitespace","replace"],"sources":["../src/matches.ts"],"sourcesContent":["export type NormalizerFn = (textToNormalize: string) => string;\n\nexport type TextMatch = string | RegExp;\nexport type TextMatchOptions = {\n exact?: boolean;\n normalizer?: NormalizerFn;\n};\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 const normalizedMatcher = normalizer(matcher);\n return exact\n ? normalizedText === normalizedMatcher\n : normalizedText.toLowerCase().includes(normalizedMatcher.toLowerCase());\n } else {\n // Reset state for global regexes: https://stackoverflow.com/a/1520839/484499\n matcher.lastIndex = 0;\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"],"mappings":";;;;;;;AAQO,SAASA,OAAO,CACrBC,OAAkB,EAClBC,IAAY,EACZC,UAAwB,GAAGC,oBAAoB,EAAE,EACjDC,KAAc,GAAG,IAAI,EACZ;EACT,IAAI,OAAOH,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAO,KAAK;EACd;EAEA,MAAMI,cAAc,GAAGH,UAAU,CAACD,IAAI,CAAC;EACvC,IAAI,OAAOD,OAAO,KAAK,QAAQ,EAAE;IAC/B,MAAMM,iBAAiB,GAAGJ,UAAU,CAACF,OAAO,CAAC;IAC7C,OAAOI,KAAK,GACRC,cAAc,KAAKC,iBAAiB,GACpCD,cAAc,CAACE,WAAW,EAAE,CAACC,QAAQ,CAACF,iBAAiB,CAACC,WAAW,EAAE,CAAC;EAC5E,CAAC,MAAM;IACL;IACAP,OAAO,CAACS,SAAS,GAAG,CAAC;IACrB,OAAOT,OAAO,CAACU,IAAI,CAACL,cAAc,CAAC;EACrC;AACF;AAOO,SAASF,oBAAoB,CAAC;EACnCQ,IAAI,GAAG,IAAI;EACXC,kBAAkB,GAAG;AACL,CAAC,GAAG,CAAC,CAAC,EAAgB;EACtC,OAAQX,IAAY,IAAK;IACvB,IAAII,cAAc,GAAGJ,IAAI;IACzBI,cAAc,GAAGM,IAAI,GAAGN,cAAc,CAACM,IAAI,EAAE,GAAGN,cAAc;IAC9DA,cAAc,GAAGO,kBAAkB,GAC/BP,cAAc,CAACQ,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,GACnCR,cAAc;IAClB,OAAOA,cAAc;EACvB,CAAC;AACH"}
package/build/pure.d.ts CHANGED
@@ -1,26 +1,15 @@
1
- import act from './act';
2
- import cleanup from './cleanup';
3
- import fireEvent from './fireEvent';
4
- import render from './render';
5
- import waitFor from './waitFor';
6
- import waitForElementToBeRemoved from './waitForElementToBeRemoved';
7
- import { within, getQueriesForElement } from './within';
8
- import { getDefaultNormalizer } from './matches';
9
- import { renderHook } from './renderHook';
10
- import { screen } from './screen';
11
- import { isInaccessible } from './helpers/accessiblity';
1
+ export { default as act } from './act';
2
+ export { default as cleanup } from './cleanup';
3
+ export { default as fireEvent } from './fireEvent';
4
+ export { default as render } from './render';
5
+ export { default as waitFor } from './waitFor';
6
+ export { default as waitForElementToBeRemoved } from './waitForElementToBeRemoved';
7
+ export { within, getQueriesForElement } from './within';
8
+ export { configure, resetToDefaults } from './config';
9
+ export { isHiddenFromAccessibility, isInaccessible, } from './helpers/accessiblity';
10
+ export { getDefaultNormalizer } from './matches';
11
+ export { renderHook } from './renderHook';
12
+ export { screen } from './screen';
12
13
  export type { RenderOptions, RenderResult, RenderResult as RenderAPI, } from './render';
13
14
  export type { RenderHookOptions, RenderHookResult } from './renderHook';
14
15
  export type { Config } from './config';
15
- export { act };
16
- export { cleanup };
17
- export { configure, resetToDefaults } from './config';
18
- export { fireEvent };
19
- export { render };
20
- export { waitFor };
21
- export { waitForElementToBeRemoved };
22
- export { within, getQueriesForElement };
23
- export { getDefaultNormalizer };
24
- export { renderHook };
25
- export { screen };
26
- export { isInaccessible };
package/build/pure.js CHANGED
@@ -39,6 +39,12 @@ Object.defineProperty(exports, "getQueriesForElement", {
39
39
  return _within.getQueriesForElement;
40
40
  }
41
41
  });
42
+ Object.defineProperty(exports, "isHiddenFromAccessibility", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _accessiblity.isHiddenFromAccessibility;
46
+ }
47
+ });
42
48
  Object.defineProperty(exports, "isInaccessible", {
43
49
  enumerable: true,
44
50
  get: function () {
@@ -94,10 +100,10 @@ var _render = _interopRequireDefault(require("./render"));
94
100
  var _waitFor = _interopRequireDefault(require("./waitFor"));
95
101
  var _waitForElementToBeRemoved = _interopRequireDefault(require("./waitForElementToBeRemoved"));
96
102
  var _within = require("./within");
103
+ var _config = require("./config");
104
+ var _accessiblity = require("./helpers/accessiblity");
97
105
  var _matches = require("./matches");
98
106
  var _renderHook = require("./renderHook");
99
107
  var _screen = require("./screen");
100
- var _accessiblity = require("./helpers/accessiblity");
101
- var _config = require("./config");
102
108
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
103
109
  //# sourceMappingURL=pure.js.map
package/build/pure.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pure.js","names":[],"sources":["../src/pure.ts"],"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';\nimport { screen } from './screen';\nimport { isInaccessible } from './helpers/accessiblity';\n\nexport type {\n RenderOptions,\n RenderResult,\n RenderResult as RenderAPI,\n} from './render';\nexport type { RenderHookOptions, RenderHookResult } from './renderHook';\nexport type { Config } from './config';\n\nexport { act };\nexport { cleanup };\nexport { configure, resetToDefaults } from './config';\nexport { fireEvent };\nexport { render };\nexport { waitFor };\nexport { waitForElementToBeRemoved };\nexport { within, getQueriesForElement };\nexport { getDefaultNormalizer };\nexport { renderHook };\nexport { screen };\nexport { isInaccessible };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAYA;AAAsD"}
1
+ {"version":3,"file":"pure.js","names":[],"sources":["../src/pure.ts"],"sourcesContent":["export { default as act } from './act';\nexport { default as cleanup } from './cleanup';\nexport { default as fireEvent } from './fireEvent';\nexport { default as render } from './render';\nexport { default as waitFor } from './waitFor';\nexport { default as waitForElementToBeRemoved } from './waitForElementToBeRemoved';\nexport { within, getQueriesForElement } from './within';\n\nexport { configure, resetToDefaults } from './config';\nexport {\n isHiddenFromAccessibility,\n isInaccessible,\n} from './helpers/accessiblity';\nexport { getDefaultNormalizer } from './matches';\nexport { renderHook } from './renderHook';\nexport { screen } from './screen';\n\nexport type {\n RenderOptions,\n RenderResult,\n RenderResult as RenderAPI,\n} from './render';\nexport type { RenderHookOptions, RenderHookResult } from './renderHook';\nexport type { Config } from './config';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAIA;AACA;AACA;AAAkC"}
@@ -1,18 +1,19 @@
1
1
  import type { ReactTestInstance } from 'react-test-renderer';
2
- import type { AccessibilityState } from 'react-native';
2
+ import { AccessibilityState } from 'react-native';
3
3
  import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
4
- export declare type ByA11yStateQueries = {
5
- getByA11yState: GetByQuery<AccessibilityState>;
6
- getAllByA11yState: GetAllByQuery<AccessibilityState>;
7
- queryByA11yState: QueryByQuery<AccessibilityState>;
8
- queryAllByA11yState: QueryAllByQuery<AccessibilityState>;
9
- findByA11yState: FindByQuery<AccessibilityState>;
10
- findAllByA11yState: FindAllByQuery<AccessibilityState>;
11
- getByAccessibilityState: GetByQuery<AccessibilityState>;
12
- getAllByAccessibilityState: GetAllByQuery<AccessibilityState>;
13
- queryByAccessibilityState: QueryByQuery<AccessibilityState>;
14
- queryAllByAccessibilityState: QueryAllByQuery<AccessibilityState>;
15
- findByAccessibilityState: FindByQuery<AccessibilityState>;
16
- findAllByAccessibilityState: FindAllByQuery<AccessibilityState>;
4
+ import { CommonQueryOptions } from './options';
5
+ export type ByA11yStateQueries = {
6
+ getByA11yState: GetByQuery<AccessibilityState, CommonQueryOptions>;
7
+ getAllByA11yState: GetAllByQuery<AccessibilityState, CommonQueryOptions>;
8
+ queryByA11yState: QueryByQuery<AccessibilityState, CommonQueryOptions>;
9
+ queryAllByA11yState: QueryAllByQuery<AccessibilityState, CommonQueryOptions>;
10
+ findByA11yState: FindByQuery<AccessibilityState, CommonQueryOptions>;
11
+ findAllByA11yState: FindAllByQuery<AccessibilityState, CommonQueryOptions>;
12
+ getByAccessibilityState: GetByQuery<AccessibilityState, CommonQueryOptions>;
13
+ getAllByAccessibilityState: GetAllByQuery<AccessibilityState, CommonQueryOptions>;
14
+ queryByAccessibilityState: QueryByQuery<AccessibilityState, CommonQueryOptions>;
15
+ queryAllByAccessibilityState: QueryAllByQuery<AccessibilityState, CommonQueryOptions>;
16
+ findByAccessibilityState: FindByQuery<AccessibilityState, CommonQueryOptions>;
17
+ findAllByAccessibilityState: FindAllByQuery<AccessibilityState, CommonQueryOptions>;
17
18
  };
18
19
  export declare const bindByA11yStateQueries: (instance: ReactTestInstance) => ByA11yStateQueries;
@@ -5,10 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.bindByA11yStateQueries = void 0;
7
7
  var _accessiblity = require("../helpers/accessiblity");
8
+ var _findAll = require("../helpers/findAll");
8
9
  var _accessibilityState = require("../helpers/matchers/accessibilityState");
9
10
  var _makeQueries = require("./makeQueries");
10
- const queryAllByA11yState = instance => function queryAllByA11yStateFn(matcher) {
11
- return instance.findAll(node => typeof node.type === 'string' && (0, _accessibilityState.matchAccessibilityState)(node, matcher));
11
+ const queryAllByA11yState = instance => function queryAllByA11yStateFn(matcher, queryOptions) {
12
+ return (0, _findAll.findAll)(instance, node => typeof node.type === 'string' && (0, _accessibilityState.matchAccessibilityState)(node, matcher), queryOptions);
12
13
  };
13
14
  const buildErrorMessage = (state = {}) => {
14
15
  const errors = [];
@@ -1 +1 @@
1
- {"version":3,"file":"a11yState.js","names":["queryAllByA11yState","instance","queryAllByA11yStateFn","matcher","findAll","node","type","matchAccessibilityState","buildErrorMessage","state","errors","accessibilityStateKeys","forEach","stateKey","undefined","push","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByA11yStateQueries","getByA11yState","getAllByA11yState","queryByA11yState","findByA11yState","findAllByA11yState","getByAccessibilityState","getAllByAccessibilityState","queryByAccessibilityState","queryAllByAccessibilityState","findByAccessibilityState","findAllByAccessibilityState"],"sources":["../../src/queries/a11yState.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport type { AccessibilityState } from 'react-native';\nimport { accessibilityStateKeys } from '../helpers/accessiblity';\nimport { matchAccessibilityState } from '../helpers/matchers/accessibilityState';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\n\nconst queryAllByA11yState = (\n instance: ReactTestInstance\n): ((matcher: AccessibilityState) => Array<ReactTestInstance>) =>\n function queryAllByA11yStateFn(matcher) {\n return instance.findAll(\n (node) =>\n typeof node.type === 'string' && matchAccessibilityState(node, matcher)\n );\n };\n\nconst buildErrorMessage = (state: AccessibilityState = {}) => {\n const errors: string[] = [];\n\n accessibilityStateKeys.forEach((stateKey) => {\n if (state[stateKey] !== undefined) {\n errors.push(`${stateKey} state: ${state[stateKey]}`);\n }\n });\n\n return errors.join(', ');\n};\n\nconst getMultipleError = (state: AccessibilityState) =>\n `Found multiple elements with ${buildErrorMessage(state)}`;\n\nconst getMissingError = (state: AccessibilityState) =>\n `Unable to find an element with ${buildErrorMessage(state)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByA11yState,\n getMissingError,\n getMultipleError\n);\n\nexport type ByA11yStateQueries = {\n getByA11yState: GetByQuery<AccessibilityState>;\n getAllByA11yState: GetAllByQuery<AccessibilityState>;\n queryByA11yState: QueryByQuery<AccessibilityState>;\n queryAllByA11yState: QueryAllByQuery<AccessibilityState>;\n findByA11yState: FindByQuery<AccessibilityState>;\n findAllByA11yState: FindAllByQuery<AccessibilityState>;\n\n getByAccessibilityState: GetByQuery<AccessibilityState>;\n getAllByAccessibilityState: GetAllByQuery<AccessibilityState>;\n queryByAccessibilityState: QueryByQuery<AccessibilityState>;\n queryAllByAccessibilityState: QueryAllByQuery<AccessibilityState>;\n findByAccessibilityState: FindByQuery<AccessibilityState>;\n findAllByAccessibilityState: FindAllByQuery<AccessibilityState>;\n};\n\nexport const bindByA11yStateQueries = (\n instance: ReactTestInstance\n): ByA11yStateQueries => {\n const getByA11yState = getBy(instance);\n const getAllByA11yState = getAllBy(instance);\n const queryByA11yState = queryBy(instance);\n const queryAllByA11yState = queryAllBy(instance);\n const findByA11yState = findBy(instance);\n const findAllByA11yState = findAllBy(instance);\n\n return {\n getByA11yState,\n getAllByA11yState,\n queryByA11yState,\n queryAllByA11yState,\n findByA11yState,\n findAllByA11yState,\n\n getByAccessibilityState: getByA11yState,\n getAllByAccessibilityState: getAllByA11yState,\n queryByAccessibilityState: queryByA11yState,\n queryAllByAccessibilityState: queryAllByA11yState,\n findByAccessibilityState: findByA11yState,\n findAllByAccessibilityState: findAllByA11yState,\n };\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;AAUA,MAAMA,mBAAmB,GACvBC,QAA2B,IAE3B,SAASC,qBAAqB,CAACC,OAAO,EAAE;EACtC,OAAOF,QAAQ,CAACG,OAAO,CACpBC,IAAI,IACH,OAAOA,IAAI,CAACC,IAAI,KAAK,QAAQ,IAAI,IAAAC,2CAAuB,EAACF,IAAI,EAAEF,OAAO,CAAC,CAC1E;AACH,CAAC;AAEH,MAAMK,iBAAiB,GAAG,CAACC,KAAyB,GAAG,CAAC,CAAC,KAAK;EAC5D,MAAMC,MAAgB,GAAG,EAAE;EAE3BC,oCAAsB,CAACC,OAAO,CAAEC,QAAQ,IAAK;IAC3C,IAAIJ,KAAK,CAACI,QAAQ,CAAC,KAAKC,SAAS,EAAE;MACjCJ,MAAM,CAACK,IAAI,CAAE,GAAEF,QAAS,WAAUJ,KAAK,CAACI,QAAQ,CAAE,EAAC,CAAC;IACtD;EACF,CAAC,CAAC;EAEF,OAAOH,MAAM,CAACM,IAAI,CAAC,IAAI,CAAC;AAC1B,CAAC;AAED,MAAMC,gBAAgB,GAAIR,KAAyB,IAChD,gCAA+BD,iBAAiB,CAACC,KAAK,CAAE,EAAC;AAE5D,MAAMS,eAAe,GAAIT,KAAyB,IAC/C,kCAAiCD,iBAAiB,CAACC,KAAK,CAAE,EAAC;AAE9D,MAAM;EAAEU,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EzB,mBAAmB,EACnBkB,eAAe,EACfD,gBAAgB,CACjB;AAkBM,MAAMS,sBAAsB,GACjCzB,QAA2B,IACJ;EACvB,MAAM0B,cAAc,GAAGR,KAAK,CAAClB,QAAQ,CAAC;EACtC,MAAM2B,iBAAiB,GAAGR,QAAQ,CAACnB,QAAQ,CAAC;EAC5C,MAAM4B,gBAAgB,GAAGR,OAAO,CAACpB,QAAQ,CAAC;EAC1C,MAAMD,mBAAmB,GAAGsB,UAAU,CAACrB,QAAQ,CAAC;EAChD,MAAM6B,eAAe,GAAGP,MAAM,CAACtB,QAAQ,CAAC;EACxC,MAAM8B,kBAAkB,GAAGP,SAAS,CAACvB,QAAQ,CAAC;EAE9C,OAAO;IACL0B,cAAc;IACdC,iBAAiB;IACjBC,gBAAgB;IAChB7B,mBAAmB;IACnB8B,eAAe;IACfC,kBAAkB;IAElBC,uBAAuB,EAAEL,cAAc;IACvCM,0BAA0B,EAAEL,iBAAiB;IAC7CM,yBAAyB,EAAEL,gBAAgB;IAC3CM,4BAA4B,EAAEnC,mBAAmB;IACjDoC,wBAAwB,EAAEN,eAAe;IACzCO,2BAA2B,EAAEN;EAC/B,CAAC;AACH,CAAC;AAAC"}
1
+ {"version":3,"file":"a11yState.js","names":["queryAllByA11yState","instance","queryAllByA11yStateFn","matcher","queryOptions","findAll","node","type","matchAccessibilityState","buildErrorMessage","state","errors","accessibilityStateKeys","forEach","stateKey","undefined","push","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByA11yStateQueries","getByA11yState","getAllByA11yState","queryByA11yState","findByA11yState","findAllByA11yState","getByAccessibilityState","getAllByAccessibilityState","queryByAccessibilityState","queryAllByAccessibilityState","findByAccessibilityState","findAllByAccessibilityState"],"sources":["../../src/queries/a11yState.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { AccessibilityState } from 'react-native';\nimport { accessibilityStateKeys } from '../helpers/accessiblity';\nimport { findAll } from '../helpers/findAll';\nimport { matchAccessibilityState } from '../helpers/matchers/accessibilityState';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport { CommonQueryOptions } from './options';\n\nconst queryAllByA11yState = (\n instance: ReactTestInstance\n): ((\n matcher: AccessibilityState,\n queryOptions?: CommonQueryOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByA11yStateFn(matcher, queryOptions) {\n return findAll(\n instance,\n (node) =>\n typeof node.type === 'string' && matchAccessibilityState(node, matcher),\n queryOptions\n );\n };\n\nconst buildErrorMessage = (state: AccessibilityState = {}) => {\n const errors: string[] = [];\n\n accessibilityStateKeys.forEach((stateKey) => {\n if (state[stateKey] !== undefined) {\n errors.push(`${stateKey} state: ${state[stateKey]}`);\n }\n });\n\n return errors.join(', ');\n};\n\nconst getMultipleError = (state: AccessibilityState) =>\n `Found multiple elements with ${buildErrorMessage(state)}`;\n\nconst getMissingError = (state: AccessibilityState) =>\n `Unable to find an element with ${buildErrorMessage(state)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByA11yState,\n getMissingError,\n getMultipleError\n);\n\nexport type ByA11yStateQueries = {\n getByA11yState: GetByQuery<AccessibilityState, CommonQueryOptions>;\n getAllByA11yState: GetAllByQuery<AccessibilityState, CommonQueryOptions>;\n queryByA11yState: QueryByQuery<AccessibilityState, CommonQueryOptions>;\n queryAllByA11yState: QueryAllByQuery<AccessibilityState, CommonQueryOptions>;\n findByA11yState: FindByQuery<AccessibilityState, CommonQueryOptions>;\n findAllByA11yState: FindAllByQuery<AccessibilityState, CommonQueryOptions>;\n\n getByAccessibilityState: GetByQuery<AccessibilityState, CommonQueryOptions>;\n getAllByAccessibilityState: GetAllByQuery<\n AccessibilityState,\n CommonQueryOptions\n >;\n queryByAccessibilityState: QueryByQuery<\n AccessibilityState,\n CommonQueryOptions\n >;\n queryAllByAccessibilityState: QueryAllByQuery<\n AccessibilityState,\n CommonQueryOptions\n >;\n findByAccessibilityState: FindByQuery<AccessibilityState, CommonQueryOptions>;\n findAllByAccessibilityState: FindAllByQuery<\n AccessibilityState,\n CommonQueryOptions\n >;\n};\n\nexport const bindByA11yStateQueries = (\n instance: ReactTestInstance\n): ByA11yStateQueries => {\n const getByA11yState = getBy(instance);\n const getAllByA11yState = getAllBy(instance);\n const queryByA11yState = queryBy(instance);\n const queryAllByA11yState = queryAllBy(instance);\n const findByA11yState = findBy(instance);\n const findAllByA11yState = findAllBy(instance);\n\n return {\n getByA11yState,\n getAllByA11yState,\n queryByA11yState,\n queryAllByA11yState,\n findByA11yState,\n findAllByA11yState,\n\n getByAccessibilityState: getByA11yState,\n getAllByAccessibilityState: getAllByA11yState,\n queryByAccessibilityState: queryByA11yState,\n queryAllByAccessibilityState: queryAllByA11yState,\n findByAccessibilityState: findByA11yState,\n findAllByAccessibilityState: findAllByA11yState,\n };\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AAWA,MAAMA,mBAAmB,GACvBC,QAA2B,IAK3B,SAASC,qBAAqB,CAACC,OAAO,EAAEC,YAAY,EAAE;EACpD,OAAO,IAAAC,gBAAO,EACZJ,QAAQ,EACPK,IAAI,IACH,OAAOA,IAAI,CAACC,IAAI,KAAK,QAAQ,IAAI,IAAAC,2CAAuB,EAACF,IAAI,EAAEH,OAAO,CAAC,EACzEC,YAAY,CACb;AACH,CAAC;AAEH,MAAMK,iBAAiB,GAAG,CAACC,KAAyB,GAAG,CAAC,CAAC,KAAK;EAC5D,MAAMC,MAAgB,GAAG,EAAE;EAE3BC,oCAAsB,CAACC,OAAO,CAAEC,QAAQ,IAAK;IAC3C,IAAIJ,KAAK,CAACI,QAAQ,CAAC,KAAKC,SAAS,EAAE;MACjCJ,MAAM,CAACK,IAAI,CAAE,GAAEF,QAAS,WAAUJ,KAAK,CAACI,QAAQ,CAAE,EAAC,CAAC;IACtD;EACF,CAAC,CAAC;EAEF,OAAOH,MAAM,CAACM,IAAI,CAAC,IAAI,CAAC;AAC1B,CAAC;AAED,MAAMC,gBAAgB,GAAIR,KAAyB,IAChD,gCAA+BD,iBAAiB,CAACC,KAAK,CAAE,EAAC;AAE5D,MAAMS,eAAe,GAAIT,KAAyB,IAC/C,kCAAiCD,iBAAiB,CAACC,KAAK,CAAE,EAAC;AAE9D,MAAM;EAAEU,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7E1B,mBAAmB,EACnBmB,eAAe,EACfD,gBAAgB,CACjB;AA8BM,MAAMS,sBAAsB,GACjC1B,QAA2B,IACJ;EACvB,MAAM2B,cAAc,GAAGR,KAAK,CAACnB,QAAQ,CAAC;EACtC,MAAM4B,iBAAiB,GAAGR,QAAQ,CAACpB,QAAQ,CAAC;EAC5C,MAAM6B,gBAAgB,GAAGR,OAAO,CAACrB,QAAQ,CAAC;EAC1C,MAAMD,mBAAmB,GAAGuB,UAAU,CAACtB,QAAQ,CAAC;EAChD,MAAM8B,eAAe,GAAGP,MAAM,CAACvB,QAAQ,CAAC;EACxC,MAAM+B,kBAAkB,GAAGP,SAAS,CAACxB,QAAQ,CAAC;EAE9C,OAAO;IACL2B,cAAc;IACdC,iBAAiB;IACjBC,gBAAgB;IAChB9B,mBAAmB;IACnB+B,eAAe;IACfC,kBAAkB;IAElBC,uBAAuB,EAAEL,cAAc;IACvCM,0BAA0B,EAAEL,iBAAiB;IAC7CM,yBAAyB,EAAEL,gBAAgB;IAC3CM,4BAA4B,EAAEpC,mBAAmB;IACjDqC,wBAAwB,EAAEN,eAAe;IACzCO,2BAA2B,EAAEN;EAC/B,CAAC;AACH,CAAC;AAAC"}
@@ -1,24 +1,19 @@
1
1
  import type { ReactTestInstance } from 'react-test-renderer';
2
+ import { AccessibilityValueMatcher } from '../helpers/matchers/accessibilityValue';
2
3
  import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
3
- declare type A11yValue = {
4
- min?: number;
5
- max?: number;
6
- now?: number;
7
- text?: string;
8
- };
9
- export declare type ByA11yValueQueries = {
10
- getByA11yValue: GetByQuery<A11yValue>;
11
- getAllByA11yValue: GetAllByQuery<A11yValue>;
12
- queryByA11yValue: QueryByQuery<A11yValue>;
13
- queryAllByA11yValue: QueryAllByQuery<A11yValue>;
14
- findByA11yValue: FindByQuery<A11yValue>;
15
- findAllByA11yValue: FindAllByQuery<A11yValue>;
16
- getByAccessibilityValue: GetByQuery<A11yValue>;
17
- getAllByAccessibilityValue: GetAllByQuery<A11yValue>;
18
- queryByAccessibilityValue: QueryByQuery<A11yValue>;
19
- queryAllByAccessibilityValue: QueryAllByQuery<A11yValue>;
20
- findByAccessibilityValue: FindByQuery<A11yValue>;
21
- findAllByAccessibilityValue: FindAllByQuery<A11yValue>;
4
+ import { CommonQueryOptions } from './options';
5
+ export type ByA11yValueQueries = {
6
+ getByA11yValue: GetByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
7
+ getAllByA11yValue: GetAllByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
8
+ queryByA11yValue: QueryByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
9
+ queryAllByA11yValue: QueryAllByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
10
+ findByA11yValue: FindByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
11
+ findAllByA11yValue: FindAllByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
12
+ getByAccessibilityValue: GetByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
13
+ getAllByAccessibilityValue: GetAllByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
14
+ queryByAccessibilityValue: QueryByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
15
+ queryAllByAccessibilityValue: QueryAllByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
16
+ findByAccessibilityValue: FindByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
17
+ findAllByAccessibilityValue: FindAllByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
22
18
  };
23
19
  export declare const bindByA11yValueQueries: (instance: ReactTestInstance) => ByA11yValueQueries;
24
- export {};
@@ -4,13 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.bindByA11yValueQueries = void 0;
7
- var _matchObjectProp = require("../helpers/matchers/matchObjectProp");
7
+ var _accessiblity = require("../helpers/accessiblity");
8
+ var _findAll = require("../helpers/findAll");
9
+ var _accessibilityValue = require("../helpers/matchers/accessibilityValue");
8
10
  var _makeQueries = require("./makeQueries");
9
- const queryAllByA11yValue = instance => function queryAllByA11yValueFn(value) {
10
- return instance.findAll(node => typeof node.type === 'string' && (0, _matchObjectProp.matchObjectProp)(node.props.accessibilityValue, value));
11
+ const queryAllByA11yValue = instance => function queryAllByA11yValueFn(value, queryOptions) {
12
+ return (0, _findAll.findAll)(instance, node => typeof node.type === 'string' && (0, _accessibilityValue.matchAccessibilityValue)(node, value), queryOptions);
11
13
  };
12
- const getMultipleError = value => `Found multiple elements with accessibilityValue: ${JSON.stringify(value)} `;
13
- const getMissingError = value => `Unable to find an element with accessibilityValue: ${JSON.stringify(value)}`;
14
+ const formatQueryParams = matcher => {
15
+ const params = [];
16
+ _accessiblity.accessiblityValueKeys.forEach(valueKey => {
17
+ if (matcher[valueKey] !== undefined) {
18
+ params.push(`${valueKey} value: ${matcher[valueKey]}`);
19
+ }
20
+ });
21
+ return params.join(', ');
22
+ };
23
+ const getMultipleError = matcher => `Found multiple elements with ${formatQueryParams(matcher)}`;
24
+ const getMissingError = matcher => `Unable to find an element with ${formatQueryParams(matcher)}`;
14
25
  const {
15
26
  getBy,
16
27
  getAllBy,