1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import axios from 'axios';
7 import { configure, shallow } from "enzyme";
8 import Adapter from 'enzyme-adapter-react-16';
9 import { ListItem } from '@material-ui/core';
10 import 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 describe('<DownloadAction />', () => {
33 (axios as any).get.mockImplementationOnce(() => Promise.resolve({ data: '1234' }));
36 it('should return null if missing href or kind of file in props', () => {
38 const wrapper = shallow(<DownloadAction {...props} />);
41 expect(wrapper.html()).toBeNull();
44 it('should return a element', () => {
49 const wrapper = shallow(<DownloadAction {...props} />);
52 expect(wrapper.html()).not.toBeNull();
55 it('should handle download', () => {
61 currentCollectionUuid: '123412-123123'
63 const wrapper = shallow(<DownloadAction {...props} />);
66 wrapper.find(ListItem).simulate('click');
69 expect(axios.get).toHaveBeenCalledWith(props.href[0]);