Files
openclaw/extensions/imessage/src/cli-output.test.ts
wings1029 4c55d46254 fix(imessage): keep CLI stderr tails UTF-16 safe (#102626)
* fix(imessage): keep CLI stderr tail truncation UTF-16 safe

* test(imessage): hit stderr surrogate boundary

* fix(imessage): use plugin sdk text helper

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-07-09 15:04:07 +01:00

28 lines
922 B
TypeScript

// Imessage tests cover cli output plugin behavior.
import { describe, expect, it } from "vitest";
import { appendIMessageCliStderrTail, appendIMessageCliStdout } from "./cli-output.js";
describe("iMessage CLI output bounds", () => {
it("rejects stdout once the JSON capture exceeds the cap", () => {
const result = appendIMessageCliStdout("abc", "def", 5);
expect(result).toEqual({
ok: false,
message: "imsg stdout exceeded 5 characters",
});
});
it("keeps only recent stderr details", () => {
const result = appendIMessageCliStderrTail("old-noise:", "recent-error", 12);
expect(result).toBe("recent-error");
});
it("does not split a surrogate pair at the tail boundary", () => {
const input = `x🚀${"y".repeat(10)}`;
expect(input.slice(-11)).toBe(`\ude80${"y".repeat(10)}`);
expect(appendIMessageCliStderrTail("", input, 11)).toBe("y".repeat(10));
});
});