From 9e355f9202d05e208dcaf36438bfae489d3c8521 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 12 Jul 2022 09:43:47 +0200 Subject: [PATCH] Test that the updateContribution mutation can not update contribution to a date that is older than 3 month. --- .../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 bdb8453da..d3d42be86 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -347,6 +347,29 @@ describe('ContributionResolver', () => { ) }) }) + + describe('update creation to a date that is older than 3 month', () => { + it('throws an error', async () => { + const date = new Date() // , + await expect( + mutate({ + mutation: updateContribution, + variables: { + contributionId: result.data.createContribution.id, + amount: 1019.0, + memo: 'Test env contribution', + creationDate: date.setMonth(date.getMonth() - 3).toString(), + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [ + new GraphQLError('No information for available creations for the given date'), + ], + }), + ) + }) + }) }) }) })