refactor(commands): centralize shared command formatting helpers

This commit is contained in:
Peter Steinberger
2026-02-22 21:18:10 +00:00
parent 06bdd53658
commit 4bf67ab698
15 changed files with 406 additions and 115 deletions

View File

@@ -0,0 +1,16 @@
import { describe, expect, it } from "vitest";
import { shortenText } from "./text-format.js";
describe("shortenText", () => {
it("returns original text when it fits", () => {
expect(shortenText("openclaw", 16)).toBe("openclaw");
});
it("truncates and appends ellipsis when over limit", () => {
expect(shortenText("openclaw-status-output", 10)).toBe("openclaw-…");
});
it("counts multi-byte characters correctly", () => {
expect(shortenText("hello🙂world", 7)).toBe("hello🙂…");
});
});