From d03a3f601c141d090ecfbb093a2d3255482823cd Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 15 Dec 2022 17:00:35 +0100 Subject: [PATCH] mock semaphore to allow to use jest fake timers --- .../src/graphql/resolver/TransactionLinkResolver.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index 28422af26..9f7d30244 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -23,6 +23,11 @@ import { User } from '@entity/User' import { UnconfirmedContribution } from '@model/UnconfirmedContribution' import Decimal from 'decimal.js-light' import { GraphQLError } from 'graphql' +import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' + +// mock semaphore to allow use fake timers +jest.mock('@/util/TRANSACTIONS_LOCK') +TRANSACTIONS_LOCK.acquire = jest.fn().mockResolvedValue(jest.fn()) let mutate: any, query: any, con: any let testEnv: any @@ -185,8 +190,7 @@ describe('TransactionLinkResolver', () => { describe('after one day', () => { beforeAll(async () => { jest.useFakeTimers() - /* eslint-disable-next-line @typescript-eslint/no-empty-function */ - setTimeout(() => {}, 1000 * 60 * 60 * 24) + setTimeout(jest.fn(), 1000 * 60 * 60 * 24) jest.runAllTimers() await mutate({ mutation: login,