c5dd56d0350d53df9d1a14afe14117e020724b88
[arvados-workbench2.git] / src / components / file-tree / file-thumbnail.test.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from "react";
6 import { shallow, configure } from "enzyme";
7 import { FileThumbnail } from "./file-thumbnail";
8 import { CollectionFileType } from '../../models/collection-file';
9 import * as Adapter from 'enzyme-adapter-react-16';
10
11 configure({ adapter: new Adapter() });
12
13 jest.mock('is-image', () => ({
14     'default': () => true,
15 }));
16
17 describe("<FileThumbnail />", () => {
18     let file;
19
20     beforeEach(() => {
21         file = {
22             name: 'test-image',
23             type: CollectionFileType.FILE,
24             url: 'http://test.com/c=test-hash/t=test-token/test-token2/test-token3/test-image.jpg',
25             size: 300
26         };
27     });
28
29     it("renders file thumbnail with proper src", () => {
30         const fileThumbnail = shallow(<FileThumbnail file={file} />);
31         expect(fileThumbnail.html()).toBe('<img class="Component-thumbnail-1" alt="test-image" src="http://test.com/c=test-hash/test-image.jpg?api_token=test-token/test-token2/test-token3"/>');
32     });
33 });