mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
chore: Update (ts-)jest and use modern fake timers where possible
* chore(deps): update dependency jest to v27 * chore: Update (ts-)jest and use modern fake timers where possible Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Joachim Van Herwegen <joachimvh@gmail.com>
This commit is contained in:
@@ -3,6 +3,9 @@ import { InteractionCompleter } from '../../../../../src/identity/interaction/ut
|
||||
import type { HttpRequest } from '../../../../../src/server/HttpRequest';
|
||||
import type { HttpResponse } from '../../../../../src/server/HttpResponse';
|
||||
|
||||
// Use fixed dates
|
||||
jest.useFakeTimers();
|
||||
|
||||
describe('An InteractionCompleter', (): void => {
|
||||
const request: HttpRequest = {} as any;
|
||||
const response: HttpResponse = {} as any;
|
||||
@@ -11,8 +14,6 @@ describe('An InteractionCompleter', (): void => {
|
||||
const completer = new InteractionCompleter();
|
||||
|
||||
beforeEach(async(): Promise<void> => {
|
||||
const now = Date.now();
|
||||
Date.now = jest.fn().mockReturnValue(now);
|
||||
provider = {
|
||||
interactionFinished: jest.fn(),
|
||||
} as any;
|
||||
|
||||
@@ -3,6 +3,9 @@ import type { ExpiringAdapter } from '../../../../src/identity/storage/ExpiringA
|
||||
import { ExpiringAdapterFactory } from '../../../../src/identity/storage/ExpiringAdapterFactory';
|
||||
import type { ExpiringStorage } from '../../../../src/storage/keyvalue/ExpiringStorage';
|
||||
|
||||
// Use fixed dates
|
||||
jest.useFakeTimers();
|
||||
|
||||
describe('An ExpiringAdapterFactory', (): void => {
|
||||
const storageName = '/storage';
|
||||
const name = 'nnaammee';
|
||||
@@ -12,14 +15,10 @@ describe('An ExpiringAdapterFactory', (): void => {
|
||||
let storage: ExpiringStorage<string, unknown>;
|
||||
let adapter: ExpiringAdapter;
|
||||
let factory: ExpiringAdapterFactory;
|
||||
// Make sure this stays consistent in tests
|
||||
const now = Date.now();
|
||||
const expiresIn = 333;
|
||||
const expireDate = new Date(now + (expiresIn * 1000));
|
||||
const expireDate = new Date(Date.now() + (expiresIn * 1000));
|
||||
|
||||
beforeEach(async(): Promise<void> => {
|
||||
Date.now = jest.fn().mockReturnValue(now);
|
||||
|
||||
payload = { data: 'data!' };
|
||||
|
||||
const map = new Map<string, any>();
|
||||
|
||||
Reference in New Issue
Block a user