fix(test): reduce channel suite startup hotspots

This commit is contained in:
Vincent Koc
2026-03-22 17:36:32 -07:00
parent 976eefe373
commit b21bcf6eb6
4 changed files with 255 additions and 187 deletions

View File

@@ -51,6 +51,7 @@ const createTelegramBot = (opts: Parameters<typeof createTelegramBotBase>[0]) =>
});
const loadConfig = getLoadConfigMock();
const loadWebMedia = getLoadWebMediaMock();
const readChannelAllowFromStore = getReadChannelAllowFromStoreMock();
const upsertChannelPairingRequest = getUpsertChannelPairingRequestMock();
@@ -1259,7 +1260,6 @@ describe("createTelegramBot", () => {
});
it("sends GIF replies as animations", async () => {
const loadWebMedia = getLoadWebMediaMock();
replySpy.mockResolvedValueOnce({
text: "caption",
mediaUrl: "https://example.com/fun",
@@ -1269,7 +1269,6 @@ describe("createTelegramBot", () => {
contentType: "image/gif",
fileName: "fun.gif",
});
createTelegramBot({ token: "tok" });
const handler = getOnHandler("message") as (ctx: Record<string, unknown>) => Promise<void>;
@@ -1292,6 +1291,8 @@ describe("createTelegramBot", () => {
reply_to_message_id: undefined,
});
expect(sendPhotoSpy).not.toHaveBeenCalled();
expect(loadWebMedia).toHaveBeenCalledTimes(1);
expect(loadWebMedia.mock.calls[0]?.[0]).toBe("https://example.com/fun");
});
function resetHarnessSpies() {