test: dedupe custom theme mock reads · openclaw/openclaw@f57c500
steipete
·
2026-05-13
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -101,6 +101,18 @@ function createResponse(
|
101 | 101 | } as unknown as Response; |
102 | 102 | } |
103 | 103 | |
| 104 | +function firstFetchCall( |
| 105 | +fetchImpl: typeof fetch, |
| 106 | +): [string, { headers?: unknown; redirect?: unknown; signal?: unknown }] { |
| 107 | +const call = vi.mocked(fetchImpl).mock.calls[0] as |
| 108 | +| [string, { headers?: unknown; redirect?: unknown; signal?: unknown }] |
| 109 | +| undefined; |
| 110 | +if (!call) { |
| 111 | +throw new Error("expected fetch call"); |
| 112 | +} |
| 113 | +return call; |
| 114 | +} |
| 115 | + |
104 | 116 | describe("custom theme import helpers", () => { |
105 | 117 | it("normalizes tweakcn share links and raw registry links", () => { |
106 | 118 | expect( |
@@ -181,10 +193,7 @@ describe("custom theme import helpers", () => {
|
181 | 193 | expect(imported.label).toBe("Light Green"); |
182 | 194 | const fetchMock = vi.mocked(fetchImpl); |
183 | 195 | expect(fetchMock).toHaveBeenCalledTimes(1); |
184 | | -const [fetchUrl, fetchOptions] = fetchMock.mock.calls.at(0) as [ |
185 | | -string, |
186 | | -{ headers?: unknown; redirect?: unknown; signal?: unknown }, |
187 | | -]; |
| 196 | +const [fetchUrl, fetchOptions] = firstFetchCall(fetchImpl); |
188 | 197 | expect(fetchUrl).toBe("https://tweakcn.com/r/themes/cmlhfpjhw000004l4f4ax3m7z"); |
189 | 198 | expect(fetchOptions.signal).toBeInstanceOf(AbortSignal); |
190 | 199 | expect(fetchOptions).toEqual({ |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。