1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import axios from 'axios';
7 import { configure, shallow } from "enzyme";
8 import * as Adapter from 'enzyme-adapter-react-16';
9 import { ListItem } from '@material-ui/core';
10 import * as JSZip from 'jszip';
11 import { DownloadAction } from './download-action';
13 configure({ adapter: new Adapter() });
17 jest.mock('file-saver', () => ({
23 generateAsync: jest.fn().mockImplementation(() => Promise.resolve('test')),
26 jest.mock('jszip', () => jest.fn().mockImplementation(() => mock));
28 describe('<DownloadAction />', () => {
35 (axios as any).get.mockImplementationOnce(() => Promise.resolve({ data: '1234' }));
38 it('should return null if missing href or kind of file in props', () => {
40 const wrapper = shallow(<DownloadAction {...props} />);
43 expect(wrapper.html()).toBeNull();
46 it('should return a element', () => {
51 const wrapper = shallow(<DownloadAction {...props} />);
54 expect(wrapper.html()).not.toBeNull();
57 it('should handle download', () => {
63 currentCollectionUuid: '123412-123123'
65 const wrapper = shallow(<DownloadAction {...props} />);
68 wrapper.find(ListItem).simulate('click');
71 expect(axios.get).toHaveBeenCalledWith(props.href[0]);