mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-16 20:43:48 +00:00
Fix shlink-web-component tests
This commit is contained in:
@@ -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'],
|
||||
|
||||
@@ -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([
|
||||
|
||||
Reference in New Issue
Block a user