test: pin narrow-truncate re-measure parity with Ink
This commit is contained in:
@@ -18,3 +18,22 @@ test("multi-line truncate text keeps its line count (height)", async () => {
|
||||
expect(lines[0]).toBe("x");
|
||||
expect(lines[1]).toBe("yhello");
|
||||
});
|
||||
|
||||
// Narrow truncate: when the text exceeds the box width, Ink re-measures the
|
||||
// wrapped text (so the node width shrinks to the truncated widest line) and
|
||||
// then truncates again at paint, yielding a doubly-truncated result. Verified
|
||||
// against real Ink (ink-testing-library): width=5 → ["x","…"]. This is
|
||||
// intentional Ink parity — do NOT "fix" it to one-pass truncation (["x","yh…"]).
|
||||
test("narrow truncate matches Ink's re-measure-then-truncate behavior", async () => {
|
||||
const { lastFrame } = await render(
|
||||
defineComponent(() => () => (
|
||||
<Box width={5}>
|
||||
<Text wrap="truncate">{"x\nyhello"}</Text>
|
||||
</Box>
|
||||
)),
|
||||
{ columns: 100 },
|
||||
);
|
||||
const lines = stripAnsi(lastFrame()!).split("\n");
|
||||
expect(lines[0]).toBe("x");
|
||||
expect(lines[1]).toBe("…");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user