mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 09:20:08 +00:00
Merge branch 'fp-attempt-9001' of https://github.com/discordeno/discordeno into fp-attempt-9001
This commit is contained in:
@@ -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."
|
||||
);
|
||||
}
|
||||
}
|
||||
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."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
22
tests/mod.ts
22
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,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user