1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { mount, configure } from 'enzyme';
7 import { ResourceFileSize } from './renderers';
8 import Adapter from "enzyme-adapter-react-16";
9 import { Provider } from 'react-redux';
10 import configureMockStore from 'redux-mock-store'
11 import { ResourceKind } from '../../models/resource';
13 const middlewares = [];
14 const mockStore = configureMockStore(middlewares);
16 configure({ adapter: new Adapter() });
18 describe('renderers', () => {
21 describe('ResourceFileSize', () => {
28 it('should render collection fileSizeTotal', () => {
30 const store = mockStore({ resources: {
32 kind: ResourceKind.COLLECTION,
38 const wrapper = mount(<Provider store={store}>
39 <ResourceFileSize {...props}></ResourceFileSize>
43 expect(wrapper.text()).toContain('100 B');
46 it('should render 0 B as file size', () => {
48 const store = mockStore({ resources: {} });
51 const wrapper = mount(<Provider store={store}>
52 <ResourceFileSize {...props}></ResourceFileSize>
56 expect(wrapper.text()).toContain('0 B');
59 it('should render empty string for non collection resource', () => {
61 const store1 = mockStore({ resources: {
63 kind: ResourceKind.PROJECT,
66 const store2 = mockStore({ resources: {
68 kind: ResourceKind.PROJECT,
73 const wrapper1 = mount(<Provider store={store1}>
74 <ResourceFileSize {...props}></ResourceFileSize>
76 const wrapper2 = mount(<Provider store={store2}>
77 <ResourceFileSize {...props}></ResourceFileSize>
81 expect(wrapper1.text()).toContain('');
82 expect(wrapper2.text()).toContain('');