2022-05-06 22:24:16 +03:00
|
|
|
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 />', () => {
|
2022-05-06 22:24:16 +03:00
|
|
|
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) => {
|
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
|
|
|
});
|
|
|
|
});
|