refactor(tui): dedupe handlers and formatter test setup

This commit is contained in:
Peter Steinberger
2026-02-22 14:05:51 +00:00
parent 66f814a0af
commit 38752338dc
20 changed files with 430 additions and 477 deletions

View File

@@ -213,20 +213,17 @@ describe("isCommandMessage", () => {
});
describe("sanitizeRenderableText", () => {
it("breaks very long unbroken tokens to avoid overflow", () => {
const input = "a".repeat(140);
function expectTokenWidthUnderLimit(input: string) {
const sanitized = sanitizeRenderableText(input);
const longestSegment = Math.max(...sanitized.split(/\s+/).map((segment) => segment.length));
expect(longestSegment).toBeLessThanOrEqual(32);
});
}
it("breaks moderately long unbroken tokens to protect narrow terminals", () => {
const input = "b".repeat(90);
const sanitized = sanitizeRenderableText(input);
const longestSegment = Math.max(...sanitized.split(/\s+/).map((segment) => segment.length));
expect(longestSegment).toBeLessThanOrEqual(32);
it.each([
{ label: "very long", input: "a".repeat(140) },
{ label: "moderately long", input: "b".repeat(90) },
])("breaks $label unbroken tokens to protect narrow terminals", ({ input }) => {
expectTokenWidthUnderLimit(input);
});
it("preserves long filesystem paths verbatim for copy safety", () => {