6533
Yo
yoctomarkdown / files
yoctomarkdown / tests / cli.test.ts
1.0 KB
1import { test, expect, describe } from "bun:test"; 2import { $ } from "bun"; 3 4describe("CLI tests", () => { 5 test("should render from stdin", async () => { 6 const result = 7 await $`echo "# Hello World" | bun src/cli.ts --theme none`.text(); 8 expect(result).toContain("Hello World"); 9 }); 10 11 test("should render an existing file", async () => { 12 const result = await $`bun src/cli.ts spec.md --theme none`.text(); 13 expect(result.length).toBeGreaterThan(100); 14 }); 15 16 test("CLI performance test", async () => { 17 const largeMdPath = "large_temp.md"; 18 await $`bun -e 'require("fs").writeFileSync("${largeMdPath}", "# Performance\\n\\nSome **bold** text here.\\n".repeat(5000))'`; 19 20 const start = performance.now(); 21 await $`bun src/cli.ts ${largeMdPath} --theme none`.text(); 22 const end = performance.now(); 23 24 const duration = end - start; 25 console.log(`CLI Execution Time: ${duration.toFixed(2)}ms`); 26 expect(duration).toBeLessThan(500); // Process boot + execution should be under 500ms 27 28 await $`rm ${largeMdPath}`; 29 }); 30});