From 91c35c6c05cfd16cbe63773291c8bc3780108e7d Mon Sep 17 00:00:00 2001 From: Vaggelis Yfantis Date: Fri, 20 Oct 2023 02:56:48 +0300 Subject: [PATCH] test(clerk-js): Update tests to use jest.now() --- packages/clerk-js/src/core/tokenCache.test.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/clerk-js/src/core/tokenCache.test.ts b/packages/clerk-js/src/core/tokenCache.test.ts index 3ab86e3f8a..9447a3f17f 100644 --- a/packages/clerk-js/src/core/tokenCache.test.ts +++ b/packages/clerk-js/src/core/tokenCache.test.ts @@ -14,6 +14,7 @@ jest.mock('./resources/Base', () => { const mockJwtToken = (now: number): string => { const nowInSeconds = Math.floor(now / 1000); + const payload = { iat: nowInSeconds, exp: nowInSeconds + 60, @@ -47,7 +48,7 @@ describe('MemoryTokenCache', () => { const token = new Token({ object: 'token', id: 'foo', - jwt: mockJwtToken(Date.now()), + jwt: mockJwtToken(jest.now()), }); const tokenResolver = new Promise(resolve => setTimeout(() => resolve(token), 100)); @@ -74,7 +75,7 @@ describe('MemoryTokenCache', () => { const token = new Token({ object: 'token', id: 'foo', - jwt: mockJwtToken(Date.now()), + jwt: mockJwtToken(jest.now()), }); let isResolved = false; @@ -130,7 +131,7 @@ describe('MemoryTokenCache', () => { const token = new Token({ object: 'token', id: 'foo', - jwt: mockJwtToken(Date.now()), + jwt: mockJwtToken(jest.now()), }); const tokenResolver = Promise.resolve(token); @@ -155,7 +156,7 @@ describe('MemoryTokenCache', () => { const token = new Token({ object: 'token', id: 'foo', - jwt: mockJwtToken(Date.now()), + jwt: mockJwtToken(jest.now()), }); const tokenResolver = Promise.resolve(token);