2022-06-10 22:35:42 +03:00
|
|
|
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({})];
|
2020-05-10 20:37:00 +03:00
|
|
|
const title = 'My header title';
|
2023-05-27 12:57:26 +03:00
|
|
|
const goBack = vi.fn();
|
2022-06-10 22:35:42 +03:00
|
|
|
const setUp = () => render(<VisitsHeader visits={visits} goBack={goBack} title={title} />);
|
2018-09-08 10:31:44 +03:00
|
|
|
|
|
|
|
it('shows the amount of visits', () => {
|
2022-06-10 22:35:42 +03:00
|
|
|
const { container } = setUp();
|
|
|
|
expect(container.querySelector('.badge')).toHaveTextContent(`Visits: ${visits.length}`);
|
2018-09-08 10:31:44 +03:00
|
|
|
});
|
|
|
|
|
2020-05-10 20:37:00 +03:00
|
|
|
it('shows the title in two places', () => {
|
2022-06-10 22:35:42 +03:00
|
|
|
setUp();
|
|
|
|
expect(screen.getAllByText(title)).toHaveLength(2);
|
2018-09-08 10:31:44 +03:00
|
|
|
});
|
|
|
|
});
|