mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
unit test for error when creating room with self
This commit is contained in:
parent
dd4e6bf2dc
commit
a4bb523cb4
@ -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({
|
||||
|
||||
@ -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) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user