mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { buildAbsoluteExplorerPath } from "./explorer-paths";
|
|
|
|
describe("buildAbsoluteExplorerPath", () => {
|
|
it("builds a POSIX absolute path from a relative explorer path", () => {
|
|
expect(
|
|
buildAbsoluteExplorerPath({
|
|
workspaceRoot: "/Users/moboudra/dev/paseo",
|
|
entryPath: "packages/app/src/components/file-explorer-pane.tsx",
|
|
})
|
|
).toBe("/Users/moboudra/dev/paseo/packages/app/src/components/file-explorer-pane.tsx");
|
|
});
|
|
|
|
it("returns workspace root when entry path points to explorer root", () => {
|
|
expect(
|
|
buildAbsoluteExplorerPath({
|
|
workspaceRoot: "/Users/moboudra/dev/paseo",
|
|
entryPath: ".",
|
|
})
|
|
).toBe("/Users/moboudra/dev/paseo");
|
|
});
|
|
|
|
it("trims trailing separators from workspace root before joining", () => {
|
|
expect(
|
|
buildAbsoluteExplorerPath({
|
|
workspaceRoot: "/Users/moboudra/dev/paseo/",
|
|
entryPath: "README.md",
|
|
})
|
|
).toBe("/Users/moboudra/dev/paseo/README.md");
|
|
});
|
|
|
|
it("builds a Windows absolute path with backslash separators", () => {
|
|
expect(
|
|
buildAbsoluteExplorerPath({
|
|
workspaceRoot: "C:\\repo\\paseo",
|
|
entryPath: "packages/app/src/components/file-explorer-pane.tsx",
|
|
})
|
|
).toBe("C:\\repo\\paseo\\packages\\app\\src\\components\\file-explorer-pane.tsx");
|
|
});
|
|
|
|
it("passes through an already-absolute entry path", () => {
|
|
expect(
|
|
buildAbsoluteExplorerPath({
|
|
workspaceRoot: "/Users/moboudra/dev/paseo",
|
|
entryPath: "/tmp/another/location.txt",
|
|
})
|
|
).toBe("/tmp/another/location.txt");
|
|
});
|
|
});
|