aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/molecules/forms/labelled-field/labelled-field.test.tsx
blob: 9e39e1fda4be1deda4d10a0b1cc8011737b89a7b (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
31
32
import { render, screen } from '../../../../../tests/utils';
import { Input, Label } from '../../../atoms';
import { LabelledField } from './labelled-field';

const doNothing = () => {
  // Do nothing
};

describe('LabelledField', () => {
  it('renders a labelled field', () => {
    const id = 'enim';
    const label = 'eum aliquam culpa';
    const value = 'vitae';

    render(
      <LabelledField
        field={
          <Input
            id={id}
            name="text-field"
            onChange={doNothing}
            type="text"
            value={value}
          />
        }
        label={<Label htmlFor={id}>{label}</Label>}
      />
    );
    expect(screen.getByLabelText(label)).toBeInTheDocument();
    expect(screen.getByRole('textbox')).toHaveValue(value);
  });
});