diff --git a/Libraries/Lists/__tests__/VirtualizedList-test.js b/Libraries/Lists/__tests__/VirtualizedList-test.js index 08be48906c687f..7a8dce8e8022c6 100644 --- a/Libraries/Lists/__tests__/VirtualizedList-test.js +++ b/Libraries/Lists/__tests__/VirtualizedList-test.js @@ -1113,6 +1113,80 @@ it('does not adjust render area until content area layed out', () => { expect(component).toMatchSnapshot(); }); +it('does not move render area when initialScrollIndex is > 0 and offset not yet known', () => { + const items = generateItems(20); + const ITEM_HEIGHT = 10; + + let component; + + ReactTestRenderer.act(() => { + component = ReactTestRenderer.create( + , + ); + }); + + ReactTestRenderer.act(() => { + simulateLayout(component, { + viewport: {width: 10, height: 50}, + content: {width: 10, height: 100}, + }); + performAllBatches(); + }); + + // 5 cells should be present starting at index 1, since we have not seen a + // scroll event yet for current position. + expect(component).toMatchSnapshot(); +}); + +it('clamps render area when items removed for initialScrollIndex > 0 and scroller position not yet known', () => { + const items = generateItems(20); + const lessItems = generateItems(15); + const ITEM_HEIGHT = 10; + + let component; + + ReactTestRenderer.act(() => { + component = ReactTestRenderer.create( + , + ); + }); + + ReactTestRenderer.act(() => { + component.update( + , + ); + }); + + ReactTestRenderer.act(() => { + simulateLayout(component, { + viewport: {width: 10, height: 50}, + content: {width: 10, height: 100}, + }); + performAllBatches(); + }); + + // The initial render range should be adjusted to not overflow the list + expect(component).toMatchSnapshot(); +}); + it('adjusts render area with non-zero initialScrollIndex', () => { const items = generateItems(20); const ITEM_HEIGHT = 10; diff --git a/Libraries/Lists/__tests__/__snapshots__/VirtualizedList-test.js.snap b/Libraries/Lists/__tests__/__snapshots__/VirtualizedList-test.js.snap index c66d68042b8eab..8013c149b8d84d 100644 --- a/Libraries/Lists/__tests__/__snapshots__/VirtualizedList-test.js.snap +++ b/Libraries/Lists/__tests__/__snapshots__/VirtualizedList-test.js.snap @@ -1829,6 +1829,163 @@ exports[`adjusts render area with non-zero initialScrollIndex 1`] = ` `; +exports[`clamps render area when items removed for initialScrollIndex > 0 and scroller position not yet known 1`] = ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +`; + exports[`constrains batch render region when an item is removed 1`] = ` `; +exports[`does not move render area when initialScrollIndex is > 0 and offset not yet known 1`] = ` + + + + + + + + + + + + + + + + + + + + + +`; + exports[`does not over-render when there is less than initialNumToRender cells 1`] = ` `; +exports[`clamps render area when items removed for initialScrollIndex > 0 and scroller position not yet known 1`] = ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +`; + exports[`constrains batch render region when an item is removed 1`] = ` `; +exports[`does not move render area when initialScrollIndex is > 0 and offset not yet known 1`] = ` + + + + + + + + + + + + + + + + + + + + + +`; + exports[`does not over-render when there is less than initialNumToRender cells 1`] = `