shlink-web-client/test/visits/VisitsHeader.test.js

36 lines
960 B
JavaScript
Raw Normal View History

2018-09-08 10:31:44 +03:00
import React from 'react';
import { shallow } from 'enzyme';
import VisitsHeader from '../../src/visits/VisitsHeader';
2018-09-08 10:31:44 +03:00
describe('<VisitsHeader />', () => {
let wrapper;
const visits = [{}, {}, {}];
const title = 'My header title';
2020-04-26 11:43:00 +03:00
const goBack = jest.fn();
2018-09-08 10:31:44 +03:00
beforeEach(() => {
wrapper = shallow(
2020-08-22 09:10:31 +03:00
<VisitsHeader visits={visits} goBack={goBack} title={title} />,
);
2018-09-08 10:31:44 +03:00
});
2018-09-08 10:31:44 +03:00
afterEach(() => wrapper.unmount());
afterEach(jest.resetAllMocks);
2018-09-08 10:31:44 +03:00
it('shows the amount of visits', () => {
const visitsBadge = wrapper.find('.badge');
expect(visitsBadge.html()).toContain(
2020-08-22 09:10:31 +03:00
`Visits: <span><strong class="short-url-visits-count__amount">${visits.length}</strong></span>`,
);
2018-09-08 10:31:44 +03:00
});
it('shows the title in two places', () => {
const titles = wrapper.find('.text-center');
2018-09-08 10:31:44 +03:00
expect(titles).toHaveLength(2);
expect(titles.at(0).html()).toContain(title);
expect(titles.at(1).html()).toContain(title);
2018-09-08 10:31:44 +03:00
});
});