shlink-web-client/test/common/img/ShlinkLogo.test.tsx

35 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

import { MAIN_COLOR } from '@shlinkio/shlink-frontend-kit';
import { render } from '@testing-library/react';
2023-02-18 12:40:37 +03:00
import type { ShlinkLogoProps } from '../../../src/common/img/ShlinkLogo';
import { ShlinkLogo } from '../../../src/common/img/ShlinkLogo';
2023-09-30 11:20:28 +03:00
import { checkAccessibility } from '../../__helpers__/accessibility';
2020-12-20 14:17:12 +03:00
describe('<ShlinkLogo />', () => {
2023-09-30 11:20:28 +03:00
const setUp = (props: ShlinkLogoProps = {}) => render(<ShlinkLogo {...props} />);
it('passes a11y checks', () => checkAccessibility(setUp()));
2020-12-20 14:17:12 +03:00
it.each([
2022-03-26 14:17:42 +03:00
[undefined, MAIN_COLOR],
['red', 'red'],
['white', 'white'],
2020-12-20 14:17:12 +03:00
])('renders expected color', (color, expectedColor) => {
const { container } = setUp({ color });
expect(container.querySelector('g')).toHaveAttribute('fill', expectedColor);
2020-12-20 14:17:12 +03:00
});
it.each([
2022-03-26 14:17:42 +03:00
[undefined, undefined],
['foo', 'foo'],
['bar', 'bar'],
2020-12-20 14:17:12 +03:00
])('renders expected class', (className, expectedClassName) => {
const { container } = setUp({ className });
2020-12-20 14:17:12 +03:00
if (expectedClassName) {
expect(container.firstChild).toHaveAttribute('class', expectedClassName);
} else {
expect(container.firstChild).not.toHaveAttribute('class');
}
2020-12-20 14:17:12 +03:00
});
});