2018-09-08 14:28:40 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
|
|
|
import { identity } from 'ramda';
|
2018-12-18 16:32:02 +03:00
|
|
|
import createShortUrlVisits from '../../src/visits/ShortUrlVisits';
|
2020-05-10 20:37:00 +03:00
|
|
|
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' },
|
|
|
|
};
|
2020-02-08 11:07:55 +03:00
|
|
|
const location = { search: '' };
|
2020-04-26 11:43:00 +03:00
|
|
|
const history = {
|
|
|
|
goBack: jest.fn(),
|
|
|
|
};
|
2020-05-10 18:49:55 +03:00
|
|
|
const VisitsStats = jest.fn();
|
2018-09-08 14:28:40 +03:00
|
|
|
|
2020-05-10 18:49:55 +03:00
|
|
|
beforeEach(() => {
|
|
|
|
const ShortUrlVisits = createShortUrlVisits(VisitsStats);
|
2018-12-18 16:32:02 +03:00
|
|
|
|
2018-09-08 14:28:40 +03:00
|
|
|
wrapper = shallow(
|
2018-12-18 16:32:02 +03:00
|
|
|
<ShortUrlVisits
|
2018-09-08 14:28:40 +03:00
|
|
|
getShortUrlDetail={identity}
|
|
|
|
getShortUrlVisits={getShortUrlVisitsMock}
|
|
|
|
match={match}
|
2020-02-08 11:07:55 +03:00
|
|
|
location={location}
|
2020-04-26 11:43:00 +03:00
|
|
|
history={history}
|
2020-05-10 18:49:55 +03:00
|
|
|
shortUrlVisits={{ loading: true, visits: [] }}
|
2018-09-08 14:28:40 +03:00
|
|
|
shortUrlDetail={{}}
|
2019-03-08 21:40:43 +03:00
|
|
|
cancelGetShortUrlVisits={identity}
|
2020-04-04 13:09:17 +03:00
|
|
|
matchMedia={() => ({ matches: false })}
|
2020-08-22 09:10:31 +03:00
|
|
|
/>,
|
2018-09-08 14:28:40 +03:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2020-05-10 18:49:55 +03:00
|
|
|
afterEach(() => wrapper.unmount());
|
|
|
|
afterEach(jest.resetAllMocks);
|
2019-01-09 22:11:22 +03:00
|
|
|
|
2020-05-10 18:49:55 +03:00
|
|
|
it('renders visit stats and visits header', () => {
|
|
|
|
const visitStats = wrapper.find(VisitsStats);
|
2020-05-10 20:37:00 +03:00
|
|
|
const visitHeader = wrapper.find(ShortUrlVisitsHeader);
|
2019-01-09 22:11:22 +03:00
|
|
|
|
2020-05-10 18:49:55 +03:00
|
|
|
expect(visitStats).toHaveLength(1);
|
|
|
|
expect(visitHeader).toHaveLength(1);
|
2019-01-09 22:11:22 +03:00
|
|
|
});
|
2018-09-08 14:28:40 +03:00
|
|
|
});
|