Merge branch '16812-token-appears-in-the-download-URL'
[arvados-workbench2.git] / src / views-components / context-menu / actions / copy-to-clipboard-action.test.tsx
diff --git a/src/views-components/context-menu/actions/copy-to-clipboard-action.test.tsx b/src/views-components/context-menu/actions/copy-to-clipboard-action.test.tsx
new file mode 100644 (file)
index 0000000..1ada703
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { shallow, configure } from 'enzyme';
+import { ListItem } from "@material-ui/core";
+import * as Adapter from 'enzyme-adapter-react-16';
+import { CopyToClipboardAction } from './copy-to-clipboard-action';
+
+configure({ adapter: new Adapter() });
+
+jest.mock('copy-to-clipboard', () => jest.fn());
+
+describe('CopyToClipboardAction', () => {
+    let props;
+
+    beforeEach(() => {
+        props = {
+            onClick: jest.fn(),
+            href: 'https://collections.ardev.roche.com/c=ardev-4zz18-k0hamvtwyit6q56/t=1ha4ykd3w14ed19b2gh3uyjrjup38vsx27x1utwdne0bxcfg5d/LIMS/1.html',
+        };
+    });
+
+    it('should render properly and handle click', () => {
+        // when
+        const wrapper = shallow(<CopyToClipboardAction {...props} />);
+        wrapper.find(ListItem).simulate('click');
+
+        // then
+        expect(wrapper).not.toBeUndefined();
+
+        // and
+        expect(props.onClick).toHaveBeenCalled();
+    });
+});
\ No newline at end of file