Skip to content

Commit

Permalink
test(clerk-js): Update tests to use jest.now()
Browse files Browse the repository at this point in the history
  • Loading branch information
octoper committed Oct 23, 2023
1 parent 57ddb13 commit 91c35c6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/clerk-js/src/core/tokenCache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<TokenResource>(resolve => setTimeout(() => resolve(token), 100));
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 91c35c6

Please sign in to comment.