diff --git a/tests/helpers/emojis/createEmoji.ts b/tests/helpers/emojis/createEmoji.ts index 8b85278f4..5ad7581a9 100644 --- a/tests/helpers/emojis/createEmoji.ts +++ b/tests/helpers/emojis/createEmoji.ts @@ -3,19 +3,19 @@ import { assertExists } from "../../deps.ts"; import { delayUntil } from "../../utils.ts"; export async function createEmojiTest(bot: Bot, guildId: bigint, t: Deno.TestContext) { - const emoji = await bot.helpers.createEmoji(guildId, { - name: "blamewolf", - image: "https://cdn.discordapp.com/emojis/814955268123000832.png", - roles: [], - }); + const emoji = await bot.helpers.createEmoji(guildId, { + name: "blamewolf", + image: "https://cdn.discordapp.com/emojis/814955268123000832.png", + roles: [], + }); - // Assertions - assertExists(emoji); + // Assertions + assertExists(emoji); - // Delay the execution to allow event to be processed - await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)); + // Delay the execution to allow event to be processed + await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)); - if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) { - throw new Error("The emoji seemed to be created but it was not cached."); - } + if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) { + throw new Error("The emoji seemed to be created but it was not cached."); + } } diff --git a/tests/helpers/emojis/deleteEmoji.ts b/tests/helpers/emojis/deleteEmoji.ts index 5c98cf782..3cb3cdde5 100644 --- a/tests/helpers/emojis/deleteEmoji.ts +++ b/tests/helpers/emojis/deleteEmoji.ts @@ -3,35 +3,35 @@ import { assertExists } from "../../deps.ts"; import { delayUntil } from "../../utils.ts"; export async function ifItFailsBlameWolf(bot: Bot, guildId: bigint, reason?: string) { - const emoji = await bot.helpers.createEmoji(guildId, { - name: "blamewolf", - image: "https://cdn.discordapp.com/emojis/814955268123000832.png", - roles: [], - }); + const emoji = await bot.helpers.createEmoji(guildId, { + name: "blamewolf", + image: "https://cdn.discordapp.com/emojis/814955268123000832.png", + roles: [], + }); - // Assertions - assertExists(emoji); + // Assertions + assertExists(emoji); - // Delay the execution to allow event to be processed - await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)); + // Delay the execution to allow event to be processed + await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)); - if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) { - throw new Error("The emoji seemed to be created but it was not cached."); - } + if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) { + throw new Error("The emoji seemed to be created but it was not cached."); + } - await bot.helpers.deleteEmoji(guildId, emoji.id, reason); + await bot.helpers.deleteEmoji(guildId, emoji.id, reason); - await delayUntil(10000, async () => !(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)); + await delayUntil(10000, async () => !(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)); - if ((await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) { - throw new Error("The emoji seemed to be deleted but it's still cached."); - } + if ((await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) { + throw new Error("The emoji seemed to be deleted but it's still cached."); + } } export async function deleteEmojiWithReasonTest(bot: Bot, guildId: bigint, t: Deno.TestContext) { - await ifItFailsBlameWolf(bot, guildId); + await ifItFailsBlameWolf(bot, guildId); } export async function deleteEmojiWithoutReasonTest(bot: Bot, guildId: bigint, t: Deno.TestContext) { - await ifItFailsBlameWolf(bot, guildId, "with a reason"); + await ifItFailsBlameWolf(bot, guildId, "with a reason"); } diff --git a/tests/helpers/emojis/editEmoji.ts b/tests/helpers/emojis/editEmoji.ts index bf07a907f..b0ecab94c 100644 --- a/tests/helpers/emojis/editEmoji.ts +++ b/tests/helpers/emojis/editEmoji.ts @@ -3,29 +3,32 @@ import { assertExists } from "../../deps.ts"; import { delayUntil } from "../../utils.ts"; export async function editEmojiTest(bot: Bot, guildId: bigint, t: Deno.TestContext) { - const emoji = await bot.helpers.createEmoji(guildId, { - name: "blamewolf", - image: "https://cdn.discordapp.com/emojis/814955268123000832.png", - roles: [], - }); + const emoji = await bot.helpers.createEmoji(guildId, { + name: "blamewolf", + image: "https://cdn.discordapp.com/emojis/814955268123000832.png", + roles: [], + }); - // Assertions - assertExists(emoji); + // Assertions + assertExists(emoji); - // Delay the execution to allow event to be processed - await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)); + // Delay the execution to allow event to be processed + await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)); - if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) { - throw new Error("The emoji seemed to be created but it was not cached."); - } + if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) { + throw new Error("The emoji seemed to be created but it was not cached."); + } - await bot.helpers.editEmoji(guildId, emoji.id, { - name: "blamewolf_infinite", - }); + await bot.helpers.editEmoji(guildId, emoji.id, { + name: "blamewolf_infinite", + }); - await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.get(emoji.id)?.name === "blamewolf_infinite"); + await delayUntil( + 10000, + async () => (await bot.cache.guilds.get(guildId))?.emojis?.get(emoji.id)?.name === "blamewolf_infinite" + ); - if ((await bot.cache.guilds.get(guildId))?.emojis?.get(emoji.id)?.name !== "blamewolf_infinite") { - throw new Error("The emoji seemed to be edited but the cache was not updated."); - } + if ((await bot.cache.guilds.get(guildId))?.emojis?.get(emoji.id)?.name !== "blamewolf_infinite") { + throw new Error("The emoji seemed to be edited but the cache was not updated."); + } } diff --git a/tests/helpers/emojis/getEmoji.ts b/tests/helpers/emojis/getEmoji.ts index 496014d83..ea94ad6a7 100644 --- a/tests/helpers/emojis/getEmoji.ts +++ b/tests/helpers/emojis/getEmoji.ts @@ -3,33 +3,33 @@ import { assertExists } from "../../deps.ts"; import { delayUntil } from "../../utils.ts"; export async function getEmojiTest(bot: Bot, guildId: bigint, t: Deno.TestContext) { - const emoji = await bot.helpers.createEmoji(guildId, { - name: "blamewolf", - image: "https://cdn.discordapp.com/emojis/814955268123000832.png", - roles: [], - }); + const emoji = await bot.helpers.createEmoji(guildId, { + name: "blamewolf", + image: "https://cdn.discordapp.com/emojis/814955268123000832.png", + roles: [], + }); - // Assertions - assertExists(emoji); + // Assertions + assertExists(emoji); - // Delay the execution to allow event to be processed - await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)); + // Delay the execution to allow event to be processed + await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)); - if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) { - throw new Error("The emoji seemed to be created but it was not cached."); - } + if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) { + throw new Error("The emoji seemed to be created but it was not cached."); + } - (await bot.cache.guilds.get(guildId))?.emojis?.delete(emoji.id); + (await bot.cache.guilds.get(guildId))?.emojis?.delete(emoji.id); - const getEmoji = await bot.helpers.getEmoji(guildId, emoji.id, true); + const getEmoji = await bot.helpers.getEmoji(guildId, emoji.id, true); - // Assertions - assertExists(getEmoji); + // Assertions + assertExists(getEmoji); - // Delay the execution to allow event to be processed - await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)); + // Delay the execution to allow event to be processed + await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)); - if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) { - throw new Error("The emoji didn't got added to cache after using the getEmoji function."); - } + if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) { + throw new Error("The emoji didn't got added to cache after using the getEmoji function."); + } } diff --git a/tests/helpers/emojis/getEmojis.ts b/tests/helpers/emojis/getEmojis.ts index c00c33879..b9e1a1bbc 100644 --- a/tests/helpers/emojis/getEmojis.ts +++ b/tests/helpers/emojis/getEmojis.ts @@ -3,25 +3,25 @@ import { assertExists } from "../../deps.ts"; import { delayUntil } from "../../utils.ts"; export async function getEmojisTest(bot: Bot, guildId: bigint, t: Deno.TestContext) { - const emoji = await bot.helpers.createEmoji(guildId, { - name: "blamewolf", - image: "https://cdn.discordapp.com/emojis/814955268123000832.png", - roles: [], - }); + const emoji = await bot.helpers.createEmoji(guildId, { + name: "blamewolf", + image: "https://cdn.discordapp.com/emojis/814955268123000832.png", + roles: [], + }); - // Assertions - assertExists(emoji); + // Assertions + assertExists(emoji); - // Delay the execution to allow event to be processed - await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)); + // Delay the execution to allow event to be processed + await delayUntil(10000, async () => (await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)); - if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) { - throw new Error("The emoji seemed to be created but it was not cached."); - } + if (!(await bot.cache.guilds.get(guildId))?.emojis?.has(emoji.id)) { + throw new Error("The emoji seemed to be created but it was not cached."); + } - const emojis = await bot.helpers.getEmojis(guildId); + const emojis = await bot.helpers.getEmojis(guildId); - if (emojis.size === 0) { - throw new Error("The getEmojis function returned 0 emojis."); - } + if (emojis.size === 0) { + throw new Error("The getEmojis function returned 0 emojis."); + } } diff --git a/tests/mod.ts b/tests/mod.ts index b385c878e..72294f8c7 100644 --- a/tests/mod.ts +++ b/tests/mod.ts @@ -28,11 +28,11 @@ import { pinMessageTests } from "./helpers/messages/pin.ts"; import { removeAllReactionTests, removeReactionEmojiTest, removeReactionTest } from "./helpers/messages/reactions.ts"; import { createChannelTests } from "./helpers/channels/createChannel.ts"; import { deleteChannelTests } from "./helpers/channels/deleteChannel.ts"; -import {createEmojiTest} from "./helpers/emojis/createEmoji.ts"; -import {deleteEmojiWithoutReasonTest, deleteEmojiWithReasonTest} from "./helpers/emojis/deleteEmoji.ts"; -import {editEmojiTest} from "./helpers/emojis/editEmoji.ts"; -import {getEmojiTest} from "./helpers/emojis/getEmoji.ts"; -import {getEmojisTest} from "./helpers/emojis/getEmojis.ts"; +import { createEmojiTest } from "./helpers/emojis/createEmoji.ts"; +import { deleteEmojiWithoutReasonTest, deleteEmojiWithReasonTest } from "./helpers/emojis/deleteEmoji.ts"; +import { editEmojiTest } from "./helpers/emojis/editEmoji.ts"; +import { getEmojiTest } from "./helpers/emojis/getEmoji.ts"; +import { getEmojisTest } from "./helpers/emojis/getEmojis.ts"; Deno.test("[Bot] - Starting Tests", async (t) => { // CHANGE TO TRUE WHEN DEBUGGING SANITIZATION ERRORS @@ -481,13 +481,13 @@ Deno.test("[Bot] - Starting Tests", async (t) => { // EMOJIS TESTS GROUPED await t.step("Emojis related tests", async (t) => { await Promise.all([ - t.step({ - name: "[emoji] create an emoji", - fn: async (t) => { - await createEmojiTest(bot, guild.id, t); - }, - ...sanitizeMode, - }), + t.step({ + name: "[emoji] create an emoji", + fn: async (t) => { + await createEmojiTest(bot, guild.id, t); + }, + ...sanitizeMode, + }), t.step({ name: "[emoji] delete an emoji without a reason", fn: async (t) => { @@ -522,9 +522,9 @@ Deno.test("[Bot] - Starting Tests", async (t) => { await getEmojisTest(bot, guild.id, t); }, ...sanitizeMode, - }) + }), ]); - }) + }); await stopBot(bot); });