2022-06-10 22:35:42 +03:00
|
|
|
import { render, screen } from '@testing-library/react';
|
2020-09-05 09:49:18 +03:00
|
|
|
import { Mock } from 'ts-mockery';
|
2022-05-28 12:16:59 +03:00
|
|
|
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>()];
|
2020-05-10 20:37:00 +03:00
|
|
|
const title = 'My header title';
|
2020-04-26 11:43:00 +03:00
|
|
|
const goBack = jest.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
|
|
|
});
|
|
|
|
});
|