Skip to content

Commit ec1ede1

Browse files
authored
Merge branch 'master' into refactor/interface-naming
2 parents 51fc5cc + bc3bd7b commit ec1ede1

File tree

6 files changed

+76
-4
lines changed

6 files changed

+76
-4
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,13 @@ See [LICENSE](LICENSE) for full details.
257257

258258
[![Steffen Leistner][sleistner_avatar]][sleistner_homepage]
259259

260+
[![Martin Pirkl][pirklmar_avatar]][pirklmar_homepage]
261+
260262

261263
[sleistner_homepage]: https://github.com/sleistner
262264
[sleistner_avatar]: https://res.cloudinary.com/enter-at/image/fetch/f_png,r_max,w_100,h_100,c_thumb/https://github.com/sleistner.png
265+
[pirklmar_homepage]: https://github.com/pirklmar
266+
[pirklmar_avatar]: https://res.cloudinary.com/enter-at/image/fetch/f_png,r_max,w_100,h_100,c_thumb/https://github.com/pirklmar.png
263267

264268

265269

README.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,5 @@ include:
6565
contributors:
6666
- name: "Steffen Leistner"
6767
github: "sleistner"
68+
- name: "Martin Pirkl"
69+
github: "pirklmar"

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
"Typescript"
3131
],
3232
"author": "Steffen Leistner",
33+
"contributors": [
34+
"Martin Pirkl <[email protected]>"
35+
],
3336
"license": "Apache-2.0",
3437
"bugs": {
3538
"url": "https://github.com/enter-at/node-aws-lambda-handlers/issues"
@@ -43,8 +46,8 @@
4346
"@types/faker": "4.1.12",
4447
"@types/jest": "26.0.5",
4548
"aws-lambda": "1.0.6",
46-
"aws-sdk": "2.717.0",
4749
"eslint": "^7.5.0",
50+
"aws-sdk": "2.718.0",
4851
"faker": "4.1.0",
4952
"husky": "4.2.5",
5053
"jest": "26.1.0",

src/handler/APIGatewayProxyHandler.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
BadRequestError,
1111
UnauthorizedError,
1212
} from "../error";
13+
import { ok, created, noContent } from '../response'
1314
import * as ContextFactory from "../../test/fixtures/ContextFactory";
1415
import * as APIGatewayProxyEventFactory from "../../test/fixtures/APIGatewayProxyEventFactory";
1516

@@ -24,6 +25,33 @@ describe(APIGatewayProxyHandler.name, () => {
2425
event = APIGatewayProxyEventFactory.factory();
2526
});
2627

28+
it("handles HTTP 200 response correctly", async () => {
29+
const fn = handler.wrapper(() => {
30+
return ok({ result: "HTTP 200" })
31+
}) as Handler<APIGatewayProxyEvent, APIGatewayProxyResult>;
32+
33+
const result = await fn(event, context, () => {});
34+
expect(result).toMatchSnapshot();
35+
});
36+
37+
it("handles HTTP 201 response correctly", async () => {
38+
const fn = handler.wrapper(() => {
39+
return created({ result: "HTTP 201" })
40+
}) as Handler<APIGatewayProxyEvent, APIGatewayProxyResult>;
41+
42+
const result = await fn(event, context, () => {});
43+
expect(result).toMatchSnapshot();
44+
});
45+
46+
it("handles HTTP 204 response correctly", async () => {
47+
const fn = handler.wrapper(() => {
48+
return noContent()
49+
}) as Handler<APIGatewayProxyEvent, APIGatewayProxyResult>;
50+
51+
const result = await fn(event, context, () => {});
52+
expect(result).toMatchSnapshot();
53+
});
54+
2755
it("handles BadRequestError response correctly", async () => {
2856
const fn = handler.wrapper(() => {
2957
throw new BadRequestError("BadRequestError message");

src/handler/__snapshots__/APIGatewayProxyHandler.spec.ts.snap

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,41 @@ Object {
3636
}
3737
`;
3838

39+
exports[`APIGatewayProxyHandler handles HTTP 200 response correctly 1`] = `
40+
Object {
41+
"body": "{\\"result\\":\\"HTTP 200\\"}",
42+
"headers": Object {
43+
"Access-Control-Allow-Credentials": true,
44+
"Access-Control-Allow-Origin": "*",
45+
"Content-Type": "application/json",
46+
},
47+
"statusCode": 200,
48+
}
49+
`;
50+
51+
exports[`APIGatewayProxyHandler handles HTTP 201 response correctly 1`] = `
52+
Object {
53+
"body": "{\\"result\\":\\"HTTP 201\\"}",
54+
"headers": Object {
55+
"Access-Control-Allow-Credentials": true,
56+
"Access-Control-Allow-Origin": "*",
57+
"Content-Type": "application/json",
58+
},
59+
"statusCode": 201,
60+
}
61+
`;
62+
63+
exports[`APIGatewayProxyHandler handles HTTP 204 response correctly 1`] = `
64+
Object {
65+
"headers": Object {
66+
"Access-Control-Allow-Credentials": true,
67+
"Access-Control-Allow-Origin": "*",
68+
"Content-Type": "application/json",
69+
},
70+
"statusCode": 204,
71+
}
72+
`;
73+
3974
exports[`APIGatewayProxyHandler handles InternalServerError response correctly 1`] = `
4075
Object {
4176
"body": "{\\"errors\\":[{\\"name\\":\\"InternalServerError\\",\\"details\\":\\"InternalServerError\\"}]}",

0 commit comments

Comments
 (0)