From fc5c837d2c040a76523b02c602124df7b221e8ed Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 4 Jun 2026 13:03:24 +0200 Subject: [PATCH] test(stammbaum): tidyTree centres a wide couple run and clears siblings (#724) Co-Authored-By: Claude Opus 4.8 --- .../person/genealogy/layout/tidyTree.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/frontend/src/lib/person/genealogy/layout/tidyTree.test.ts b/frontend/src/lib/person/genealogy/layout/tidyTree.test.ts index a7d274ea..c237f6e9 100644 --- a/frontend/src/lib/person/genealogy/layout/tidyTree.test.ts +++ b/frontend/src/lib/person/genealogy/layout/tidyTree.test.ts @@ -116,3 +116,22 @@ describe('tidyTree — multi-root packing', () => { expect(Math.min(...x.values())).toBe(0); }); }); + +describe('tidyTree — variable-width run', () => { + it('centres a wide couple run over its children and clears its siblings', () => { + // A couple unit is one node whose width spans two cards + the gap. It + // must still centre over its own children and stay clear of siblings by + // the FULL run width, not a single card. + const COUPLE = 2 * W + GAP; + const couple = node('couple', [leaf('g1'), leaf('g2')], COUPLE); + const sibling = node('sib', [leaf('s1')]); + const roots = [sibling, couple]; + const x = layoutForest(roots, GAP); + + expectNoOverlap(x, roots, GAP); + // Couple centred over its two children. + expect(center(x, couple)).toBe((center(x, leaf('g1')) + center(x, leaf('g2'))) / 2); + // The sibling root clears the couple's full run width. + expect(x.get('couple')! - x.get('sib')!).toBeGreaterThanOrEqual(W + GAP); + }); +});