refactor(agents): share text block extraction helper

This commit is contained in:
Peter Steinberger
2026-02-18 18:01:09 +00:00
parent 2d55cc446a
commit 85ebdf88b0
5 changed files with 42 additions and 41 deletions

View File

@@ -0,0 +1,19 @@
import { describe, expect, it } from "vitest";
import { collectTextContentBlocks } from "./content-blocks.js";
describe("collectTextContentBlocks", () => {
it("collects text content blocks in order", () => {
const blocks = [
{ type: "text", text: "first" },
{ type: "image", data: "abc" },
{ type: "text", text: "second" },
];
expect(collectTextContentBlocks(blocks)).toEqual(["first", "second"]);
});
it("ignores invalid entries and non-arrays", () => {
expect(collectTextContentBlocks(null)).toEqual([]);
expect(collectTextContentBlocks([{ type: "text", text: 1 }, undefined, "x"])).toEqual([]);
});
});