software-mansion / react-native-gesture-handler

Declarative API exposing platform native touch and gesture system to React Native.
https://docs.swmansion.com/react-native-gesture-handler/
MIT License
6.13k stars 982 forks source link

[jest] Fix `enabled` prop in buttons. #3062

Closed m-bert closed 2 months ago

m-bert commented 3 months ago

Description

Currently using enabled prop in our buttons doesn't work. Mocks are done using TouchableNativeFeedback and it has disabled prop instead of enabled. This PR changes mocked version of our buttons to handle enabled properly.

Fixes #2385

Test plan

Run the following test ```tsx import { fireEvent, render } from '@testing-library/react-native'; import Mocks from '../mocks'; describe.only('Testing disabled Button', () => { it('onPress does not trigger', function () { const onPress = jest.fn(); const { getByTestId } = render( ); const btn = getByTestId('btn'); expect(onPress).not.toHaveBeenCalled(); fireEvent.press(btn); expect(onPress).not.toHaveBeenCalled(); }); }); ```