Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(PC-33527)[PRO] test: Add unit tests for base checkbox.
Browse files Browse the repository at this point in the history
gmeigniez-pass committed Jan 3, 2025
1 parent 7c9ce2d commit 681b6f7
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pro/src/ui-kit/form/shared/BaseCheckbox/BaseCheckbox.spec.tsx
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()
})
})

0 comments on commit 681b6f7

Please sign in to comment.