shlink-web-client/test/visits/charts/HorizontalBarChart.test.tsx

21 lines
838 B
TypeScript
Raw Normal View History

import { render } from '@testing-library/react';
import { HorizontalBarChart, HorizontalBarChartProps } from '../../../src/visits/charts/HorizontalBarChart';
2018-09-08 10:06:18 +03:00
2021-09-19 11:57:36 +03:00
describe('<HorizontalBarChart />', () => {
const setUp = (props: HorizontalBarChartProps) => {
const { container } = render(<HorizontalBarChart {...props} />);
return container.querySelector('canvas')?.getContext('2d')?.__getEvents(); // eslint-disable-line no-underscore-dangle
2018-09-08 10:06:18 +03:00
};
it.each([
[{ foo: 123, bar: 456 }, undefined],
[{ one: 999, two: 131313 }, { one: 30, two: 100 }],
[{ one: 999, two: 131313, max: 3 }, { one: 30, two: 100 }],
])('renders chart with expected canvas', (stats, highlightedStats) => {
const events = setUp({ stats, highlightedStats });
expect(events).toBeTruthy();
expect(events).toMatchSnapshot();
});
2018-09-08 10:06:18 +03:00
});