From 7b22f8fdf73248340f22486ff3859e9fcf2cb8a8 Mon Sep 17 00:00:00 2001 From: Karim Date: Thu, 9 Jul 2026 21:16:08 +0200 Subject: [PATCH] Text-Marks-Test: textDrawing-Helfer (umgeht Union-Verengung, tsc sauber) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nachzügler-Fix zum Text-Styling-Test: das inline-gespreizte marks-Feld verengte die Drawing2DGeom-Union und liess tsc meckern; ein Helfer baut das Text-Drawing typkorrekt. Reine Testdatei. --- src/plan/generatePlan.text.test.ts | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/plan/generatePlan.text.test.ts b/src/plan/generatePlan.text.test.ts index 1adc2b7..a16cf35 100644 --- a/src/plan/generatePlan.text.test.ts +++ b/src/plan/generatePlan.text.test.ts @@ -6,6 +6,18 @@ import { describe, it, expect } from "vitest"; import { generatePlan } from "./generatePlan"; import type { Drawing2D, Project } from "../model/types"; +import type { Marks } from "../text/richText"; + +/** Baut ein Text-Drawing mit optionalen Marks (umgeht die Union-Verengung). */ +function textDrawing(marks?: Marks): Drawing2D { + return { + id: "TX1", + type: "drawing2d", + levelId: "eg", + categoryCode: "70", + geom: { shape: "text", at: { x: 1, y: 1 }, text: "Hallo", height: 0.2, angle: 0, ...(marks ? { marks } : {}) }, + }; +} function projectWithText(drawing: Drawing2D): Project { return { @@ -49,34 +61,22 @@ function textPrim(drawing: Drawing2D) { } describe("Drawing2D-Text: Marks im drawingText-Primitiv", () => { - const base: Drawing2D = { - id: "TX1", - type: "drawing2d", - levelId: "eg", - categoryCode: "70", - geom: { shape: "text", at: { x: 1, y: 1 }, text: "Hallo", height: 0.2, angle: 0 }, - }; - it("trägt marks (font/bold/italic) ins Primitiv", () => { - const p = textPrim({ - ...base, - geom: { ...base.geom, marks: { font: "Merriweather", bold: true, italic: true } }, - }) as { marks?: { font?: string; bold?: boolean; italic?: boolean } } | undefined; + const p = textPrim(textDrawing({ font: "Merriweather", bold: true, italic: true })) as + | { marks?: { font?: string; bold?: boolean; italic?: boolean } } + | undefined; expect(p?.marks?.font).toBe("Merriweather"); expect(p?.marks?.bold).toBe(true); expect(p?.marks?.italic).toBe(true); }); it("marks.color übersteuert die Kategorie-Farbe", () => { - const p = textPrim({ - ...base, - geom: { ...base.geom, marks: { color: "#ff0000" } }, - }) as { color: string } | undefined; + const p = textPrim(textDrawing({ color: "#ff0000" })) as { color: string } | undefined; expect(p?.color).toBe("#ff0000"); }); it("ohne marks bleibt das Primitiv unverändert (kein marks-Feld)", () => { - const p = textPrim(base) as { marks?: unknown } | undefined; + const p = textPrim(textDrawing()) as { marks?: unknown } | undefined; expect(p).toBeTruthy(); expect(p?.marks).toBeUndefined(); });