mirror of
https://github.com/Permissionless-Software-Foundation/x402-base-facilitator.git
synced 2026-09-21 16:52:01 -07:00
Added unit test to users API
This commit is contained in:
+27
-2
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user