workspaceContextPath.test.ts 902 B

1234567891011121314151617181920
  1. import { describe, expect, it } from "vitest";
  2. import { formatWorkspaceContextPath } from "@/WorkspaceHeaderSections/workspaceContextPathFormat.js";
  3. describe("workspace context path", () => {
  4. it("abbreviates only the supplied host home and its descendants", () => {
  5. expect(formatWorkspaceContextPath("/Users/a/Projects/z-code", "/Users/a")).toBe(
  6. "~/Projects/z-code",
  7. );
  8. expect(formatWorkspaceContextPath("/Users/a", "/Users/a/")).toBe("~");
  9. expect(formatWorkspaceContextPath("/Users/another/project", "/Users/a")).toBe(
  10. "/Users/another/project",
  11. );
  12. });
  13. it("preserves paths before host information is available", () => {
  14. expect(formatWorkspaceContextPath("/remote/project")).toBe("/remote/project");
  15. });
  16. it("supports Windows host paths", () => {
  17. expect(formatWorkspaceContextPath("C:\\Users\\a\\project", "C:\\Users\\a")).toBe("~/project");
  18. });
  19. });