mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 03:24:32 +00:00
test: trim redundant ack-reaction removeAfterReply guard case
This commit is contained in:
@@ -1,11 +1,14 @@
|
|||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
import { sleep } from "../utils.ts";
|
|
||||||
import {
|
import {
|
||||||
removeAckReactionAfterReply,
|
removeAckReactionAfterReply,
|
||||||
shouldAckReaction,
|
shouldAckReaction,
|
||||||
shouldAckReactionForWhatsApp,
|
shouldAckReactionForWhatsApp,
|
||||||
} from "./ack-reactions.js";
|
} from "./ack-reactions.js";
|
||||||
|
|
||||||
|
const flushMicrotasks = async () => {
|
||||||
|
await Promise.resolve();
|
||||||
|
};
|
||||||
|
|
||||||
describe("shouldAckReaction", () => {
|
describe("shouldAckReaction", () => {
|
||||||
it("honors direct and group-all scopes", () => {
|
it("honors direct and group-all scopes", () => {
|
||||||
expect(
|
expect(
|
||||||
@@ -238,7 +241,7 @@ describe("removeAckReactionAfterReply", () => {
|
|||||||
remove,
|
remove,
|
||||||
onError,
|
onError,
|
||||||
});
|
});
|
||||||
await sleep(0);
|
await flushMicrotasks();
|
||||||
expect(remove).toHaveBeenCalledTimes(1);
|
expect(remove).toHaveBeenCalledTimes(1);
|
||||||
expect(onError).not.toHaveBeenCalled();
|
expect(onError).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@@ -251,19 +254,7 @@ describe("removeAckReactionAfterReply", () => {
|
|||||||
ackReactionValue: "👀",
|
ackReactionValue: "👀",
|
||||||
remove,
|
remove,
|
||||||
});
|
});
|
||||||
await sleep(0);
|
await flushMicrotasks();
|
||||||
expect(remove).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("skips when not configured", async () => {
|
|
||||||
const remove = vi.fn().mockResolvedValue(undefined);
|
|
||||||
removeAckReactionAfterReply({
|
|
||||||
removeAfterReply: false,
|
|
||||||
ackReactionPromise: Promise.resolve(true),
|
|
||||||
ackReactionValue: "👀",
|
|
||||||
remove,
|
|
||||||
});
|
|
||||||
await sleep(0);
|
|
||||||
expect(remove).not.toHaveBeenCalled();
|
expect(remove).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user