import { act } from 'react'; import { Pressable } from 'react-native'; import * as renderer from 'react-test-renderer'; import { useKeyProps } from '../useKeyProps'; import type { PressablePropsExtended } from '../usePressableState.types'; const dummyFunction = () => { console.log('dummy'); }; // Simple wrapper function to let us use `PressablePropsExtended` to fix type errors const PressableWithDesktopProps = (props: PressablePropsExtended) => { return ; }; it('Pressable with useKeyProps', () => { const TestComponent = () => { const keyboardProps = useKeyProps(dummyFunction, ' ', 'Enter'); return ; }; let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); }); it('useKeyProps called twice', () => { const TestComponent = () => { const keyboardProps1 = useKeyProps(dummyFunction, ' ', 'Enter'); const keyboardProps2 = useKeyProps(dummyFunction, ' ', 'Enter'); expect(keyboardProps1).toBe(keyboardProps2); return ; }; let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); });