2018-11-01 14:35:51 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
2020-01-15 20:16:12 +03:00
|
|
|
import { ExternalLink } from 'react-external-link';
|
2018-11-01 14:35:51 +03:00
|
|
|
import QrCodeModal from '../../../src/short-urls/helpers/QrCodeModal';
|
|
|
|
|
|
|
|
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`);
|
|
|
|
});
|
|
|
|
});
|