Skip to content

Commit 4fe12fc

Browse files
committed
test: clarify block chunker length assertion
1 parent f8e3442 commit 4fe12fc

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/agents/pi-embedded-block-chunker.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ function drainChunks(chunker: EmbeddedBlockChunker, force = false) {
1717
return chunks;
1818
}
1919

20+
function expectChunksWithinLength(chunks: string[], maxLength: number) {
21+
expect(
22+
chunks
23+
.map((chunk, index) => ({ index, length: chunk.length }))
24+
.filter((entry) => entry.length > maxLength),
25+
).toEqual([]);
26+
}
27+
2028
describe("EmbeddedBlockChunker", () => {
2129
it("breaks at paragraph boundary right after fence close", () => {
2230
const chunker = new EmbeddedBlockChunker({
@@ -95,7 +103,7 @@ describe("EmbeddedBlockChunker", () => {
95103

96104
const chunks = drainChunks(chunker);
97105

98-
expect(chunks.every((chunk) => chunk.length <= 10)).toBe(true);
106+
expectChunksWithinLength(chunks, 10);
99107
expect(chunks).toEqual(["abcdefghij", "k"]);
100108
expect(chunker.bufferedText).toBe("Rest");
101109
});

0 commit comments

Comments
 (0)