1f61eb5ca9
deploy-www / deploy (push) Has been cancelled
publish / version (push) Has been cancelled
publish / build-cli (push) Has been cancelled
publish / sign-cli-macos (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-ubuntu-2404 target:linux-x64]) (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-ubuntu-2404-arm target:linux-arm64]) (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-windows-2025 target:windows-arm64]) (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-windows-2025 target:windows-x64]) (push) Has been cancelled
publish / build-node-cli (map[host:macos-26 target:darwin-arm64]) (push) Has been cancelled
publish / sign-cli-windows (push) Has been cancelled
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=arm64 host:macos-26 platform_flag:--mac --arm64 target:aarch64-apple-darwin]) (push) Has been cancelled
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=x64 host:macos-26-intel platform_flag:--mac --x64 target:x86_64-apple-darwin]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404 platform_flag:--linux target:x86_64-unknown-linux-gnu]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404-arm platform_flag:--linux --arm64 target:aarch64-unknown-linux-gnu]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-windows-2025 platform_flag:--win target:x86_64-pc-windows-msvc]) (push) Has been cancelled
publish / build-electron (map[host:windows-2025 platform_flag:--win --arm64 target:aarch64-pc-windows-msvc]) (push) Has been cancelled
publish / publish (push) Has been cancelled
typecheck / typecheck (push) Has been cancelled
26 lines
1.1 KiB
TypeScript
26 lines
1.1 KiB
TypeScript
import { describe, expect, test } from "bun:test"
|
|
import { getDirectory, getFilename, getFilenameTruncated, truncateMiddle } from "./path.js"
|
|
|
|
describe("client paths", () => {
|
|
test("reads POSIX and Windows paths with the same rules", () => {
|
|
expect(getFilename("/repo/src/index.ts")).toBe("index.ts")
|
|
expect(getFilename("C:\\repo\\src\\index.ts\\")).toBe("index.ts")
|
|
expect(getDirectory("/repo/src/index.ts")).toBe("/repo/src/")
|
|
expect(getDirectory("C:\\repo\\src\\index.ts")).toBe("C:/repo/src/")
|
|
})
|
|
|
|
test("preserves root, UNC, mixed, and single-segment behavior", () => {
|
|
expect(getFilename("\\\\server\\share\\file")).toBe("file")
|
|
expect(getDirectory("\\\\server\\share\\file")).toBe("//server/share/")
|
|
expect(getDirectory("C:\\repo/src\\file")).toBe("C:/repo/src/")
|
|
expect(getDirectory("file")).toBe("/")
|
|
expect(getFilename(undefined)).toBe("")
|
|
expect(getDirectory("")).toBe("")
|
|
})
|
|
|
|
test("keeps filename truncation stable", () => {
|
|
expect(getFilenameTruncated("/repo/long-component-name.tsx", 16)).toBe("long-compon….tsx")
|
|
expect(truncateMiddle("abcdefghijklmnop", 9)).toBe("abcd…mnop")
|
|
})
|
|
})
|