mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-02-09 23:49:29 -06:00
Ok lets just merge it all together
This commit is contained in:
@@ -96,4 +96,52 @@ describe('PermissionsGuard', () => {
|
||||
expect(canActivate).toHaveProperty('root') // returns UrlTree
|
||||
expect(toastSpy).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should activate when any required permission is granted', () => {
|
||||
jest
|
||||
.spyOn(permissionsService, 'currentUserCan')
|
||||
.mockImplementation((action, type) => {
|
||||
return type === PermissionType.Tag
|
||||
})
|
||||
|
||||
const canActivate = guard.canActivate(
|
||||
{
|
||||
data: {
|
||||
requiredPermissionAny: [
|
||||
{ action: PermissionAction.View, type: PermissionType.Tag },
|
||||
{
|
||||
action: PermissionAction.View,
|
||||
type: PermissionType.DocumentType,
|
||||
},
|
||||
],
|
||||
},
|
||||
} as any,
|
||||
routerState.snapshot
|
||||
)
|
||||
|
||||
expect(canActivate).toBeTruthy()
|
||||
})
|
||||
|
||||
it('should not activate when no required permission is granted', () => {
|
||||
jest
|
||||
.spyOn(permissionsService, 'currentUserCan')
|
||||
.mockImplementation(() => false)
|
||||
|
||||
const canActivate = guard.canActivate(
|
||||
{
|
||||
data: {
|
||||
requiredPermissionAny: [
|
||||
{ action: PermissionAction.View, type: PermissionType.Tag },
|
||||
{
|
||||
action: PermissionAction.View,
|
||||
type: PermissionType.DocumentType,
|
||||
},
|
||||
],
|
||||
},
|
||||
} as any,
|
||||
routerState.snapshot
|
||||
)
|
||||
|
||||
expect(canActivate).toHaveProperty('root')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user