mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-05-23 12:56:55 +00:00
25 lines
984 B
TypeScript
25 lines
984 B
TypeScript
import { describe, expect, test } from "vitest";
|
|
import { UserMessageComponent } from "../src/modes/interactive/components/user-message.js";
|
|
import { initTheme } from "../src/modes/interactive/theme/theme.js";
|
|
|
|
const OSC133_ZONE_START = "\x1b]133;A\x07";
|
|
const OSC133_ZONE_END = "\x1b]133;B\x07";
|
|
const OSC133_ZONE_FINAL = "\x1b]133;C\x07";
|
|
const BG_RESET = "\x1b[49m";
|
|
|
|
describe("UserMessageComponent", () => {
|
|
test("keeps user message height stable while moving closing OSC markers off line end", () => {
|
|
initTheme("dark");
|
|
|
|
const component = new UserMessageComponent("hello");
|
|
const lines = component.render(20);
|
|
|
|
expect(lines).toHaveLength(3);
|
|
expect(lines[0]).toContain(OSC133_ZONE_START);
|
|
expect(lines[0].endsWith(BG_RESET)).toBe(true);
|
|
expect(lines[0]).not.toContain(OSC133_ZONE_END);
|
|
expect(lines[1]).toContain("hello");
|
|
expect(lines[2].startsWith(OSC133_ZONE_END + OSC133_ZONE_FINAL)).toBe(true);
|
|
expect(lines[2].endsWith(BG_RESET)).toBe(true);
|
|
});
|
|
});
|