Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jest] Fix enabled prop in buttons. #3062

Merged
merged 4 commits into from
Aug 26, 2024
Merged

[jest] Fix enabled prop in buttons. #3062

merged 4 commits into from
Aug 26, 2024

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
2 participants