diff --git a/packages/backend/test/misc/FakeInternalEventService.ts b/packages/backend/test/misc/MockInternalEventService.ts similarity index 89% rename from packages/backend/test/misc/FakeInternalEventService.ts rename to packages/backend/test/misc/MockInternalEventService.ts index d18a080eaf..8dc40a6503 100644 --- a/packages/backend/test/misc/FakeInternalEventService.ts +++ b/packages/backend/test/misc/MockInternalEventService.ts @@ -3,11 +3,14 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import { Injectable } from '@nestjs/common'; import type { Listener, ListenerProps } from '@/core/InternalEventService.js'; import type Redis from 'ioredis'; import type { GlobalEventService, InternalEventTypes } from '@/core/GlobalEventService.js'; import { InternalEventService } from '@/core/InternalEventService.js'; import { bindThis } from '@/decorators.js'; +import type { Config } from '@/config.js'; +import { MockRedis } from './MockRedis.js'; type FakeCall = [K, Parameters]; type FakeListener = [K, Listener, ListenerProps]; @@ -17,7 +20,8 @@ type FakeListener = [K, Listener, Listene * There is no redis connection, and metadata is tracked in the public _calls and _listeners arrays. * The on/off/emit methods are fully functional and can be called in tests to invoke any registered listeners. */ -export class FakeInternalEventService extends InternalEventService { +@Injectable() +export class MockInternalEventService extends InternalEventService { /** * List of calls to public methods, in chronological order. */ @@ -45,11 +49,11 @@ export class FakeInternalEventService extends InternalEventService { await this.emit(type, value, false); } - constructor() { - super( - { on: () => {} } as unknown as Redis.Redis, - {} as unknown as GlobalEventService, - ); + constructor( + config?: Pick, + ) { + const redis = new MockRedis(); + super(redis, redis, config ?? { host: 'example.com' }); } @bindThis