From 8b62696c91aaa8116dc5960360d586f99a6dc136 Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 29 Aug 2022 13:07:24 +0200 Subject: [PATCH] Add test that listContributionMessages throws error for non authenticated user. --- .../ContributionMessageResolver.test.ts | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts index f98e4f211..8d65db306 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts @@ -1,18 +1,13 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' -import { cleanDB, resetToken, testEnvironment } from '@test/helpers' +import { cleanDB, testEnvironment } from '@test/helpers' import { GraphQLError } from 'graphql' -import { userFactory } from '@/seeds/factory/user' -import { creationFactory } from '@/seeds/factory/creation' -import { creations } from '@/seeds/creation/index' -import { peterLustig } from '@/seeds/users/peter-lustig' import { createContributionMessage } from '@/seeds/graphql/mutations' +import { listContributionMessages } from '@/seeds/graphql/queries' let mutate: any, query: any, con: any let testEnv: any -let result: any beforeAll(async () => { testEnv = await testEnvironment() @@ -44,4 +39,21 @@ describe('ContributionMessageResolver', () => { }) }) }) + + describe('listContributionMessages', () => { + describe('unauthenticated', () => { + it('returns an error', async () => { + await expect( + mutate({ + mutation: listContributionMessages, + variables: { contributionId: 1 }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('401 Unauthorized')], + }), + ) + }) + }) + }) })