1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as resource from '~/models/resource';
6 import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
7 import { resourceKindToContextMenuKind } from './context-menu-actions';
9 describe('context-menu-actions', () => {
10 describe('resourceKindToContextMenuKind', () => {
13 describe('ResourceKind.PROJECT', () => {
16 jest.spyOn(resource, 'extractUuidKind')
17 .mockImplementation(() => resource.ResourceKind.PROJECT);
20 it('should return ContextMenuKind.PROJECT_ADMIN', () => {
25 const result = resourceKindToContextMenuKind(uuid, isAdmin);
28 expect(result).toEqual(ContextMenuKind.PROJECT_ADMIN);
31 it('should return ContextMenuKind.PROJECT', () => {
33 const isAdmin = false;
34 const isEditable = true;
37 const result = resourceKindToContextMenuKind(uuid, isAdmin, isEditable);
40 expect(result).toEqual(ContextMenuKind.PROJECT);
43 it('should return ContextMenuKind.READONLY_PROJECT', () => {
45 const isAdmin = false;
46 const isEditable = false;
49 const result = resourceKindToContextMenuKind(uuid, isAdmin, isEditable);
52 expect(result).toEqual(ContextMenuKind.READONLY_PROJECT);
56 describe('ResourceKind.COLLECTION', () => {
59 jest.spyOn(resource, 'extractUuidKind')
60 .mockImplementation(() => resource.ResourceKind.COLLECTION);
63 it('should return ContextMenuKind.COLLECTION_ADMIN', () => {
68 const result = resourceKindToContextMenuKind(uuid, isAdmin);
71 expect(result).toEqual(ContextMenuKind.COLLECTION_ADMIN);
74 it('should return ContextMenuKind.COLLECTION_RESOURCE', () => {
76 const isAdmin = false;
77 const isEditable = true;
80 const result = resourceKindToContextMenuKind(uuid, isAdmin, isEditable);
83 expect(result).toEqual(ContextMenuKind.COLLECTION_RESOURCE);
86 it('should return ContextMenuKind.READONLY_COLLECTION', () => {
88 const isAdmin = false;
89 const isEditable = false;
92 const result = resourceKindToContextMenuKind(uuid, isAdmin, isEditable);
95 expect(result).toEqual(ContextMenuKind.READONLY_COLLECTION);
99 describe('ResourceKind.PROCESS', () => {
102 jest.spyOn(resource, 'extractUuidKind')
103 .mockImplementation(() => resource.ResourceKind.PROCESS);
106 it('should return ContextMenuKind.PROCESS_ADMIN', () => {
108 const isAdmin = true;
111 const result = resourceKindToContextMenuKind(uuid, isAdmin);
114 expect(result).toEqual(ContextMenuKind.PROCESS_ADMIN);
117 it('should return ContextMenuKind.PROCESS_RESOURCE', () => {
119 const isAdmin = false;
122 const result = resourceKindToContextMenuKind(uuid, isAdmin);
125 expect(result).toEqual(ContextMenuKind.PROCESS_RESOURCE);
129 describe('ResourceKind.USER', () => {
132 jest.spyOn(resource, 'extractUuidKind')
133 .mockImplementation(() => resource.ResourceKind.USER);
136 it('should return ContextMenuKind.ROOT_PROJECT', () => {
138 const result = resourceKindToContextMenuKind(uuid);
141 expect(result).toEqual(ContextMenuKind.ROOT_PROJECT);
145 describe('ResourceKind.LINK', () => {
148 jest.spyOn(resource, 'extractUuidKind')
149 .mockImplementation(() => resource.ResourceKind.LINK);
152 it('should return ContextMenuKind.LINK', () => {
154 const result = resourceKindToContextMenuKind(uuid);
157 expect(result).toEqual(ContextMenuKind.LINK);