-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
(PC-33527)[PRO] test: Add unit tests for base checkbox.
1 parent
7c9ce2d
commit 681b6f7
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
pro/src/ui-kit/form/shared/BaseCheckbox/BaseCheckbox.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { render, screen } from '@testing-library/react' | ||
|
||
import { BaseCheckbox } from './BaseCheckbox' | ||
|
||
describe('BaseCHeckbox', () => { | ||
it('should render a checkbox with a label', () => { | ||
render(<BaseCheckbox label="My label" checked onChange={() => {}} />) | ||
|
||
expect(screen.getByLabelText('My label')).toBeChecked() | ||
}) | ||
|
||
it('should show the checkbox children when the input is checked', () => { | ||
render( | ||
<BaseCheckbox | ||
label="My label" | ||
checked | ||
onChange={() => {}} | ||
childrenOnChecked={<span>My child</span>} | ||
/> | ||
) | ||
|
||
expect(screen.getByText('My child')).toBeInTheDocument() | ||
}) | ||
|
||
it('should not show the checkbox children when the input is not checked', () => { | ||
render( | ||
<BaseCheckbox | ||
label="My label" | ||
onChange={() => {}} | ||
childrenOnChecked={<span>My child</span>} | ||
/> | ||
) | ||
|
||
expect(screen.queryByText('My child')).not.toBeInTheDocument() | ||
}) | ||
}) |