Created
March 4, 2025 11:52
-
-
Save spacesuitdiver/0b70e417072a918397da93eafafc5a8e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('correctly forwards refs for grabberProps, closeButtonProps, and headlineProps', () => { | |
// Create refs for each prop | |
const grabberRef = createRef<View>(); | |
const closeButtonRef = createRef<typeof Pressable>(); | |
const headlineRef = createRef<Text>(); | |
// Render component with refs | |
const { getByTestId } = render( | |
<MyComponent | |
grabberProps={{ ref: grabberRef, testID: 'grabber' }} | |
closeButtonProps={{ ref: closeButtonRef, testID: 'close-button' }} | |
headlineProps={{ ref: headlineRef, testID: 'headline' }} | |
/> | |
); | |
// Verify refs are correctly attached | |
expect(grabberRef.current).not.toBeNull(); | |
expect(closeButtonRef.current).not.toBeNull(); | |
expect(headlineRef.current).not.toBeNull(); | |
// Ensure the refs map to real native nodes | |
expect(findNodeHandle(grabberRef.current)).not.toBeNull(); | |
expect(findNodeHandle(closeButtonRef.current)).not.toBeNull(); | |
expect(findNodeHandle(headlineRef.current)).not.toBeNull(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment