test: dedupe fetch guard mock reads · openclaw/openclaw@cbf6d5c
steipete
·
2026-05-13
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -102,7 +102,7 @@ function firstMockCall<T extends unknown[]>(mock: { mock: { calls: T[] } }): T |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | function getSecondRequestHeaders(fetchImpl: ReturnType<typeof vi.fn>): Headers { |
105 | | -const [, secondInit] = fetchImpl.mock.calls.at(1) as [string, RequestInit]; |
| 105 | +const secondInit = getSecondRequestInit(fetchImpl); |
106 | 106 | return new Headers(secondInit.headers); |
107 | 107 | } |
108 | 108 | |
@@ -123,7 +123,11 @@ function getFirstRequestInit(fetchImpl: ReturnType<typeof vi.fn>): RequestInit {
|
123 | 123 | } |
124 | 124 | |
125 | 125 | function getSecondRequestInit(fetchImpl: ReturnType<typeof vi.fn>): RequestInit { |
126 | | -const [, secondInit] = fetchImpl.mock.calls.at(1) as [string, RequestInit]; |
| 126 | +const call = fetchImpl.mock.calls[1]; |
| 127 | +if (!call) { |
| 128 | +throw new Error("expected second fetch call"); |
| 129 | +} |
| 130 | +const [, secondInit] = call as [string, RequestInit]; |
127 | 131 | return secondInit; |
128 | 132 | } |
129 | 133 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。