shlink-web-client/test/visits/VisitsHeader.test.tsx

22 lines
808 B
TypeScript
Raw Normal View History

import { render, screen } from '@testing-library/react';
2023-04-13 23:47:13 +03:00
import { fromPartial } from '@total-typescript/shoehorn';
2023-02-18 12:40:37 +03:00
import type { Visit } from '../../src/visits/types';
2023-02-18 13:11:01 +03:00
import { VisitsHeader } from '../../src/visits/VisitsHeader';
2018-09-08 10:31:44 +03:00
describe('<VisitsHeader />', () => {
2023-04-13 23:47:13 +03:00
const visits: Visit[] = [fromPartial({}), fromPartial({}), fromPartial({})];
const title = 'My header title';
2020-04-26 11:43:00 +03:00
const goBack = jest.fn();
const setUp = () => render(<VisitsHeader visits={visits} goBack={goBack} title={title} />);
2018-09-08 10:31:44 +03:00
it('shows the amount of visits', () => {
const { container } = setUp();
expect(container.querySelector('.badge')).toHaveTextContent(`Visits: ${visits.length}`);
2018-09-08 10:31:44 +03:00
});
it('shows the title in two places', () => {
setUp();
expect(screen.getAllByText(title)).toHaveLength(2);
2018-09-08 10:31:44 +03:00
});
});