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

31 lines
977 B
TypeScript
Raw Normal View History

import { render } from '@testing-library/react';
2020-12-20 14:17:12 +03:00
import { ShlinkLogo, ShlinkLogoProps } from '../../../src/common/img/ShlinkLogo';
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
});
});