import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
import RadioGroup from 'sentry/components/forms/controls/radioGroup';
describe('RadioGroup', function () {
it('renders', function () {
const {container} = render(
);
expect(container).toSnapshot();
});
it('renders disabled', function () {
const {container} = render(
);
expect(container).toSnapshot();
expect(screen.getByRole('radio', {name: 'Select Choice One'})).toBeDisabled();
});
it('renders disabled choice', async function () {
const {container} = render(
);
expect(container).toSnapshot();
expect(screen.getByRole('radio', {name: 'Select Choice One'})).toBeEnabled();
expect(screen.getByRole('radio', {name: 'Select Choice Two'})).toBeDisabled();
userEvent.hover(screen.getByRole('radio', {name: 'Select Choice Two'}));
expect(
await screen.findByText('Reason why choice two is disabled')
).toBeInTheDocument();
});
it('can select a different item', function () {
const {container} = render(
);
expect(container).toSnapshot();
});
it('calls onChange when clicked', function () {
const mock = jest.fn();
render(
);
userEvent.click(screen.getByRole('radio', {name: 'Select Choice Three'}));
expect(mock).toHaveBeenCalledTimes(1);
});
});