test: 新增测试代码文件

This commit is contained in:
claude-code-best
2026-04-02 14:44:56 +08:00
parent 9c3803d16b
commit 006ad97fbb
32 changed files with 1102 additions and 68 deletions

View File

@@ -375,6 +375,16 @@ describe("isNotEmptyMessage", () => {
};
expect(isNotEmptyMessage(msg)).toBe(true);
});
test("returns false for whitespace-only text block in content array", () => {
const msg: any = {
type: "user",
message: {
content: [{ type: "text", text: " " }],
},
};
expect(isNotEmptyMessage(msg)).toBe(false);
});
});
// ─── deriveUUID ─────────────────────────────────────────────────────────
@@ -458,6 +468,11 @@ describe("normalizeMessages", () => {
]);
const normalized = normalizeMessages([msg]);
expect(normalized.length).toBe(2);
// Verify each split message contains only one content block
expect(normalized[0].message.content).toHaveLength(1);
expect((normalized[0].message.content as any[])[0].text).toBe("first");
expect(normalized[1].message.content).toHaveLength(1);
expect((normalized[1].message.content as any[])[0].text).toBe("second");
});
test("handles empty array", () => {