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

22 lines
777 B
TypeScript
Raw Normal View History

import { render, screen } from '@testing-library/react';
2020-09-05 09:49:18 +03:00
import { Mock } from 'ts-mockery';
import { VisitsHeader } from '../../src/visits/VisitsHeader';
2020-09-05 09:49:18 +03:00
import { Visit } from '../../src/visits/types';
2018-09-08 10:31:44 +03:00
describe('<VisitsHeader />', () => {
2022-03-26 14:17:42 +03:00
const visits = [Mock.all<Visit>(), Mock.all<Visit>(), Mock.all<Visit>()];
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
});
});