import userEvent from '@testing-library/user-event'
import * as React from 'react'
import renderWithTheme from '../../tests/helpers/renderWithTheme'
import CheckBoxCard from './CheckBoxCard'
// Click then wait for the `setTimeout` call in `ToggleCard.tsx` to clear.
const waitForTimeout = (resolve: (v: unknown) => void) => setTimeout(resolve)
const clickAndWait: typeof userEvent.click = async (...args) => {
const result = userEvent.click(...args)
await new Promise(waitForTimeout)
return result
}
describe('component: CheckBoxCard', () => {
test('style props go to wrapper', () => {
const style = { outline: '1px solid orange' }
const { getByTestId } = renderWithTheme(
)
const input = getByTestId('mycheckbox')
const wrapper = input.parentElement
expect(input).toHaveAttribute('id', 'what')
expect(input).toHaveAttribute('name', 'hope')
expect(input).toHaveAttribute('value', 'quest')
expect(input).toHaveAttribute('aria-labelledby', wrapper?.id)
expect(input).not.toHaveStyle(style)
expect(input).not.toHaveClass('sup')
expect(wrapper?.id).not.toBe('what')
expect(wrapper).toHaveStyle(style)
expect(wrapper).toHaveClass('sup', CheckBoxCard.toString().slice(1))
})
test('card wrapper behaves like