test: tighten proxy fetch assertions · openclaw/openclaw@0f31b64
steipete
·
2026-05-08
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -44,7 +44,8 @@ describe("createDiscordRestClient proxy support", () => {
|
44 | 44 | options?: { fetch?: typeof fetch }; |
45 | 45 | }; |
46 | 46 | |
47 | | -expect(requestClient.options?.fetch).toEqual(expect.any(Function)); |
| 47 | +expect(makeProxyFetchMock).toHaveBeenCalledWith("http://127.0.0.1:8080"); |
| 48 | +expect(requestClient.options?.fetch).toBe(makeProxyFetchMock.mock.results[0]?.value); |
48 | 49 | expect(requestClient.customFetch).toBe(requestClient.options?.fetch); |
49 | 50 | }); |
50 | 51 | |
@@ -119,7 +120,7 @@ describe("createDiscordRestClient proxy support", () => {
|
119 | 120 | }; |
120 | 121 | |
121 | 122 | expect(makeProxyFetchMock).toHaveBeenCalledWith("http://[::1]:8080"); |
122 | | -expect(requestClient.options?.fetch).toEqual(expect.any(Function)); |
| 123 | +expect(requestClient.options?.fetch).toBe(makeProxyFetchMock.mock.results[0]?.value); |
123 | 124 | }); |
124 | 125 | |
125 | 126 | it("serializes multipart media with undici-compatible FormData for proxy fetches", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -571,15 +571,22 @@ describe("resolveTelegramFetch", () => {
|
571 | 571 | ); |
572 | 572 | }); |
573 | 573 | |
574 | | -it("exports fallback dispatcher attempts for Telegram media downloads", () => { |
| 574 | +it("exports fallback dispatcher attempts for Telegram media downloads", async () => { |
| 575 | +undiciFetch.mockResolvedValueOnce({ ok: true } as Response); |
575 | 576 | const transport = resolveTelegramTransport(undefined, { |
576 | 577 | network: { |
577 | 578 | autoSelectFamily: true, |
578 | 579 | dnsResultOrder: "ipv4first", |
579 | 580 | }, |
580 | 581 | }); |
581 | 582 | |
582 | | -expect(transport.sourceFetch).toEqual(expect.any(Function)); |
| 583 | +await expect( |
| 584 | +transport.sourceFetch("https://api.telegram.org/botTOKEN/getFile"), |
| 585 | +).resolves.toEqual({ ok: true }); |
| 586 | +expect(undiciFetch).toHaveBeenCalledWith( |
| 587 | +"https://api.telegram.org/botTOKEN/getFile", |
| 588 | +undefined, |
| 589 | +); |
583 | 590 | expect(transport.fetch).not.toBe(transport.sourceFetch); |
584 | 591 | expect(transport.dispatcherAttempts).toHaveLength(3); |
585 | 592 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。