[READ-ONLY] Mirror of https://github.com/bombshell-dev/tty. Platform independent 2D layout engine for terminal applications based on Clay
5

Configure Feed

Select the types of activity you want to include in your feed.

test: failing repro for justify-space

Nate Moore (Jun 4, 2026, 12:33 AM -0500) a769af18 d75fb4b6

+55
+55
test/justify-space.test.ts
··· 1 + import { describe, expect, it } from "./suite.ts"; 2 + import { createTerm } from "../term.ts"; 3 + import { close, fixed, grow, open, text } from "../ops.ts"; 4 + import { print } from "./print.ts"; 5 + 6 + const decode = (b: Uint8Array) => new TextDecoder().decode(b); 7 + 8 + // Two 1-wide fixed children inside a 10-wide grow row. 9 + function row(alignX: number) { 10 + return [ 11 + open("row", { 12 + layout: { width: grow(), height: fixed(1), direction: "ltr", alignX }, 13 + }), 14 + open("a", { layout: { width: fixed(1), height: fixed(1) } }), 15 + text("A"), 16 + close(), 17 + open("b", { layout: { width: fixed(1), height: fixed(1) } }), 18 + text("B"), 19 + close(), 20 + close(), 21 + ]; 22 + } 23 + 24 + describe("justifyContent space distribution", () => { 25 + it("space-between pushes children to opposite edges", async () => { 26 + let term = await createTerm({ width: 10, height: 1 }); 27 + let res = term.render(row(3)); // 3 = space-between 28 + // first child hugs the left edge 29 + expect(res.info.get("a")!.bounds.x).toBe(0); 30 + // last child hugs the right edge 31 + expect(res.info.get("b")!.bounds.x).toBe(9); 32 + // all free space sits between the two children 33 + expect(print(decode(res.output), 10, 1)).toBe("A B"); 34 + }); 35 + 36 + it("space-evenly puts equal gaps on the ends and between", async () => { 37 + let term = await createTerm({ width: 10, height: 1 }); 38 + let res = term.render(row(5)); // 5 = space-evenly 39 + // leading gap is non-zero (first child not at the left edge) 40 + expect(res.info.get("a")!.bounds.x).toBeGreaterThan(0); 41 + // trailing gap is non-zero (last child not at the right edge) 42 + expect(res.info.get("b")!.bounds.x).toBeLessThan(9); 43 + // 3 equal gaps of (10-2)/3 -> A at col 2, B at col 6 44 + expect(print(decode(res.output), 10, 1)).toBe(" A B"); 45 + }); 46 + 47 + it("space-around puts half-size gaps on the ends", async () => { 48 + let term = await createTerm({ width: 10, height: 1 }); 49 + let res = term.render(row(4)); // 4 = space-around 50 + // leading gap is non-zero (first child not at the left edge) 51 + expect(res.info.get("a")!.bounds.x).toBeGreaterThan(0); 52 + // last child is not pinned to the right edge 53 + expect(res.info.get("b")!.bounds.x).toBeLessThan(9); 54 + }); 55 + });