37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import type { OpenClawConfig, PluginRuntime } from "openclaw/plugin-sdk/discord";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { discordPlugin } from "./channel.js";
|
|
import { setDiscordRuntime } from "./runtime.js";
|
|
|
|
describe("discordPlugin outbound", () => {
|
|
it("forwards mediaLocalRoots to sendMessageDiscord", async () => {
|
|
const sendMessageDiscord = vi.fn(async () => ({ messageId: "m1" }));
|
|
setDiscordRuntime({
|
|
channel: {
|
|
discord: {
|
|
sendMessageDiscord,
|
|
},
|
|
},
|
|
} as unknown as PluginRuntime);
|
|
|
|
const result = await discordPlugin.outbound!.sendMedia!({
|
|
cfg: {} as OpenClawConfig,
|
|
to: "channel:123",
|
|
text: "hi",
|
|
mediaUrl: "/tmp/image.png",
|
|
mediaLocalRoots: ["/tmp/agent-root"],
|
|
accountId: "work",
|
|
});
|
|
|
|
expect(sendMessageDiscord).toHaveBeenCalledWith(
|
|
"channel:123",
|
|
"hi",
|
|
expect.objectContaining({
|
|
mediaUrl: "/tmp/image.png",
|
|
mediaLocalRoots: ["/tmp/agent-root"],
|
|
}),
|
|
);
|
|
expect(result).toMatchObject({ channel: "discord", messageId: "m1" });
|
|
});
|
|
});
|