[ARVADOS-WORKBENCH2] updated: 2.1.0-398-g826435d2
Git user
git at public.arvados.org
Mon Jun 7 19:42:14 UTC 2021
Summary of changes:
.../data-explorer/renderers.test.tsx | 85 ++++++++++++++++++++++
src/views-components/data-explorer/renderers.tsx | 2 +-
2 files changed, 86 insertions(+), 1 deletion(-)
create mode 100644 src/views-components/data-explorer/renderers.test.tsx
via 826435d2e41cae04847672a38619b1d7ebae1ba7 (commit)
from ad79cd83fc26c3314a6c79137db02b12d1f2714a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 826435d2e41cae04847672a38619b1d7ebae1ba7
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date: Mon Jun 7 21:41:30 2021 +0200
17305: Added unit tests
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
diff --git a/src/views-components/data-explorer/renderers.test.tsx b/src/views-components/data-explorer/renderers.test.tsx
new file mode 100644
index 00000000..5f752b6b
--- /dev/null
+++ b/src/views-components/data-explorer/renderers.test.tsx
@@ -0,0 +1,85 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { mount, configure } from 'enzyme';
+import { ResourceFileSize } from './renderers';
+import * as Adapter from "enzyme-adapter-react-16";
+import { Provider } from 'react-redux';
+import configureMockStore from 'redux-mock-store'
+import { ResourceKind } from '../../models/resource';
+
+const middlewares = [];
+const mockStore = configureMockStore(middlewares);
+
+configure({ adapter: new Adapter() });
+
+describe('renderers', () => {
+ let props = null;
+
+ describe('ResourceFileSize', () => {
+ beforeEach(() => {
+ props = {
+ uuid: 'UUID',
+ };
+ });
+
+ it('should render collection fileSizeTotal', () => {
+ // given
+ const store = mockStore({ resources: {
+ [props.uuid]: {
+ kind: ResourceKind.COLLECTION,
+ fileSizeTotal: 100,
+ }
+ }});
+
+ // when
+ const wrapper = mount(<Provider store={store}>
+ <ResourceFileSize {...props}></ResourceFileSize>
+ </Provider>);
+
+ // then
+ expect(wrapper.text()).toContain('100 B');
+ });
+
+ it('should render 0 B as file size', () => {
+ // given
+ const store = mockStore({ resources: {} });
+
+ // when
+ const wrapper = mount(<Provider store={store}>
+ <ResourceFileSize {...props}></ResourceFileSize>
+ </Provider>);
+
+ // then
+ expect(wrapper.text()).toContain('0 B');
+ });
+
+ it('should render empty string for non collection resource', () => {
+ // given
+ const store1 = mockStore({ resources: {
+ [props.uuid]: {
+ kind: ResourceKind.PROJECT,
+ }
+ }});
+ const store2 = mockStore({ resources: {
+ [props.uuid]: {
+ kind: ResourceKind.PROJECT,
+ }
+ }});
+
+ // when
+ const wrapper1 = mount(<Provider store={store1}>
+ <ResourceFileSize {...props}></ResourceFileSize>
+ </Provider>);
+ const wrapper2 = mount(<Provider store={store2}>
+ <ResourceFileSize {...props}></ResourceFileSize>
+ </Provider>);
+
+ // then
+ expect(wrapper1.text()).toContain('');
+ expect(wrapper2.text()).toContain('');
+ });
+ });
+});
\ No newline at end of file
diff --git a/src/views-components/data-explorer/renderers.tsx b/src/views-components/data-explorer/renderers.tsx
index 4ec07344..0e3eefe2 100644
--- a/src/views-components/data-explorer/renderers.tsx
+++ b/src/views-components/data-explorer/renderers.tsx
@@ -418,7 +418,7 @@ export const ResourceFileSize = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource<CollectionResource>(props.uuid)(state.resources);
- if (resource && resource.kind === ResourceKind.COLLECTION) {
+ if (resource && resource.kind !== ResourceKind.COLLECTION) {
return { fileSize: '' };
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list