mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-21 16:41:56 +00:00
test(telegram): table-drive proxy client assertions and trim resets
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user