Files
projekt-plattform/viewer/tests/format2lint.3.mjs

16 lines
1.3 KiB
JavaScript

// format2lint.3 (Logikteil): erkennt der Viewer-Parser eine neuere Formatversion?
// Aufruf: node viewer/tests/format2lint.3.mjs (Node 24: TypeScript-Quellen laufen direkt)
import { readFileSync } from "node:fs";
import { formatVersion, isNewerFormat, parseDoc, VIEWER_FORMAT } from "../src/lib/roadmap.ts";
let ok = true;
const prüfe = (name, bed, notiz) => { ok &&= bed; console.log(`- ${name}: ${bed ? "✓" : "✗"} ${notiz}`); };
const echt = parseDoc(readFileSync(new URL("../../ROADMAP.md", import.meta.url), "utf-8"));
prüfe("format2lint.3a", formatVersion(echt.head) === 1 && !isNewerFormat(echt.head), `echte ROADMAP.md: Format ${formatVersion(echt.head)}, nicht neuer (Viewer versteht bis ${VIEWER_FORMAT})`);
const neu = parseDoc("# X\n\nStand: 2026-11-03 · Projekt-ID: P-0001 · Format: 2 · Nächste freie ID: #1003\n\n## 1. Todo\n- [#1001] a\n");
prüfe("format2lint.3b", isNewerFormat(neu.head) && formatVersion(neu.head) === 2, "Format 2 wird als neuer erkannt");
prüfe("format2lint.3c", !isNewerFormat(parseDoc("# X\n\nStand: heute\n\n## 1. Todo\n").head), "ohne Format-Zeile (Format 0): nicht neuer");
prüfe("format2lint.3d", !isNewerFormat(parseDoc("# X\n\nFormat: abc\n").head), "Format ohne Zahl: nicht als neuer behandelt");
process.exit(ok ? 0 : 1);