import { screen, render, userEvent } from '../../test-utils';

import RadioButton from '.';

describe('Radio button', () => {
  it('responds to user input', async () => {
    const onChange = jest.fn();
    render(
      <label htmlFor="an-id">
        <RadioButton id="an-id" name="a-name" value="a-value" onChange={onChange} />A radio
      </label>,
    );

    await userEvent.click(screen.getByLabelText('A radio'));

    expect(onChange).toHaveBeenCalledWith('a-value');
  });
});
