Files
openclaw/src/commands/text-format.test.ts
Super-Cabbage 5acabfd897 fix(commands): guard shortenText against non-positive maxLen (#99917)
* fix(commands): guard shortenText against non-positive maxLen

* fix(commands): guard shortenText against non-positive maxLen

---------

Co-authored-by: openclaw-clownfish[bot] <280122609+openclaw-clownfish[bot]@users.noreply.github.com>
2026-07-06 01:00:08 -07:00

23 lines
754 B
TypeScript

// Text format tests cover command-facing shortening helpers.
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("returns an empty string for non-positive limits", () => {
expect(shortenText("openclaw", 0)).toBe("");
expect(shortenText("openclaw", -1)).toBe("");
});
it("counts multi-byte characters correctly", () => {
expect(shortenText("hello🙂world", 7)).toBe("hello🙂…");
});
});