diff --git a/packages/third-parties/terminus/src/TerminusModule.spec.ts b/packages/third-parties/terminus/src/TerminusModule.spec.ts index b4306e70368..4ddba144e07 100644 --- a/packages/third-parties/terminus/src/TerminusModule.spec.ts +++ b/packages/third-parties/terminus/src/TerminusModule.spec.ts @@ -13,6 +13,8 @@ class MyService { redis() { return Promise.resolve("OK"); } + + $beforeShutdown() {} } describe("TerminusModule", () => { @@ -71,4 +73,17 @@ describe("TerminusModule", () => { await props.onSignal(); }); + + it("should emit event", async () => { + const terminusModule = PlatformTest.get(TerminusModule); + const service = PlatformTest.get(MyService); + + jest.spyOn(service, "$beforeShutdown"); + + const {beforeShutdown} = terminusModule.getConfiguration(); + + await beforeShutdown(); + + expect(service.$beforeShutdown).toHaveBeenCalledWith(); + }); }); diff --git a/packages/third-parties/terminus/src/TerminusModule.ts b/packages/third-parties/terminus/src/TerminusModule.ts index bf52c488243..c08081d5e9f 100644 --- a/packages/third-parties/terminus/src/TerminusModule.ts +++ b/packages/third-parties/terminus/src/TerminusModule.ts @@ -143,7 +143,7 @@ export class TerminusModule implements OnInit { private createEmitter(name: string) { return async (...args: any[]) => { - return this.injector.emit(`$${name}`, ...args); + return this.injector.emit(name, ...args); }; } }