Skip to content

Commit

Permalink
🔥 (VirtualizedList-test) remove unrelevant test case
Browse files Browse the repository at this point in the history
This test case is unrelevant because we do not need to simulate a scroll to check that the render
area has been adjusted, and this behavior is already tested by "adjusts render area with non-zero
initialScrollIndex".
  • Loading branch information
Antoine Doubovetzky committed Apr 3, 2022
1 parent e7f4e10 commit dcd60dc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 265 deletions.
36 changes: 1 addition & 35 deletions Libraries/Lists/__tests__/VirtualizedList-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -862,40 +862,7 @@ it('does not adjust render area until content area layed out', () => {
expect(component).toMatchSnapshot();
});

it('does not adjust render area with non-zero initialScrollIndex until scrolled', () => {
const items = generateItems(20);
const ITEM_HEIGHT = 10;

let component;
ReactTestRenderer.act(() => {
component = ReactTestRenderer.create(
<VirtualizedList
initialNumToRender={5}
initialScrollIndex={1}
windowSize={10}
maxToRenderPerBatch={10}
{...baseItemProps(items)}
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
/>,
);
});

ReactTestRenderer.act(() => {
simulateLayout(component, {
viewport: {width: 10, height: 50},
content: {width: 10, height: 200},
});
performAllBatches();
});

// Layout information from before the time we scroll to initial index may not
// correspond to the area "initialScrollIndex" points to. Expect only the 5
// initial items (starting at initialScrollIndex) to be rendered after
// processing all batch work, even though the windowSize allows for more.
expect(component).toMatchSnapshot();
});

it('adjusts render area with non-zero initialScrollIndex after scrolled', () => {
it('adjusts render area with non-zero initialScrollIndex', () => {
const items = generateItems(20);
const ITEM_HEIGHT = 10;

Expand All @@ -919,7 +886,6 @@ it('adjusts render area with non-zero initialScrollIndex after scrolled', () =>
content: {width: 10, height: 200},
});

simulateScroll(component, {x: 0, y: 10});
performAllBatches();
});

Expand Down
231 changes: 1 addition & 230 deletions Libraries/Lists/__tests__/__snapshots__/VirtualizedList-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,7 @@ exports[`VirtualizedList warns if both renderItem or ListItemComponent are speci
</RCTScrollView>
`;

exports[`adjusts render area with non-zero initialScrollIndex after scrolled 1`] = `
exports[`adjusts render area with non-zero initialScrollIndex 1`] = `
<RCTScrollView
data={
Array [
Expand Down Expand Up @@ -2207,235 +2207,6 @@ exports[`does not adjust render area until content area layed out 1`] = `
</RCTScrollView>
`;

exports[`does not adjust render area with non-zero initialScrollIndex until scrolled 1`] = `
<RCTScrollView
data={
Array [
Object {
"key": 0,
},
Object {
"key": 1,
},
Object {
"key": 2,
},
Object {
"key": 3,
},
Object {
"key": 4,
},
Object {
"key": 5,
},
Object {
"key": 6,
},
Object {
"key": 7,
},
Object {
"key": 8,
},
Object {
"key": 9,
},
Object {
"key": 10,
},
Object {
"key": 11,
},
Object {
"key": 12,
},
Object {
"key": 13,
},
Object {
"key": 14,
},
Object {
"key": 15,
},
Object {
"key": 16,
},
Object {
"key": 17,
},
Object {
"key": 18,
},
Object {
"key": 19,
},
]
}
getItem={[Function]}
getItemCount={[Function]}
getItemLayout={[Function]}
initialNumToRender={5}
initialScrollIndex={1}
maxToRenderPerBatch={10}
onContentSizeChange={[Function]}
onLayout={[Function]}
onMomentumScrollBegin={[Function]}
onMomentumScrollEnd={[Function]}
onScroll={[Function]}
onScrollBeginDrag={[Function]}
onScrollEndDrag={[Function]}
renderItem={[Function]}
scrollEventThrottle={50}
stickyHeaderIndices={Array []}
windowSize={10}
>
<View>
<View
style={null}
>
<MockCellItem
value={0}
/>
</View>
<View
style={null}
>
<MockCellItem
value={1}
/>
</View>
<View
style={null}
>
<MockCellItem
value={2}
/>
</View>
<View
style={null}
>
<MockCellItem
value={3}
/>
</View>
<View
style={null}
>
<MockCellItem
value={4}
/>
</View>
<View
style={null}
>
<MockCellItem
value={5}
/>
</View>
<View
style={null}
>
<MockCellItem
value={6}
/>
</View>
<View
style={null}
>
<MockCellItem
value={7}
/>
</View>
<View
style={null}
>
<MockCellItem
value={8}
/>
</View>
<View
style={null}
>
<MockCellItem
value={9}
/>
</View>
<View
style={null}
>
<MockCellItem
value={10}
/>
</View>
<View
style={null}
>
<MockCellItem
value={11}
/>
</View>
<View
style={null}
>
<MockCellItem
value={12}
/>
</View>
<View
style={null}
>
<MockCellItem
value={13}
/>
</View>
<View
style={null}
>
<MockCellItem
value={14}
/>
</View>
<View
style={null}
>
<MockCellItem
value={15}
/>
</View>
<View
style={null}
>
<MockCellItem
value={16}
/>
</View>
<View
style={null}
>
<MockCellItem
value={17}
/>
</View>
<View
style={null}
>
<MockCellItem
value={18}
/>
</View>
<View
style={null}
>
<MockCellItem
value={19}
/>
</View>
</View>
</RCTScrollView>
`;

exports[`does not over-render when there is less than initialNumToRender cells 1`] = `
<RCTScrollView
data={
Expand Down

0 comments on commit dcd60dc

Please sign in to comment.