aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/molecules/forms/labelled-field/labelled-field.test.tsx
blob: 8bc7c397b7726c49e0f825effca88a0baa739981 (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
33
import { describe, expect, it } from '@jest/globals';
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);
  });
});