Skip to content

Checkbox - render tests #1685

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

Merged
merged 6 commits into from
Dec 6, 2021
Merged

Checkbox - render tests #1685

merged 6 commits into from
Dec 6, 2021

Conversation

M-i-k-e-l
Copy link
Collaborator

Description

Checkbox - render tests

Changelog

Checkbox - render tests

import {render, fireEvent} from '@testing-library/react-native';
import Checkbox from '../index';

export const testID = 'checkbox';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you exporting the testID?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I've put the TestCase in a different file and it was copy-pasted, 10x

jest.clearAllMocks();
});

it('Default value is false', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why your tests are async?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I blame copy-pasted again. 10x

expect(onValueChange).toHaveBeenCalledWith(true);
});

it('Send value (false)', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you need this test? You checked the default (false) in the previous test, are you checking react's passed prop mechanism or there's a different behavior when passing false over a default false?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I prefer to test explicitly as well as default behaviour, not sure what the best practice, do you want to ask the team?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we can ask them. Anyways Let's leave it in the meantime


it('Disabled (value = true)', async () => {
const props = {onValueChange, value: true, disabled: true};
const element = <TestCase {...props}/>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can pass on the 'element' const and extract getByTestId directly (like you did in the other tests)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed that, 10x

@M-i-k-e-l M-i-k-e-l requested a review from Inbal-Tish December 5, 2021 14:41
@Inbal-Tish Inbal-Tish merged commit 8300b1c into master Dec 6, 2021
@M-i-k-e-l M-i-k-e-l deleted the infra/checkbox-render-tests branch December 6, 2021 12:22
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.

2 participants