2022-05-13 21:25:32 +03:00
|
|
|
import { screen } from '@testing-library/react';
|
2023-07-24 21:14:59 +03:00
|
|
|
import { DoughnutChart } from '../../../shlink-web-component/visits/charts/DoughnutChart';
|
2022-07-10 20:44:49 +03:00
|
|
|
import { setUpCanvas } from '../../__helpers__/setUpTest';
|
2021-09-18 20:05:28 +03:00
|
|
|
|
2021-09-19 11:57:36 +03:00
|
|
|
describe('<DoughnutChart />', () => {
|
2021-09-18 20:05:28 +03:00
|
|
|
const stats = {
|
|
|
|
foo: 123,
|
|
|
|
bar: 456,
|
|
|
|
};
|
|
|
|
|
|
|
|
it('renders Doughnut with expected props', () => {
|
2022-05-13 21:18:40 +03:00
|
|
|
const { events } = setUpCanvas(<DoughnutChart stats={stats} />);
|
2021-09-18 20:05:28 +03:00
|
|
|
|
2022-05-13 21:18:40 +03:00
|
|
|
expect(events).toBeTruthy();
|
|
|
|
expect(events).toMatchSnapshot();
|
|
|
|
});
|
2021-09-18 20:05:28 +03:00
|
|
|
|
2022-05-13 21:18:40 +03:00
|
|
|
it('renders expected legend', () => {
|
|
|
|
setUpCanvas(<DoughnutChart stats={stats} />);
|
2021-09-18 20:05:28 +03:00
|
|
|
|
2022-05-13 21:18:40 +03:00
|
|
|
expect(screen.getByText('foo')).toBeInTheDocument();
|
|
|
|
expect(screen.getByText('bar')).toBeInTheDocument();
|
2022-05-13 21:25:32 +03:00
|
|
|
});
|
2021-09-18 20:05:28 +03:00
|
|
|
});
|