17782: Fixes almost all tests (4 left) mostly by fixing namespace-type imports.
[arvados-workbench2.git] / src / views-components / context-menu / actions / copy-to-clipboard-action.test.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import React from 'react';
6 import { shallow, configure } from 'enzyme';
7 import { ListItem } from "@material-ui/core";
8 import Adapter from 'enzyme-adapter-react-16';
9 import { CopyToClipboardAction } from './copy-to-clipboard-action';
10
11 configure({ adapter: new Adapter() });
12
13 jest.mock('copy-to-clipboard', () => jest.fn());
14
15 describe('CopyToClipboardAction', () => {
16     let props;
17
18     beforeEach(() => {
19         props = {
20             onClick: jest.fn(),
21             href: 'https://collections.example.com/c=zzzzz-4zz18-k0hamvtwyit6q56/t=xxxxxxxx/LIMS/1.html',
22         };
23     });
24
25     it('should render properly and handle click', () => {
26         // when
27         const wrapper = shallow(<CopyToClipboardAction {...props} />);
28         wrapper.find(ListItem).simulate('click');
29
30         // then
31         expect(wrapper).not.toBeUndefined();
32
33         // and
34         expect(props.onClick).toHaveBeenCalled();
35     });
36 });