From 707e0f5b0d8cf60cfcfed3cdc8150fba5387f719 Mon Sep 17 00:00:00 2001 From: Skillz4Killz Date: Sun, 31 Oct 2021 19:12:38 +0000 Subject: [PATCH] change: prettier code --- tests/helpers/channels/createChannel.ts | 56 ++++++++++++------------- tests/mod.ts | 22 +++++++--- 2 files changed, 45 insertions(+), 33 deletions(-) diff --git a/tests/helpers/channels/createChannel.ts b/tests/helpers/channels/createChannel.ts index c6716b0fc..876745469 100644 --- a/tests/helpers/channels/createChannel.ts +++ b/tests/helpers/channels/createChannel.ts @@ -1,34 +1,34 @@ import { Bot } from "../../../src/bot.ts"; import { CreateGuildChannel } from "../../../src/types/guilds/create_guild_channel.ts"; import { DiscordChannelTypes } from "../../../src/types/mod.ts"; -import { assertExists,assertEquals } from "../../deps.ts"; +import { assertExists, assertEquals } from "../../deps.ts"; import { delayUntil } from "../../utils.ts"; export async function createChannelTests(bot: Bot, guildId: bigint, options: CreateGuildChannel, t: Deno.TestContext) { - const channel = await bot.helpers.createChannel(guildId, options); - - // Assertions - assertExists(channel); - assertEquals(channel.type, options.type || DiscordChannelTypes.GuildText); - - // Delay the execution to allow event to be processed - await delayUntil(10000, () => bot.cache.channels.has(channel.id)); - - if (!bot.cache.channels.has(channel.id)) { - throw new Error("The channel seemed to be created but it was not cached."); - } - - if (options.topic && channel.topic !== options.topic) { - throw new Error("The channel was supposed to have a topic but it does not appear to be the same topic."); - } - - if (options.bitrate && channel.bitrate !== options.bitrate) { - throw new Error("The channel was supposed to have a bitrate but it does not appear to be the same bitrate."); - } - - if (options.permissionOverwrites && channel.permissionOverwrites?.length !== options.permissionOverwrites.length) { - throw new Error( - "The channel was supposed to have a permissionOverwrites but it does not appear to be the same permissionOverwrites." - ); - } - } \ No newline at end of file + const channel = await bot.helpers.createChannel(guildId, options); + + // Assertions + assertExists(channel); + assertEquals(channel.type, options.type || DiscordChannelTypes.GuildText); + + // Delay the execution to allow event to be processed + await delayUntil(10000, () => bot.cache.channels.has(channel.id)); + + if (!bot.cache.channels.has(channel.id)) { + throw new Error("The channel seemed to be created but it was not cached."); + } + + if (options.topic && channel.topic !== options.topic) { + throw new Error("The channel was supposed to have a topic but it does not appear to be the same topic."); + } + + if (options.bitrate && channel.bitrate !== options.bitrate) { + throw new Error("The channel was supposed to have a bitrate but it does not appear to be the same bitrate."); + } + + if (options.permissionOverwrites && channel.permissionOverwrites?.length !== options.permissionOverwrites.length) { + throw new Error( + "The channel was supposed to have a permissionOverwrites but it does not appear to be the same permissionOverwrites." + ); + } +} diff --git a/tests/mod.ts b/tests/mod.ts index baa68791c..101a976a2 100644 --- a/tests/mod.ts +++ b/tests/mod.ts @@ -1,5 +1,12 @@ import { TOKEN } from "../configs.ts"; -import { createBot, createEventHandlers, DiscordChannelTypes, DiscordOverwriteTypes, startBot, stopBot } from "../mod.ts"; +import { + createBot, + createEventHandlers, + DiscordChannelTypes, + DiscordOverwriteTypes, + startBot, + stopBot, +} from "../mod.ts"; import { assertEquals, assertExists } from "./deps.ts"; import { deleteMessageWithReasonTest, deleteMessageWithoutReasonTest } from "./helpers/messages/deleteMessage.ts"; import { getMessagesTest } from "./helpers/messages/getMessages.ts"; @@ -260,10 +267,15 @@ Deno.test("[Bot] - Starting Tests", async (t) => { t.step({ name: "[channel] create a new category channel", async fn() { - await createChannelTests(bot, guild.id, { - name: "Discordeno-test", - type: DiscordChannelTypes.GuildCategory, - }, t); + await createChannelTests( + bot, + guild.id, + { + name: "Discordeno-test", + type: DiscordChannelTypes.GuildCategory, + }, + t + ); }, ...sanitizeMode, }),