Skip to content

Commit

Permalink
fix(terminus): fix events emitted by terminus
Browse files Browse the repository at this point in the history
Closes: #2086
  • Loading branch information
Romakita committed Sep 15, 2022
1 parent 70a88fe commit 7cdc748
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions packages/third-parties/terminus/src/TerminusModule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class MyService {
redis() {
return Promise.resolve("OK");
}

$beforeShutdown() {}
}

describe("TerminusModule", () => {
Expand Down Expand Up @@ -71,4 +73,17 @@ describe("TerminusModule", () => {

await props.onSignal();
});

it("should emit event", async () => {
const terminusModule = PlatformTest.get<TerminusModule>(TerminusModule);
const service = PlatformTest.get<MyService>(MyService);

jest.spyOn(service, "$beforeShutdown");

const {beforeShutdown} = terminusModule.getConfiguration();

await beforeShutdown();

expect(service.$beforeShutdown).toHaveBeenCalledWith();
});
});
2 changes: 1 addition & 1 deletion packages/third-parties/terminus/src/TerminusModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
}
}

0 comments on commit 7cdc748

Please sign in to comment.