18128: Improves process panel.
[arvados-workbench2.git] / src / components / file-tree / file-thumbnail.test.tsx
index c5dd56d0350d53df9d1a14afe14117e020724b88..3d93c890f934c3bb6989ee9fc07c52abacc78e6d 100644 (file)
@@ -2,32 +2,42 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from "react";
-import { shallow, configure } from "enzyme";
+import React from "react";
+import { configure, mount } from "enzyme";
 import { FileThumbnail } from "./file-thumbnail";
 import { CollectionFileType } from '../../models/collection-file';
-import * as Adapter from 'enzyme-adapter-react-16';
+import Adapter from 'enzyme-adapter-react-16';
+import { Provider } from "react-redux";
+import { combineReducers, createStore } from "redux";
 
 configure({ adapter: new Adapter() });
 
-jest.mock('is-image', () => ({
-    'default': () => true,
-}));
+let store;
 
 describe("<FileThumbnail />", () => {
     let file;
 
     beforeEach(() => {
+        const initialAuthState = {
+            config: {
+                keepWebServiceUrl: 'http://example.com/',
+                keepWebInlineServiceUrl: 'http://*.collections.example.com/',
+            }
+        }
+        store = createStore(combineReducers({
+            auth: (state: any = initialAuthState, action: any) => state,
+        }));
+
         file = {
-            name: 'test-image',
+            name: 'test-image.jpg',
             type: CollectionFileType.FILE,
-            url: 'http://test.com/c=test-hash/t=test-token/test-token2/test-token3/test-image.jpg',
+            url: 'http://example.com/c=zzzzz-4zz18-0123456789abcde/t=v2/zzzzz-gj3su-0123456789abcde/xxxxxxtokenxxxxx/test-image.jpg',
             size: 300
         };
     });
 
     it("renders file thumbnail with proper src", () => {
-        const fileThumbnail = shallow(<FileThumbnail file={file} />);
-        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"/>');
+        const fileThumbnail = mount(<Provider store={store}><FileThumbnail file={file} /></Provider>);
+        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">');
     });
 });