test: dedupe matrix handler mock reads · openclaw/openclaw@da23f45
steipete
·
2026-05-13
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -64,13 +64,21 @@ describe("createMatrixRoomMessageHandler inbound body formatting", () => {
|
64 | 64 | function latestFinalizedReplyContext( |
65 | 65 | finalizeInboundContext: MatrixHandlerHarness["finalizeInboundContext"], |
66 | 66 | ) { |
67 | | -return vi.mocked(finalizeInboundContext).mock.calls.at(-1)?.[0] as FinalizedReplyContext; |
| 67 | +const calls = vi.mocked(finalizeInboundContext).mock.calls; |
| 68 | +const call = calls[calls.length - 1]; |
| 69 | +if (!call) { |
| 70 | +throw new Error("expected finalizeInboundContext call"); |
| 71 | +} |
| 72 | +return call[0] as FinalizedReplyContext; |
68 | 73 | } |
69 | 74 | |
70 | 75 | function latestSessionKey(recordInboundSession: MatrixHandlerHarness["recordInboundSession"]) { |
71 | | -const context = vi.mocked(recordInboundSession).mock.calls.at(-1)?.[0] as |
72 | | -| { sessionKey?: string } |
73 | | -| undefined; |
| 76 | +const calls = vi.mocked(recordInboundSession).mock.calls; |
| 77 | +const call = calls[calls.length - 1]; |
| 78 | +if (!call) { |
| 79 | +throw new Error("expected recordInboundSession call"); |
| 80 | +} |
| 81 | +const context = call[0] as { sessionKey?: string }; |
74 | 82 | return context?.sessionKey; |
75 | 83 | } |
76 | 84 | |
@@ -355,11 +363,7 @@ describe("createMatrixRoomMessageHandler inbound body formatting", () => {
|
355 | 363 | }), |
356 | 364 | ); |
357 | 365 | |
358 | | -const finalized = vi.mocked(finalizeInboundContext).mock.calls.at(-1)?.[0] as { |
359 | | -ReplyToBody?: string; |
360 | | -ReplyToSender?: string; |
361 | | -ThreadStarterBody?: string; |
362 | | -}; |
| 366 | +const finalized = latestFinalizedReplyContext(finalizeInboundContext); |
363 | 367 | expect(finalized.ThreadStarterBody).toBeUndefined(); |
364 | 368 | expect(finalized.ReplyToBody).toBeUndefined(); |
365 | 369 | expect(finalized.ReplyToSender).toBeUndefined(); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。