Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
refactor: change jaypie function scope
Browse files Browse the repository at this point in the history
  • Loading branch information
nullfame committed Jul 13, 2024
1 parent 909fa93 commit e92c873
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
21 changes: 0 additions & 21 deletions src/__tests__/lambdaHandler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,27 +197,6 @@ describe("Lambda Handler Module", () => {
// Assert
expect(jaypieHandler).not.toHaveBeenCalled();
});
it("Re-uses Jaypie handlers", async () => {
// Arrange
const mockFunction = vi.fn();
// Act
const handler1 = lambdaHandler(mockFunction);
const handler2 = lambdaHandler(mockFunction);
// Assert
expect(jaypieHandler).not.toHaveBeenCalled();
// Act
await handler1();
expect(jaypieHandler).toHaveBeenCalledTimes(1);
// Act
await handler2();
// Assert
expect(jaypieHandler).toHaveBeenCalledTimes(2);
// Act
await handler1();
await handler2();
// Assert
expect(jaypieHandler).toHaveBeenCalledTimes(2);
});
});
});
});
4 changes: 1 addition & 3 deletions src/lambdaHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ const lambdaHandler = (
// Setup
//

let jaypieFunction;

return async (event = {}, context = {}, ...args) => {
if (!name) {
// If handler has a name, use it
Expand Down Expand Up @@ -69,7 +67,7 @@ const lambdaHandler = (
// Preprocess
//

jaypieFunction = jaypieHandler(handler, {
const jaypieFunction = jaypieHandler(handler, {
name,
setup,
teardown,
Expand Down

0 comments on commit e92c873

Please sign in to comment.