mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-24 08:43:51 +03:00
Created QrCodeModal test
This commit is contained in:
parent
79a16a2c2c
commit
1697ef9306
2 changed files with 32 additions and 2 deletions
|
@ -10,7 +10,7 @@ const propTypes = {
|
||||||
isOpen: PropTypes.bool,
|
isOpen: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function QrCodeModal({ url, toggle, isOpen }) {
|
const QrCodeModal = ({ url, toggle, isOpen }) => {
|
||||||
return (
|
return (
|
||||||
<Modal isOpen={isOpen} toggle={toggle} centered>
|
<Modal isOpen={isOpen} toggle={toggle} centered>
|
||||||
<ModalHeader toggle={toggle}>
|
<ModalHeader toggle={toggle}>
|
||||||
|
@ -23,6 +23,8 @@ export default function QrCodeModal({ url, toggle, isOpen }) {
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
QrCodeModal.propTypes = propTypes;
|
QrCodeModal.propTypes = propTypes;
|
||||||
|
|
||||||
|
export default QrCodeModal;
|
||||||
|
|
28
test/short-urls/helpers/QrCodeModal.test.js
Normal file
28
test/short-urls/helpers/QrCodeModal.test.js
Normal file
|
@ -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('<QrCodeModal />', () => {
|
||||||
|
let wrapper;
|
||||||
|
const url = 'https://doma.in/abc123';
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
wrapper = shallow(<QrCodeModal url={url} />);
|
||||||
|
});
|
||||||
|
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`);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Add table
Reference in a new issue