21224: added chevron, moved description section Arvados-DCO-1.1-Signed-off-by: Lisa...
[arvados.git] / services / workbench2 / src / views-components / main-app-bar / account-menu.test.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import React from 'react';
6 import Adapter from 'enzyme-adapter-react-16';
7 import {configure, shallow } from 'enzyme';
8
9 import { AccountMenuComponent } from './account-menu';
10
11 configure({ adapter: new Adapter() });
12
13 describe('<AccountMenu />', () => {
14     let props;
15     let wrapper;
16
17     beforeEach(() => {
18       props = {
19         classes: {},
20         user: {
21             email: 'email@example.com',
22             firstName: 'User',
23             lastName: 'Test',
24             uuid: 'zzzzz-tpzed-testuseruuid',
25             ownerUuid: '',
26             username: 'testuser',
27             prefs: {},
28             isAdmin: false,
29             isActive: true
30         },
31         currentRoute: '',
32         workbenchURL: '',
33         localCluser: 'zzzzz',
34         dispatch: jest.fn(),
35       };
36     });
37
38     describe('Logout Menu Item', () => {
39         beforeEach(() => {
40             wrapper = shallow(<AccountMenuComponent {...props} />).dive();
41         });
42
43         it('should dispatch a logout action when clicked', () => {
44             wrapper.find('[data-cy="logout-menuitem"]').simulate('click');
45             expect(props.dispatch).toHaveBeenCalledWith({
46                 payload: {deleteLinkData: true, preservePath: false},
47                 type: 'LOGOUT',
48             });
49         });
50     });
51 });