mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-16 20:43:48 +00:00
Migrate more tests to shoehorn
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import type { Chart, ChartDataset } from 'chart.js';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { DoughnutChartLegend } from '../../../src/visits/charts/DoughnutChartLegend';
|
||||
|
||||
describe('<DoughnutChartLegend />', () => {
|
||||
const labels = ['foo', 'bar', 'baz', 'foo2', 'bar2'];
|
||||
const colors = ['green', 'blue', 'yellow'];
|
||||
const defaultColor = 'red';
|
||||
const datasets = [Mock.of<ChartDataset>({ backgroundColor: colors })];
|
||||
const chart = Mock.of<Chart>({
|
||||
const datasets = [fromPartial<ChartDataset>({ backgroundColor: colors })];
|
||||
const chart = fromPartial<Chart>({
|
||||
config: {
|
||||
data: { labels, datasets },
|
||||
options: { defaultColor } as any,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import { formatISO, subDays, subMonths, subYears } from 'date-fns';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { LineChartCard } from '../../../src/visits/charts/LineChartCard';
|
||||
import type { NormalizedVisit } from '../../../src/visits/types';
|
||||
import { setUpCanvas } from '../../__helpers__/setUpTest';
|
||||
@@ -29,7 +29,7 @@ describe('<LineChartCard />', () => {
|
||||
visits,
|
||||
expectedActiveIndex,
|
||||
) => {
|
||||
const { user } = setUp(visits.map((visit) => Mock.of<NormalizedVisit>(visit)));
|
||||
const { user } = setUp(visits.map((visit) => fromPartial(visit)));
|
||||
|
||||
await user.click(screen.getByRole('button', { name: /Group by/ }));
|
||||
|
||||
@@ -46,8 +46,8 @@ describe('<LineChartCard />', () => {
|
||||
it.each([
|
||||
[undefined, undefined],
|
||||
[[], []],
|
||||
[[Mock.of<NormalizedVisit>({ date: '2016-04-01' })], []],
|
||||
[[Mock.of<NormalizedVisit>({ date: '2016-04-01' })], [Mock.of<NormalizedVisit>({ date: '2016-04-01' })]],
|
||||
[[fromPartial<NormalizedVisit>({ date: '2016-04-01' })], []],
|
||||
[[fromPartial<NormalizedVisit>({ date: '2016-04-01' })], [fromPartial<NormalizedVisit>({ date: '2016-04-01' })]],
|
||||
])('renders chart with expected data', (visits, highlightedVisits) => {
|
||||
const { events } = setUp(visits, highlightedVisits);
|
||||
|
||||
@@ -57,8 +57,8 @@ describe('<LineChartCard />', () => {
|
||||
|
||||
it('includes stats for visits with no dates if selected', async () => {
|
||||
const { getEvents, user } = setUp([
|
||||
Mock.of<NormalizedVisit>({ date: '2016-04-01' }),
|
||||
Mock.of<NormalizedVisit>({ date: '2016-01-01' }),
|
||||
fromPartial({ date: '2016-04-01' }),
|
||||
fromPartial({ date: '2016-01-01' }),
|
||||
]);
|
||||
|
||||
const eventsBefore = getEvents();
|
||||
|
||||
Reference in New Issue
Block a user