1
0
mirror of https://github.com/sasjs/server.git synced 2025-12-10 11:24:35 +00:00

chore: add specs for delete permission api endpoint

This commit is contained in:
2022-05-10 06:40:34 +05:00
parent 72a3197a06
commit 98b8a75148

View File

@@ -348,6 +348,37 @@ describe('permission', () => {
expect(res.body).toEqual({})
})
})
describe('delete', () => {
it('should delete permission', async () => {
const dbUser = await userController.createUser({
...user,
username: 'deleted username'
})
const dbPermission = await permissionController.createPermission({
...permission,
principalId: dbUser.id
})
const res = await request(app)
.delete(`/SASjsApi/permission/${dbPermission?.permissionId}`)
.auth(adminAccessToken, { type: 'bearer' })
.send()
.expect(200)
expect(res.text).toEqual('Permission Deleted!')
})
it('should respond with forbidden Request (403) if permission with provided id does not exists', async () => {
const res = await request(app)
.delete('/SASjsApi/permission/123')
.auth(adminAccessToken, { type: 'bearer' })
.send()
.expect(403)
expect(res.text).toEqual('Error: Permission is not found.')
})
})
})
const generateSaveTokenAndCreateUser = async (