test: make media route fixture cross-platform

This commit is contained in:
Simo committed 2026-08-30 12:27:12 +02:00
1 parent b70bd401d1
commit 1ec05cda39
1 file changed
+8 -6
+8 -6
View File
@@ -5,12 +5,14 @@ import { GET } from "./route";
vi.mock("node:fs", () => ({ existsSync: vi.fn() }));
vi.mock("node:fs/promises", () => ({ readFile: vi.fn() }));
vi.mock("@/lib/media-storage", () => ({
MEDIA_ROOT: "C:\\media",
resolveMediaPath: vi.fn(
(name: string) => `C:\\media\\${name.replaceAll("/", "\\")}`,
),
}));
vi.mock("@/lib/media-storage", async () => {
const path = await import("node:path");
const mediaRoot = path.resolve("media-fixture");
return {
MEDIA_ROOT: mediaRoot,
resolveMediaPath: vi.fn((name: string) => path.join(mediaRoot, name)),
};
});
describe("GET /api/media/[...path]", () => {
beforeEach(() => {