test: trim redundant ack-reaction removeAfterReply guard case

This commit is contained in:
Peter Steinberger
2026-02-16 09:27:12 +00:00
parent f8ae538985
commit 6a392b8493

View File

@@ -1,11 +1,14 @@
import { describe, expect, it, vi } from "vitest";
import { sleep } from "../utils.ts";
import {
removeAckReactionAfterReply,
shouldAckReaction,
shouldAckReactionForWhatsApp,
} from "./ack-reactions.js";
const flushMicrotasks = async () => {
await Promise.resolve();
};
describe("shouldAckReaction", () => {
it("honors direct and group-all scopes", () => {
expect(
@@ -238,7 +241,7 @@ describe("removeAckReactionAfterReply", () => {
remove,
onError,
});
await sleep(0);
await flushMicrotasks();
expect(remove).toHaveBeenCalledTimes(1);
expect(onError).not.toHaveBeenCalled();
});
@@ -251,19 +254,7 @@ describe("removeAckReactionAfterReply", () => {
ackReactionValue: "👀",
remove,
});
await sleep(0);
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);
await flushMicrotasks();
expect(remove).not.toHaveBeenCalled();
});
});