From cd090420cf318f5b9fbd7618ac3a0f8d65d67700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 23 Aug 2022 12:30:01 +0200 Subject: [PATCH] Move 'JoinGroup' to building up mode in 'groups.spec.js' --- backend/src/schema/resolvers/groups.spec.js | 56 +++++++++++++-------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/backend/src/schema/resolvers/groups.spec.js b/backend/src/schema/resolvers/groups.spec.js index 054e3abb0..e966506a7 100644 --- a/backend/src/schema/resolvers/groups.spec.js +++ b/backend/src/schema/resolvers/groups.spec.js @@ -122,34 +122,40 @@ describe('in mode', () => { }) it('creates a group', async () => { - await expect(mutate({ mutation: createGroupMutation, variables })).resolves.toMatchObject({ - data: { - CreateGroup: { - name: 'The Best Group', - slug: 'the-group', - about: 'We will change the world!', + await expect(mutate({ mutation: createGroupMutation, variables })).resolves.toMatchObject( + { + data: { + CreateGroup: { + name: 'The Best Group', + slug: 'the-group', + about: 'We will change the world!', + }, }, + errors: undefined, }, - errors: undefined, - }) + ) }) it('assigns the authenticated user as owner', async () => { - await expect(mutate({ mutation: createGroupMutation, variables })).resolves.toMatchObject({ - data: { - CreateGroup: { - name: 'The Best Group', - myRole: 'owner', + await expect(mutate({ mutation: createGroupMutation, variables })).resolves.toMatchObject( + { + data: { + CreateGroup: { + name: 'The Best Group', + myRole: 'owner', + }, }, + errors: undefined, }, - errors: undefined, - }) + ) }) it('has "disabled" and "deleted" default to "false"', async () => { - await expect(mutate({ mutation: createGroupMutation, variables })).resolves.toMatchObject({ - data: { CreateGroup: { disabled: false, deleted: false } }, - }) + await expect(mutate({ mutation: createGroupMutation, variables })).resolves.toMatchObject( + { + data: { CreateGroup: { disabled: false, deleted: false } }, + }, + ) }) describe('description', () => { @@ -313,8 +319,18 @@ describe('in mode', () => { }) }) }) + }) + describe('building up – clean db after each resolver', () => { describe('JoinGroup', () => { + beforeAll(async () => { + await seedBasicsAndClearAuthentication() + }) + + afterAll(async () => { + await cleanDatabase() + }) + describe('unauthenticated', () => { it('throws authorization error', async () => { const { errors } = await mutate({ @@ -332,7 +348,7 @@ describe('in mode', () => { let ownerOfClosedGroupUser let ownerOfHiddenGroupUser - beforeEach(async () => { + beforeAll(async () => { // create users ownerOfClosedGroupUser = await Factory.build( 'user', @@ -535,9 +551,7 @@ describe('in mode', () => { }) }) }) - }) - describe('building up – clean db after each resolver', () => { describe('GroupMembers', () => { beforeAll(async () => { await seedBasicsAndClearAuthentication()