diff --git a/test/a02-users.spec.js b/test/a02-users.spec.js index 0fb78e1..be3edf4 100644 --- a/test/a02-users.spec.js +++ b/test/a02-users.spec.js @@ -393,7 +393,7 @@ describe('Users', () => { } }) - it('should not be able to update other user', async () => { + it('should not be able to update other user when not admin', async () => { try { const options = { method: 'PUT', @@ -424,6 +424,31 @@ describe('Users', () => { } } }) + + it('should be able to update other user when admin', async () => { + const adminJWT = context.adminJWT + + const options = { + method: 'PUT', + uri: `${LOCALHOST}/users/${context.user2._id.toString()}`, + resolveWithFullResponse: true, + json: true, + headers: { + Authorization: `Bearer ${adminJWT}` + }, + body: { + user: { + name: 'This should work' + } + } + } + + let result = await rp(options) + // console.log(`result stringified: ${JSON.stringify(result, null, 2)}`) + + const userName = result.body.user.name + assert.equal(userName, 'This should work') + }) }) describe('DELETE /users/:id', () => { @@ -519,7 +544,7 @@ describe('Users', () => { assert.equal(result.body.success, true) }) - it('should delete other account when admin', async () => { + it('should be able to delete other users when admin', async () => { const id = context.id2 const adminJWT = context.adminJWT