Skip to content

Commit

Permalink
Mobile - Keyboard Aware FlatList - useScrollToTextInput: Update "does…
Browse files Browse the repository at this point in the history
… not scroll when the ScrollView ref is not available" test to check scrollTo wasn't called
  • Loading branch information
Gerardo committed Mar 28, 2023
1 parent fe189fe commit fd42475
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ describe( 'useScrollToTextInput', () => {
const scrollViewYOffset = { value: 0 };
const textInputOffset = 50;

// Mock scrollTo method
const scrollTo = jest.fn();
if ( scrollViewRef.current ) {
scrollViewRef.current.scrollTo = scrollTo;
}

const { result } = renderHook( () =>
useScrollToTextInput(
extraScrollHeight,
Expand All @@ -107,6 +113,7 @@ describe( 'useScrollToTextInput', () => {

// Assert
expect( scrollViewRef.current ).toBeNull();
expect( scrollTo ).not.toHaveBeenCalled();
} );

it( 'does not scroll when the scroll is not enabled', () => {
Expand Down

0 comments on commit fd42475

Please sign in to comment.