add test for room creation with existing user id

This commit is contained in:
Moriz Wahl 2023-06-20 09:18:50 +02:00
parent 66652cf74e
commit 3a95e25e1c

View File

@ -71,6 +71,8 @@ describe('Room', () => {
}) })
describe('authenticated', () => { describe('authenticated', () => {
let roomId: string
beforeAll(async () => { beforeAll(async () => {
authenticatedUser = await chattingUser.toJson() authenticatedUser = await chattingUser.toJson()
}) })
@ -93,12 +95,14 @@ describe('Room', () => {
describe('user id exists', () => { describe('user id exists', () => {
it('returns the id of the room', async () => { it('returns the id of the room', async () => {
await expect(mutate({ const result = await mutate({
mutation: createRoomMutation(), mutation: createRoomMutation(),
variables: { variables: {
userId: 'other-chatting-user', userId: 'other-chatting-user',
}, },
})).resolves.toMatchObject({ })
roomId = result.data.CreateRoom.id
await expect(result).toMatchObject({
errors: undefined, errors: undefined,
data: { data: {
CreateRoom: { CreateRoom: {
@ -108,6 +112,24 @@ describe('Room', () => {
}) })
}) })
}) })
describe('create room with same user id', () => {
it('returns the id of the room', async () => {
await expect(mutate({
mutation: createRoomMutation(),
variables: {
userId: 'other-chatting-user',
},
})).resolves.toMatchObject({
errors: undefined,
data: {
CreateRoom: {
id: roomId,
},
},
})
})
})
}) })
}) })