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); + }); +});