-
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 tests & give xhr util method name
- Loading branch information
1 parent
e2a8bf0
commit f009234
Showing
5 changed files
with
141 additions
and
49 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
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
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { updateTest } from './update.test.mjs'; | ||
|
||
export const userTest = { | ||
updateTest | ||
} |
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
|
||
/** | ||
* ## user.updateTest() | ||
* @module user/update | ||
*/ | ||
|
||
/** | ||
* 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') | ||
|
||
}); | ||
|
||
/** | ||
### 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') | ||
|
||
}); | ||
|
||
}); | ||
} |