rename MockInternalEventService methods to match other utilities
This commit is contained in:
parent
a1ef776f6f
commit
acf29ff40b
2 changed files with 10 additions and 11 deletions
|
|
@ -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 extends keyof InternalEventService> = [K, Parameters<InternalEventService[K]>];
|
||||
type FakeListener<K extends keyof InternalEventTypes> = [K, Listener<K>, 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<K extends keyof InternalEventTypes>(type: K, value: InternalEventTypes[K]): Promise<void> {
|
||||
public async mockEmit<K extends keyof InternalEventTypes>(type: K, value: InternalEventTypes[K]): Promise<void> {
|
||||
await this.emit(type, value, false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ describe(QuantumKVCache, () => {
|
|||
const cache = makeCache<string>({ 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<string>({ 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']]);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue