test: dedupe embedded reasoning mock reads · openclaw/openclaw@b8bbe0e
steipete
·
2026-05-13
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -24,10 +24,18 @@ describe("subscribeEmbeddedPiSession", () => {
|
24 | 24 | return { emit, onBlockReply }; |
25 | 25 | } |
26 | 26 | |
| 27 | +function blockReplyTextAt(onBlockReply: ReturnType<typeof vi.fn>, callIndex: number): string { |
| 28 | +const call = onBlockReply.mock.calls[callIndex]; |
| 29 | +if (!call) { |
| 30 | +throw new Error(`expected block reply call ${callIndex + 1}`); |
| 31 | +} |
| 32 | +return (call[0] as { text?: string }).text ?? ""; |
| 33 | +} |
| 34 | + |
27 | 35 | function expectReasoningAndAnswerCalls(onBlockReply: ReturnType<typeof vi.fn>) { |
28 | 36 | expect(onBlockReply).toHaveBeenCalledTimes(2); |
29 | | -expect(onBlockReply.mock.calls.at(0)?.[0].text).toBe("Because it helps"); |
30 | | -expect(onBlockReply.mock.calls.at(1)?.[0].text).toBe("Final answer"); |
| 37 | +expect(blockReplyTextAt(onBlockReply, 0)).toBe("Because it helps"); |
| 38 | +expect(blockReplyTextAt(onBlockReply, 1)).toBe("Final answer"); |
31 | 39 | } |
32 | 40 | |
33 | 41 | it("emits reasoning as a separate message when enabled", () => { |
@@ -46,7 +54,7 @@ describe("subscribeEmbeddedPiSession", () => {
|
46 | 54 | emit({ type: "message_end", message: createReasoningFinalAnswerMessage() }); |
47 | 55 | |
48 | 56 | expect(onBlockReply).toHaveBeenCalledTimes(1); |
49 | | -expect(onBlockReply.mock.calls.at(0)?.[0].text).toBe("Final answer"); |
| 57 | +expect(blockReplyTextAt(onBlockReply, 0)).toBe("Final answer"); |
50 | 58 | }); |
51 | 59 | |
52 | 60 | it.each(THINKING_TAG_CASES)( |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。