diff --git a/src/visits/NonOrphanVisits.tsx b/src/visits/NonOrphanVisits.tsx index 231c2f7e..2ebfe913 100644 --- a/src/visits/NonOrphanVisits.tsx +++ b/src/visits/NonOrphanVisits.tsx @@ -7,7 +7,7 @@ import VisitsStats from './VisitsStats'; import { NormalizedVisit, VisitsInfo, VisitsParams } from './types'; import { CommonVisitsProps } from './types/CommonVisitsProps'; import { toApiParams } from './types/helpers'; -import { NonOrphanVisitsHeader } from './NonOrphanVisitsHeader'; +import VisitsHeader from './VisitsHeader'; export interface NonOrphanVisitsProps extends CommonVisitsProps { getNonOrphanVisits: (params?: ShlinkVisitsParams, doIntervalFallback?: boolean) => void; @@ -36,7 +36,7 @@ export const NonOrphanVisits = ({ exportVisits }: ReportExporter) => boundToMerc exportCsv={exportCsv} selectedServer={selectedServer} > - + ); }, () => [Topics.visits]); diff --git a/src/visits/NonOrphanVisitsHeader.tsx b/src/visits/NonOrphanVisitsHeader.tsx deleted file mode 100644 index a361defe..00000000 --- a/src/visits/NonOrphanVisitsHeader.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import VisitsHeader from './VisitsHeader'; -import { VisitsInfo } from './types'; -import './ShortUrlVisitsHeader.scss'; - -interface NonOrphanVisitsHeaderProps { - nonOrphanVisits: VisitsInfo; - goBack: () => void; -} - -export const NonOrphanVisitsHeader = ({ nonOrphanVisits, goBack }: NonOrphanVisitsHeaderProps) => { - const { visits } = nonOrphanVisits; - - return ; -}; diff --git a/src/visits/OrphanVisits.tsx b/src/visits/OrphanVisits.tsx index 8779be4b..bc2ee1d1 100644 --- a/src/visits/OrphanVisits.tsx +++ b/src/visits/OrphanVisits.tsx @@ -4,10 +4,10 @@ import { Topics } from '../mercure/helpers/Topics'; import { useGoBack } from '../utils/helpers/hooks'; import { ReportExporter } from '../common/services/ReportExporter'; import VisitsStats from './VisitsStats'; -import { OrphanVisitsHeader } from './OrphanVisitsHeader'; import { NormalizedVisit, OrphanVisitType, VisitsInfo, VisitsParams } from './types'; import { CommonVisitsProps } from './types/CommonVisitsProps'; import { toApiParams } from './types/helpers'; +import VisitsHeader from './VisitsHeader'; export interface OrphanVisitsProps extends CommonVisitsProps { getOrphanVisits: ( @@ -41,7 +41,7 @@ export const OrphanVisits = ({ exportVisits }: ReportExporter) => boundToMercure selectedServer={selectedServer} isOrphanVisits > - + ); }, () => [Topics.orphanVisits]); diff --git a/src/visits/OrphanVisitsHeader.tsx b/src/visits/OrphanVisitsHeader.tsx deleted file mode 100644 index cf8c7191..00000000 --- a/src/visits/OrphanVisitsHeader.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import VisitsHeader from './VisitsHeader'; -import { VisitsInfo } from './types'; -import './ShortUrlVisitsHeader.scss'; - -interface OrphanVisitsHeaderProps { - orphanVisits: VisitsInfo; - goBack: () => void; -} - -export const OrphanVisitsHeader = ({ orphanVisits, goBack }: OrphanVisitsHeaderProps) => { - const { visits } = orphanVisits; - - return ; -}; diff --git a/test/visits/NonOrphanVisits.test.tsx b/test/visits/NonOrphanVisits.test.tsx index db6e7666..9419b327 100644 --- a/test/visits/NonOrphanVisits.test.tsx +++ b/test/visits/NonOrphanVisits.test.tsx @@ -4,10 +4,10 @@ import { NonOrphanVisits as createNonOrphanVisits } from '../../src/visits/NonOr import { MercureBoundProps } from '../../src/mercure/helpers/boundToMercureHub'; import { VisitsInfo } from '../../src/visits/types'; import VisitsStats from '../../src/visits/VisitsStats'; -import { NonOrphanVisitsHeader } from '../../src/visits/NonOrphanVisitsHeader'; import { Settings } from '../../src/settings/reducers/settings'; import { ReportExporter } from '../../src/common/services/ReportExporter'; import { SelectedServer } from '../../src/servers/data'; +import VisitsHeader from '../../src/visits/VisitsHeader'; jest.mock('react-router-dom', () => ({ ...jest.requireActual('react-router-dom'), @@ -33,14 +33,14 @@ describe('', () => { />, ).dive(); const stats = wrapper.find(VisitsStats); - const header = wrapper.find(NonOrphanVisitsHeader); + const header = wrapper.find(VisitsHeader); expect(stats).toHaveLength(1); expect(header).toHaveLength(1); expect(stats.prop('cancelGetVisits')).toEqual(cancelGetNonOrphanVisits); expect(stats.prop('visitsInfo')).toEqual(nonOrphanVisits); expect(stats.prop('isOrphanVisits')).not.toBeDefined(); - expect(header.prop('nonOrphanVisits')).toEqual(nonOrphanVisits); + expect(header.prop('visits')).toEqual(nonOrphanVisits.visits); expect(header.prop('goBack')).toEqual(expect.any(Function)); }); }); diff --git a/test/visits/NonOrphanVisitsHeader.test.tsx b/test/visits/NonOrphanVisitsHeader.test.tsx deleted file mode 100644 index ea0f1fdc..00000000 --- a/test/visits/NonOrphanVisitsHeader.test.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { shallow } from 'enzyme'; -import { Mock } from 'ts-mockery'; -import { NonOrphanVisitsHeader } from '../../src/visits/NonOrphanVisitsHeader'; -import VisitsHeader from '../../src/visits/VisitsHeader'; -import { Visit, VisitsInfo } from '../../src/visits/types'; - -describe('', () => { - it('wraps a VisitsHeader with provided data', () => { - const visits: Visit[] = []; - const orphanVisits = Mock.of({ visits }); - const goBack = jest.fn(); - - const wrapper = shallow(); - const visitsHeader = wrapper.find(VisitsHeader); - - expect(visitsHeader).toHaveLength(1); - expect(visitsHeader.prop('visits')).toEqual(visits); - expect(visitsHeader.prop('goBack')).toEqual(goBack); - expect(visitsHeader.prop('title')).toEqual('Non-orphan visits'); - }); -}); diff --git a/test/visits/OrphanVisits.test.tsx b/test/visits/OrphanVisits.test.tsx index 1f8cd22d..b9b284d2 100644 --- a/test/visits/OrphanVisits.test.tsx +++ b/test/visits/OrphanVisits.test.tsx @@ -4,10 +4,10 @@ import { OrphanVisits as createOrphanVisits } from '../../src/visits/OrphanVisit 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 { ReportExporter } from '../../src/common/services/ReportExporter'; import { SelectedServer } from '../../src/servers/data'; +import VisitsHeader from '../../src/visits/VisitsHeader'; jest.mock('react-router-dom', () => ({ ...jest.requireActual('react-router-dom'), @@ -33,14 +33,14 @@ describe('', () => { />, ).dive(); const stats = wrapper.find(VisitsStats); - const header = wrapper.find(OrphanVisitsHeader); + const header = wrapper.find(VisitsHeader); expect(stats).toHaveLength(1); expect(header).toHaveLength(1); expect(stats.prop('cancelGetVisits')).toEqual(cancelGetOrphanVisits); expect(stats.prop('visitsInfo')).toEqual(orphanVisits); expect(stats.prop('isOrphanVisits')).toEqual(true); - expect(header.prop('orphanVisits')).toEqual(orphanVisits); + expect(header.prop('visits')).toEqual(orphanVisits.visits); expect(header.prop('goBack')).toEqual(expect.any(Function)); }); }); diff --git a/test/visits/OrphanVisitsHeader.test.tsx b/test/visits/OrphanVisitsHeader.test.tsx deleted file mode 100644 index 66eccad0..00000000 --- a/test/visits/OrphanVisitsHeader.test.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { shallow } from 'enzyme'; -import { Mock } from 'ts-mockery'; -import { OrphanVisitsHeader } from '../../src/visits/OrphanVisitsHeader'; -import VisitsHeader from '../../src/visits/VisitsHeader'; -import { Visit, VisitsInfo } from '../../src/visits/types'; - -describe('', () => { - it('wraps a VisitsHeader with provided data', () => { - const visits: Visit[] = []; - const orphanVisits = Mock.of({ visits }); - const goBack = jest.fn(); - - const wrapper = shallow(); - const visitsHeader = wrapper.find(VisitsHeader); - - expect(visitsHeader).toHaveLength(1); - expect(visitsHeader.prop('visits')).toEqual(visits); - expect(visitsHeader.prop('goBack')).toEqual(goBack); - expect(visitsHeader.prop('title')).toEqual('Orphan visits'); - }); -});