From 8dab3c9a9454b977aa17043a1c3b96370e291ffb Mon Sep 17 00:00:00 2001 From: Ayaan Zaidi Date: Tue, 17 Feb 2026 14:14:28 +0530 Subject: [PATCH] test: use fresh fetch responses in telegram tests --- src/telegram/bot.create-telegram-bot.test.ts | 28 ++++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/telegram/bot.create-telegram-bot.test.ts b/src/telegram/bot.create-telegram-bot.test.ts index 465c79927d9..172b98fcff6 100644 --- a/src/telegram/bot.create-telegram-bot.test.ts +++ b/src/telegram/bot.create-telegram-bot.test.ts @@ -1890,13 +1890,13 @@ describe("createTelegramBot", () => { }, }); - const fetchSpy = vi.spyOn(globalThis, "fetch" as never).mockResolvedValue({ - ok: true, - status: 200, - statusText: "OK", - headers: { get: () => "image/png" }, - arrayBuffer: async () => new Uint8Array([0x89, 0x50, 0x4e, 0x47]).buffer, - } as Response); + const fetchSpy = vi.spyOn(globalThis, "fetch").mockImplementation( + async () => + new Response(new Uint8Array([0x89, 0x50, 0x4e, 0x47]), { + status: 200, + headers: { "content-type": "image/png" }, + }), + ); createTelegramBot({ token: "tok", testTimings: TELEGRAM_TEST_TIMINGS }); const handler = getOnHandler("channel_post") as (ctx: Record) => Promise; @@ -2009,13 +2009,13 @@ describe("createTelegramBot", () => { }, }); - const fetchSpy = vi.spyOn(globalThis, "fetch" as never).mockResolvedValue({ - ok: true, - status: 200, - statusText: "OK", - headers: { get: () => "image/jpeg" }, - arrayBuffer: async () => new Uint8Array([0xff, 0xd8, 0xff, 0x00]).buffer, - } as Response); + const fetchSpy = vi.spyOn(globalThis, "fetch").mockImplementation( + async () => + new Response(new Uint8Array([0xff, 0xd8, 0xff, 0x00]), { + status: 200, + headers: { "content-type": "image/jpeg" }, + }), + ); createTelegramBot({ token: "tok", mediaMaxMb: 0 }); const handler = getOnHandler("channel_post") as (ctx: Record) => Promise;