From 7574fda8bfa1de771611016056b2b0db0a4c6fd0 Mon Sep 17 00:00:00 2001 From: Haider Ali Date: Sat, 13 Jan 2024 23:10:05 +0500 Subject: [PATCH] Adding Tests These tests will ensure serving and transformation of .html and .htm files when request explicitly includes filenames. --- tests/env/dist/main.htm | 12 ++++++++++++ tests/env/main.htm | 12 ++++++++++++ tests/server.test.ts | 8 ++++++++ 3 files changed, 32 insertions(+) create mode 100644 tests/env/dist/main.htm create mode 100644 tests/env/main.htm diff --git a/tests/env/dist/main.htm b/tests/env/dist/main.htm new file mode 100644 index 0000000..e6bce70 --- /dev/null +++ b/tests/env/dist/main.htm @@ -0,0 +1,12 @@ + + + + + + + Document + + +

main

+ + diff --git a/tests/env/main.htm b/tests/env/main.htm new file mode 100644 index 0000000..e6bce70 --- /dev/null +++ b/tests/env/main.htm @@ -0,0 +1,12 @@ + + + + + + + Document + + +

main

+ + diff --git a/tests/server.test.ts b/tests/server.test.ts index ea0522a..725ea01 100644 --- a/tests/server.test.ts +++ b/tests/server.test.ts @@ -32,6 +32,10 @@ test("Express app", async (done) => { expect(response.text).toMatch(/

index<\/h1>/); response = await request(app).get("/route"); expect(response.text).toMatch(/

index<\/h1>/); + response = await request(app).get("/index.html"); + expect(response.text).toMatch(/

index<\/h1>/); + response = await request(app).get("/main.htm"); + expect(response.text).toMatch(/

main<\/h1>/); it("html is served correctly"); @@ -247,6 +251,10 @@ test("Express app with transformer function", async (done) => { it("html is served correctly"); + expect(response.text).toMatch(//); + response = await request(app).get("/index.html"); + expect(response.text).toMatch(//); + response = await request(app).get("/main.htm"); expect(response.text).toMatch(//); it("html is transformed correctly");