From acf29ff40bdad1a59d981de3e672989f5abac947 Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Thu, 2 Oct 2025 15:34:40 -0400 Subject: [PATCH] rename MockInternalEventService methods to match other utilities --- .../backend/test/misc/MockInternalEventService.ts | 11 +++++------ packages/backend/test/unit/misc/QuantumKVCache.ts | 10 +++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/backend/test/misc/MockInternalEventService.ts b/packages/backend/test/misc/MockInternalEventService.ts index 8dc40a6503..24e5be62a4 100644 --- a/packages/backend/test/misc/MockInternalEventService.ts +++ b/packages/backend/test/misc/MockInternalEventService.ts @@ -4,13 +4,12 @@ */ import { Injectable } from '@nestjs/common'; +import { MockRedis } from './MockRedis.js'; import type { Listener, ListenerProps } from '@/core/InternalEventService.js'; -import type Redis from 'ioredis'; -import type { GlobalEventService, InternalEventTypes } from '@/core/GlobalEventService.js'; +import type { InternalEventTypes } from '@/core/GlobalEventService.js'; +import type { Config } from '@/config.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]; @@ -36,7 +35,7 @@ export class MockInternalEventService extends InternalEventService { * Resets the mock. * Clears all listeners and tracked calls. */ - public _reset() { + public mockReset() { this._calls = []; this._listeners = []; } @@ -45,7 +44,7 @@ export class MockInternalEventService extends InternalEventService { * Simulates a remote event sent from another process in the cluster via redis. */ @bindThis - public async _emitRedis(type: K, value: InternalEventTypes[K]): Promise { + public async mockEmit(type: K, value: InternalEventTypes[K]): Promise { await this.emit(type, value, false); } diff --git a/packages/backend/test/unit/misc/QuantumKVCache.ts b/packages/backend/test/unit/misc/QuantumKVCache.ts index 4475bfb97d..ffc03dea52 100644 --- a/packages/backend/test/unit/misc/QuantumKVCache.ts +++ b/packages/backend/test/unit/misc/QuantumKVCache.ts @@ -201,7 +201,7 @@ describe(QuantumKVCache, () => { const cache = makeCache({ name: 'fake' }); await cache.set('foo', 'bar'); - await fakeInternalEventService._emitRedis('quantumCacheUpdated', { name: 'fake', keys: ['foo'] }); + await fakeInternalEventService.mockEmit('quantumCacheUpdated', { name: 'fake', keys: ['foo'] }); const result = cache.has('foo'); expect(result).toBe(false); @@ -214,7 +214,7 @@ describe(QuantumKVCache, () => { onChanged: fakeOnChanged, }); - await fakeInternalEventService._emitRedis('quantumCacheUpdated', { name: 'fake', keys: ['foo'] }); + await fakeInternalEventService.mockEmit('quantumCacheUpdated', { name: 'fake', keys: ['foo'] }); expect(fakeOnChanged).toHaveBeenCalledWith(['foo'], cache); }); @@ -223,7 +223,7 @@ describe(QuantumKVCache, () => { const cache = makeCache({ name: 'fake' }); await cache.set('foo', 'bar'); - await fakeInternalEventService._emitRedis('quantumCacheUpdated', { name: 'fake', keys: ['foo'] }); + await fakeInternalEventService.mockEmit('quantumCacheUpdated', { name: 'fake', keys: ['foo'] }); const result = cache.has('foo'); expect(result).toBe(false); @@ -237,7 +237,7 @@ describe(QuantumKVCache, () => { }); await cache.set('foo', 'bar'); - await fakeInternalEventService._emitRedis('quantumCacheUpdated', { name: 'fake', keys: ['foo'] }); + await fakeInternalEventService.mockEmit('quantumCacheUpdated', { name: 'fake', keys: ['foo'] }); expect(fakeOnChanged).toHaveBeenCalledWith(['foo'], cache); }); @@ -303,7 +303,7 @@ describe(QuantumKVCache, () => { await cache.set('foo', 'bar'); fakeOnChanged.mockClear(); - fakeInternalEventService._reset(); + fakeInternalEventService.mockReset(); await cache.setMany([['foo', 'bar'], ['alpha', 'omega']]);