Skip to content

Conversation

@m-bert
Copy link
Contributor

@m-bert m-bert commented Aug 23, 2024

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
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(
      <Mocks.RectButton testID="btn" onPress={onPress} enabled={false} />
    );
    const btn = getByTestId('btn');

    expect(onPress).not.toHaveBeenCalled();
    fireEvent.press(btn);
    expect(onPress).not.toHaveBeenCalled();
  });
});

@m-bert m-bert requested a review from j-piasecki August 23, 2024 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enabled = false has no effect during tests

3 participants