


















@@ -43,9 +43,13 @@ describe("tool-helpers", () => {
4343const input = '{"outer":{"inner":"value"}}';
4444const result = formatToolOutputForSidebar(input);
454546-expect(result).toContain("```json");
47-expect(result).toContain('"outer"');
48-expect(result).toContain('"inner"');
46+expect(result).toBe(`\`\`\`json
47+{
48+ "outer": {
49+ "inner": "value"
50+ }
51+}
52+\`\`\``);
4953});
50545155it("returns plain text for non-JSON content", () => {
@@ -73,8 +77,11 @@ describe("tool-helpers", () => {
7377const input = ' {"trimmed": true} ';
7478const result = formatToolOutputForSidebar(input);
757976-expect(result).toContain("```json");
77-expect(result).toContain('"trimmed"');
80+expect(result).toBe(`\`\`\`json
81+{
82+ "trimmed": true
83+}
84+\`\`\``);
7885});
79868087it("handles whitespace-only string", () => {
@@ -95,8 +102,7 @@ describe("tool-helpers", () => {
95102const input = "a".repeat(150);
96103const result = getTruncatedPreview(input);
9710498-expect(result.length).toBe(101); // 100 chars + ellipsis
99-expect(result.endsWith("…")).toBe(true);
105+expect(result).toBe(`${"a".repeat(100)}…`);
100106});
101107102108it("truncates to max lines", () => {
@@ -111,15 +117,14 @@ describe("tool-helpers", () => {
111117const input = "Line 1\nLine 2\nLine 3";
112118const result = getTruncatedPreview(input);
113119114-expect(result.endsWith("…")).toBe(true);
120+expect(result).toBe("Line 1\nLine 2…");
115121});
116122117123it("does not add ellipsis when all lines fit", () => {
118124const input = "Line 1\nLine 2";
119125const result = getTruncatedPreview(input);
120126121127expect(result).toBe("Line 1\nLine 2");
122-expect(result.endsWith("…")).toBe(false);
123128});
124129125130it("handles single line within limits", () => {
@@ -135,8 +140,7 @@ describe("tool-helpers", () => {
135140const input = `${longLine}\n${longLine}`;
136141const result = getTruncatedPreview(input);
137142138-expect(result.length).toBe(101); // 100 + ellipsis
139-expect(result.endsWith("…")).toBe(true);
143+expect(result).toBe(`${"x".repeat(80)}\n${"x".repeat(19)}…`);
140144});
141145});
142146});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。