test: guard usage command mock calls · openclaw/openclaw@9677da3
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -106,12 +106,28 @@ function buildCostTotals(overrides: Partial<CostUsageTotals> = {}): CostUsageTot
|
106 | 106 | |
107 | 107 | function expectSessionCostArgs(): Record<string, unknown> { |
108 | 108 | expect(loadSessionCostSummaryMock).toHaveBeenCalledTimes(1); |
109 | | -return (loadSessionCostSummaryMock.mock.calls[0] as unknown as [Record<string, unknown>])[0]; |
| 109 | +const call = loadSessionCostSummaryMock.mock.calls.at(0); |
| 110 | +if (!call) { |
| 111 | +throw new Error("expected loadSessionCostSummary call"); |
| 112 | +} |
| 113 | +const args = call.at(0); |
| 114 | +if (!args || typeof args !== "object") { |
| 115 | +throw new Error("expected loadSessionCostSummary args"); |
| 116 | +} |
| 117 | +return args as Record<string, unknown>; |
110 | 118 | } |
111 | 119 | |
112 | 120 | function expectFastModeArgs(): Record<string, unknown> { |
113 | 121 | expect(resolveFastModeStateMock).toHaveBeenCalledTimes(1); |
114 | | -return (resolveFastModeStateMock.mock.calls[0] as unknown as [Record<string, unknown>])[0]; |
| 122 | +const call = resolveFastModeStateMock.mock.calls.at(0); |
| 123 | +if (!call) { |
| 124 | +throw new Error("expected resolveFastModeState call"); |
| 125 | +} |
| 126 | +const args = call.at(0); |
| 127 | +if (!args || typeof args !== "object") { |
| 128 | +throw new Error("expected resolveFastModeState args"); |
| 129 | +} |
| 130 | +return args as Record<string, unknown>; |
115 | 131 | } |
116 | 132 | |
117 | 133 | describe("handleUsageCommand", () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。