From 1b31d09278abdb30f74db3cb1c2635e2ad950c23 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 13 Dec 2022 20:42:20 +0100 Subject: [PATCH] add tests for semaphore --- .../resolver/TransactionResolver.test.ts | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/backend/src/graphql/resolver/TransactionResolver.test.ts b/backend/src/graphql/resolver/TransactionResolver.test.ts index 1d4fe5708..69673d47c 100644 --- a/backend/src/graphql/resolver/TransactionResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionResolver.test.ts @@ -368,5 +368,74 @@ describe('send coins', () => { ) }) }) + + describe('more transactions to test semaphore', () => { + it('sends the coins four times in a row', async () => { + await expect( + mutate({ + mutation: sendCoins, + variables: { + email: 'peter@lustig.de', + amount: 50, + memo: 'first transaction', + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + sendCoins: 'true', + }, + }), + ) + await expect( + mutate({ + mutation: sendCoins, + variables: { + email: 'peter@lustig.de', + amount: 50, + memo: 'second transaction', + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + sendCoins: 'true', + }, + }), + ) + await expect( + mutate({ + mutation: sendCoins, + variables: { + email: 'peter@lustig.de', + amount: 50, + memo: 'third transaction', + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + sendCoins: 'true', + }, + }), + ) + await expect( + mutate({ + mutation: sendCoins, + variables: { + email: 'peter@lustig.de', + amount: 50, + memo: 'fourth transaction', + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + sendCoins: 'true', + }, + }), + ) + }) + }) }) })