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

32 lines
1 KiB
TypeScript
Raw Normal View History

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';
2020-12-20 14:17:12 +03:00
import { MAIN_COLOR } from '../../../src/utils/theme';
describe('<ShlinkLogo />', () => {
const setUp = (props: ShlinkLogoProps) => render(<ShlinkLogo {...props} />);
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
});
});