From 2450af26eccfa05d46feec93fa52b4713627eb0b Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 8 Jan 2026 07:51:58 +0000 Subject: [PATCH] test: fix telegram fetch expectation --- src/telegram/bot.test.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/telegram/bot.test.ts b/src/telegram/bot.test.ts index 8a98d6f27..c53682fce 100644 --- a/src/telegram/bot.test.ts +++ b/src/telegram/bot.test.ts @@ -4,6 +4,7 @@ import path from "node:path"; import { beforeEach, describe, expect, it, vi } from "vitest"; import * as replyModule from "../auto-reply/reply.js"; import { createTelegramBot, getTelegramSequentialKey } from "./bot.js"; +import { resolveTelegramFetch } from "./fetch.js"; const { loadWebMedia } = vi.hoisted(() => ({ loadWebMedia: vi.fn(), @@ -140,12 +141,17 @@ describe("createTelegramBot", () => { globalThis.fetch = fetchSpy; try { createTelegramBot({ token: "tok" }); - expect(botCtorSpy).toHaveBeenCalledWith( - "tok", - expect.objectContaining({ - client: expect.objectContaining({ fetch: fetchSpy }), - }), - ); + const fetchImpl = resolveTelegramFetch(); + if (fetchImpl) { + expect(botCtorSpy).toHaveBeenCalledWith( + "tok", + expect.objectContaining({ + client: expect.objectContaining({ fetch: fetchSpy }), + }), + ); + } else { + expect(botCtorSpy).toHaveBeenCalledWith("tok", undefined); + } } finally { globalThis.fetch = originalFetch; }