|
|
@@ -1,21 +1,25 @@
|
|
|
import {$roleUtils} from "~/services/rights/roleUtils";
|
|
|
|
|
|
-const roles = [
|
|
|
- 'ROLE_BOOK_CONFIG_VIEW',
|
|
|
- 'ROLE_ROOM_CONFIG',
|
|
|
- 'ROLE_USER',
|
|
|
- 'ROLE_ADMIN',
|
|
|
- 'ROLE_ADMIN_CORE',
|
|
|
- 'ROLE_PLACE_VIEW',
|
|
|
- 'ROLE_ADMINISTRATIF_MANAGER_CORE',
|
|
|
-];
|
|
|
-
|
|
|
-const final_role = [
|
|
|
- 'ROLE_GENERAL-CONFIG_VIEW',
|
|
|
- 'ROLE_TAGG-ADVANCED',
|
|
|
- 'ROLE_ROOM',
|
|
|
- 'ROLE_USER_EDIT'
|
|
|
-];
|
|
|
+let roles, final_role
|
|
|
+
|
|
|
+beforeEach(() => {
|
|
|
+ roles = [
|
|
|
+ 'ROLE_BOOK_CONFIG_VIEW',
|
|
|
+ 'ROLE_ROOM_CONFIG',
|
|
|
+ 'ROLE_USER',
|
|
|
+ 'ROLE_ADMIN',
|
|
|
+ 'ROLE_ADMIN_CORE',
|
|
|
+ 'ROLE_PLACE_VIEW',
|
|
|
+ 'ROLE_ADMINISTRATIF_MANAGER_CORE',
|
|
|
+ ];
|
|
|
+
|
|
|
+ final_role = [
|
|
|
+ 'ROLE_GENERAL-CONFIG_VIEW',
|
|
|
+ 'ROLE_TAGG-ADVANCED',
|
|
|
+ 'ROLE_ROOM',
|
|
|
+ 'ROLE_USER_VIEW'
|
|
|
+ ];
|
|
|
+});
|
|
|
|
|
|
test('test isA', () => {
|
|
|
expect($roleUtils.isA('ADMINISTRATIF_MANAGER', roles)).toBeTruthy();
|
|
|
@@ -38,7 +42,7 @@ test('test transformUnderscoreToHyphenBeforeCompleteMigration', () => {
|
|
|
'ROLE_GENERAL_CONFIG_VIEW',
|
|
|
'ROLE_TAGG_ADVANCED',
|
|
|
'ROLE_ROOM',
|
|
|
- 'ROLE_USER_EDIT'
|
|
|
+ 'ROLE_USER_VIEW'
|
|
|
];
|
|
|
|
|
|
expect($roleUtils.transformUnderscoreToHyphenBeforeCompleteMigration(roles_to_array)).toStrictEqual(final_role);
|
|
|
@@ -46,10 +50,10 @@ test('test transformUnderscoreToHyphenBeforeCompleteMigration', () => {
|
|
|
|
|
|
test('test transformRoleToAbilities', () => {
|
|
|
let abilities_to_have = [
|
|
|
- {action: 'read', subject: 'book-config'},
|
|
|
- {action: 'read', subject: 'place'},
|
|
|
- {action: 'manage', subject: 'room-config'},
|
|
|
- {action: 'manage', subject: 'user'}
|
|
|
+ {action: 'read', subject: 'general-config'},
|
|
|
+ {action: 'manage', subject: 'tagg-advanced'},
|
|
|
+ {action: 'manage', subject: 'room'},
|
|
|
+ {action: 'read', subject: 'user'}
|
|
|
]
|
|
|
|
|
|
expect($roleUtils.transformRoleToAbilities(final_role)).toStrictEqual(abilities_to_have);
|