test(telegram): table-drive proxy client assertions and trim resets

This commit is contained in:
Peter Steinberger
2026-02-22 00:03:50 +00:00
parent 397d48c0a4
commit 91dd21b6b6

View File

@@ -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);
});