fixed tests

This commit is contained in:
Skillz4Killz
2021-10-30 17:26:48 +00:00
committed by GitHub
parent 7386413850
commit d65178f694
4 changed files with 24 additions and 71 deletions
+7 -6
View File
@@ -2,6 +2,8 @@ import { Bot } from "../../../src/bot.ts";
import { assertEquals, assertExists } from "../../deps.ts";
import { delayUntil } from "../../utils.ts";
const reactionCounters = new Map<bigint, number>();
export async function addReactionTest(
bot: Bot,
guildId: bigint,
@@ -59,18 +61,17 @@ export async function addReactionTest(
}
}
let reactions = 0;
reactionCounters.set(message.id, 0);
bot.events.reactionAdd = function (bot, payload) {
if (payload.messageId !== message.id) return;
reactions++;
const current = reactionCounters.get(payload.messageId) || 0;
reactionCounters.set(payload.messageId, current + 1);
};
if (options.single) await bot.helpers.addReaction(message.channelId, message.id, emojiId);
else await bot.helpers.addReactions(message.channelId, message.id, emojiIds, options.ordered);
await delayUntil(10000, () => reactions === (options.single ? 1 : emojiIds.length));
await delayUntil(10000, () => reactionCounters.get(message.id) === (options.single ? 1 : emojiIds.length));
assertEquals(reactions, options.single ? 1 : emojiIds.length);
assertEquals(reactionCounters.get(message.id), options.single ? 1 : emojiIds.length);
}