@@ -211,8 +211,10 @@ fireEvent.changeText(getByTestId('text-input'), CHANGE_TEXT);
211211
212212Invokes ` scroll ` event handler on the element or parent element in the tree.
213213
214+ #### On a ` ScrollView `
215+
214216``` jsx
215- import { ScrollView , TextInput } from ' react-native' ;
217+ import { ScrollView , Text } from ' react-native' ;
216218import { render , fireEvent } from ' react-native-testing-library' ;
217219
218220const onScrollMock = jest .fn ();
@@ -233,6 +235,43 @@ const { getByTestId } = render(
233235fireEvent .scroll (getByTestId (' scroll-view' ), eventData);
234236```
235237
238+ #### On a ` FlatList `
239+
240+ ``` jsx
241+ import { FlatList , View } from ' react-native' ;
242+ import { render , fireEvent } from ' react-native-testing-library' ;
243+
244+ const onEndReached = jest .fn ();
245+ const { getByType } = render (
246+ < FlatList
247+ data= {Array .from ({ length: 10 }, (_ , key ) => ({ key: ` ${ key} ` }))}
248+ renderItem= {() => < View style= {{ height: 500 , width: 100 }} / > }
249+ onEndReached= {onEndReached}
250+ onEndReachedThreshold= {0.2 }
251+ / >
252+ );
253+ const eventData = {
254+ nativeEvent: {
255+ contentOffset: {
256+ y: 500 ,
257+ },
258+ contentSize: {
259+ // Dimensions of the scrollable content
260+ height: 500 ,
261+ width: 100 ,
262+ },
263+ layoutMeasurement: {
264+ // Dimensions of the device
265+ height: 100 ,
266+ width: 100 ,
267+ },
268+ },
269+ };
270+
271+ fireEvent .scroll (getByType (ScrollView), eventData);
272+ expect (onEndReached).toHaveBeenCalled ();
273+ ```
274+
236275## ` waitForElement `
237276
238277- [ ` Example code ` ] ( https://github.com/callstack/react-native-testing-library/blob/master/src/__tests__/waitForElement.test.js )
0 commit comments