forked from Lilly-Protocol/lily-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnot-found.test.ts
More file actions
26 lines (20 loc) · 916 Bytes
/
Copy pathnot-found.test.ts
File metadata and controls
26 lines (20 loc) · 916 Bytes
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
import request from "supertest";
import { describe, expect, it } from "vitest";
import { createApp } from "../src/app";
describe("not found handler", () => {
const app = createApp();
it("returns 404 with method and path for unknown routes under /api/v1", async () => {
const response = await request(app).get("/api/v1/nope");
expect(response.status).toBe(404);
expect(response.body.success).toBe(false);
expect(response.body.message).toContain("GET");
expect(response.body.message).toContain("/api/v1/nope");
});
it("returns 404 with method and path for unknown routes outside the API prefix", async () => {
const response = await request(app).post("/unknown-path");
expect(response.status).toBe(404);
expect(response.body.success).toBe(false);
expect(response.body.message).toContain("POST");
expect(response.body.message).toContain("/unknown-path");
});
});