unit test for error when creating room with self

This commit is contained in:
Ulf Gebhardt 2023-07-11 12:57:37 +02:00
parent dd4e6bf2dc
commit a4bb523cb4
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
2 changed files with 16 additions and 1 deletions

View File

@ -92,6 +92,21 @@ describe('Room', () => {
})
})
describe('user id is self', () => {
it('throws error', async () => {
await expect(
mutate({
mutation: createRoomMutation(),
variables: {
userId: 'chatting-user',
},
}),
).resolves.toMatchObject({
errors: [{ message: 'Cannot create a room with self' }],
})
})
})
describe('user id exists', () => {
it('returns the id of the room', async () => {
const result = await mutate({

View File

@ -33,7 +33,7 @@ export default {
user: { id: currentUserId },
} = context
if (userId === currentUserId) {
throw new Error('Cannot create a room with yourself')
throw new Error('Cannot create a room with self')
}
const session = context.driver.session()
const writeTxResultPromise = session.writeTransaction(async (transaction) => {