From 1697ef9306c1ff707e6c5fba791b2237f4d78d29 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 1 Nov 2018 12:35:51 +0100 Subject: [PATCH] Created QrCodeModal test --- src/short-urls/helpers/QrCodeModal.js | 6 +++-- test/short-urls/helpers/QrCodeModal.test.js | 28 +++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 test/short-urls/helpers/QrCodeModal.test.js 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`); + }); +});