aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/molecules/forms/radio-group.test.tsx
blob: 8171a499ad950d78ad8ba4def9347ded91742f4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { render, screen } from '@test-utils';
import RadioGroup from './radio-group';
import { getOptions, initialChoice, legend } from './radio-group.fixture';

describe('RadioGroup', () => {
  it('renders a legend', () => {
    render(
      <RadioGroup
        initialChoice={initialChoice}
        legend={legend}
        options={getOptions()}
      />
    );
    expect(screen.findByRole('radiogroup', { name: legend })).toBeDefined();
  });

  it('renders the correct number of radio', () => {
    const options = getOptions();

    render(
      <RadioGroup
        initialChoice={initialChoice}
        legend={legend}
        options={options}
      />
    );
    const radios = screen.getAllByRole('radio');
    expect(radios).toHaveLength(options.length);
  });
});