mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 19:04:58 +00:00
test: merge telegram reaction scenarios
This commit is contained in:
@@ -1102,47 +1102,44 @@ describe("sendMessageTelegram", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("reactMessageTelegram", () => {
|
describe("reactMessageTelegram", () => {
|
||||||
it("sends emoji reactions", async () => {
|
it.each([
|
||||||
const setMessageReaction = vi.fn().mockResolvedValue(undefined);
|
{
|
||||||
const api = { setMessageReaction } as unknown as {
|
testName: "sends emoji reactions",
|
||||||
setMessageReaction: typeof setMessageReaction;
|
target: "telegram:123",
|
||||||
};
|
messageId: "456",
|
||||||
|
emoji: "✅",
|
||||||
await reactMessageTelegram("telegram:123", "456", "✅", {
|
remove: false,
|
||||||
token: "tok",
|
expected: [{ type: "emoji", emoji: "✅" }],
|
||||||
api,
|
},
|
||||||
});
|
{
|
||||||
|
testName: "removes reactions when emoji is empty",
|
||||||
expect(setMessageReaction).toHaveBeenCalledWith("123", 456, [{ type: "emoji", emoji: "✅" }]);
|
target: "123",
|
||||||
});
|
messageId: 456,
|
||||||
|
emoji: "",
|
||||||
it("removes reactions when emoji is empty", async () => {
|
remove: false,
|
||||||
const setMessageReaction = vi.fn().mockResolvedValue(undefined);
|
expected: [],
|
||||||
const api = { setMessageReaction } as unknown as {
|
},
|
||||||
setMessageReaction: typeof setMessageReaction;
|
{
|
||||||
};
|
testName: "removes reactions when remove flag is set",
|
||||||
|
target: "123",
|
||||||
await reactMessageTelegram("123", 456, "", {
|
messageId: 456,
|
||||||
token: "tok",
|
emoji: "✅",
|
||||||
api,
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(setMessageReaction).toHaveBeenCalledWith("123", 456, []);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("removes reactions when remove flag is set", async () => {
|
|
||||||
const setMessageReaction = vi.fn().mockResolvedValue(undefined);
|
|
||||||
const api = { setMessageReaction } as unknown as {
|
|
||||||
setMessageReaction: typeof setMessageReaction;
|
|
||||||
};
|
|
||||||
|
|
||||||
await reactMessageTelegram("123", 456, "✅", {
|
|
||||||
token: "tok",
|
|
||||||
api,
|
|
||||||
remove: true,
|
remove: true,
|
||||||
|
expected: [],
|
||||||
|
},
|
||||||
|
] as const)("$testName", async (testCase) => {
|
||||||
|
const setMessageReaction = vi.fn().mockResolvedValue(undefined);
|
||||||
|
const api = { setMessageReaction } as unknown as {
|
||||||
|
setMessageReaction: typeof setMessageReaction;
|
||||||
|
};
|
||||||
|
|
||||||
|
await reactMessageTelegram(testCase.target, testCase.messageId, testCase.emoji, {
|
||||||
|
token: "tok",
|
||||||
|
api,
|
||||||
|
...(testCase.remove ? { remove: true } : {}),
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(setMessageReaction).toHaveBeenCalledWith("123", 456, []);
|
expect(setMessageReaction).toHaveBeenCalledWith("123", 456, testCase.expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user