2021-01-24 20:06:11 +03:00
|
|
|
import { shallow, ShallowWrapper } from 'enzyme';
|
|
|
|
import CopyToClipboard from 'react-copy-to-clipboard';
|
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
|
import { faCopy as copyIcon } from '@fortawesome/free-regular-svg-icons';
|
|
|
|
import { CopyToClipboardIcon } from '../../src/utils/CopyToClipboardIcon';
|
|
|
|
|
|
|
|
describe('<CopyToClipboardIcon />', () => {
|
|
|
|
let wrapper: ShallowWrapper;
|
|
|
|
const onCopy = () => {};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
wrapper = shallow(<CopyToClipboardIcon text="foo" onCopy={onCopy} />);
|
|
|
|
});
|
|
|
|
afterEach(() => wrapper?.unmount());
|
|
|
|
|
2021-03-06 19:25:09 +03:00
|
|
|
it('wraps expected components', () => {
|
2021-01-24 20:06:11 +03:00
|
|
|
const copyToClipboard = wrapper.find(CopyToClipboard);
|
|
|
|
const icon = wrapper.find(FontAwesomeIcon);
|
|
|
|
|
|
|
|
expect(copyToClipboard).toHaveLength(1);
|
|
|
|
expect(copyToClipboard.prop('text')).toEqual('foo');
|
|
|
|
expect(copyToClipboard.prop('onCopy')).toEqual(onCopy);
|
|
|
|
expect(icon).toHaveLength(1);
|
|
|
|
expect(icon.prop('icon')).toEqual(copyIcon);
|
|
|
|
expect(icon.prop('className')).toEqual('ml-2 copy-to-clipboard-icon');
|
|
|
|
});
|
|
|
|
});
|