aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/molecules/forms/ackee-select.test.tsx
blob: e1e6b2d722feca72f248cd08871b03b143ecca5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import userEvent from '@testing-library/user-event';
import { render, screen } from '@test-utils';
import AckeeSelect from './ackee-select';

describe('Select', () => {
  it('should correctly set default option', () => {
    render(<AckeeSelect initialValue="full" />);
    expect(screen.getByRole('combobox')).toHaveValue('full');
    expect(screen.queryByRole('combobox')).not.toHaveValue('partial');
  });

  it('should correctly change value when user choose another option', () => {
    render(<AckeeSelect initialValue="full" />);

    userEvent.selectOptions(
      screen.getByRole('combobox'),
      screen.getByRole('option', { name: 'Partial' })
    );

    expect(screen.getByRole('combobox')).toHaveValue('partial');
    expect(screen.queryByRole('combobox')).not.toHaveValue('full');
  });
});