Skip to content

Commit 70b2207

Browse files
mepriprithehabes
andauthored
Project roles fix (#306)
* Project Update Roles * Custom Role API * Update Change * changing variable name * upda;te comment * Use the static value from Group.defaultRoles * Revert "Merge branch 'development' into project-roles-fix" This reverts commit 4412996, reversing changes made to 2f3d09a. * Roles update * isDefaultRole test file --------- Co-authored-by: Bryan Haberberger <bryan.j.haberberger@slu.edu>
1 parent 875b98d commit 70b2207

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

utilities/__tests__/isDefaultRole.test.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,31 @@
11
import scrubDefaultRoles from '../isDefaultRole.js'
2-
import Group from '../../classes/Group/Group.js'
32

43
describe('scrubDefaultRoles function #customRole_unit', () => {
5-
beforeAll(() => {
6-
Group.defaultRoles = {
7-
admin: 'admin',
8-
user: 'user',
9-
guest: 'guest'
10-
}
11-
})
12-
134
it('should remove default roles from an array of role strings', () => {
14-
const roles = ['admin', 'customRole']
5+
const roles = ['OWNER', 'customRole']
156
const result = scrubDefaultRoles(roles)
167
expect(result).toEqual(['customRole'])
178
})
189

1910
it('should return false if all roles in the array are default roles', () => {
20-
const roles = ['admin', 'user']
11+
const roles = ['OWNER', 'VIEWER']
2112
const result = scrubDefaultRoles(roles)
2213
expect(result).toBe(false)
2314
})
2415

2516
it('should throw an error if the array contains non-string elements', () => {
26-
const roles = ['admin', 123]
17+
const roles = ['OWNER', 123]
2718
expect(() => scrubDefaultRoles(roles)).toThrow('Expecting a RolesMap and not an Array.')
2819
})
2920

3021
it('should remove default roles from an object of roles', () => {
31-
const roles = { admin: 'admin', customRole: 'customRole' }
22+
const roles = { OWNER: 'OWNER', customRole: 'customRole' }
3223
const result = scrubDefaultRoles(roles)
3324
expect(result).toEqual({ customRole: 'customRole' })
3425
})
3526

3627
it('should return false if all roles in the object are default roles', () => {
37-
const roles = { admin: 'admin', user: 'user' }
28+
const roles = { OWNER: 'OWNER', VIEWER: 'VIEWER' }
3829
const result = scrubDefaultRoles(roles)
3930
expect(result).toBe(false)
4031
})

0 commit comments

Comments
 (0)