mirror of https://github.com/openclaw/openclaw.git
test: tighten shared join and message content coverage
This commit is contained in:
parent
2d7a061161
commit
ae5563dd18
|
|
@ -18,6 +18,19 @@ describe("shared/chat-message-content", () => {
|
|||
).toBe("");
|
||||
});
|
||||
|
||||
it("only considers the first content block even if later blocks have text", () => {
|
||||
expect(
|
||||
extractFirstTextBlock({
|
||||
content: [null, { text: "later" }],
|
||||
}),
|
||||
).toBeUndefined();
|
||||
expect(
|
||||
extractFirstTextBlock({
|
||||
content: [{ type: "image" }, { text: "later" }],
|
||||
}),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("returns undefined for missing, empty, or non-text content", () => {
|
||||
expect(extractFirstTextBlock(null)).toBeUndefined();
|
||||
expect(extractFirstTextBlock({ content: [] })).toBeUndefined();
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ describe("concatOptionalTextSegments", () => {
|
|||
it("falls back to whichever side is present and honors custom separators", () => {
|
||||
expect(concatOptionalTextSegments({ left: "A" })).toBe("A");
|
||||
expect(concatOptionalTextSegments({ right: "B" })).toBe("B");
|
||||
expect(concatOptionalTextSegments({ left: "", right: "B" })).toBe("B");
|
||||
expect(concatOptionalTextSegments({ left: "" })).toBe("");
|
||||
expect(concatOptionalTextSegments({ left: "A", right: "B", separator: " | " })).toBe("A | B");
|
||||
});
|
||||
});
|
||||
|
|
@ -36,4 +38,8 @@ describe("joinPresentTextSegments", () => {
|
|||
"A | B",
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves segment whitespace when trim is disabled", () => {
|
||||
expect(joinPresentTextSegments(["A", " B "], { separator: "|" })).toBe("A| B ");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue