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