Files
openclaw/packages/normalization-core/src/text-decoding.test.ts
Peter Steinberger d185f9a0b4 fix(infra): preserve characters in truncated response snippets (#103136)
* fix(infra): preserve bounded response text characters

Co-authored-by: qingminlong <34085845+qingminglong@users.noreply.github.com>

* ci(plugin-sdk): refresh API baseline

---------

Co-authored-by: qingminlong <34085845+qingminglong@users.noreply.github.com>
2026-07-09 23:43:26 +01:00

19 lines
640 B
TypeScript
Raw Blame History

import { describe, expect, it } from "vitest";
import { decodeTextPrefix } from "./text-decoding.js";
describe("decodeTextPrefix", () => {
const encoded = new TextEncoder().encode("ab😀cd");
it("decodes complete text normally", () => {
expect(decodeTextPrefix(encoded)).toBe("ab😀cd");
});
it("drops an incomplete trailing sequence from a truncated prefix", () => {
expect(decodeTextPrefix(encoded.subarray(0, 3), { truncated: true })).toBe("ab");
});
it("preserves normal replacement behavior for a complete malformed body", () => {
expect(decodeTextPrefix(encoded.subarray(0, 3))).toBe("ab<61>");
});
});