1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from "react";
6 import { configure, mount } 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 import { Provider } from "react-redux";
11 import { combineReducers, createStore } from "redux";
13 configure({ adapter: new Adapter() });
15 jest.mock('is-image', () => ({
16 'default': () => true,
21 describe("<FileThumbnail />", () => {
25 const initialAuthState = {
27 keepWebServiceUrl: 'http://example.com/',
28 keepWebInlineServiceUrl: 'http://*.collections.example.com/',
31 store = createStore(combineReducers({
32 auth: (state: any = initialAuthState, action: any) => state,
37 type: CollectionFileType.FILE,
38 url: 'http://example.com/c=zzzzz-4zz18-0123456789abcde/t=v2/zzzzz-gj3su-0123456789abcde/xxxxxxtokenxxxxx/test-image.jpg',
43 it("renders file thumbnail with proper src", () => {
44 const fileThumbnail = mount(<Provider store={store}><FileThumbnail file={file} /></Provider>);
45 expect(fileThumbnail.html()).toBe('<img class="Component-thumbnail-1" alt="test-image" src="http://zzzzz-4zz18-0123456789abcde.collections.example.com/test-image.jpg?api_token=v2/zzzzz-gj3su-0123456789abcde/xxxxxxtokenxxxxx">');