chore(user): use rejectionOf() (#32)

This commit is contained in:
badrAZ
2017-01-13 11:30:50 +01:00
committed by Julien Fontanet
parent d50e1b4e02
commit 1355477e37

View File

@@ -4,6 +4,7 @@ import {
createUser, createUser,
deleteUsers, deleteUsers,
getUser, getUser,
rejectionOf,
testConnection, testConnection,
xo xo
} from './util' } from './util'
@@ -44,17 +45,10 @@ describe('user', () => {
password: 'batman' password: 'batman'
}) })
await createUser(xo, userIds, { expect((await rejectionOf(createUser(xo, userIds, {
email: 'wayne@vates.fr', email: 'wayne@vates.fr',
password: 'alfred' password: 'alfred'
}).then( }))).message).toMatch(/already exists/i)
() => {
throw new Error('createUser() should have thrown')
},
error => {
expect(error.message).toMatch(/already exists/i)
}
)
}) })
it('can set the user permission', async () => { it('can set the user permission', async () => {
@@ -104,14 +98,7 @@ describe('user', () => {
}) })
it('not allows an user to delete itself', async () => { it('not allows an user to delete itself', async () => {
await xo.call('user.delete', {id: xo.user.id}).then( expect((await rejectionOf(xo.call('user.delete', {id: xo.user.id}))).message).toBe('a user cannot delete itself')
() => {
throw new Error('user.delete() should have thrown')
},
function (error) {
expect(error.message).toBe('a user cannot delete itself')
}
)
}) })
}) })