mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-22 22:52:03 +00:00
62 lines
1.7 KiB
TypeScript
62 lines
1.7 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { telegramMessageActions, telegramMessageActionRuntime } from "./channel-actions.js";
|
|
|
|
const handleTelegramActionMock = vi.hoisted(() => vi.fn());
|
|
const originalHandleTelegramAction = telegramMessageActionRuntime.handleTelegramAction;
|
|
|
|
describe("telegramMessageActions", () => {
|
|
beforeEach(() => {
|
|
handleTelegramActionMock.mockReset().mockResolvedValue({
|
|
ok: true,
|
|
content: [],
|
|
details: {},
|
|
});
|
|
telegramMessageActionRuntime.handleTelegramAction = (...args) =>
|
|
handleTelegramActionMock(...args);
|
|
});
|
|
|
|
afterEach(() => {
|
|
telegramMessageActionRuntime.handleTelegramAction = originalHandleTelegramAction;
|
|
});
|
|
|
|
it("allows interactive-only sends", async () => {
|
|
await telegramMessageActions.handleAction!({
|
|
action: "send",
|
|
params: {
|
|
to: "123456",
|
|
interactive: {
|
|
blocks: [
|
|
{
|
|
type: "buttons",
|
|
buttons: [{ label: "Approve", value: "approve", style: "success" }],
|
|
},
|
|
],
|
|
},
|
|
},
|
|
cfg: {} as never,
|
|
accountId: "default",
|
|
mediaLocalRoots: [],
|
|
} as never);
|
|
|
|
expect(handleTelegramActionMock).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
action: "sendMessage",
|
|
to: "123456",
|
|
interactive: {
|
|
blocks: [
|
|
{
|
|
type: "buttons",
|
|
buttons: [{ label: "Approve", value: "approve", style: "success" }],
|
|
},
|
|
],
|
|
},
|
|
accountId: "default",
|
|
}),
|
|
expect.anything(),
|
|
expect.objectContaining({
|
|
mediaLocalRoots: [],
|
|
}),
|
|
);
|
|
});
|
|
});
|