Skip to content

Commit

Permalink
Tests for non existing indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
elturpin committed Oct 27, 2023
1 parent 6a4e74a commit 9e11bc1
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ test("Express app", async (done) => {

it("subpath html is served correctly");

response = await request(app).get("/nopath/");
expect(response.status).toBe(404);
response = await request(app).get("/nopath/route");
expect(response.status).toBe(404);

it("no existing indexes response with 404");

response = await request(app).get("/test.txt");
expect(response.text).toBe("Hello from test.txt");

Expand Down Expand Up @@ -103,6 +110,13 @@ test("Express app with explicit static middleware", async (done) => {
expect(response.headers.before).toBe("1");
expect(response.headers.after).toBe("1");

response = await request(app).get("/nopath/");
expect(response.status).toBe(404);
response = await request(app).get("/nopath/route");
expect(response.status).toBe(404);

it("no existing indexes response with 404");

response = await request(app).get("/test.txt");
expect(response.text).toBe("Hello from test.txt");

Expand Down Expand Up @@ -157,6 +171,13 @@ test("Express app with custom http server", async (done) => {

it("subpath html is served correctly");

response = await request(app).get("/nopath/");
expect(response.status).toBe(404);
response = await request(app).get("/nopath/route");
expect(response.status).toBe(404);

it("no existing indexes response with 404");

response = await request(app).get("/test.txt");
expect(response.text).toBe("Hello from test.txt");

Expand Down Expand Up @@ -241,6 +262,13 @@ test("Express app with transformer function", async (done) => {

it("subpath html is transformed correctly");

response = await request(app).get("/nopath/");
expect(response.status).toBe(404);
response = await request(app).get("/nopath/route");
expect(response.status).toBe(404);

it("no existing indexes response with 404");

response = await request(app).get("/test.txt");
expect(response.text).toBe("Hello from test.txt");

Expand Down Expand Up @@ -275,6 +303,13 @@ test("Express app with ignored paths", async (done) => {

it("subpath html is served correctly");

response = await request(app).get("/nopath/");
expect(response.status).toBe(404);
response = await request(app).get("/nopath/route");
expect(response.status).toBe(404);

it("no existing indexes response with 404");

response = await request(app).get("/ignored");
expect(response.text).toMatch(/Cannot GET \/ignored/);

Expand Down

0 comments on commit 9e11bc1

Please sign in to comment.