import { shallow, ShallowWrapper } from 'enzyme'; import { Mock } from 'ts-mockery'; import VisitsHeader from '../../src/visits/VisitsHeader'; import { Visit } from '../../src/visits/types'; describe('', () => { let wrapper: ShallowWrapper; const visits = [Mock.all(), Mock.all(), Mock.all()]; const title = 'My header title'; const goBack = jest.fn(); beforeEach(() => { wrapper = shallow( , ); }); afterEach(() => wrapper.unmount()); afterEach(jest.resetAllMocks); it('shows the amount of visits', () => { const visitsBadge = wrapper.find('.badge'); expect(visitsBadge.html()).toContain( `Visits: ${visits.length}`, ); }); it('shows the title in two places', () => { const titles = wrapper.find('.text-center'); expect(titles).toHaveLength(2); expect(titles.at(0).html()).toContain(title); expect(titles.at(1).html()).toContain(title); }); });