refactor(web): split provider module
This commit is contained in:
32
src/web/inbound.test.ts
Normal file
32
src/web/inbound.test.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { extractMediaPlaceholder, extractText } from "./inbound.js";
|
||||
|
||||
describe("web inbound helpers", () => {
|
||||
it("prefers the main conversation body", () => {
|
||||
const body = extractText({
|
||||
conversation: " hello ",
|
||||
} as unknown as import("@whiskeysockets/baileys").proto.IMessage);
|
||||
expect(body).toBe("hello");
|
||||
});
|
||||
|
||||
it("falls back to captions when conversation text is missing", () => {
|
||||
const body = extractText({
|
||||
imageMessage: { caption: " caption " },
|
||||
} as unknown as import("@whiskeysockets/baileys").proto.IMessage);
|
||||
expect(body).toBe("caption");
|
||||
});
|
||||
|
||||
it("returns placeholders for media-only payloads", () => {
|
||||
expect(
|
||||
extractMediaPlaceholder({
|
||||
imageMessage: {},
|
||||
} as unknown as import("@whiskeysockets/baileys").proto.IMessage),
|
||||
).toBe("<media:image>");
|
||||
expect(
|
||||
extractMediaPlaceholder({
|
||||
audioMessage: {},
|
||||
} as unknown as import("@whiskeysockets/baileys").proto.IMessage),
|
||||
).toBe("<media:audio>");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user