import * as React from 'react'
import { CheckboxGroup, Checkbox } from './'
import { render } from '@testing-library/react'
describe('CheckboxGroup', () => {
describe('Accessibility', () => {
it('Label and icon tooltip', () => {
const { getByRole } = render(
)
expect(
getByRole('group', {
name: 'My label',
description: 'This is extra information',
})
).toBeInTheDocument()
})
it('should render correctly with a single checkbox', () => {
const { getByRole } = render(
)
expect(
getByRole('checkbox', {
name: 'One',
})
).toBeInTheDocument()
})
it('should render correctly with additional rendering approaches', () => {
const isTrue = true
const { getAllByRole } = render(
{['One', 'Two', 'Three'].map((opt) => (
))}
{isTrue ? : null}
{isTrue ? null : (
)}
)
expect(
getAllByRole('checkbox').map(
(el) => el.closest('label')?.textContent
)
).toEqual(['One', 'Two', 'Three', 'Conditional (Display)'])
})
it('Error', () => {
const { getByRole } = render(
)
expect(
getByRole('group', {
name: 'My label',
description: 'This is an error',
})
).toBeInTheDocument()
})
it('Warning', () => {
const { getByRole } = render(
)
expect(
getByRole('group', {
name: 'My label',
description: 'This is a warning',
})
).toBeInTheDocument()
})
})
})