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

48 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-09-08 14:28:40 +03:00
import React from 'react';
import { shallow } from 'enzyme';
import { identity } from 'ramda';
import createShortUrlVisits from '../../src/visits/ShortUrlVisits';
import ShortUrlVisitsHeader from '../../src/visits/ShortUrlVisitsHeader';
2018-09-08 14:28:40 +03:00
describe('<ShortUrlVisits />', () => {
let wrapper;
2019-04-19 13:41:59 +03:00
const getShortUrlVisitsMock = jest.fn();
2018-09-08 14:28:40 +03:00
const match = {
params: { shortCode: 'abc123' },
};
const location = { search: '' };
2020-04-26 11:43:00 +03:00
const history = {
goBack: jest.fn(),
};
const VisitsStats = jest.fn();
2018-09-08 14:28:40 +03:00
beforeEach(() => {
const ShortUrlVisits = createShortUrlVisits(VisitsStats);
2018-09-08 14:28:40 +03:00
wrapper = shallow(
<ShortUrlVisits
2018-09-08 14:28:40 +03:00
getShortUrlDetail={identity}
getShortUrlVisits={getShortUrlVisitsMock}
match={match}
location={location}
2020-04-26 11:43:00 +03:00
history={history}
shortUrlVisits={{ loading: true, visits: [] }}
2018-09-08 14:28:40 +03:00
shortUrlDetail={{}}
cancelGetShortUrlVisits={identity}
matchMedia={() => ({ matches: false })}
2018-09-08 14:28:40 +03:00
/>
);
});
afterEach(() => wrapper.unmount());
afterEach(jest.resetAllMocks);
it('renders visit stats and visits header', () => {
const visitStats = wrapper.find(VisitsStats);
const visitHeader = wrapper.find(ShortUrlVisitsHeader);
expect(visitStats).toHaveLength(1);
expect(visitHeader).toHaveLength(1);
});
2018-09-08 14:28:40 +03:00
});