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()
}) })
@ -92,6 +94,26 @@ describe('Room', () => {
}) })
describe('user id exists', () => { describe('user id exists', () => {
it('returns the id of the room', async () => {
const result = await mutate({
mutation: createRoomMutation(),
variables: {
userId: 'other-chatting-user',
},
})
roomId = result.data.CreateRoom.id
await expect(result).toMatchObject({
errors: undefined,
data: {
CreateRoom: {
id: expect.any(String),
},
},
})
})
})
describe('create room with same user id', () => {
it('returns the id of the room', async () => { it('returns the id of the room', async () => {
await expect(mutate({ await expect(mutate({
mutation: createRoomMutation(), mutation: createRoomMutation(),
@ -102,7 +124,7 @@ describe('Room', () => {
errors: undefined, errors: undefined,
data: { data: {
CreateRoom: { CreateRoom: {
id: expect.any(String), id: roomId,
}, },
}, },
}) })