mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-19 21:16:18 +00:00
Added button to export visits as CSV
This commit is contained in:
@@ -2,12 +2,13 @@ import { shallow } from 'enzyme';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { History, Location } from 'history';
|
||||
import { match } from 'react-router'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||
import { OrphanVisits } from '../../src/visits/OrphanVisits';
|
||||
import { OrphanVisits as createOrphanVisits } from '../../src/visits/OrphanVisits';
|
||||
import { MercureBoundProps } from '../../src/mercure/helpers/boundToMercureHub';
|
||||
import { VisitsInfo } from '../../src/visits/types';
|
||||
import VisitsStats from '../../src/visits/VisitsStats';
|
||||
import { OrphanVisitsHeader } from '../../src/visits/OrphanVisitsHeader';
|
||||
import { Settings } from '../../src/settings/reducers/settings';
|
||||
import { VisitsExporter } from '../../src/visits/services/VisitsExporter';
|
||||
|
||||
describe('<OrphanVisits />', () => {
|
||||
it('wraps visits stats and header', () => {
|
||||
@@ -15,6 +16,7 @@ describe('<OrphanVisits />', () => {
|
||||
const getOrphanVisits = jest.fn();
|
||||
const cancelGetOrphanVisits = jest.fn();
|
||||
const orphanVisits = Mock.all<VisitsInfo>();
|
||||
const OrphanVisits = createOrphanVisits(Mock.all<VisitsExporter>());
|
||||
|
||||
const wrapper = shallow(
|
||||
<OrphanVisits
|
||||
|
||||
@@ -3,12 +3,13 @@ import { identity } from 'ramda';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { History, Location } from 'history';
|
||||
import { match } from 'react-router'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||
import ShortUrlVisits, { ShortUrlVisitsProps } from '../../src/visits/ShortUrlVisits';
|
||||
import createShortUrlVisits, { ShortUrlVisitsProps } from '../../src/visits/ShortUrlVisits';
|
||||
import ShortUrlVisitsHeader from '../../src/visits/ShortUrlVisitsHeader';
|
||||
import { ShortUrlVisits as ShortUrlVisitsState } from '../../src/visits/reducers/shortUrlVisits';
|
||||
import { ShortUrlDetail } from '../../src/short-urls/reducers/shortUrlDetail';
|
||||
import VisitsStats from '../../src/visits/VisitsStats';
|
||||
import { MercureBoundProps } from '../../src/mercure/helpers/boundToMercureHub';
|
||||
import { VisitsExporter } from '../../src/visits/services/VisitsExporter';
|
||||
|
||||
describe('<ShortUrlVisits />', () => {
|
||||
let wrapper: ShallowWrapper;
|
||||
@@ -20,6 +21,7 @@ describe('<ShortUrlVisits />', () => {
|
||||
const history = Mock.of<History>({
|
||||
goBack: jest.fn(),
|
||||
});
|
||||
const ShortUrlVisits = createShortUrlVisits(Mock.all<VisitsExporter>());
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(
|
||||
|
||||
@@ -8,6 +8,7 @@ import ColorGenerator from '../../src/utils/services/ColorGenerator';
|
||||
import { TagVisits as TagVisitsStats } from '../../src/visits/reducers/tagVisits';
|
||||
import VisitsStats from '../../src/visits/VisitsStats';
|
||||
import { MercureBoundProps } from '../../src/mercure/helpers/boundToMercureHub';
|
||||
import { VisitsExporter } from '../../src/visits/services/VisitsExporter';
|
||||
|
||||
describe('<TagVisits />', () => {
|
||||
let wrapper: ShallowWrapper;
|
||||
@@ -20,7 +21,7 @@ describe('<TagVisits />', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
const TagVisits = createTagVisits(Mock.of<ColorGenerator>());
|
||||
const TagVisits = createTagVisits(Mock.all<ColorGenerator>(), Mock.all<VisitsExporter>());
|
||||
|
||||
wrapper = shallow(
|
||||
<TagVisits
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { shallow, ShallowWrapper } from 'enzyme';
|
||||
import { Progress } from 'reactstrap';
|
||||
import { Button, Progress } from 'reactstrap';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import VisitStats from '../../src/visits/VisitsStats';
|
||||
import Message from '../../src/utils/Message';
|
||||
@@ -16,6 +16,7 @@ describe('<VisitStats />', () => {
|
||||
|
||||
let wrapper: ShallowWrapper;
|
||||
const getVisitsMock = jest.fn();
|
||||
const exportCsv = jest.fn();
|
||||
|
||||
const createComponent = (visitsInfo: Partial<VisitsInfo>) => {
|
||||
wrapper = shallow(
|
||||
@@ -25,6 +26,7 @@ describe('<VisitStats />', () => {
|
||||
cancelGetVisits={() => {}}
|
||||
baseUrl={''}
|
||||
settings={Mock.all<Settings>()}
|
||||
exportCsv={exportCsv}
|
||||
/>,
|
||||
);
|
||||
|
||||
@@ -89,4 +91,13 @@ describe('<VisitStats />', () => {
|
||||
expect(extraHeaderContent).toHaveLength(1);
|
||||
expect(typeof extraHeaderContent).toEqual('function');
|
||||
});
|
||||
|
||||
it('exports CSV when export btn is clicked', () => {
|
||||
const wrapper = createComponent({ visits });
|
||||
const exportBtn = wrapper.find(Button).last();
|
||||
|
||||
expect(exportBtn).toHaveLength(1);
|
||||
exportBtn.simulate('click');
|
||||
expect(exportCsv).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user