fix: improve unit tests style

This commit is contained in:
Skillz4Killz
2021-11-22 16:34:30 +00:00
committed by GitHub
parent 70e9ef29ac
commit d23ff868c7
46 changed files with 1048 additions and 545 deletions
+32
View File
@@ -0,0 +1,32 @@
import { assertExists } from "../deps.ts";
import { bot, guild } from "../mod.ts";
import { delayUntil } from "../utils.ts";
Deno.test({
name: "[emoji] delete an emoji without a reason",
fn: async (t) => {
const emoji = await bot.helpers.createEmoji(guild.id, {
name: "blamewolf",
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
roles: [],
});
// Assertions
assertExists(emoji);
// Delay the execution to allow event to be processed
await delayUntil(10000, async () => bot.cache.guilds.get(guild.id)?.emojis?.has(emoji.id));
if (!bot.cache.guilds.get(guild.id)?.emojis?.has(emoji.id)) {
throw new Error("The emoji seemed to be created but it was not cached.");
}
await bot.helpers.deleteEmoji(guild.id, emoji.id);
await delayUntil(10000, async () => !bot.cache.guilds.get(guild.id)?.emojis?.has(emoji.id));
if (bot.cache.guilds.get(guild.id)?.emojis?.has(emoji.id)) {
throw new Error("The emoji seemed to be deleted but it's still cached.");
}
},
});