From d5605d3afb4b2cf83dcc534b085ad43ee32a3ef9 Mon Sep 17 00:00:00 2001 From: elweyn Date: Sat, 28 Jan 2023 08:36:46 +0100 Subject: [PATCH] Add test for error case wrong statusFilter value. --- .../resolver/ContributionResolver.test.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 7958fd0cb..738c6fc25 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -45,6 +45,7 @@ import { Transaction as DbTransaction } from '@entity/Transaction' import { User } from '@entity/User' import { EventProtocolType } from '@/event/EventProtocolType' import { logger, i18n as localization } from '@test/testSetup' +import { UserInputError } from 'apollo-server-express' // mock account activation email to avoid console spam // mock account activation email to avoid console spam @@ -718,6 +719,28 @@ describe('ContributionResolver', () => { resetToken() }) + it('throws an error with non existing filter', async () => { + await expect( + query({ + query: listAllContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + statusFilter: ['CONFIRMD'], + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [ + new UserInputError( + 'Variable "$statusFilter" got invalid value "CONFIRMD" at "statusFilter[0]"; Value "CONFIRMD" does not exist in "ContributionStatus" enum. Did you mean the enum value "CONFIRMED"?', + ), + ], + }), + ) + }) + it('returns allCreation', async () => { await expect( query({