shlink-web-client/test/short-urls/helpers/QrCodeModal.test.tsx

31 lines
1,000 B
TypeScript
Raw Normal View History

2018-11-01 14:35:51 +03:00
import React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import { ExternalLink } from 'react-external-link';
import { Mock } from 'ts-mockery';
2018-11-01 14:35:51 +03:00
import QrCodeModal from '../../../src/short-urls/helpers/QrCodeModal';
import { ShortUrl } from '../../../src/short-urls/data';
2018-11-01 14:35:51 +03:00
describe('<QrCodeModal />', () => {
let wrapper: ShallowWrapper;
const shortUrl = 'https://doma.in/abc123';
2018-11-01 14:35:51 +03:00
beforeEach(() => {
wrapper = shallow(<QrCodeModal shortUrl={Mock.of<ShortUrl>({ shortUrl })} isOpen={true} toggle={() => {}} />);
2018-11-01 14:35:51 +03:00
});
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(shortUrl);
2018-11-01 14:35:51 +03:00
});
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(`${shortUrl}/qr-code`);
2018-11-01 14:35:51 +03:00
});
});