22003: prevent redirect loop in Wb2 client-side redirect handler
[arvados.git] / services / workbench2 / 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 React from "react";
6 import { configure, mount } from "enzyme";
7 import { FileThumbnail } from "./file-thumbnail";
8 import { CollectionFileType } from '../../models/collection-file';
9 import Adapter from 'enzyme-adapter-react-16';
10 import { Provider } from "react-redux";
11 import { combineReducers, createStore } from "redux";
12
13 configure({ adapter: new Adapter() });
14
15 let store;
16
17 describe("<FileThumbnail />", () => {
18     let file;
19
20     beforeEach(() => {
21         const initialAuthState = {
22             config: {
23                 keepWebServiceUrl: 'http://example.com/',
24                 keepWebInlineServiceUrl: 'http://*.collections.example.com/',
25             }
26         }
27         store = createStore(combineReducers({
28             auth: (state: any = initialAuthState, action: any) => state,
29         }));
30
31         file = {
32             name: 'test-image.jpg',
33             type: CollectionFileType.FILE,
34             url: 'http://example.com/c=zzzzz-4zz18-0123456789abcde/t=v2/zzzzz-gj3su-0123456789abcde/xxxxxxtokenxxxxx/test-image.jpg',
35             size: 300
36         };
37     });
38
39     it("renders file thumbnail with proper src", () => {
40         const fileThumbnail = mount(<Provider store={store}><FileThumbnail file={file} /></Provider>);
41         expect(fileThumbnail.html()).toBe('<img class="Component-thumbnail-1" alt="test-image.jpg" src="http://zzzzz-4zz18-0123456789abcde.collections.example.com/test-image.jpg?api_token=v2/zzzzz-gj3su-0123456789abcde/xxxxxxtokenxxxxx">');
42     });
43 });