diff --git a/src/short-urls/helpers/QrCodeModal.js b/src/short-urls/helpers/QrCodeModal.js index ee83b1df..d98696ef 100644 --- a/src/short-urls/helpers/QrCodeModal.js +++ b/src/short-urls/helpers/QrCodeModal.js @@ -10,7 +10,7 @@ const propTypes = { isOpen: PropTypes.bool, }; -export default function QrCodeModal({ url, toggle, isOpen }) { +const QrCodeModal = ({ url, toggle, isOpen }) => { return ( @@ -23,6 +23,8 @@ export default function QrCodeModal({ url, toggle, isOpen }) { ); -} +}; QrCodeModal.propTypes = propTypes; + +export default QrCodeModal; diff --git a/test/short-urls/helpers/QrCodeModal.test.js b/test/short-urls/helpers/QrCodeModal.test.js new file mode 100644 index 00000000..5999cf51 --- /dev/null +++ b/test/short-urls/helpers/QrCodeModal.test.js @@ -0,0 +1,28 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import QrCodeModal from '../../../src/short-urls/helpers/QrCodeModal'; +import ExternalLink from '../../../src/utils/ExternalLink'; + +describe('', () => { + let wrapper; + const url = 'https://doma.in/abc123'; + + beforeEach(() => { + wrapper = shallow(); + }); + afterEach(() => wrapper.unmount()); + + it('shows an external link to the URL', () => { + const externalLink = wrapper.find(ExternalLink); + + expect(externalLink).toHaveLength(1); + expect(externalLink.prop('href')).toEqual(url); + }); + + it('displays an image with the QR code of the URL', () => { + const img = wrapper.find('img'); + + expect(img).toHaveLength(1); + expect(img.prop('src')).toEqual(`${url}/qr-code`); + }); +});