a reactive (signals based) hypermedia web framework (wip) stormlightlabs.github.io/volt/
hypermedia frontend signals
at main 2.3 kB view raw
1import { 2 findMonorepoRoot, 3 getDocsPath, 4 getExamplesPath, 5 getLibPath, 6 getLibSrcPath, 7 getLibTestPath, 8} from "$utils/paths.js"; 9import { existsSync } from "node:fs"; 10import path from "node:path"; 11import { describe, expect, it } from "vitest"; 12 13describe("path utilities", () => { 14 it("should find monorepo root from cli directory", async () => { 15 const root = await findMonorepoRoot(process.cwd()); 16 17 expect(root).toBeTruthy(); 18 expect(existsSync(path.join(root, "pnpm-workspace.yaml"))).toBe(true); 19 }); 20 21 it("should find lib package path", async () => { 22 const libPath = await getLibPath(); 23 24 expect(libPath).toBeTruthy(); 25 expect(libPath).toContain("lib"); 26 expect(existsSync(path.join(libPath, "package.json"))).toBe(true); 27 }); 28 29 it("should find lib src path", async () => { 30 const srcPath = await getLibSrcPath(); 31 32 expect(srcPath).toBeTruthy(); 33 expect(srcPath).toContain("lib"); 34 expect(srcPath).toContain("src"); 35 expect(existsSync(srcPath)).toBe(true); 36 }); 37 38 it("should find lib test path", async () => { 39 const testPath = await getLibTestPath(); 40 41 expect(testPath).toBeTruthy(); 42 expect(testPath).toContain("lib"); 43 expect(testPath).toContain("test"); 44 expect(existsSync(testPath)).toBe(true); 45 }); 46 47 it("should find docs package path", async () => { 48 const docsPath = await getDocsPath(); 49 50 expect(docsPath).toBeTruthy(); 51 expect(docsPath).toContain("docs"); 52 expect(existsSync(path.join(docsPath, "package.json"))).toBe(true); 53 }); 54 55 it("should find examples directory path", async () => { 56 const examplesPath = await getExamplesPath(); 57 58 expect(examplesPath).toBeTruthy(); 59 expect(examplesPath).toContain("examples"); 60 expect(existsSync(examplesPath)).toBe(true); 61 }); 62 63 it("should return consistent paths when called multiple times", async () => { 64 const root1 = await findMonorepoRoot(); 65 const root2 = await findMonorepoRoot(); 66 67 expect(root1).toBe(root2); 68 69 const libPath1 = await getLibPath(); 70 const libPath2 = await getLibPath(); 71 72 expect(libPath1).toBe(libPath2); 73 }); 74 75 it("should handle being called from monorepo root", async () => { 76 const root = await findMonorepoRoot(); 77 const rootFromRoot = await findMonorepoRoot(root); 78 79 expect(root).toBe(rootFromRoot); 80 }); 81});