Add import template into tui. Fix tests that fail on macos. Fix some updates.
This commit is contained in:
44
tests/tui/format-dialog-message.test.ts
Normal file
44
tests/tui/format-dialog-message.test.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import {
|
||||
formatDialogMessageLines,
|
||||
getMessageContentWidth,
|
||||
getMessageDialogWidth,
|
||||
} from "../../src/tui/utils/format-dialog-message.js";
|
||||
|
||||
describe("formatDialogMessageLines", () => {
|
||||
test("drops empty lines from leading newlines", () => {
|
||||
const lines = formatDialogMessageLines("\n- first\n- second", 80);
|
||||
|
||||
expect(lines).toEqual(["- first", "- second"]);
|
||||
});
|
||||
|
||||
test("keeps short lines unchanged", () => {
|
||||
const lines = formatDialogMessageLines("- actions.receive: Invalid", 80);
|
||||
|
||||
expect(lines).toEqual(["- actions.receive: Invalid"]);
|
||||
});
|
||||
|
||||
test("breaks long dot-separated paths at segment boundaries", () => {
|
||||
const line =
|
||||
"- actions.requestFungibleTokens.roles.receiver.requirements: Unrecognized key: \"generate\"";
|
||||
const lines = formatDialogMessageLines(line, 56);
|
||||
|
||||
expect(lines.length).toBeGreaterThan(1);
|
||||
expect(lines.join("\n")).toContain("actions.requestFungibleTokens.");
|
||||
expect(lines.every((entry) => entry.length <= 58)).toBe(true);
|
||||
expect(lines[1]?.startsWith(" ")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("dialog width helpers", () => {
|
||||
test("getMessageDialogWidth respects terminal bounds", () => {
|
||||
expect(getMessageDialogWidth(120)).toBe(100);
|
||||
expect(getMessageDialogWidth(80)).toBe(76);
|
||||
expect(getMessageDialogWidth(40)).toBe(60);
|
||||
});
|
||||
|
||||
test("getMessageContentWidth subtracts border and padding", () => {
|
||||
expect(getMessageContentWidth(76)).toBe(70);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user