Skip to content

Commit 2ec8db4

Browse files
committed
Add truncateText multi-byte boundary test to spawn.test.ts
1 parent 2bf4843 commit 2ec8db4

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tests/unit/spawn.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
createChildTools,
1111
executeSpawn,
1212
registerSpawnTool,
13+
truncateText,
1314
} from "../../spawn/index.js";
1415
import { renderSpawnResult } from "../../spawn/renderer.js";
1516
import { createTestPI, createRenderContext, createSession, createSubscribableSession, messageText, makeTUICtx, theme, createTestAssistantMessage, createTestAssistantStream } from "./helpers.js";
@@ -222,6 +223,13 @@ test("spawn execute builds prompt with notebook pages and task", async () => {
222223
assert.match(seenPrompt, /entry-a: preview line/);
223224
});
224225

226+
test("truncateText handles multi-byte boundaries correctly", () => {
227+
assert.equal(truncateText("🙂", 10, 2), "");
228+
assert.equal(truncateText("🙂", 10, 4), "🙂");
229+
assert.equal(truncateText("", 10, 1024), "");
230+
assert.equal(truncateText("hello", 10, 1024), "hello");
231+
});
232+
225233
test("spawn renderResult falls back to static text when no live session is stored", () => {
226234
const state = createState();
227235
const pi = createTestPI();

0 commit comments

Comments
 (0)