Merge a1b43ac3239dc79ca
Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
38 files changed
+879
-60
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { emptyProject, sampleProject } from "./sampleProject";
|
||||
import { standardsMergeOps, withStandards } from "./standards";
|
||||
import { standardsMergeCounts, standardsMergeOps, withStandards } from "./standards";
|
||||
|
||||
describe("Standard-Bibliothek ([100]–[102])", () => {
|
||||
it("bringt Baustoffe, Linientypen und Aufbauten in ein neues Projekt", () => {
|
||||
@@ -27,4 +27,13 @@ describe("Standard-Bibliothek ([100]–[102])", () => {
|
||||
expect(p.components.length).toBeGreaterThan(sampleProject.components.length);
|
||||
expect(standardsMergeOps(p)).toEqual([]);
|
||||
});
|
||||
|
||||
it("zählt, was „Standards laden“ hinzufügt (Rückmeldung)", () => {
|
||||
const empty = { ...emptyProject, components: [], hatches: [], lineStyles: [], wallTypes: [], ceilingTypes: [], roofTypes: [] };
|
||||
const c = standardsMergeCounts(standardsMergeOps(empty));
|
||||
expect(c.components).toBe(34);
|
||||
expect(c.lineStyles).toBeGreaterThan(5);
|
||||
expect(c.wallTypes + c.ceilingTypes + c.roofTypes).toBe(5);
|
||||
expect(standardsMergeCounts(standardsMergeOps(withStandards(empty)))).toEqual({ lineStyles: 0, hatches: 0, components: 0, wallTypes: 0, ceilingTypes: 0, roofTypes: 0 });
|
||||
});
|
||||
});
|
||||
@@ -17,3 +17,23 @@ export function standardsMergeOps(project: Project): CoreOp[] {
|
||||
export function withStandards(project: Project): Project {
|
||||
return applyOps(project, standardsMergeOps(project));
|
||||
}
|
||||
|
||||
/** Was „Standards laden" anhängt: Anzahl neuer Einträge je Projekt-Liste (für die Rückmeldung). */
|
||||
export interface StandardsMergeCounts {
|
||||
lineStyles: number;
|
||||
hatches: number;
|
||||
components: number;
|
||||
wallTypes: number;
|
||||
ceilingTypes: number;
|
||||
roofTypes: number;
|
||||
}
|
||||
|
||||
export function standardsMergeCounts(ops: readonly CoreOp[]): StandardsMergeCounts {
|
||||
const out: StandardsMergeCounts = { lineStyles: 0, hatches: 0, components: 0, wallTypes: 0, ceilingTypes: 0, roofTypes: 0 };
|
||||
for (const op of ops) {
|
||||
const key = op.kind === "add" ? op.collection : op.kind === "setField" ? op.key : null;
|
||||
const n = op.kind === "add" ? op.items.length : op.kind === "setField" && Array.isArray(op.value) ? op.value.length : 0;
|
||||
if (key && key in out) out[key as keyof StandardsMergeCounts] += n;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
Reference in new issue
Block a user