diff --git a/src/telegram/send.proxy.test.ts b/src/telegram/send.proxy.test.ts index aa20cb72db7..ee47ec765c4 100644 --- a/src/telegram/send.proxy.test.ts +++ b/src/telegram/send.proxy.test.ts @@ -79,34 +79,31 @@ describe("telegram proxy client", () => { botApi.sendMessage.mockResolvedValue({ message_id: 1, chat: { id: "123" } }); botApi.setMessageReaction.mockResolvedValue(undefined); botApi.deleteMessage.mockResolvedValue(true); - botCtorSpy.mockReset(); + botCtorSpy.mockClear(); loadConfig.mockReturnValue({ channels: { telegram: { accounts: { foo: { proxy: proxyUrl } } } }, }); - makeProxyFetch.mockReset(); - resolveTelegramFetch.mockReset(); + makeProxyFetch.mockClear(); + resolveTelegramFetch.mockClear(); }); - it("uses proxy fetch for sendMessage", async () => { + it.each([ + { + name: "sendMessage", + run: () => sendMessageTelegram("123", "hi", { token: "tok", accountId: "foo" }), + }, + { + name: "reactions", + run: () => reactMessageTelegram("123", "456", "✅", { token: "tok", accountId: "foo" }), + }, + { + name: "deleteMessage", + run: () => deleteMessageTelegram("123", "456", { token: "tok", accountId: "foo" }), + }, + ])("uses proxy fetch for $name", async (testCase) => { const { fetchImpl } = prepareProxyFetch(); - await sendMessageTelegram("123", "hi", { token: "tok", accountId: "foo" }); - - expectProxyClient(fetchImpl); - }); - - it("uses proxy fetch for reactions", async () => { - const { fetchImpl } = prepareProxyFetch(); - - await reactMessageTelegram("123", "456", "✅", { token: "tok", accountId: "foo" }); - - expectProxyClient(fetchImpl); - }); - - it("uses proxy fetch for deleteMessage", async () => { - const { fetchImpl } = prepareProxyFetch(); - - await deleteMessageTelegram("123", "456", { token: "tok", accountId: "foo" }); + await testCase.run(); expectProxyClient(fetchImpl); });