Replaced firEvent with userEvent as much as possible

This commit is contained in:
Alejandro Celaya
2022-05-11 19:18:43 +02:00
parent 7f059c3f3b
commit 3870752bba
9 changed files with 121 additions and 93 deletions

View File

@@ -1,12 +1,14 @@
import { fireEvent, render, screen } from '@testing-library/react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { UseExistingIfFoundInfoIcon } from '../../src/short-urls/UseExistingIfFoundInfoIcon';
describe('<UseExistingIfFoundInfoIcon />', () => {
it('shows modal when icon is clicked', async () => {
const user = userEvent.setup();
render(<UseExistingIfFoundInfoIcon />);
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
fireEvent.click(screen.getByTitle('What does this mean?').firstChild as Node);
await user.click(screen.getByTitle('What does this mean?').firstElementChild as Element);
expect(await screen.findByRole('dialog')).toBeInTheDocument();
});
});