16743: fix for non existing parent project
[arvados-workbench2.git] / src / views-components / side-panel-button / side-panel-button.test.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { isProjectTrashed } from './side-panel-button';
6
7 describe('<SidePanelButton />', () => {
8     describe('isProjectTrashed', () => {
9         it('should return false if parent project is undefined', () => {
10             // given
11             const proj = {};
12             const resources = {};
13
14             // when
15             const result = isProjectTrashed(proj, resources);
16
17             // then
18             expect(result).toBeFalsy();
19         });
20
21         it('should return false for owner', () => {
22             // given
23             const proj = {
24                 ownerUuid: 'ce8i5-tpzed-000000000000000',
25             };
26             const resources = {};
27
28             // when
29             const result = isProjectTrashed(proj, resources);
30
31             // then
32             expect(result).toBeFalsy();
33         });
34
35         it('should return true for trashed', () => {
36             // given
37             const proj = {
38                 isTrashed: true,
39             };
40             const resources = {};
41
42             // when
43             const result = isProjectTrashed(proj, resources);
44
45             // then
46             expect(result).toBeTruthy();
47         });
48
49         it.only('should return false for undefined parent projects', () => {
50             // given
51             const proj = {
52                 ownerUuid: 'ce8i5-j7d0g-000000000000000',
53             };
54             const resources = {};
55
56             // when
57             const result = isProjectTrashed(proj, resources);
58
59             // then
60             expect(result).toBeFalsy();
61         });
62     });
63 });