arrow-express
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -203,4 +203,6 @@ import Express from "express"; | ||
it("should pass context through controllers chain", async () => { | ||
const rootSpy = jest.fn().mockResolvedValue("root") as ControllerHandler<any>; | ||
const spy = jest.fn().mockImplementation((_, __, context) => context + "-child") as ControllerHandler<any>; | ||
const rootSpy = jest.fn().mockResolvedValue("root-context") as ControllerHandler<any>; | ||
const spy = jest | ||
.fn() | ||
.mockImplementation((_, __, context) => context + "-child-context") as ControllerHandler<any>; | ||
const routeSpy = jest.fn(); | ||
@@ -215,5 +217,19 @@ Application({ app: ExpressAppStub, logRequests: false }) | ||
await mocked(ExpressAppStub.get).mock.calls[0][1]({} as never, resSpy); | ||
expect(routeSpy).toHaveBeenCalledWith(expect.anything(), expect.anything(), "root-child"); | ||
expect(routeSpy).toHaveBeenCalledWith(expect.anything(), expect.anything(), "root-context-child-context"); | ||
}); | ||
it("should pass context through controllers chain if child controllers doesn't have context", async () => { | ||
const rootSpy = jest.fn().mockResolvedValue("root-context") as ControllerHandler<any>; | ||
const routeSpy = jest.fn(); | ||
Application({ app: ExpressAppStub, logRequests: false }) | ||
.registerController( | ||
Controller() | ||
.handler(rootSpy) | ||
.registerController(Controller().registerRoute(Route().method("get").handler(routeSpy))) | ||
) | ||
.configure(false); | ||
await mocked(ExpressAppStub.get).mock.calls[0][1]({} as never, resSpy); | ||
expect(routeSpy).toHaveBeenCalledWith(expect.anything(), expect.anything(), "root-context"); | ||
}); | ||
it("should call controller handler", async () => { | ||
@@ -220,0 +236,0 @@ const spy = jest.fn().mockRejectedValue(new Error()) as ControllerHandler<any>; |
{ | ||
"name": "arrow-express", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Library to bootstrap express applications with zero configuration", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
797223
15815