-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update user update to check if there is a user
- Loading branch information
1 parent
ef72c1e
commit 64763c0
Showing
1 changed file
with
71 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,74 +8,77 @@ | |
* This function is used as an entry point for the changeEndTest | ||
* @function updateTest | ||
*/ | ||
export async function updateTest(mapview) { | ||
|
||
await codi.describe('User: update', async () => { | ||
|
||
/** | ||
* ### update endpoint should be able to process a body | ||
* The user update endpoint should be able to take a body as the request. | ||
* @function it | ||
*/ | ||
await codi.it('update endpoint should be able to process a body', async () => { | ||
|
||
let params = { | ||
url: '/test/api/user/update', | ||
body: JSON.stringify( | ||
{ | ||
email: '[email protected]', | ||
admin: false, | ||
approved: false, | ||
verified: false | ||
} | ||
) | ||
}; | ||
|
||
await mapp.utils.xhr(params); | ||
|
||
params = { | ||
url: '/test/api/user/update', | ||
body: JSON.stringify( | ||
{ | ||
email: '[email protected]', | ||
admin: true, | ||
approved: true, | ||
verified: false | ||
} | ||
) | ||
} | ||
|
||
await mapp.utils.xhr(params); | ||
|
||
const acl = await mapp.utils.xhr('/test/api/user/list'); | ||
const test_user = acl.filter(user => user.email === '[email protected]')[0]; | ||
|
||
await codi.assertEqual(test_user.email, '[email protected]', 'The users email address should be [email protected]') | ||
await codi.assertFalse(test_user.verified, 'The user should be not verified') | ||
await codi.assertTrue(test_user.admin, 'The user should an admin') | ||
await codi.assertTrue(test_user.approved, 'The user should be approved') | ||
export async function updateTest() { | ||
|
||
if (mapp.user) { | ||
await codi.describe('User: update', async () => { | ||
|
||
console.log(mapp); | ||
/** | ||
* ### update endpoint should be able to process a body | ||
* The user update endpoint should be able to take a body as the request. | ||
* @function it | ||
*/ | ||
await codi.it('update endpoint should be able to process a body', async () => { | ||
|
||
let params = { | ||
url: '/test/api/user/update', | ||
body: JSON.stringify( | ||
{ | ||
email: '[email protected]', | ||
admin: false, | ||
approved: false, | ||
verified: false | ||
} | ||
) | ||
}; | ||
|
||
await mapp.utils.xhr(params); | ||
|
||
params = { | ||
url: '/test/api/user/update', | ||
body: JSON.stringify( | ||
{ | ||
email: '[email protected]', | ||
admin: true, | ||
approved: true, | ||
verified: false | ||
} | ||
) | ||
} | ||
|
||
await mapp.utils.xhr(params); | ||
|
||
const acl = await mapp.utils.xhr('/test/api/user/list'); | ||
const test_user = acl.filter(user => user.email === '[email protected]')[0]; | ||
|
||
await codi.assertEqual(test_user.email, '[email protected]', 'The users email address should be [email protected]') | ||
await codi.assertFalse(test_user.verified, 'The user should be not verified') | ||
await codi.assertTrue(test_user.admin, 'The user should an admin') | ||
await codi.assertTrue(test_user.approved, 'The user should be approved') | ||
|
||
}); | ||
|
||
/** | ||
### update endpoint should be able to be just params | ||
* The user update endpoint should be able to take a body as the request. | ||
* @function it | ||
*/ | ||
await codi.it('update endpoint should be able to be just params', async () => { | ||
|
||
const url = `/test/api/user/[email protected]&field=admin&value=false` | ||
await mapp.utils.xhr(url); | ||
|
||
const acl = await mapp.utils.xhr('/test/api/user/list'); | ||
const test_user = acl.filter(user => user.email === '[email protected]')[0]; | ||
|
||
await codi.assertEqual(test_user.email, '[email protected]', 'The users email address should be [email protected]') | ||
await codi.assertFalse(test_user.verified, 'The user should be not verified') | ||
await codi.assertFalse(test_user.admin, 'The user should an admin') | ||
await codi.assertTrue(test_user.approved, 'The user should be approved') | ||
|
||
}); | ||
|
||
}); | ||
|
||
/** | ||
### update endpoint should be able to be just params | ||
* The user update endpoint should be able to take a body as the request. | ||
* @function it | ||
*/ | ||
await codi.it('update endpoint should be able to be just params', async () => { | ||
|
||
const url = `/test/api/user/[email protected]&field=admin&value=false` | ||
await mapp.utils.xhr(url); | ||
|
||
const acl = await mapp.utils.xhr('/test/api/user/list'); | ||
const test_user = acl.filter(user => user.email === '[email protected]')[0]; | ||
|
||
await codi.assertEqual(test_user.email, '[email protected]', 'The users email address should be [email protected]') | ||
await codi.assertFalse(test_user.verified, 'The user should be not verified') | ||
await codi.assertFalse(test_user.admin, 'The user should an admin') | ||
await codi.assertTrue(test_user.approved, 'The user should be approved') | ||
|
||
}); | ||
|
||
}); | ||
} | ||
} |