|
1 | 1 | 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'; |
3 | 10 | import { render } from '..';
|
4 | 11 |
|
5 | 12 | /**
|
@@ -124,3 +131,81 @@ test('React Native API assumption: <Switch> renders single host element', () =>
|
124 | 131 | />
|
125 | 132 | `);
|
126 | 133 | });
|
| 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 | +}); |
0 commit comments