refactor: cron payload migration cleanup (#621)
* refactor: centralize cron payload migration * test: stabilize block streaming mocks * test: adjust chunker fence-close case
This commit is contained in:
committed by
GitHub
parent
e3c340fd38
commit
98d0318d4e
34
src/agents/pi-embedded-block-chunker.test.ts
Normal file
34
src/agents/pi-embedded-block-chunker.test.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
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/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user