1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
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";
13 configure({ adapter: new Adapter() });
17 describe("<FileThumbnail />", () => {
21 const initialAuthState = {
23 keepWebServiceUrl: 'http://example.com/',
24 keepWebInlineServiceUrl: 'http://*.collections.example.com/',
27 store = createStore(combineReducers({
28 auth: (state: any = initialAuthState, action: any) => state,
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',
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">');