mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 18:28:26 +00:00
refactor(agents): share text block extraction helper
This commit is contained in:
19
src/agents/content-blocks.test.ts
Normal file
19
src/agents/content-blocks.test.ts
Normal 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([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user