-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler-index-html.spec.ts
29 lines (24 loc) · 1.33 KB
/
handler-index-html.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import {APIGatewayProxyEvent} from "aws-lambda";
import {IndexHtmlHandler} from "./handler-index-html";
describe("Index HTML Handler canHandleThis", () => {
const staticContentHandler = new IndexHtmlHandler();
it("should return true for '/' or '/index.html' paths", () => {
expect(staticContentHandler.canHandleThis({path: "/"} as APIGatewayProxyEvent)).toEqual(true);
expect(staticContentHandler.canHandleThis({path: "/index.html"} as APIGatewayProxyEvent)).toEqual(true);
});
it("should return false for other paths", () => {
expect(staticContentHandler.canHandleThis({path: "/other"} as APIGatewayProxyEvent)).toEqual(false);
expect(staticContentHandler.canHandleThis({path: "/services/test.json"} as APIGatewayProxyEvent)).toEqual(false);
});
});
describe("Index HTML Handler handle", () => {
const staticContentHandler = new IndexHtmlHandler();
it("should return 200 response with index.html base64 data", async () => {
const response = await staticContentHandler.handle({path: "/"} as APIGatewayProxyEvent);
expect(response.statusCode).toEqual(200);
expect(response.isBase64Encoded).toEqual(false);
expect(response.headers).toEqual({"Content-Type": "text/html"});
const text = response.body;
expect(text).toContain("AWS Lambda App");
});
});