@@ -6,26 +6,272 @@ import { Style } from './to-have-style';
6
6
7
7
export interface JestNativeMatchers < R > {
8
8
/**
9
- * Assert whether an element is present in the element tree or not.
9
+ * Assert whether a host element is present in the element tree (screen) or not.
10
+ *
11
+ * @see
12
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeonthescreen)
13
+ *
14
+ * @example
15
+ * <Text>Hello</Text>
16
+ *
17
+ * expect(getByText('Hello')).toBeOnTheScreen()
18
+ * expect(queryByText('Other')).not.toBeOnTheScreen()
10
19
*/
11
20
toBeOnTheScreen ( ) : R ;
12
21
22
+ /**
23
+ * Assert whether a host element is checked based on accessibility props.
24
+ *
25
+ * @see
26
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobechecked)
27
+ *
28
+ * @see {@link toBePartiallyChecked } for a related matcher.
29
+ *
30
+ * @example
31
+ * <View accessible role="checkbox" aria-checked aria-label="Enable" />
32
+ *
33
+ * expect(getByRole('checkbox', { name: "Enable" })).toBeChecked()
34
+ */
13
35
toBeChecked ( ) : R ;
36
+
37
+ /**
38
+ * Assert whether a host element is collapsed based on accessibility props.
39
+ *
40
+ * @see
41
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeexpanded)
42
+ *
43
+ * @see {@link toBeExpanded } for an inverse matcher.
44
+ *
45
+ * @example
46
+ * <View testID="details" aria-expanded={false} />
47
+ *
48
+ * expect(getByTestId('details').toBeCollapsed()
49
+ */
14
50
toBeCollapsed ( ) : R ;
51
+
52
+ /**
53
+ * Assert whether a host element is disabled based on accessibility props.
54
+ *
55
+ * This matcher will check ancestor elements for their disabled state as well.
56
+ *
57
+ * @see
58
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeenabled)
59
+ *
60
+ * @see {@link toBeEnabled } for an inverse matcher.
61
+ *
62
+ * @example
63
+ * <View role="button" aria-disabled />
64
+ *
65
+ * expect(getByRole('button').toBeDisabled()
66
+ *
67
+ */
15
68
toBeDisabled ( ) : R ;
69
+
70
+ /**
71
+ * Assert whether a host element is busy based on accessibility props.
72
+ *
73
+ * @see
74
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobebusy)
75
+ *
76
+ * @example
77
+ * <View testID="loader" aria-busy />
78
+ *
79
+ * expect(getByTestId('loader')).toBeBusy()
80
+ */
16
81
toBeBusy ( ) : R ;
82
+
83
+ /**
84
+ * Assert whether a host element has no host children or text content.
85
+ *
86
+ * @see
87
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeemptyelement)
88
+ *
89
+ * @example
90
+ * <View testID="not-empty">
91
+ * <View testID="empty" />
92
+ * </View>
93
+ *
94
+ * expect(getByTestId('empty')).toBeEmptyElement()
95
+ * expect(getByTestId('not-mepty')).not.toBeEmptyElement()
96
+ */
17
97
toBeEmptyElement ( ) : R ;
98
+
99
+ /**
100
+ * Assert whether a host element is enabled based on accessibility props.
101
+ *
102
+ * This matcher will check ancestor elements for their enabled state as well.
103
+ *
104
+ * @see
105
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeenabled)
106
+ *
107
+ * @see {@link toBeDisabled } for inverse matcher.
108
+ *
109
+ * @example
110
+ * <View role="button" aria-disabled={false} />
111
+ *
112
+ * expect(getByRole('button').toBeEnabled()
113
+ */
18
114
toBeEnabled ( ) : R ;
115
+
116
+ /**
117
+ * Assert whether a host element is expanded based on accessibility props.
118
+ *
119
+ * @see
120
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeexpanded)
121
+ *
122
+ * @see {@link toBeCollapsed } for inverse matcher.
123
+ *
124
+ * @example
125
+ * <View testID="details" aria-expanded />
126
+ *
127
+ * expect(getByTestId('details').toBeExpanded()
128
+ */
19
129
toBeExpanded ( ) : R ;
130
+
131
+ /**
132
+ * Assert whether a host element is partially checked based on accessibility props.
133
+ *
134
+ * @see
135
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobechecked)
136
+ *
137
+ * @see {@link toBeChecked } for related matcher.
138
+ *
139
+ * @example
140
+ * <View accessible role="checkbox" aria-checked="mixed" aria-label="Enable" />
141
+ *
142
+ * expect(getByRole('checkbox', { name: "Enable" })).toBePartiallyChecked()
143
+ */
20
144
toBePartiallyChecked ( ) : R ;
145
+
146
+ /**
147
+ * Assert whether a host element is selected based on accessibility props.
148
+ *
149
+ * @see
150
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeselected)
151
+ *
152
+ * @example
153
+ * <View testID="view" aria-selected />
154
+ *
155
+ * expect(getByTestId('view')).toBeSelected()
156
+ */
21
157
toBeSelected ( ) : R ;
158
+
159
+ /**
160
+ * Assert whether a host element is visible based on style and accessibility props.
161
+ *
162
+ * This matcher will check ancestor elements for their visibility as well.
163
+ *
164
+ * @see
165
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobevisible)
166
+ *
167
+ * @example
168
+ * <View testID="visible" />
169
+ * <View testID="not-visible" style={{ display: 'none' }} />
170
+ *
171
+ * expect(getByTestId('visible')).toBeVisible()
172
+ * expect(getByTestId('not-visible')).not.toBeVisible()
173
+ */
22
174
toBeVisible ( ) : R ;
175
+
176
+ /**
177
+ * Assert whether a host element contains another host element.
178
+ *
179
+ * @see
180
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tocontainelement)
181
+ *
182
+ * @example
183
+ * <View testID="outer">
184
+ * <View testID="inner" />
185
+ * </View>
186
+ *
187
+ * expect(getByTestId('outer')).toContainElement(getByTestId('inner'));
188
+ */
23
189
toContainElement ( element : ReactTestInstance | null ) : R ;
190
+
191
+ /**
192
+ * Assert whether a host element has a given accessbility value.
193
+ *
194
+ * @see
195
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveaccessibilityvalue)
196
+ *
197
+ *
198
+ * @example
199
+ * <View testID="view" aria-valuetext="33%" />
200
+ *
201
+ * expect(getByTestId('view')).toHaveAccessibilityValue({ text: '33%' });
202
+ */
24
203
toHaveAccessibilityValue ( expectedValue : AccessibilityValueMatcher ) : R ;
204
+
205
+ /**
206
+ * Assert whether a host element has a given accessibile name based on the accessibility label or text content.
207
+ *
208
+ * @see
209
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveaccessiblename)
210
+ *
211
+ * @example
212
+ * <View testID="view" aria-label="Hello" />
213
+ *
214
+ * expect(getByTestId('view')).toHaveAccessibleName('Hello');
215
+ */
25
216
toHaveAccessibleName ( expectedName ?: TextMatch , options ?: TextMatchOptions ) : R ;
217
+
218
+ /**
219
+ * Assert whether a host `TextInput` element has a given display value based on `value` and `defaultValue` props.
220
+ *
221
+ * @see
222
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavedisplayvalue)
223
+ *
224
+ * @example
225
+ * <TextInput testID="input" value="Hello" />
226
+ *
227
+ * expect(getByTestId('input')).toHaveDisplayValue('Hello');
228
+ */
26
229
toHaveDisplayValue ( expectedValue : TextMatch , options ?: TextMatchOptions ) : R ;
230
+
231
+ /**
232
+ * Assert whether a host element has a given prop.
233
+ *
234
+ * @see
235
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveprop)
236
+ *
237
+ * @example
238
+ * <Text testID="text" numberOfLines={1]} />
239
+ *
240
+ * expect(getByTestId('text')).toHaveProp('numberOfLines');
241
+ * expect(getByTestId('text')).toHaveProp('numberOfLines', 1);
242
+ */
27
243
toHaveProp ( name : string , expectedValue ?: unknown ) : R ;
244
+
245
+ /**
246
+ * Assert whether a host element has a given style.
247
+ *
248
+ * @see
249
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavestyle)
250
+ *
251
+ * @example
252
+ * <View testID="view" style={{ width: '100%' }} />
253
+ *
254
+ * expect(getByTestId('view')).toHaveStyle({ width: '100%' });
255
+ * expect(getByTestId('view')).not.toHaveStyle({ width: '50%' });
256
+ */
28
257
toHaveStyle ( style : StyleProp < Style > ) : R ;
258
+
259
+ /**
260
+ * Assert whether a host element has a given text content.
261
+ *
262
+ * @see
263
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavetextcontent)
264
+ *
265
+ * @example
266
+ * <View testID="view">
267
+ * <Text>Hello World</Text>
268
+ * </View>
269
+ *
270
+ * expect(getByTestId('view')).toHaveTextContent('Hello World');
271
+ * expect(getByTestId('view')).toHaveTextContent('Hello', { exact: false }});
272
+ * expect(getByTestId('view')).toHaveTextContent(/hello/i);
273
+ * expect(getByTestId('view')).not.toHaveTextContent('Hello');
274
+ */
29
275
toHaveTextContent ( expectedText : TextMatch , options ?: TextMatchOptions ) : R ;
30
276
}
31
277
0 commit comments