Skip to content

Commit

Permalink
add multidropdown tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Реутов Данила Валерьевич authored and Реутов Данила Валерьевич committed Mar 30, 2024
1 parent c4d4840 commit ccf8acc
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/__test__/MultiDropdown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,36 @@ describe('Тестирование компонента MultiDropdown', () => {

expect(secondOption).not.toBeInTheDocument();
});

test('Проверка фильтрации', () => {
const title = 'TEST_TITLE';
render(
<WrappedDropdown options={options} getTitle={() => title} />
);

const dropdownElement = screen.getByDisplayValue('');
expect(dropdownElement).toBeInTheDocument();

userEvent.click(dropdownElement);

const firstOption = screen.getByText(options[0].value);
const secondOption = screen.getByText(options[1].value);
const thirdOption = screen.getByText(options[2].value);

expect(firstOption).toBeInTheDocument();
expect(secondOption).toBeInTheDocument();
expect(thirdOption).toBeInTheDocument();

userEvent.type(dropdownElement, 'Екат');

expect(firstOption).not.toBeInTheDocument();
expect(secondOption).not.toBeInTheDocument();
expect(thirdOption).toBeInTheDocument();

userEvent.clear(dropdownElement);

expect(screen.getByText(options[0].value)).toBeInTheDocument();
expect(screen.getByText(options[1].value)).toBeInTheDocument();
expect(screen.getByText(options[2].value)).toBeInTheDocument();
});
});

0 comments on commit ccf8acc

Please sign in to comment.