shlink-web-client/test/short-urls/helpers/ShortUrlFormCheckboxGroup.test.tsx

18 lines
731 B
TypeScript
Raw Normal View History

import { render, screen } from '@testing-library/react';
import { ShortUrlFormCheckboxGroup } from '../../../shlink-web-component/short-urls/helpers/ShortUrlFormCheckboxGroup';
2021-06-23 20:59:06 +03:00
describe('<ShortUrlFormCheckboxGroup />', () => {
it.each([
2022-03-26 14:17:42 +03:00
[undefined, '', 0],
['This is the tooltip', 'me-2', 1],
2021-06-23 20:59:06 +03:00
])('renders tooltip only when provided', (infoTooltip, expectedClassName, expectedAmountOfTooltips) => {
render(<ShortUrlFormCheckboxGroup infoTooltip={infoTooltip} />);
2021-06-23 20:59:06 +03:00
expect(screen.getByRole('checkbox').parentNode).toHaveAttribute(
'class',
expect.stringContaining(expectedClassName),
);
expect(screen.queryAllByRole('img', { hidden: true })).toHaveLength(expectedAmountOfTooltips);
2021-06-23 20:59:06 +03:00
});
});