Avoids 404 responses when no container request is selected.
[arvados-workbench2.git] / src / views-components / owner-name-uuid-enhancer / owner-name-uuid-enhancer.test.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from 'react';
6 import { mount, configure } from 'enzyme';
7 import * as Adapter from "enzyme-adapter-react-16";
8 import { OwnerNameUuidEnhancer, OwnerNameUuidEnhancerProps } from './owner-name-uuid-enhancer';
9
10 configure({ adapter: new Adapter() });
11
12 describe('NotFoundPanelRoot', () => {
13     let props: OwnerNameUuidEnhancerProps;
14
15     beforeEach(() => {
16         props = {
17             ownerNamesMap: {},
18             fetchOwner: () => {},
19             uuid: 'zzzz-tpzed-xxxxxxxxxxxxxxx',
20         };
21     });
22
23     it('should render uuid without name', () => {
24         // when
25         const wrapper = mount(<OwnerNameUuidEnhancer {...props} />);
26
27         // then
28         expect(wrapper.html()).toBe('<span>zzzz-tpzed-xxxxxxxxxxxxxxx</span>');
29     });
30
31     it('should render uuid with name', () => {
32         // given
33         const fullName = 'John Doe';
34
35         // setup
36         props.ownerNamesMap = {
37             [props.uuid]: fullName
38         };
39
40         // when
41         const wrapper = mount(<OwnerNameUuidEnhancer {...props} />);
42
43         // then
44         expect(wrapper.html()).toBe('<span>zzzz-tpzed-xxxxxxxxxxxxxxx (John Doe)</span>');
45     });
46 });