test: tighten proxy fetch assertions

This commit is contained in:
Peter Steinberger
2026-05-08 06:28:52 +01:00
parent 6eae017dd6
commit 0f31b6424e
2 changed files with 12 additions and 4 deletions

View File

@@ -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 () => {

View File

@@ -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);