|
|
@ -2,12 +2,9 @@ import { ExitCode, InternalService, Microservice, MicroserviceState } from "../. |
|
|
|
|
|
|
|
class MockService<M extends Microservice> extends InternalService<M> { |
|
|
|
public NAME = "Mock Service"; |
|
|
|
public hasBooted = false; |
|
|
|
public hasStarted = false; |
|
|
|
public hasShutdown = false; |
|
|
|
public override async boot() { this.hasBooted = true; } |
|
|
|
public override async start() { this.hasStarted = true; } |
|
|
|
public override async shutdown() { this.hasShutdown = true; } |
|
|
|
public override boot = jest.fn(); |
|
|
|
public override start = jest.fn(); |
|
|
|
public override shutdown = jest.fn(); |
|
|
|
} |
|
|
|
|
|
|
|
class MockServiceBootFail<M extends Microservice> extends InternalService<M> { |
|
|
@ -38,9 +35,9 @@ describe("Microservice/Internal Service Integration", () => { |
|
|
|
let executing = microservice.exec(); |
|
|
|
microservice.on("ready", () => microservice.quit()); |
|
|
|
await executing; |
|
|
|
expect(microservice.service(MockService).hasBooted).toBe(true); |
|
|
|
expect(microservice.service(MockService).hasStarted).toBe(true); |
|
|
|
expect(microservice.service(MockService).hasShutdown).toBe(true); |
|
|
|
expect(microservice.service(MockService).boot).toHaveBeenCalled(); |
|
|
|
expect(microservice.service(MockService).start).toHaveBeenCalled(); |
|
|
|
expect(microservice.service(MockService).shutdown).toHaveBeenCalled(); |
|
|
|
}); |
|
|
|
test("Trigger boot failure", async () => { |
|
|
|
let microservice = new Microservice(); |
|
|
|