diff --git a/src/visits/ShortUrlVisits.js b/src/visits/ShortUrlVisits.js index c5b4ef99..bd291590 100644 --- a/src/visits/ShortUrlVisits.js +++ b/src/visits/ShortUrlVisits.js @@ -134,7 +134,7 @@ const ShortUrlVisits = ( return (
- +
diff --git a/src/visits/VisitsHeader.js b/src/visits/VisitsHeader.js index 34bb0288..d631eb31 100644 --- a/src/visits/VisitsHeader.js +++ b/src/visits/VisitsHeader.js @@ -2,18 +2,16 @@ import { Card, UncontrolledTooltip } from 'reactstrap'; import Moment from 'react-moment'; import React from 'react'; import ExternalLink from '../utils/ExternalLink'; -import './VisitsHeader.scss'; +import ShortUrlVisitsCount from '../short-urls/helpers/ShortUrlVisitsCount'; import { shortUrlDetailType } from './reducers/shortUrlDetail'; -import { shortUrlVisitsType } from './reducers/shortUrlVisits'; +import './VisitsHeader.scss'; const propTypes = { shortUrlDetail: shortUrlDetailType.isRequired, - shortUrlVisits: shortUrlVisitsType.isRequired, }; -export default function VisitsHeader({ shortUrlDetail, shortUrlVisits }) { +export default function VisitsHeader({ shortUrlDetail }) { const { shortUrl, loading } = shortUrlDetail; - const { visits } = shortUrlVisits; const shortLink = shortUrl && shortUrl.shortUrl ? shortUrl.shortUrl : ''; const longLink = shortUrl && shortUrl.longUrl ? shortUrl.longUrl : ''; @@ -30,14 +28,16 @@ export default function VisitsHeader({ shortUrlDetail, shortUrlVisits }) {

- Visits: {visits.length} + + Visits:{' '} + + Visit stats for


Created: {renderDate()}
- Long URL: -   + Long URL:{' '} {loading && Loading...} {!loading && }
diff --git a/test/visits/VisitsHeader.test.js b/test/visits/VisitsHeader.test.js index a0fce13f..84b287d1 100644 --- a/test/visits/VisitsHeader.test.js +++ b/test/visits/VisitsHeader.test.js @@ -11,24 +11,20 @@ describe('', () => { shortUrl: 'https://doma.in/abc123', longUrl: 'https://foo.bar/bar/foo', dateCreated: '2018-01-01T10:00:00+01:00', + visitsCount: 3, }, loading: false, }; - const shortUrlVisits = { - visits: [{}, {}, {}], - }; beforeEach(() => { - wrapper = shallow( - - ); + wrapper = shallow(); }); afterEach(() => wrapper.unmount()); it('shows the amount of visits', () => { const visitsBadge = wrapper.find('.badge'); - expect(visitsBadge.text()).toEqual(`Visits: ${shortUrlVisits.visits.length}`); + expect(visitsBadge.html()).toContain(`Visits: ${shortUrlDetail.shortUrl.visitsCount}`); }); it('shows when the URL was created', () => {