diff --git a/src/short-urls/helpers/EditTagsModal.js b/src/short-urls/helpers/EditTagsModal.js
index f5d34dd2..261b12e3 100644
--- a/src/short-urls/helpers/EditTagsModal.js
+++ b/src/short-urls/helpers/EditTagsModal.js
@@ -1,7 +1,7 @@
import React from 'react';
import { Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
import PropTypes from 'prop-types';
-import ExternalLink from '../../utils/ExternalLink';
+import { ExternalLink } from 'react-external-link';
import { shortUrlTagsType } from '../reducers/shortUrlTags';
import { shortUrlType } from '../reducers/shortUrlsList';
diff --git a/src/short-urls/helpers/PreviewModal.js b/src/short-urls/helpers/PreviewModal.js
index 8496be7a..9570ec75 100644
--- a/src/short-urls/helpers/PreviewModal.js
+++ b/src/short-urls/helpers/PreviewModal.js
@@ -1,8 +1,8 @@
import React from 'react';
import { Modal, ModalBody, ModalHeader } from 'reactstrap';
import PropTypes from 'prop-types';
+import { ExternalLink } from 'react-external-link';
import './PreviewModal.scss';
-import ExternalLink from '../../utils/ExternalLink';
const propTypes = {
url: PropTypes.string,
diff --git a/src/short-urls/helpers/QrCodeModal.js b/src/short-urls/helpers/QrCodeModal.js
index 3a8cd43f..dcc8b323 100644
--- a/src/short-urls/helpers/QrCodeModal.js
+++ b/src/short-urls/helpers/QrCodeModal.js
@@ -1,8 +1,8 @@
import React from 'react';
import { Modal, ModalBody, ModalHeader } from 'reactstrap';
import PropTypes from 'prop-types';
+import { ExternalLink } from 'react-external-link';
import './QrCodeModal.scss';
-import ExternalLink from '../../utils/ExternalLink';
const propTypes = {
url: PropTypes.string,
diff --git a/src/short-urls/helpers/ShortUrlVisitsCount.js b/src/short-urls/helpers/ShortUrlVisitsCount.js
index 663b3a0e..458ce16e 100644
--- a/src/short-urls/helpers/ShortUrlVisitsCount.js
+++ b/src/short-urls/helpers/ShortUrlVisitsCount.js
@@ -1,16 +1,17 @@
import React from 'react';
+import PropTypes from 'prop-types';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faInfoCircle as infoIcon } from '@fortawesome/free-solid-svg-icons';
import { UncontrolledTooltip } from 'reactstrap';
-import { shortUrlType } from '../reducers/shortUrlsList';
+import { shortUrlMetaType } from '../reducers/shortUrlsList';
import './ShortUrlVisitsCount.scss';
const propTypes = {
- shortUrl: shortUrlType,
+ visitsCount: PropTypes.number.isRequired,
+ meta: shortUrlMetaType,
};
-const ShortUrlVisitsCount = ({ shortUrl }) => {
- const { visitsCount, meta } = shortUrl;
+const ShortUrlVisitsCount = ({ visitsCount, meta }) => {
const maxVisits = meta && meta.maxVisits;
if (!maxVisits) {
diff --git a/src/short-urls/helpers/ShortUrlsRow.js b/src/short-urls/helpers/ShortUrlsRow.js
index 10585db7..43d4205f 100644
--- a/src/short-urls/helpers/ShortUrlsRow.js
+++ b/src/short-urls/helpers/ShortUrlsRow.js
@@ -2,9 +2,9 @@ import { isEmpty } from 'ramda';
import React from 'react';
import Moment from 'react-moment';
import PropTypes from 'prop-types';
+import { ExternalLink } from 'react-external-link';
import { shortUrlsListParamsType } from '../reducers/shortUrlsListParams';
import { serverType } from '../../servers/prop-types';
-import ExternalLink from '../../utils/ExternalLink';
import { shortUrlType } from '../reducers/shortUrlsList';
import Tag from '../../tags/helpers/Tag';
import ShortUrlVisitsCount from './ShortUrlVisitsCount';
@@ -58,7 +58,7 @@ const ShortUrlsRow = (
{this.renderTags(shortUrl.tags)} |
-
+
|
-
+
Visits:{' '}
-
+
Visit stats for
diff --git a/test/short-urls/helpers/PreviewModal.test.js b/test/short-urls/helpers/PreviewModal.test.js
index 694eb0f7..ee7356be 100644
--- a/test/short-urls/helpers/PreviewModal.test.js
+++ b/test/short-urls/helpers/PreviewModal.test.js
@@ -1,7 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';
+import { ExternalLink } from 'react-external-link';
import PreviewModal from '../../../src/short-urls/helpers/PreviewModal';
-import ExternalLink from '../../../src/utils/ExternalLink';
describe('', () => {
let wrapper;
diff --git a/test/short-urls/helpers/QrCodeModal.test.js b/test/short-urls/helpers/QrCodeModal.test.js
index 5999cf51..44ccf2a3 100644
--- a/test/short-urls/helpers/QrCodeModal.test.js
+++ b/test/short-urls/helpers/QrCodeModal.test.js
@@ -1,7 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';
+import { ExternalLink } from 'react-external-link';
import QrCodeModal from '../../../src/short-urls/helpers/QrCodeModal';
-import ExternalLink from '../../../src/utils/ExternalLink';
describe('', () => {
let wrapper;
diff --git a/test/short-urls/helpers/ShortUrlVisitsCount.test.js b/test/short-urls/helpers/ShortUrlVisitsCount.test.js
index 9949fa4c..42508219 100644
--- a/test/short-urls/helpers/ShortUrlVisitsCount.test.js
+++ b/test/short-urls/helpers/ShortUrlVisitsCount.test.js
@@ -1,22 +1,23 @@
import React from 'react';
import { shallow } from 'enzyme';
import { UncontrolledTooltip } from 'reactstrap';
+import each from 'jest-each';
import ShortUrlVisitsCount from '../../../src/short-urls/helpers/ShortUrlVisitsCount';
describe('', () => {
let wrapper;
- const createWrapper = (shortUrl) => {
- wrapper = shallow();
+ const createWrapper = (visitsCount, meta) => {
+ wrapper = shallow();
return wrapper;
};
afterEach(() => wrapper && wrapper.unmount());
- it('just returns visits when no maxVisits is provided', () => {
+ each([ undefined, {}]).it('just returns visits when no maxVisits is provided', (meta) => {
const visitsCount = 45;
- const wrapper = createWrapper({ visitsCount });
+ const wrapper = createWrapper(visitsCount, meta);
const maxVisitsHelper = wrapper.find('.short-urls-visits-count__max-visits-control');
const maxVisitsTooltip = wrapper.find(UncontrolledTooltip);
@@ -29,7 +30,7 @@ describe('', () => {
const visitsCount = 45;
const maxVisits = 500;
const meta = { maxVisits };
- const wrapper = createWrapper({ visitsCount, meta });
+ const wrapper = createWrapper(visitsCount, meta);
const maxVisitsHelper = wrapper.find('.short-urls-visits-count__max-visits-control');
const maxVisitsTooltip = wrapper.find(UncontrolledTooltip);
diff --git a/test/short-urls/helpers/ShortUrlsRow.test.js b/test/short-urls/helpers/ShortUrlsRow.test.js
index 5be8718a..cb6d9a77 100644
--- a/test/short-urls/helpers/ShortUrlsRow.test.js
+++ b/test/short-urls/helpers/ShortUrlsRow.test.js
@@ -3,8 +3,8 @@ import { shallow } from 'enzyme';
import moment from 'moment';
import Moment from 'react-moment';
import { assoc, toString } from 'ramda';
+import { ExternalLink } from 'react-external-link';
import createShortUrlsRow from '../../../src/short-urls/helpers/ShortUrlsRow';
-import ExternalLink from '../../../src/utils/ExternalLink';
import Tag from '../../../src/tags/helpers/Tag';
describe('', () => {
diff --git a/test/visits/VisitsHeader.test.js b/test/visits/VisitsHeader.test.js
index 84b287d1..9af5b41a 100644
--- a/test/visits/VisitsHeader.test.js
+++ b/test/visits/VisitsHeader.test.js
@@ -1,8 +1,8 @@
import React from 'react';
import { shallow } from 'enzyme';
import Moment from 'react-moment';
+import { ExternalLink } from 'react-external-link';
import VisitsHeader from '../../src/visits/VisitsHeader';
-import ExternalLink from '../../src/utils/ExternalLink';
describe('', () => {
let wrapper;
@@ -11,20 +11,22 @@ 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.html()).toContain(`Visits: ${shortUrlDetail.shortUrl.visitsCount}`);
+ expect(visitsBadge.html()).toContain(`Visits: ${shortUrlVisits.visits.length}`);
});
it('shows when the URL was created', () => {
|