Something went wrong. Try again.
a reactive (signals based) hypermedia web framework (wip) stormlightlabs.github.io/volt
hypermedia frontend signals
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129import { getLibSrcPath } from "$utils/paths.js";import { readFile } from "node:fs/promises";import path from "node:path";import { describe, expect, it } from "vitest";
describe("stats command", () => { it("should count lines excluding doc comments", async () => { const srcPath = await getLibSrcPath(); const testDir = path.join(srcPath, "core"); const signalFile = path.join(testDir, "signal.ts"); const content = await readFile(signalFile, "utf8");
const lines = content.split("\n"); let codeLines = 0; let inDocComment = false;
for (const line of lines) { const trimmed = line.trim();
if (trimmed.startsWith("/**")) { inDocComment = true; continue; }
if (inDocComment) { if (trimmed.endsWith("*/")) { inDocComment = false; } continue; }
if (trimmed === "" || trimmed.startsWith("//")) { continue; }
codeLines++; }
expect(codeLines).toBeGreaterThan(0); expect(codeLines).toBeLessThan(lines.length); });
it("should exclude empty lines", () => { const content = `function test() { return true;}
export { test };`;
const lines = content.split("\n"); let codeLines = 0;
for (const line of lines) { const trimmed = line.trim();
if (trimmed === "" || trimmed.startsWith("//")) { continue; }
codeLines++; }
expect(codeLines).toBe(4); });
it("should exclude single-line comments", () => { const content = `// This is a commentfunction test() { // Another comment return true;}`;
const lines = content.split("\n"); let codeLines = 0;
for (const line of lines) { const trimmed = line.trim();
if (trimmed === "" || trimmed.startsWith("//")) { continue; }
codeLines++; }
expect(codeLines).toBe(3); });
it("should exclude doc comment blocks", () => { const content = `/** * This is a doc comment * @param foo - some param */function test(foo: string) { return foo;}`;
const lines = content.split("\n"); let codeLines = 0; let inDocComment = false;
for (const line of lines) { const trimmed = line.trim();
if (trimmed.startsWith("/**")) { inDocComment = true; continue; }
if (inDocComment) { if (trimmed.endsWith("*/")) { inDocComment = false; } continue; }
if (trimmed === "" || trimmed.startsWith("//")) { continue; }
codeLines++; }
expect(codeLines).toBe(3); });});