-
Notifications
You must be signed in to change notification settings - Fork 346
Expand file tree
/
Copy pathgetAllowedPermissionLevels.test.ts
More file actions
29 lines (24 loc) · 1.31 KB
/
getAllowedPermissionLevels.test.ts
File metadata and controls
29 lines (24 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { PERMISSION_CAN_DOWNLOAD, PERMISSION_CAN_PREVIEW } from '../../../../constants';
import { getAllowedPermissionLevels } from '../getAllowedPermissionLevels';
describe('getAllowedPermissionLevels', () => {
test('should return both permission levels when all conditions are met', () => {
const result = getAllowedPermissionLevels(true, true, PERMISSION_CAN_DOWNLOAD);
expect(result).toEqual([PERMISSION_CAN_DOWNLOAD, PERMISSION_CAN_PREVIEW]);
});
test.each([PERMISSION_CAN_DOWNLOAD, PERMISSION_CAN_PREVIEW])(
'should return only current permission when cannot change access level',
permission => {
const result = getAllowedPermissionLevels(false, true, permission);
expect(result).toEqual([permission]);
},
);
test('should exclude download permission when download setting is not available', () => {
const result = getAllowedPermissionLevels(true, false, PERMISSION_CAN_DOWNLOAD);
expect(result).toEqual([PERMISSION_CAN_PREVIEW]);
});
test('should return empty array for unknown permission values when cannot change access level', () => {
const unknownPermission = 'unknown_permission';
const result = getAllowedPermissionLevels(false, true, unknownPermission);
expect(result).toEqual([]);
});
});