@gguf/claw
Version:
Multi-channel AI gateway with extensible messaging integrations
67 lines (59 loc) • 1.82 kB
text/typescript
import { describe, expect, it, vi } from "vitest";
import { imessagePlugin } from "./channel.js";
describe("imessagePlugin outbound", () => {
const cfg = {
channels: {
imessage: {
mediaMaxMb: 3,
},
},
};
it("forwards replyToId on direct sendText adapter path", async () => {
const sendIMessage = vi.fn().mockResolvedValue({ messageId: "m-text" });
const sendText = imessagePlugin.outbound?.sendText;
expect(sendText).toBeDefined();
const result = await sendText!({
cfg,
to: "chat_id:12",
text: "hello",
accountId: "default",
replyToId: "reply-1",
deps: { sendIMessage },
});
expect(sendIMessage).toHaveBeenCalledWith(
"chat_id:12",
"hello",
expect.objectContaining({
accountId: "default",
replyToId: "reply-1",
maxBytes: 3 * 1024 * 1024,
}),
);
expect(result).toEqual({ channel: "imessage", messageId: "m-text" });
});
it("forwards replyToId on direct sendMedia adapter path", async () => {
const sendIMessage = vi.fn().mockResolvedValue({ messageId: "m-media" });
const sendMedia = imessagePlugin.outbound?.sendMedia;
expect(sendMedia).toBeDefined();
const result = await sendMedia!({
cfg,
to: "chat_id:77",
text: "caption",
mediaUrl: "https://example.com/pic.png",
accountId: "acct-1",
replyToId: "reply-2",
deps: { sendIMessage },
});
expect(sendIMessage).toHaveBeenCalledWith(
"chat_id:77",
"caption",
expect.objectContaining({
mediaUrl: "https://example.com/pic.png",
accountId: "acct-1",
replyToId: "reply-2",
maxBytes: 3 * 1024 * 1024,
}),
);
expect(result).toEqual({ channel: "imessage", messageId: "m-media" });
});
});