-
Notifications
You must be signed in to change notification settings - Fork 734
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
Checkbox - render tests #1685
Conversation
import {render, fireEvent} from '@testing-library/react-native'; | ||
import Checkbox from '../index'; | ||
|
||
export const testID = 'checkbox'; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 () => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 () => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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}/>; |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed that, 10x
Description
Checkbox - render tests
Changelog
Checkbox - render tests