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

import RadioGroup from '.';
import { Field } from '../field/Field';

describe('RadioGroup', () => {
  it('has accessible role', () => {
    render(
      <RadioGroup
        name="currency"
        radios={[{ label: 'USD' }, { label: 'EUR' }]}
        onChange={() => {}}
      />,
    );
    expect(screen.getByRole('radiogroup')).toBeInTheDocument();
  });

  it('supports `Field` for labeling', () => {
    render(
      <Field label="Currency">
        <RadioGroup
          name="currency"
          radios={[{ label: 'USD' }, { label: 'EUR' }]}
          onChange={() => {}}
        />
      </Field>,
    );
    expect(screen.getByRole('radiogroup')).toHaveAccessibleName(/^Currency/);
  });
});
