From 189f2d3af7239d933dca51b0cce7782d498a0d22 Mon Sep 17 00:00:00 2001 From: Xiao Yijun Date: Wed, 31 May 2023 20:03:08 +0800 Subject: [PATCH] chore(test): use fake time in webhook unit tests (#3933) --- packages/core/src/libraries/hook/index.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core/src/libraries/hook/index.test.ts b/packages/core/src/libraries/hook/index.test.ts index 9c2dc3b94..977e69bf8 100644 --- a/packages/core/src/libraries/hook/index.test.ts +++ b/packages/core/src/libraries/hook/index.test.ts @@ -135,6 +135,8 @@ describe('testHook', () => { }); it('should call sendWebhookRequest with correct values', async () => { + jest.useFakeTimers().setSystemTime(100_000); + await testHook(hook.id, [HookEvent.PostSignIn], hook.config); const testHookPayload = generateHookTestPayload(hook.id, HookEvent.PostSignIn); expect(sendWebhookRequest).toHaveBeenCalledWith({ @@ -142,6 +144,8 @@ describe('testHook', () => { payload: testHookPayload, signingKey: hook.signingKey, }); + + jest.useRealTimers(); }); it('should call sendWebhookRequest with correct times if multiple events are provided', async () => {