forked from Lilly-Protocol/lily-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-versioning-strategy.test.ts
More file actions
35 lines (29 loc) · 1.2 KB
/
Copy pathapi-versioning-strategy.test.ts
File metadata and controls
35 lines (29 loc) · 1.2 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
35
import { describe, it, expect } from "vitest";
import request from "supertest";
import { createApp } from "../src/app";
describe("API versioning strategy (issue #118)", () => {
const app = createApp();
it("should serve all endpoints under /api/v1 prefix", async () => {
const healthRes = await request(app).get("/api/v1/health");
expect(healthRes.status).toBe(200);
expect(healthRes.body.success).toBe(true);
const agentsRes = await request(app).get("/api/v1/agents");
expect(agentsRes.status).toBe(200);
expect(agentsRes.body.success).toBe(true);
});
it("should return 404 for unversioned API paths", async () => {
const res = await request(app).get("/api/health");
expect(res.status).toBe(404);
expect(res.body.success).toBe(false);
});
it("should return 404 for future version paths not yet implemented", async () => {
const res = await request(app).get("/api/v2/health");
expect(res.status).toBe(404);
expect(res.body.success).toBe(false);
});
it("should document the current API version in root endpoint", async () => {
const res = await request(app).get("/");
expect(res.status).toBe(200);
expect(res.body.docs).toContain("/api/v1/");
});
});