diff --git a/packages/backend/src/core/TimeService.ts b/packages/backend/src/core/TimeService.ts index b71836399c..7281d04d55 100644 --- a/packages/backend/src/core/TimeService.ts +++ b/packages/backend/src/core/TimeService.ts @@ -10,9 +10,12 @@ import { bindThis } from '@/decorators.js'; * Provides abstractions to access the current time. * Exists for unit testing purposes, so that tests can "simulate" any given time for consistency. */ +@Injectable() export abstract class TimeService implements OnApplicationShutdown { protected readonly timers = new Map(); + protected constructor() {} + /** * Returns Date.now() */ @@ -91,6 +94,10 @@ export class NativeTimeService extends TimeService implements OnApp return Date.now(); } + public constructor() { + super(); + } + protected startNativeTimer(timerId: symbol, repeating: boolean, callback: () => void, delay: number): NativeTimer { // Wrap the caller's callback to make sure we clean up the registration. const wrappedCallback = () => { diff --git a/packages/backend/test/misc/GodOfTimeService.ts b/packages/backend/test/misc/GodOfTimeService.ts index f58dc7a58d..584f4bdefd 100644 --- a/packages/backend/test/misc/GodOfTimeService.ts +++ b/packages/backend/test/misc/GodOfTimeService.ts @@ -17,15 +17,8 @@ import { TimeService, Timer } from '@/core/TimeService.js'; export class GodOfTimeService extends TimeService { private _now = 0; - constructor(opts?: { start?: { at: number } | 'now' }) { + constructor() { super(); - - // Jump to the correct start time - if (opts?.start === 'now') { - this.resetToNow(); - } else if (opts?.start?.at) { - this.resetTo(opts.start.at); - } } /**