mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 21:20:43 +00:00
test: tighten proxy fetch assertions
This commit is contained in:
@@ -44,7 +44,8 @@ describe("createDiscordRestClient proxy support", () => {
|
||||
options?: { fetch?: typeof fetch };
|
||||
};
|
||||
|
||||
expect(requestClient.options?.fetch).toEqual(expect.any(Function));
|
||||
expect(makeProxyFetchMock).toHaveBeenCalledWith("http://127.0.0.1:8080");
|
||||
expect(requestClient.options?.fetch).toBe(makeProxyFetchMock.mock.results[0]?.value);
|
||||
expect(requestClient.customFetch).toBe(requestClient.options?.fetch);
|
||||
});
|
||||
|
||||
@@ -119,7 +120,7 @@ describe("createDiscordRestClient proxy support", () => {
|
||||
};
|
||||
|
||||
expect(makeProxyFetchMock).toHaveBeenCalledWith("http://[::1]:8080");
|
||||
expect(requestClient.options?.fetch).toEqual(expect.any(Function));
|
||||
expect(requestClient.options?.fetch).toBe(makeProxyFetchMock.mock.results[0]?.value);
|
||||
});
|
||||
|
||||
it("serializes multipart media with undici-compatible FormData for proxy fetches", async () => {
|
||||
|
||||
@@ -571,7 +571,8 @@ describe("resolveTelegramFetch", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("exports fallback dispatcher attempts for Telegram media downloads", () => {
|
||||
it("exports fallback dispatcher attempts for Telegram media downloads", async () => {
|
||||
undiciFetch.mockResolvedValueOnce({ ok: true } as Response);
|
||||
const transport = resolveTelegramTransport(undefined, {
|
||||
network: {
|
||||
autoSelectFamily: true,
|
||||
@@ -579,7 +580,13 @@ describe("resolveTelegramFetch", () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(transport.sourceFetch).toEqual(expect.any(Function));
|
||||
await expect(
|
||||
transport.sourceFetch("https://api.telegram.org/botTOKEN/getFile"),
|
||||
).resolves.toEqual({ ok: true });
|
||||
expect(undiciFetch).toHaveBeenCalledWith(
|
||||
"https://api.telegram.org/botTOKEN/getFile",
|
||||
undefined,
|
||||
);
|
||||
expect(transport.fetch).not.toBe(transport.sourceFetch);
|
||||
expect(transport.dispatcherAttempts).toHaveLength(3);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user