[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 flex-wrap

Nate Moore (Jun 4, 2026, 1:26 AM -0500) c0d89095 d75fb4b6

+69
+69
test/flex-wrap.test.ts
··· 1 + import { describe, expect, it } from "./suite.ts"; 2 + import { createTerm } from "../term.ts"; 3 + import { close, fit, fixed, open, type OpenElement, text } from "../ops.ts"; 4 + import { print } from "./print.ts"; 5 + 6 + const decode = (b: Uint8Array) => new TextDecoder().decode(b); 7 + const trim = (s: string) => s.split("\n").map((l) => l.trimEnd()).join("\n"); 8 + 9 + // flexWrap is not a layout key yet; this shim lets the file type-check today. 10 + // The extra key is dropped by pack(), so it is inert at runtime against the 11 + // current build. 12 + const layout = (l: Record<string, unknown>): OpenElement["layout"] => 13 + l as unknown as OpenElement["layout"]; 14 + 15 + describe("flex-wrap", () => { 16 + it("row wrap: child exceeding main size breaks to the next line", async () => { 17 + let term = await createTerm({ width: 6, height: 4 }); 18 + let res = term.render([ 19 + open("root", { 20 + layout: layout({ 21 + width: fixed(2), 22 + height: fixed(4), 23 + direction: "ltr", 24 + flexWrap: "wrap", 25 + }), 26 + }), 27 + open("a", { layout: { width: fit(), height: fit() } }), 28 + text("A"), 29 + close(), 30 + open("bc", { layout: { width: fit(), height: fit() } }), 31 + text("BC"), 32 + close(), 33 + close(), 34 + ]); 35 + let lines = trim(print(decode(res.output), 6, 4)).split("\n"); 36 + // pins: "A" stays alone on the first flex line. 37 + expect(lines[0]).toBe("A"); 38 + // pins: "BC" no longer fits beside "A", so it wraps to a second line. 39 + expect(lines[1]).toBe("BC"); 40 + }); 41 + 42 + it("row wrap: wrapped child starts a new flex line at x=0", async () => { 43 + let term = await createTerm({ width: 6, height: 4 }); 44 + let res = term.render([ 45 + open("root", { 46 + layout: layout({ 47 + width: fixed(2), 48 + height: fixed(4), 49 + direction: "ltr", 50 + flexWrap: "wrap", 51 + }), 52 + }), 53 + open("a", { layout: { width: fit(), height: fit() } }), 54 + text("A"), 55 + close(), 56 + open("bc", { layout: { width: fit(), height: fit() } }), 57 + text("BC"), 58 + close(), 59 + close(), 60 + ]); 61 + // pins: the wrapped "BC" sits on cross-axis line 1 (y:1), not beside "A". 62 + expect(res.info.get("bc")!.bounds).toEqual({ 63 + x: 0, 64 + y: 1, 65 + width: 2, 66 + height: 1, 67 + }); 68 + }); 69 + });