Silenced ts errors on chart tests

This commit is contained in:
Alejandro Celaya 2022-03-07 18:06:28 +01:00
parent 45c6d3996e
commit 2b59d02ed9
3 changed files with 8 additions and 8 deletions

View file

@ -19,9 +19,9 @@ describe('<DoughnutChart />', () => {
expect(doughnut).toHaveLength(1);
const { labels, datasets } = doughnut.prop('data');
const { labels, datasets } = doughnut.prop('data') as any;
const [{ data, backgroundColor, borderColor }] = datasets;
const { plugins, scales } = doughnut.prop('options') ?? {};
const { plugins, scales } = (doughnut.prop('options') ?? {}) as any;
expect(labels).toEqual(keys(stats));
expect(data).toEqual(values(stats));

View file

@ -19,8 +19,8 @@ describe('<HorizontalBarChart />', () => {
expect(horizontal).toHaveLength(1);
const { datasets: [{ backgroundColor, borderColor }] } = horizontal.prop('data');
const { plugins, scales } = horizontal.prop('options') ?? {};
const { datasets: [{ backgroundColor, borderColor }] } = horizontal.prop('data') as any;
const { plugins, scales } = (horizontal.prop('options') ?? {}) as any;
expect(backgroundColor).toEqual(MAIN_COLOR_ALPHA);
expect(borderColor).toEqual(MAIN_COLOR);
@ -48,7 +48,7 @@ describe('<HorizontalBarChart />', () => {
wrapper = shallow(<HorizontalBarChart stats={stats} highlightedStats={highlightedStats} />);
const horizontal = wrapper.find(Bar);
const { datasets: [{ data, label }, highlightedData ] } = horizontal.prop('data');
const { datasets: [{ data, label }, highlightedData ] } = horizontal.prop('data') as any;
expect(label).toEqual('Visits');
expect(data).toEqual(expectedData);

View file

@ -85,7 +85,7 @@ describe('<LineChartCard />', () => {
])('renders chart with expected data', (visits, highlightedVisits, expectedLines) => {
const wrapper = createWrapper(visits, highlightedVisits);
const chart = wrapper.find(Line);
const { datasets } = chart.prop('data');
const { datasets } = chart.prop('data') as any;
expect(datasets).toHaveLength(expectedLines);
});
@ -96,8 +96,8 @@ describe('<LineChartCard />', () => {
Mock.of<NormalizedVisit>({ date: '2016-01-01' }),
]);
expect(wrapper.find(Line).prop('data').labels).toHaveLength(2);
expect((wrapper.find(Line).prop('data') as any).labels).toHaveLength(2);
wrapper.find(ToggleSwitch).simulate('change');
expect(wrapper.find(Line).prop('data').labels).toHaveLength(4);
expect((wrapper.find(Line).prop('data') as any).labels).toHaveLength(4);
});
});