mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 20:34:32 +00:00
refactor: reuse ack reaction helper for whatsapp
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { shouldAckReaction } from "./ack-reactions.js";
|
||||
import { shouldAckReaction, shouldAckReactionForWhatsApp } from "./ack-reactions.js";
|
||||
|
||||
describe("shouldAckReaction", () => {
|
||||
it("honors direct and group-all scopes", () => {
|
||||
@@ -132,3 +132,93 @@ describe("shouldAckReaction", () => {
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldAckReactionForWhatsApp", () => {
|
||||
it("respects direct and group modes", () => {
|
||||
expect(
|
||||
shouldAckReactionForWhatsApp({
|
||||
emoji: "👀",
|
||||
isDirect: true,
|
||||
isGroup: false,
|
||||
directEnabled: true,
|
||||
groupMode: "mentions",
|
||||
wasMentioned: false,
|
||||
groupActivated: false,
|
||||
}),
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
shouldAckReactionForWhatsApp({
|
||||
emoji: "👀",
|
||||
isDirect: true,
|
||||
isGroup: false,
|
||||
directEnabled: false,
|
||||
groupMode: "mentions",
|
||||
wasMentioned: false,
|
||||
groupActivated: false,
|
||||
}),
|
||||
).toBe(false);
|
||||
|
||||
expect(
|
||||
shouldAckReactionForWhatsApp({
|
||||
emoji: "👀",
|
||||
isDirect: false,
|
||||
isGroup: true,
|
||||
directEnabled: true,
|
||||
groupMode: "always",
|
||||
wasMentioned: false,
|
||||
groupActivated: false,
|
||||
}),
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
shouldAckReactionForWhatsApp({
|
||||
emoji: "👀",
|
||||
isDirect: false,
|
||||
isGroup: true,
|
||||
directEnabled: true,
|
||||
groupMode: "never",
|
||||
wasMentioned: true,
|
||||
groupActivated: true,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("honors mentions or activation for group-mentions", () => {
|
||||
expect(
|
||||
shouldAckReactionForWhatsApp({
|
||||
emoji: "👀",
|
||||
isDirect: false,
|
||||
isGroup: true,
|
||||
directEnabled: true,
|
||||
groupMode: "mentions",
|
||||
wasMentioned: true,
|
||||
groupActivated: false,
|
||||
}),
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
shouldAckReactionForWhatsApp({
|
||||
emoji: "👀",
|
||||
isDirect: false,
|
||||
isGroup: true,
|
||||
directEnabled: true,
|
||||
groupMode: "mentions",
|
||||
wasMentioned: false,
|
||||
groupActivated: true,
|
||||
}),
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
shouldAckReactionForWhatsApp({
|
||||
emoji: "👀",
|
||||
isDirect: false,
|
||||
isGroup: true,
|
||||
directEnabled: true,
|
||||
groupMode: "mentions",
|
||||
wasMentioned: false,
|
||||
groupActivated: false,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user