Fix shlink-web-component tests

This commit is contained in:
Alejandro Celaya
2023-08-04 11:16:01 +02:00
parent bdcfcee60e
commit 4d8477a32c
54 changed files with 345 additions and 431 deletions

View File

@@ -1,27 +1,17 @@
import { screen, waitFor } from '@testing-library/react';
import type { ReactNode } from 'react';
import type { PropsWithChildren } from 'react';
import { MemoryRouter } from 'react-router-dom';
import type { HighlightCardProps } from '../../../src/overview/helpers/HighlightCard';
import { HighlightCard } from '../../../src/overview/helpers/HighlightCard';
import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<HighlightCard />', () => {
const setUp = (props: HighlightCardProps & { children?: ReactNode }) => renderWithEvents(
const setUp = (props: PropsWithChildren<Partial<HighlightCardProps>>) => renderWithEvents(
<MemoryRouter>
<HighlightCard {...props} />
<HighlightCard link="" title="" {...props} />
</MemoryRouter>,
);
it.each([
[undefined],
[''],
])('does not render icon when there is no link', (link) => {
setUp({ title: 'foo', link });
expect(screen.queryByRole('img', { hidden: true })).not.toBeInTheDocument();
expect(screen.queryByRole('link')).not.toBeInTheDocument();
});
it.each([
['foo'],
['bar'],

View File

@@ -1,18 +1,21 @@
import { screen, waitFor } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
import type { VisitsHighlightCardProps } from '../../../src/overview/helpers/VisitsHighlightCard';
import { VisitsHighlightCard } from '../../../src/overview/helpers/VisitsHighlightCard';
import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<VisitsHighlightCard />', () => {
const setUp = (props: Partial<VisitsHighlightCardProps> = {}) => renderWithEvents(
<VisitsHighlightCard
loading={false}
visitsSummary={{ total: 0 }}
excludeBots={false}
title=""
link=""
{...props}
/>,
<MemoryRouter>
<VisitsHighlightCard
loading={false}
visitsSummary={{ total: 0 }}
excludeBots={false}
title=""
link=""
{...props}
/>
</MemoryRouter>,
);
it.each([