import * as React from 'react'
import { Radio, RadioGroup } from './'
import { fireEvent, render } from '@testing-library/react'
describe('RadioGroup', () => {
describe('Accessability', () => {
it('Label and icon tooltip', () => {
const { getByRole } = render(
)
expect(
getByRole('radiogroup', {
name: 'My label',
description: 'This is extra information',
})
).toBeInTheDocument()
})
it('Error message', () => {
const { getByRole } = render(
)
expect(
getByRole('radiogroup', {
name: 'My label',
description: 'Something went wrong',
})
).toBeInTheDocument()
})
it('Warning message', () => {
const { getByRole } = render(
)
expect(
getByRole('radiogroup', {
name: 'My label',
description: 'Something might be wrong',
})
).toBeInTheDocument()
})
})
describe('Interaction', () => {
it('Should call onChange with value', async () => {
const spy = jest.fn()
const { getByRole } = render(
spy(val)}
value="one"
id="group"
label={{
text: 'My label',
iconTooltip: 'This is extra information',
}}
>
)
await fireEvent.click(getByRole('radio', { name: 'Two' }))
expect(spy).toHaveBeenCalledWith('two')
})
})
})