2019-04-05 02:23:40 +07:00
|
|
|
import React from 'react';
|
2019-10-11 03:20:05 +07:00
|
|
|
import { mount, ReactWrapper } from 'enzyme';
|
2019-04-05 02:23:40 +07:00
|
|
|
|
2019-10-16 15:00:05 +07:00
|
|
|
import { copyToClipBoardUtility } from '../../utils/cli-utils';
|
|
|
|
|
2019-06-20 19:37:28 +07:00
|
|
|
import CopyToClipBoard from './CopyToClipBoard';
|
|
|
|
import { CopyIcon } from './styles';
|
2019-04-05 02:23:40 +07:00
|
|
|
|
2019-10-16 15:00:05 +07:00
|
|
|
jest.mock('../../utils/cli-utils');
|
|
|
|
|
2019-04-05 02:23:40 +07:00
|
|
|
describe('<CopyToClipBoard /> component', () => {
|
2019-10-11 03:20:05 +07:00
|
|
|
let wrapper: ReactWrapper;
|
2019-10-16 15:00:05 +07:00
|
|
|
const copyText = 'copy text';
|
2019-04-05 02:23:40 +07:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2019-10-16 15:00:05 +07:00
|
|
|
wrapper = mount(<CopyToClipBoard text={copyText} />);
|
2019-04-05 02:23:40 +07:00
|
|
|
});
|
|
|
|
|
|
|
|
test('render the component', () => {
|
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2019-10-16 15:00:05 +07:00
|
|
|
test('should call the copyToClipBoardUtility for copy to clipboard utility', () => {
|
|
|
|
wrapper.find(CopyIcon).simulate('click');
|
|
|
|
expect(copyToClipBoardUtility).toHaveBeenCalledWith(copyText);
|
2019-04-05 02:23:40 +07:00
|
|
|
});
|
|
|
|
});
|