feat: add extensive test suite

This commit is contained in:
2026-08-30 11:33:53 +07:00 Unverified
parent 061cce00dc
commit 8359c7272e
131 changed files with 8717 additions and 2200 deletions
+24
View File
@@ -0,0 +1,24 @@
import { describe, expect, mock, test } from "bun:test";
import { listFilesService } from "./service";
describe("listFilesService", () => {
test("requires admin before querying CDN files", async () => {
const list = mock(async () => []);
expect(
listFilesService({ adminCheck: async () => false, list }),
).rejects.toBe("Unauthorized");
expect(list).not.toHaveBeenCalled();
});
test("returns the chooser projection from its query", async () => {
const files = [
{ id: "asset", name: "image.png", size: "4", type: "image/png" },
];
expect(
await listFilesService({
adminCheck: async () => true,
list: async () => files,
}),
).toBe(files);
});
});