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-07-16 09:47:10 +03:00
|
|
|
import type { Visit } from '../../src/shlink-web-component/visits/types';
|
|
|
|
import { VisitsHeader } from '../../src/shlink-web-component/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
|
|
|
});
|
|
|
|
});
|