1
1
import * as React from 'react' ;
2
- import { FlatList , ScrollView , Switch , Text , TextInput , View } from 'react-native' ;
2
+ import { FlatList , Image , Modal , ScrollView , Switch , Text , TextInput , View } from 'react-native' ;
3
3
import { render , screen } from '..' ;
4
4
5
5
/**
6
6
* Tests in this file are intended to give us an proactive warning that React Native behavior has
7
7
* changed in a way that may impact our code like queries or event handling.
8
8
*/
9
9
10
- test ( 'React Native API assumption: <View> renders single host element' , ( ) => {
10
+ test ( 'React Native API assumption: <View> renders a single host element' , ( ) => {
11
11
render ( < View testID = "test" /> ) ;
12
12
13
13
expect ( screen . toJSON ( ) ) . toMatchInlineSnapshot ( `
@@ -17,7 +17,7 @@ test('React Native API assumption: <View> renders single host element', () => {
17
17
` ) ;
18
18
} ) ;
19
19
20
- test ( 'React Native API assumption: <Text> renders single host element' , ( ) => {
20
+ test ( 'React Native API assumption: <Text> renders a single host element' , ( ) => {
21
21
render ( < Text testID = "test" > Hello</ Text > ) ;
22
22
23
23
expect ( screen . toJSON ( ) ) . toMatchInlineSnapshot ( `
@@ -29,7 +29,7 @@ test('React Native API assumption: <Text> renders single host element', () => {
29
29
` ) ;
30
30
} ) ;
31
31
32
- test ( 'React Native API assumption: nested <Text> renders single host element' , ( ) => {
32
+ test ( 'React Native API assumption: nested <Text> renders a single host element' , ( ) => {
33
33
render (
34
34
< Text testID = "test" >
35
35
< Text testID = "before" > Before</ Text >
@@ -63,7 +63,7 @@ test('React Native API assumption: nested <Text> renders single host element', (
63
63
` ) ;
64
64
} ) ;
65
65
66
- test ( 'React Native API assumption: <TextInput> renders single host element' , ( ) => {
66
+ test ( 'React Native API assumption: <TextInput> renders a single host element' , ( ) => {
67
67
render (
68
68
< TextInput
69
69
testID = "test"
@@ -102,7 +102,7 @@ test('React Native API assumption: <TextInput> with nested Text renders single h
102
102
` ) ;
103
103
} ) ;
104
104
105
- test ( 'React Native API assumption: <Switch> renders single host element' , ( ) => {
105
+ test ( 'React Native API assumption: <Switch> renders a single host element' , ( ) => {
106
106
render ( < Switch testID = "test" value = { true } onChange = { jest . fn ( ) } /> ) ;
107
107
108
108
expect ( screen . toJSON ( ) ) . toMatchInlineSnapshot ( `
@@ -123,7 +123,117 @@ test('React Native API assumption: <Switch> renders single host element', () =>
123
123
` ) ;
124
124
} ) ;
125
125
126
- test ( 'React Native API assumption: aria-* props render on host View' , ( ) => {
126
+ test ( 'React Native API assumption: <Image> renders a single host element' , ( ) => {
127
+ render ( < Image testID = "test" source = { { uri : 'https://fake.url/image.jpg' } } alt = "Alt text" /> ) ;
128
+
129
+ expect ( screen . toJSON ( ) ) . toMatchInlineSnapshot ( `
130
+ <Image
131
+ alt="Alt text"
132
+ source={
133
+ {
134
+ "uri": "https://fake.url/image.jpg",
135
+ }
136
+ }
137
+ testID="test"
138
+ />
139
+ ` ) ;
140
+ } ) ;
141
+
142
+ test ( 'React Native API assumption: <ScrollView> renders a single host element' , ( ) => {
143
+ render (
144
+ < ScrollView testID = "scrollView" >
145
+ < View testID = "view" />
146
+ </ ScrollView > ,
147
+ ) ;
148
+
149
+ expect ( screen . toJSON ( ) ) . toMatchInlineSnapshot ( `
150
+ <RCTScrollView
151
+ testID="scrollView"
152
+ >
153
+ <View>
154
+ <View
155
+ testID="view"
156
+ />
157
+ </View>
158
+ </RCTScrollView>
159
+ ` ) ;
160
+ } ) ;
161
+
162
+ test ( 'React Native API assumption: <FlatList> renders a single host <ScrollView> element' , ( ) => {
163
+ render (
164
+ < FlatList testID = "flatList" data = { [ 1 , 2 ] } renderItem = { ( { item } ) => < Text > { item } </ Text > } /> ,
165
+ ) ;
166
+
167
+ expect ( screen . toJSON ( ) ) . toMatchInlineSnapshot ( `
168
+ <RCTScrollView
169
+ data={
170
+ [
171
+ 1,
172
+ 2,
173
+ ]
174
+ }
175
+ getItem={[Function]}
176
+ getItemCount={[Function]}
177
+ keyExtractor={[Function]}
178
+ onContentSizeChange={[Function]}
179
+ onLayout={[Function]}
180
+ onMomentumScrollBegin={[Function]}
181
+ onMomentumScrollEnd={[Function]}
182
+ onScroll={[Function]}
183
+ onScrollBeginDrag={[Function]}
184
+ onScrollEndDrag={[Function]}
185
+ removeClippedSubviews={false}
186
+ renderItem={[Function]}
187
+ scrollEventThrottle={0.0001}
188
+ stickyHeaderIndices={[]}
189
+ testID="flatList"
190
+ viewabilityConfigCallbackPairs={[]}
191
+ >
192
+ <View>
193
+ <View
194
+ onFocusCapture={[Function]}
195
+ onLayout={[Function]}
196
+ style={null}
197
+ >
198
+ <Text>
199
+ 1
200
+ </Text>
201
+ </View>
202
+ <View
203
+ onFocusCapture={[Function]}
204
+ onLayout={[Function]}
205
+ style={null}
206
+ >
207
+ <Text>
208
+ 2
209
+ </Text>
210
+ </View>
211
+ </View>
212
+ </RCTScrollView>
213
+ ` ) ;
214
+ } ) ;
215
+
216
+ test ( 'React Native API assumption: <Modal> renders a single host element' , ( ) => {
217
+ render (
218
+ < Modal testID = "test" >
219
+ < Text > Modal Content</ Text >
220
+ </ Modal > ,
221
+ ) ;
222
+
223
+ expect ( screen . toJSON ( ) ) . toMatchInlineSnapshot ( `
224
+ <Modal
225
+ hardwareAccelerated={false}
226
+ testID="test"
227
+ visible={true}
228
+ >
229
+ <Text>
230
+ Modal Content
231
+ </Text>
232
+ </Modal>
233
+ ` ) ;
234
+ } ) ;
235
+
236
+ test ( 'React Native API assumption: aria-* props render directly on host View' , ( ) => {
127
237
render (
128
238
< View
129
239
testID = "test"
@@ -171,7 +281,7 @@ test('React Native API assumption: aria-* props render on host View', () => {
171
281
` ) ;
172
282
} ) ;
173
283
174
- test ( 'React Native API assumption: aria-* props render on host Text' , ( ) => {
284
+ test ( 'React Native API assumption: aria-* props render directly on host Text' , ( ) => {
175
285
render (
176
286
< Text
177
287
testID = "test"
@@ -219,7 +329,7 @@ test('React Native API assumption: aria-* props render on host Text', () => {
219
329
` ) ;
220
330
} ) ;
221
331
222
- test ( 'React Native API assumption: aria-* props render on host TextInput' , ( ) => {
332
+ test ( 'React Native API assumption: aria-* props render directly on host TextInput' , ( ) => {
223
333
render (
224
334
< TextInput
225
335
testID = "test"
@@ -266,77 +376,3 @@ test('React Native API assumption: aria-* props render on host TextInput', () =>
266
376
/>
267
377
` ) ;
268
378
} ) ;
269
-
270
- test ( 'ScrollView renders correctly' , ( ) => {
271
- render (
272
- < ScrollView testID = "scrollView" >
273
- < View testID = "view" />
274
- </ ScrollView > ,
275
- ) ;
276
-
277
- expect ( screen . toJSON ( ) ) . toMatchInlineSnapshot ( `
278
- <RCTScrollView
279
- testID="scrollView"
280
- >
281
- <View>
282
- <View
283
- testID="view"
284
- />
285
- </View>
286
- </RCTScrollView>
287
- ` ) ;
288
- } ) ;
289
-
290
- test ( 'FlatList renders correctly' , ( ) => {
291
- render (
292
- < FlatList testID = "flatList" data = { [ 1 , 2 ] } renderItem = { ( { item } ) => < Text > { item } </ Text > } /> ,
293
- ) ;
294
-
295
- expect ( screen . toJSON ( ) ) . toMatchInlineSnapshot ( `
296
- <RCTScrollView
297
- data={
298
- [
299
- 1,
300
- 2,
301
- ]
302
- }
303
- getItem={[Function]}
304
- getItemCount={[Function]}
305
- keyExtractor={[Function]}
306
- onContentSizeChange={[Function]}
307
- onLayout={[Function]}
308
- onMomentumScrollBegin={[Function]}
309
- onMomentumScrollEnd={[Function]}
310
- onScroll={[Function]}
311
- onScrollBeginDrag={[Function]}
312
- onScrollEndDrag={[Function]}
313
- removeClippedSubviews={false}
314
- renderItem={[Function]}
315
- scrollEventThrottle={0.0001}
316
- stickyHeaderIndices={[]}
317
- testID="flatList"
318
- viewabilityConfigCallbackPairs={[]}
319
- >
320
- <View>
321
- <View
322
- onFocusCapture={[Function]}
323
- onLayout={[Function]}
324
- style={null}
325
- >
326
- <Text>
327
- 1
328
- </Text>
329
- </View>
330
- <View
331
- onFocusCapture={[Function]}
332
- onLayout={[Function]}
333
- style={null}
334
- >
335
- <Text>
336
- 2
337
- </Text>
338
- </View>
339
- </View>
340
- </RCTScrollView>
341
- ` ) ;
342
- } ) ;
0 commit comments