TASKS Phase 1 (abgeschlossen). Warnungen sind jetzt maschinenlesbare Objekte
{type, line, ...data} statt vorformatierter Strings: der Renderer emittiert
{type:'mixedGate', line, label}; src/warnings.js `formatWarning(w, t)` macht
daraus an EINER Stelle den lokalisierten, HTML-escapten Anzeigetext. Damit sind
Typ und Zeilennummer sortier-/filter-/testbar, und Phase 2 (unbekannte
Statuszeichen -> {type:'unknownStatus', line, code}) dockt ohne Formatstreuung an.
tests/warnings.test.js + Mixed-Gate-Test im Renderer (29 Tests grün).
Ende-zu-Ende im Browser verifiziert (lokalisierte Warnung mit Zeile + Label).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
24 lines
1.0 KiB
JavaScript
24 lines
1.0 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { formatWarning } from '../src/warnings.js';
|
|
|
|
/* Stub bildet key + interpolierte Variablen sichtbar ab, damit wir prüfen
|
|
können, welche Werte (inkl. Escaping) formatWarning durchreicht. */
|
|
const t = (key, vars) => `${key}|${JSON.stringify(vars)}`;
|
|
|
|
describe('formatWarning — vereinheitlichtes Warnungs-Modell', () => {
|
|
it('mixedGate reicht Zeile durch und HTML-escaped das Label', () => {
|
|
const out = formatWarning({type: 'mixedGate', line: 7, label: 'A & <B>'}, t);
|
|
expect(out).toBe('mixedWarn|{"line":7,"label":"A & <B>"}');
|
|
});
|
|
|
|
it('unknownStatus reicht Zeile durch und escaped den Code', () => {
|
|
const out = formatWarning({type: 'unknownStatus', line: 3, code: '<'}, t);
|
|
expect(out).toBe('unknownStatusWarn|{"line":3,"code":"<"}');
|
|
});
|
|
|
|
it('unbekannter Typ fällt auf eine generische, escapte Meldung zurück', () => {
|
|
expect(formatWarning({type: 'was?', line: 9}, t)).toBe('was? (9)');
|
|
expect(formatWarning({type: 'x'}, t)).toBe('x (?)');
|
|
});
|
|
});
|