Files
clawdbot/src/agents/pi-embedded-block-chunker.test.ts
Peter Steinberger 98d0318d4e refactor: cron payload migration cleanup (#621)
* refactor: centralize cron payload migration

* test: stabilize block streaming mocks

* test: adjust chunker fence-close case
2026-01-09 22:56:55 +00:00

35 lines
899 B
TypeScript

import { describe, expect, it } from "vitest";
import { EmbeddedBlockChunker } from "./pi-embedded-block-chunker.js";
describe("EmbeddedBlockChunker", () => {
it("breaks at paragraph boundary right after fence close", () => {
const chunker = new EmbeddedBlockChunker({
minChars: 1,
maxChars: 40,
breakPreference: "paragraph",
});
const text = [
"Intro",
"```js",
"console.log('x')",
"```",
"",
"After first line",
"After second line",
].join("\n");
chunker.append(text);
const chunks: string[] = [];
chunker.drain({ force: false, emit: (chunk) => chunks.push(chunk) });
expect(chunks.length).toBe(1);
expect(chunks[0]).toContain("console.log");
expect(chunks[0]).toMatch(/```\n?$/);
expect(chunks[0]).not.toContain("After");
expect(chunker.bufferedText).toMatch(/^After/);
});
});