test: cover 400 validation branches in request API
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,26 @@ describe("requests API", () => {
|
|||||||
expect(res.status).toBe(400);
|
expect(res.status).toBe(400);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("rejects a malformed JSON body", async () => {
|
||||||
|
const req = new Request("http://localhost/api/requests", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "content-type": "application/json" },
|
||||||
|
body: "{not json",
|
||||||
|
});
|
||||||
|
const res = await POST(req);
|
||||||
|
expect(res.status).toBe(400);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("rejects an empty/whitespace-only artist", async () => {
|
||||||
|
const res = await POST(postReq({ artist: " ", album: "X" }));
|
||||||
|
expect(res.status).toBe(400);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("rejects a non-string artist field", async () => {
|
||||||
|
const res = await POST(postReq({ artist: 123, album: "X" }));
|
||||||
|
expect(res.status).toBe(400);
|
||||||
|
});
|
||||||
|
|
||||||
it("lists requests newest first with job state", async () => {
|
it("lists requests newest first with job state", async () => {
|
||||||
await POST(postReq({ artist: "A", album: "1" }));
|
await POST(postReq({ artist: "A", album: "1" }));
|
||||||
await POST(postReq({ artist: "B", album: "2" }));
|
await POST(postReq({ artist: "B", album: "2" }));
|
||||||
|
|||||||
Reference in New Issue
Block a user