From 3a95e25e1c38e5d26cc97ecc952e1b478bc1ae8a Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 20 Jun 2023 09:18:50 +0200 Subject: [PATCH] add test for room creation with existing user id --- backend/src/schema/resolvers/rooms.spec.ts | 26 ++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/backend/src/schema/resolvers/rooms.spec.ts b/backend/src/schema/resolvers/rooms.spec.ts index dd6bce156..1c9333bd7 100644 --- a/backend/src/schema/resolvers/rooms.spec.ts +++ b/backend/src/schema/resolvers/rooms.spec.ts @@ -71,6 +71,8 @@ describe('Room', () => { }) describe('authenticated', () => { + let roomId: string + beforeAll(async () => { authenticatedUser = await chattingUser.toJson() }) @@ -93,12 +95,14 @@ describe('Room', () => { describe('user id exists', () => { it('returns the id of the room', async () => { - await expect(mutate({ + const result = await mutate({ mutation: createRoomMutation(), variables: { userId: 'other-chatting-user', }, - })).resolves.toMatchObject({ + }) + roomId = result.data.CreateRoom.id + await expect(result).toMatchObject({ errors: undefined, data: { 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, + }, + }, + }) + }) + }) }) })