forked from Lilly-Protocol/lily-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethod-not-allowed.test.ts
More file actions
34 lines (30 loc) · 1.09 KB
/
Copy pathmethod-not-allowed.test.ts
File metadata and controls
34 lines (30 loc) · 1.09 KB
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
30
31
32
33
34
import { describe, expect, it } from 'vitest';
import request from "supertest";
import { createApp } from "../src/app";
describe("Method Not Allowed (405)", () => {
const app = createApp();
it("returns 405 when POST is used on GET-only /api/v1/health", async () => {
const res = await request(app).post("/api/v1/health");
expect(res.status).toBe(405);
expect(res.body).toMatchObject({
success: false,
message: expect.stringContaining("Method POST not allowed"),
});
});
it("returns 405 when PUT is used on GET/POST /api/v1/agents", async () => {
const res = await request(app).put("/api/v1/agents");
expect(res.status).toBe(405);
expect(res.body).toMatchObject({
success: false,
message: expect.stringContaining("Method PUT not allowed"),
});
});
it("still returns 404 for completely unknown paths", async () => {
const res = await request(app).get("/api/v1/nonexistent");
expect(res.status).toBe(404);
expect(res.body).toMatchObject({
success: false,
message: expect.stringContaining("Route not found"),
});
});
});