From 787b2b95529c9a2c3d44f6f9678abb5a4f083151 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 31 Jan 2023 11:38:37 +0100 Subject: [PATCH] Add test for value null in statusFilter array. --- .../resolver/ContributionResolver.test.ts | 49 ++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index be4b91713..6c9c1136b 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -719,7 +719,7 @@ describe('ContributionResolver', () => { resetToken() }) - it('throws an error with non existing filter', async () => { + it('throws an error with "NOT_VALID" in statusFilter', async () => { await expect( query({ query: listAllContributions, @@ -741,6 +741,53 @@ describe('ContributionResolver', () => { ) }) + it('throws an error with a null in statusFilter', async () => { + await expect( + query({ + query: listAllContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + statusFilter: [null], + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [ + new UserInputError( + 'Variable "$statusFilter" got invalid value null at "statusFilter[0]"; Expected non-nullable type "ContributionStatus!" not to be null.', + ), + ], + }), + ) + }) + + it('throws an error with null and "NOT_VALID" in statusFilter', async () => { + await expect( + query({ + query: listAllContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + statusFilter: [null, 'NOT_VALID'], + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [ + new UserInputError( + 'Variable "$statusFilter" got invalid value null at "statusFilter[0]"; Expected non-nullable type "ContributionStatus!" not to be null.', + ), + new UserInputError( + 'Variable "$statusFilter" got invalid value "NOT_VALID" at "statusFilter[1]"; Value "NOT_VALID" does not exist in "ContributionStatus" enum.', + ), + ], + }), + ) + }) + it('returns allCreation without statusFilter', async () => { await expect( query({