@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 03:37 UTC

main
ts 28 lines 1.18 KB
Raw
1 import { describe, expect, it } from "vite-plus/test";
2
3 import { mediaFileReference, mediaReferenceFileName } from "./mediaReference.ts";
4
5 describe("mediaFileReference", () => {
6 it.each([
7 ["/work/project/./media/../clip.mp4", "/work/project/", "clip.mp4"],
8 ["/work/project-other/clip.mp4", "/work/project", undefined],
9 ["C:\\WORK\\project\\media\\..\\Clip.mp4", "c:/work/project/", "Clip.mp4"],
10 ["\\\\Server\\Share\\Project\\Clip.mp4", "//server/share/project", "Clip.mp4"],
11 ])("preserves %s and only labels paths inside %s as relative", (path, root, relativePath) => {
12 expect(mediaFileReference(path, root)).toEqual({
13 kind: "file",
14 path,
15 ...(relativePath === undefined ? {} : { relativePath }),
16 });
17 });
18 });
19
20 describe("mediaReferenceFileName", () => {
21 it.each([
22 [{ kind: "file", path: "/tmp/take\\one%20.mp4" }, "take\\one%20.mp4"],
23 [{ kind: "url", url: "//cdn.example/clip%20one%2Emp4?sig=a+b#t=2" }, "clip one.mp4"],
24 [{ kind: "url", url: "https://cdn.example/clip%20%oops.mp4" }, "clip%20%oops.mp4"],
25 ] as const)("preserves filename semantics for %j", (reference, name) => {
26 expect(mediaReferenceFileName(reference)).toBe(name);
27 });
28 });