mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-05-27 07:36:34 +00:00
Migrated ShortUrlFormCheckboxGroup test to react testing library
This commit is contained in:
@@ -1,17 +1,17 @@
|
|||||||
import { shallow } from 'enzyme';
|
import { render, screen } from '@testing-library/react';
|
||||||
import { ShortUrlFormCheckboxGroup } from '../../../src/short-urls/helpers/ShortUrlFormCheckboxGroup';
|
import { ShortUrlFormCheckboxGroup } from '../../../src/short-urls/helpers/ShortUrlFormCheckboxGroup';
|
||||||
import { Checkbox } from '../../../src/utils/Checkbox';
|
|
||||||
import { InfoTooltip } from '../../../src/utils/InfoTooltip';
|
|
||||||
|
|
||||||
describe('<ShortUrlFormCheckboxGroup />', () => {
|
describe('<ShortUrlFormCheckboxGroup />', () => {
|
||||||
it.each([
|
it.each([
|
||||||
[undefined, '', 0],
|
[undefined, '', 0],
|
||||||
['This is the tooltip', 'me-2', 1],
|
['This is the tooltip', 'me-2', 1],
|
||||||
])('renders tooltip only when provided', (infoTooltip, expectedClassName, expectedAmountOfTooltips) => {
|
])('renders tooltip only when provided', (infoTooltip, expectedClassName, expectedAmountOfTooltips) => {
|
||||||
const wrapper = shallow(<ShortUrlFormCheckboxGroup infoTooltip={infoTooltip} />);
|
render(<ShortUrlFormCheckboxGroup infoTooltip={infoTooltip} />);
|
||||||
const checkbox = wrapper.find(Checkbox);
|
|
||||||
|
|
||||||
expect(checkbox.prop('className')).toEqual(expectedClassName);
|
expect(screen.getByRole('checkbox').parentNode).toHaveAttribute(
|
||||||
expect(wrapper.find(InfoTooltip)).toHaveLength(expectedAmountOfTooltips);
|
'class',
|
||||||
|
expect.stringContaining(expectedClassName),
|
||||||
|
);
|
||||||
|
expect(screen.queryAllByRole('img', { hidden: true })).toHaveLength(expectedAmountOfTooltips);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user