Skip to content

Commit 2aaa32f

Browse files
committed
Add another test case to handler
1 parent 1b8d410 commit 2aaa32f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/utils/handler.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,24 @@ describe("wrap", () => {
205205
expect(result).toEqual({ statusCode: 204, body: "The callback response" });
206206
expect(calledOriginalHandler).toBeFalsy();
207207
});
208+
209+
it("doesn't complete using non-promise return values", async () => {
210+
const handler: Handler = (event, context, callback) => {
211+
setTimeout(() => {
212+
callback(null, { statusCode: 204, body: "The callback response" });
213+
}, 10);
214+
return ({ statusCode: 200, body: "The promise response" } as unknown) as void;
215+
};
216+
217+
let calledOriginalHandler = false;
218+
219+
const wrappedHandler = wrap(handler, () => {}, async () => {});
220+
221+
const result = await wrappedHandler({}, mockContext, () => {
222+
calledOriginalHandler = true;
223+
});
224+
225+
expect(result).toEqual({ statusCode: 204, body: "The callback response" });
226+
expect(calledOriginalHandler).toBeFalsy();
227+
});
208228
});

0 commit comments

Comments
 (0)