1
1
import type { ReactTestInstance } from 'react-test-renderer' ;
2
- import type { AccessibilityRole , AccessibilityState } from 'react-native' ;
2
+ import type { AccessibilityState } from 'react-native' ;
3
3
import type { WaitForOptions } from '../waitFor' ;
4
4
import type { TextMatch } from '../matches' ;
5
5
import makeA11yQuery from './makeA11yQuery' ;
@@ -11,6 +11,34 @@ type A11yValue = {
11
11
now ?: number ;
12
12
text ?: string ;
13
13
} ;
14
+ type A11yRole =
15
+ | 'none'
16
+ | 'button'
17
+ | 'link'
18
+ | 'search'
19
+ | 'image'
20
+ | 'keyboardkey'
21
+ | 'text'
22
+ | 'adjustable'
23
+ | 'imagebutton'
24
+ | 'header'
25
+ | 'summary'
26
+ | 'alert'
27
+ | 'checkbox'
28
+ | 'combobox'
29
+ | 'menu'
30
+ | 'menubar'
31
+ | 'menuitem'
32
+ | 'progressbar'
33
+ | 'radio'
34
+ | 'radiogroup'
35
+ | 'scrollbar'
36
+ | 'spinbutton'
37
+ | 'switch'
38
+ | 'tab'
39
+ | 'tablist'
40
+ | 'timer'
41
+ | 'toolbar' ;
14
42
15
43
type GetReturn = ReactTestInstance ;
16
44
type GetAllReturn = Array < ReactTestInstance > ;
@@ -19,6 +47,10 @@ type QueryAllReturn = Array<ReactTestInstance>;
19
47
type FindReturn = Promise < GetReturn > ;
20
48
type FindAllReturn = Promise < GetAllReturn > ;
21
49
50
+ export type QueryOptions = {
51
+ name ?: string | RegExp ;
52
+ } ;
53
+
22
54
export type A11yAPI = {
23
55
// Label
24
56
getByLabelText : ( label : TextMatch ) => GetReturn ;
@@ -61,16 +93,30 @@ export type A11yAPI = {
61
93
) => FindAllReturn ;
62
94
63
95
// Role
64
- getByRole : ( role : AccessibilityRole | RegExp ) => GetReturn ;
65
- getAllByRole : ( role : AccessibilityRole | RegExp ) => GetAllReturn ;
66
- queryByRole : ( role : AccessibilityRole | RegExp ) => QueryReturn ;
67
- queryAllByRole : ( role : AccessibilityRole | RegExp ) => QueryAllReturn ;
96
+ getByRole : (
97
+ role : A11yRole | RegExp ,
98
+ queryOptions ?: QueryOptions
99
+ ) => GetReturn ;
100
+ getAllByRole : (
101
+ role : A11yRole | RegExp ,
102
+ queryOptions ?: QueryOptions
103
+ ) => GetAllReturn ;
104
+ queryByRole : (
105
+ role : A11yRole | RegExp ,
106
+ queryOptions ?: QueryOptions
107
+ ) => QueryReturn ;
108
+ queryAllByRole : (
109
+ role : A11yRole | RegExp ,
110
+ queryOptions ?: QueryOptions
111
+ ) => QueryAllReturn ;
68
112
findByRole : (
69
- role : AccessibilityRole ,
113
+ role : A11yRole ,
114
+ queryOptions ?: QueryOptions & WaitForOptions ,
70
115
waitForOptions ?: WaitForOptions
71
116
) => FindReturn ;
72
117
findAllByRole : (
73
- role : AccessibilityRole ,
118
+ role : A11yRole ,
119
+ queryOptions ?: QueryOptions & WaitForOptions ,
74
120
waitForOptions ?: WaitForOptions
75
121
) => FindAllReturn ;
76
122
0 commit comments