Skip to content

Commit 4148038

Browse files
pierrezimmermannbampierrezimmermannmdjastrzebski
authored
fix: flatlist not rendering in rntl repo (#1467)
* fix: flatlist not rendering in rntl repo * refactor: move render tests to RN tests file --------- Co-authored-by: pierrezimmermann <[email protected]> Co-authored-by: Maciej Jastrzebski <[email protected]>
1 parent 4a8072d commit 4148038

File tree

5 files changed

+89
-6
lines changed

5 files changed

+89
-6
lines changed

babel.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ module.exports = {
1212
},
1313
],
1414
],
15-
plugins: ['@babel/plugin-proposal-class-properties'],
1615
env: {
1716
test: {
1817
// https://github.com/react-native-community/upgrade-support/issues/152

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
"devDependencies": {
3535
"@babel/cli": "^7.19.3",
3636
"@babel/core": "^7.20.2",
37-
"@babel/plugin-proposal-class-properties": "^7.18.6",
3837
"@babel/plugin-transform-flow-strip-types": "^7.19.0",
3938
"@babel/preset-env": "^7.20.2",
4039
"@babel/preset-flow": "^7.18.6",

src/__tests__/__snapshots__/render-debug.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ exports[`debug: shallow 1`] = `
393393
value=""
394394
/>
395395
<MyButton
396-
onPress={[Function anonymous]}
396+
onPress={[Function changeFresh]}
397397
type="primary"
398398
>
399399
Change freshness!
@@ -445,7 +445,7 @@ exports[`debug: shallow with message 1`] = `
445445
value=""
446446
/>
447447
<MyButton
448-
onPress={[Function anonymous]}
448+
onPress={[Function changeFresh]}
449449
type="primary"
450450
>
451451
Change freshness!

src/__tests__/react-native-api.test.tsx

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import * as React from 'react';
2-
import { View, Text, TextInput, Switch } from 'react-native';
2+
import {
3+
View,
4+
Text,
5+
TextInput,
6+
Switch,
7+
ScrollView,
8+
FlatList,
9+
} from 'react-native';
310
import { render } from '..';
411

512
/**
@@ -124,3 +131,81 @@ test('React Native API assumption: <Switch> renders single host element', () =>
124131
/>
125132
`);
126133
});
134+
135+
test('ScrollView renders correctly', () => {
136+
const screen = render(
137+
<ScrollView testID="scrollView">
138+
<View testID="view" />
139+
</ScrollView>
140+
);
141+
142+
expect(screen.toJSON()).toMatchInlineSnapshot(`
143+
<RCTScrollView
144+
testID="scrollView"
145+
>
146+
<View>
147+
<View
148+
testID="view"
149+
/>
150+
</View>
151+
</RCTScrollView>
152+
`);
153+
});
154+
155+
test('FlatList renders correctly', () => {
156+
const screen = render(
157+
<FlatList
158+
testID="flatList"
159+
data={[1, 2]}
160+
renderItem={({ item }) => <Text>{item}</Text>}
161+
/>
162+
);
163+
164+
expect(screen.toJSON()).toMatchInlineSnapshot(`
165+
<RCTScrollView
166+
data={
167+
[
168+
1,
169+
2,
170+
]
171+
}
172+
getItem={[Function]}
173+
getItemCount={[Function]}
174+
keyExtractor={[Function]}
175+
onContentSizeChange={[Function]}
176+
onLayout={[Function]}
177+
onMomentumScrollBegin={[Function]}
178+
onMomentumScrollEnd={[Function]}
179+
onScroll={[Function]}
180+
onScrollBeginDrag={[Function]}
181+
onScrollEndDrag={[Function]}
182+
removeClippedSubviews={false}
183+
renderItem={[Function]}
184+
scrollEventThrottle={50}
185+
stickyHeaderIndices={[]}
186+
testID="flatList"
187+
viewabilityConfigCallbackPairs={[]}
188+
>
189+
<View>
190+
<View
191+
onFocusCapture={[Function]}
192+
onLayout={[Function]}
193+
style={null}
194+
>
195+
<Text>
196+
1
197+
</Text>
198+
</View>
199+
<View
200+
onFocusCapture={[Function]}
201+
onLayout={[Function]}
202+
style={null}
203+
>
204+
<Text>
205+
2
206+
</Text>
207+
</View>
208+
</View>
209+
</RCTScrollView>
210+
`);
211+
});

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@
312312
"@babel/helper-remap-async-to-generator" "^7.18.9"
313313
"@babel/plugin-syntax-async-generators" "^7.8.4"
314314

315-
"@babel/plugin-proposal-class-properties@^7.0.0", "@babel/plugin-proposal-class-properties@^7.13.0", "@babel/plugin-proposal-class-properties@^7.18.6":
315+
"@babel/plugin-proposal-class-properties@^7.0.0", "@babel/plugin-proposal-class-properties@^7.13.0":
316316
version "7.18.6"
317317
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.18.6.tgz#b110f59741895f7ec21a6fff696ec46265c446a3"
318318
integrity sha512-cumfXOF0+nzZrrN8Rf0t7M+tF6sZc7vhQwYQck9q1/5w2OExlD+b4v4RpMJFaV1Z7WcDRgO6FqvxqxGlwo+RHQ==

0 commit comments

Comments
 (0)