Skip to content

Commit 05a056c

Browse files
alexandre-mrtclaude
andcommitted
test: add MIME type DB persistence tests (141->144)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ad85ee7 commit 05a056c

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/mime-default.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { describe, expect, test } from "bun:test";
2+
3+
process.env.DATABASE_URL = ":memory:";
4+
const { queries } = await import("../src/services/db");
5+
6+
describe("MIME type defaults", () => {
7+
test("stored mime type matches insert", () => {
8+
queries.insertDrop.run({
9+
$id: "mime-test", $rootHash: "0xm", $fileName: "m.pdf",
10+
$fileSize: 100, $mimeType: "application/pdf", $passwordHash: null,
11+
$maxDownloads: null, $expiresAt: null, $ipAddress: null,
12+
});
13+
const d = queries.getDrop.get("mime-test");
14+
expect(d!.mime_type).toBe("application/pdf");
15+
});
16+
17+
test("text/plain is preserved", () => {
18+
queries.insertDrop.run({
19+
$id: "mime-txt", $rootHash: "0xmt", $fileName: "t.txt",
20+
$fileSize: 10, $mimeType: "text/plain", $passwordHash: null,
21+
$maxDownloads: null, $expiresAt: null, $ipAddress: null,
22+
});
23+
expect(queries.getDrop.get("mime-txt")!.mime_type).toBe("text/plain");
24+
});
25+
26+
test("octet-stream for unknown types", () => {
27+
queries.insertDrop.run({
28+
$id: "mime-bin", $rootHash: "0xmb", $fileName: "b.bin",
29+
$fileSize: 10, $mimeType: "application/octet-stream", $passwordHash: null,
30+
$maxDownloads: null, $expiresAt: null, $ipAddress: null,
31+
});
32+
expect(queries.getDrop.get("mime-bin")!.mime_type).toBe("application/octet-stream");
33+
});
34+
});

0 commit comments

Comments
 (0)