1import { normalizeBundleFilePath } from "@/Prisma/Internal/BundlePaths";
2import { describe, expect, it } from "alchemy-test";
3import * as Effect from "effect/Effect";
4
5describe(
6 "Prisma Compute bundle paths",
7 { tags: ["unit", "provider:prisma", "local"] },
8 () => {
9 it.effect("accepts normalized relative bundle paths", () =>
10 Effect.gen(function* () {
11 expect(yield* normalizeBundleFilePath("chunks/api.js")).toBe(
12 "chunks/api.js",
13 );
14 }),
15 );
16
17 it.effect("rejects empty, absolute, and traversal bundle paths", () =>
18 Effect.gen(function* () {
19 for (const path of [
20 "",
21 "/tmp/escape.js",
22 "C:\\tmp\\escape.js",
23 "../escape.js",
24 "chunks/../../escape.js",
25 "chunks//escape.js",
26 ]) {
27 const error = yield* normalizeBundleFilePath(path).pipe(Effect.flip);
28 expect(error).toBeInstanceOf(Error);
29 }
30 }),
31 );
32 },
33);