Skip to content

Commit a75190d

Browse files
alexandre-mrtclaude
andcommitted
test: add upload validation shape tests (121 tests)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 535eaa7 commit a75190d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/upload-shape.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { describe, expect, test } from "bun:test";
2+
import { Hono } from "hono";
3+
4+
process.env.DATABASE_URL = ":memory:";
5+
const { dropRouter } = await import("../src/routes/drop");
6+
const app = new Hono();
7+
app.route("/api", dropRouter);
8+
9+
describe("Upload validation shapes", () => {
10+
test("missing file returns error with message", async () => {
11+
const res = await app.request("/api/upload", { method: "POST" });
12+
expect(res.status).toBe(400);
13+
const json = await res.json();
14+
expect(json).toHaveProperty("error");
15+
expect(json.error.length).toBeGreaterThan(5);
16+
});
17+
18+
test("empty file returns specific error", async () => {
19+
const formData = new FormData();
20+
formData.append("file", new File([], "empty.txt"));
21+
const res = await app.request("/api/upload", { method: "POST", body: formData });
22+
expect(res.status).toBe(400);
23+
const json = await res.json();
24+
expect(json.error).toContain("empty");
25+
});
26+
});

0 commit comments

Comments
 (0)