2022-05-13 20:59:30 +03:00
|
|
|
import { render, screen } from '@testing-library/react';
|
2023-02-18 13:11:01 +03:00
|
|
|
import type { ReactNode } from 'react';
|
2023-08-02 10:01:44 +03:00
|
|
|
import { ChartCard } from '../../../src/visits/charts/ChartCard';
|
2020-06-06 13:16:19 +03:00
|
|
|
|
2021-09-18 20:05:28 +03:00
|
|
|
describe('<ChartCard />', () => {
|
2022-05-13 20:59:30 +03:00
|
|
|
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) => {
|
2022-05-13 20:59:30 +03:00
|
|
|
setUp(title);
|
|
|
|
expect(screen.getByText(expectedTitle)).toBeInTheDocument();
|
2020-06-06 13:16:19 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders footer only when provided', () => {
|
2022-05-13 20:59:30 +03:00
|
|
|
setUp('', 'the footer');
|
|
|
|
expect(screen.getByText('the footer')).toBeInTheDocument();
|
2020-06-06 13:16:19 +03:00
|
|
|
});
|
|
|
|
});
|