mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-14 03:23:49 +00:00
Migrated UseExistingIfFoundInfoIcon test from enzyme to react testing library
This commit is contained in:
@@ -1,22 +1,12 @@
|
||||
import { mount, ReactWrapper } from 'enzyme';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { Modal } from 'reactstrap';
|
||||
import UseExistingIfFoundInfoIcon from '../../src/short-urls/UseExistingIfFoundInfoIcon';
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import { UseExistingIfFoundInfoIcon } from '../../src/short-urls/UseExistingIfFoundInfoIcon';
|
||||
|
||||
describe('<UseExistingIfFoundInfoIcon />', () => {
|
||||
let wrapped: ReactWrapper;
|
||||
it('shows modal when icon is clicked', async () => {
|
||||
render(<UseExistingIfFoundInfoIcon />);
|
||||
|
||||
beforeEach(() => {
|
||||
wrapped = mount(<UseExistingIfFoundInfoIcon />);
|
||||
});
|
||||
|
||||
afterEach(() => wrapped.unmount());
|
||||
|
||||
it('shows modal when icon is clicked', () => {
|
||||
const icon = wrapped.find(FontAwesomeIcon);
|
||||
|
||||
expect(wrapped.find(Modal).prop('isOpen')).toEqual(false);
|
||||
icon.simulate('click');
|
||||
expect(wrapped.find(Modal).prop('isOpen')).toEqual(true);
|
||||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByTitle('What does this mean?').firstChild as Node);
|
||||
expect(await screen.findByRole('dialog')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user