mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
309785f847
* fix: guild create tests * fix(test): use setTimeout instead of while loop and fix some tests * fix(test): fix some test and fix maxMs Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { addReaction, cache, getReactions, sendMessage } from "../../mod.ts";
|
|
import { defaultTestOptions, tempData } from "../ws/start_bot.ts";
|
|
import { assertEquals, assertExists } from "../deps.ts";
|
|
import { delayUntil } from "../util/delay_until.ts";
|
|
|
|
Deno.test({
|
|
name: "[message] fetch reactions",
|
|
async fn() {
|
|
const message = await sendMessage(tempData.channelId, "Hello World!");
|
|
|
|
// Assertions
|
|
assertExists(message);
|
|
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
|
|
await delayUntil(10000, () => cache.messages.has(message.id));
|
|
// Make sure the message was created.
|
|
if (!cache.messages.has(message.id)) {
|
|
throw new Error("The message seemed to be sent but it was not cached.");
|
|
}
|
|
|
|
await addReaction(message.channelId, message.id, "❤");
|
|
|
|
// Fetch the message
|
|
const fetchedReactions = await getReactions(
|
|
tempData.channelId,
|
|
message.id,
|
|
"❤",
|
|
);
|
|
// Check if getMessage has worked
|
|
assertEquals(fetchedReactions.size, 1);
|
|
},
|
|
...defaultTestOptions,
|
|
});
|