Open History to see the last commit
1import { describe, expect, it } from "vitest";
2import {
3 isExplicitRelativePath,
4 isUncPath,
5 isWindowsAbsolutePath,
6 isWindowsDrivePath,
7} from "./path.ts";
8
9describe("path helpers", () => {
10 it("detects windows drive paths", () => {
11 expect(isWindowsDrivePath("C:\\repo")).toBe(true);
12 expect(isWindowsDrivePath("D:/repo")).toBe(true);
13 expect(isWindowsDrivePath("/repo")).toBe(false);
14 });
15
16 it("detects UNC paths", () => {
17 expect(isUncPath("\\\\server\\share\\repo")).toBe(true);
18 expect(isUncPath("C:\\repo")).toBe(false);
19 });
20
21 it("detects windows absolute paths", () => {
22 expect(isWindowsAbsolutePath("C:\\repo")).toBe(true);
23 expect(isWindowsAbsolutePath("\\\\server\\share\\repo")).toBe(true);
24 expect(isWindowsAbsolutePath("./repo")).toBe(false);
25 });
26
27 it("detects explicit relative paths", () => {
28 expect(isExplicitRelativePath(".")).toBe(true);
29 expect(isExplicitRelativePath("..")).toBe(true);
30 expect(isExplicitRelativePath("./repo")).toBe(true);
31 expect(isExplicitRelativePath("..\\repo")).toBe(true);
32 expect(isExplicitRelativePath("~/repo")).toBe(false);
33 });
34});