From c824ef3bceb17f63550c115bed254ea3273b6254 Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Fri, 29 Oct 2021 17:23:51 +0000 Subject: [PATCH] refactor --- tests/helpers/messages/deleteMessage.ts | 12 ++---------- tests/mod.ts | 10 ++++++---- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/helpers/messages/deleteMessage.ts b/tests/helpers/messages/deleteMessage.ts index d35078b9d..cfd7a617d 100644 --- a/tests/helpers/messages/deleteMessage.ts +++ b/tests/helpers/messages/deleteMessage.ts @@ -7,7 +7,7 @@ async function ifItFailsBlameWolf(bot: Bot, channelId: bigint, reason?: string) // Assertions assertExists(message); - // Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed + // Delay the execution by to allow MESSAGE_CREATE event to be processed await delayUntil(10000, () => bot.cache.messages.has(message.id)); // Make sure the message was created. if (!bot.cache.messages.has(message.id)) { @@ -17,7 +17,7 @@ async function ifItFailsBlameWolf(bot: Bot, channelId: bigint, reason?: string) // Delete the message now await bot.helpers.deleteMessage(channelId, message.id, reason); - // Wait 5 seconds to give it time for MESSAGE_DELETE event + // Wait to give it time for MESSAGE_DELETE event await delayUntil(10000, () => !bot.cache.messages.has(message.id)); // Make sure it is gone from cache if (bot.cache.messages.has(message.id)) { @@ -26,17 +26,9 @@ async function ifItFailsBlameWolf(bot: Bot, channelId: bigint, reason?: string) } export async function deleteMessageWithoutReasonTest(bot: Bot, channelId: bigint, t: Deno.TestContext) { - console.log("⏳ [message] delete a message without a reason."); - await ifItFailsBlameWolf(bot, channelId); - - console.log("✅ [message] delete a message without a reason."); } export async function deleteMessageWithReasonTest(bot: Bot, channelId: bigint, t: Deno.TestContext) { - console.log("⏳ [message] delete a message with a reason."); - await ifItFailsBlameWolf(bot, channelId, "with a reason"); - - console.log("✅ [message] delete a message with a reason."); } diff --git a/tests/mod.ts b/tests/mod.ts index 3fea6a781..fb571b49c 100644 --- a/tests/mod.ts +++ b/tests/mod.ts @@ -82,10 +82,12 @@ Deno.test("[Bot] - Starting Tests", async (t) => { } // CONDUCT ALL TESTS RELATED TO A MESSAGE HERE - await Promise.all([ - deleteMessageWithoutReasonTest(bot, channel.id, t), - deleteMessageWithReasonTest(bot, channel.id, t), - ]); + await t.step("[message] delete message without a reason", async (t) => { + await deleteMessageWithoutReasonTest(bot, channel.id, t); + }); + await t.step("[message] delete message with a reason", async (t) => { + await deleteMessageWithReasonTest(bot, channel.id, t); + }); }); });