From 9e7da0f451fd18920880d589baffee2fc0a73a5d Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 25 Jan 2023 08:11:47 +0100 Subject: [PATCH] Add tests for filterState parameter in listAllContributions query. --- .../resolver/ContributionResolver.test.ts | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 3d251ced1..f65a8d5a5 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -754,6 +754,42 @@ describe('ContributionResolver', () => { ) }) + it('returns allCreation', async () => { + await expect( + query({ + query: listAllContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterState: [], + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listAllContributions: { + contributionCount: 2, + contributionList: expect.arrayContaining([ + expect.objectContaining({ + id: expect.any(Number), + state: 'CONFIRMED', + memo: 'Herzlich Willkommen bei Gradido!', + amount: '1000', + }), + expect.objectContaining({ + id: expect.any(Number), + state: 'PENDING', + memo: 'Test env contribution', + amount: '100', + }), + ]), + }, + }, + }), + ) + }) + it('returns all CONFIRMED Creation', async () => { await expect( query({ @@ -826,6 +862,42 @@ describe('ContributionResolver', () => { ) }) + it('returns all IN_PROGRESS Creation', async () => { + await expect( + query({ + query: listAllContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterState: ['IN_PROGRESS'], + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listAllContributions: { + contributionCount: 0, + contributionList: expect.not.arrayContaining([ + expect.objectContaining({ + id: expect.any(Number), + state: 'CONFIRMED', + memo: 'Herzlich Willkommen bei Gradido!', + amount: '1000', + }), + expect.objectContaining({ + id: expect.any(Number), + state: 'PENDING', + memo: 'Test env contribution', + amount: '100', + }), + ]), + }, + }, + }), + ) + }) + it('returns all DENIED Creation', async () => { await expect( query({ @@ -861,6 +933,78 @@ describe('ContributionResolver', () => { }), ) }) + + it('returns all DELETED Creation', async () => { + await expect( + query({ + query: listAllContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterState: ['DELETED'], + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listAllContributions: { + contributionCount: 0, + contributionList: expect.not.arrayContaining([ + expect.objectContaining({ + id: expect.any(Number), + state: 'CONFIRMED', + memo: 'Herzlich Willkommen bei Gradido!', + amount: '1000', + }), + expect.objectContaining({ + id: expect.any(Number), + state: 'PENDING', + memo: 'Test env contribution', + amount: '100', + }), + ]), + }, + }, + }), + ) + }) + + it('returns all CONFIRMED and PENDING Creation', async () => { + await expect( + query({ + query: listAllContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterState: ['CONFIRMED', 'PENDING'], + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listAllContributions: { + contributionCount: 2, + contributionList: expect.arrayContaining([ + expect.objectContaining({ + id: expect.any(Number), + state: 'CONFIRMED', + memo: 'Herzlich Willkommen bei Gradido!', + amount: '1000', + }), + expect.objectContaining({ + id: expect.any(Number), + state: 'PENDING', + memo: 'Test env contribution', + amount: '100', + }), + ]), + }, + }, + }), + ) + }) }) })