2023-08-05 12:14:03 +03:00
|
|
|
import { MAIN_COLOR } from '@shlinkio/shlink-frontend-kit';
|
2022-05-06 22:24:16 +03:00
|
|
|
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) => {
|
2022-05-06 22:24:16 +03:00
|
|
|
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) => {
|
2022-05-06 22:24:16 +03:00
|
|
|
const { container } = setUp({ className });
|
2020-12-20 14:17:12 +03:00
|
|
|
|
2022-05-06 22:24:16 +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
|
|
|
});
|
|
|
|
});
|