Skip to content

Commit 0f31b64

Browse files
committed
test: tighten proxy fetch assertions
1 parent 6eae017 commit 0f31b64

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

extensions/discord/src/client.proxy.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ describe("createDiscordRestClient proxy support", () => {
4444
options?: { fetch?: typeof fetch };
4545
};
4646

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);
4849
expect(requestClient.customFetch).toBe(requestClient.options?.fetch);
4950
});
5051

@@ -119,7 +120,7 @@ describe("createDiscordRestClient proxy support", () => {
119120
};
120121

121122
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);
123124
});
124125

125126
it("serializes multipart media with undici-compatible FormData for proxy fetches", async () => {

extensions/telegram/src/fetch.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,15 +571,22 @@ describe("resolveTelegramFetch", () => {
571571
);
572572
});
573573

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);
575576
const transport = resolveTelegramTransport(undefined, {
576577
network: {
577578
autoSelectFamily: true,
578579
dnsResultOrder: "ipv4first",
579580
},
580581
});
581582

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+
);
583590
expect(transport.fetch).not.toBe(transport.sourceFetch);
584591
expect(transport.dispatcherAttempts).toHaveLength(3);
585592

0 commit comments

Comments
 (0)