shlink-web-client/shlink-web-component/test/visits/charts/ChartCard.test.tsx

23 lines
762 B
TypeScript
Raw Normal View History

import { render, screen } from '@testing-library/react';
2023-02-18 13:11:01 +03:00
import type { ReactNode } from 'react';
import { ChartCard } from '../../../src/visits/charts/ChartCard';
2020-06-06 13:16:19 +03:00
describe('<ChartCard />', () => {
const setUp = (title: Function | string = '', footer?: ReactNode) => render(
<ChartCard title={title} footer={footer} />,
);
2020-06-06 13:16:19 +03:00
it.each([
2022-03-26 14:17:42 +03:00
['the title', 'the title'],
[() => 'the title from func', 'the title from func'],
2020-06-06 13:16:19 +03:00
])('properly renders title by parsing provided value', (title, expectedTitle) => {
setUp(title);
expect(screen.getByText(expectedTitle)).toBeInTheDocument();
2020-06-06 13:16:19 +03:00
});
it('renders footer only when provided', () => {
setUp('', 'the footer');
expect(screen.getByText('the footer')).toBeInTheDocument();
2020-06-06 13:16:19 +03:00
});
});