From 4da861babe6f8944d345cfba11afa51711b6052a Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Thu, 13 May 2021 17:37:50 +0000 Subject: [PATCH] tests: add more clone channel tests --- tests/channels/clone_channel.ts | 373 +++++++++++++++++++++++++++++++- 1 file changed, 371 insertions(+), 2 deletions(-) diff --git a/tests/channels/clone_channel.ts b/tests/channels/clone_channel.ts index 9838a7698..fc1a6af15 100644 --- a/tests/channels/clone_channel.ts +++ b/tests/channels/clone_channel.ts @@ -10,10 +10,16 @@ import { assertEquals, assertExists } from "../deps.ts"; import { delayUntil } from "../util/delay_until.ts"; import { defaultTestOptions, tempData } from "../ws/start_bot.ts"; -async function ifItFailsBlameWolf(options: CreateGuildChannel) { +async function ifItFailsBlameWolf( + options: CreateGuildChannel, + useGetter = false, + reason?: string, +) { const channel = await createChannel(tempData.guildId, options); - const cloned = await cloneChannel(channel.id); + const cloned = useGetter + ? await channel.clone(reason) + : await cloneChannel(channel.id, reason); //Assertations assertExists(cloned); @@ -47,6 +53,7 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel) { ); } } + Deno.test({ name: "[channel] clone a new text channel", async fn() { @@ -55,6 +62,18 @@ Deno.test({ ...defaultTestOptions, }); +Deno.test({ + name: "[channel] clone a new text channel w/reason", + async fn() { + await ifItFailsBlameWolf( + { name: "Discordeno-clone-test" }, + false, + "w/reason", + ); + }, + ...defaultTestOptions, +}); + Deno.test({ name: "[channel] clone a new category channel", async fn() { @@ -68,6 +87,21 @@ Deno.test({ ...defaultTestOptions, }); +Deno.test({ + name: "[channel] clone a new category channel w/reason", + async fn() { + await ifItFailsBlameWolf( + { + name: "Discordeno-clone-test", + type: DiscordChannelTypes.GuildCategory, + }, + false, + "w/reason", + ); + }, + ...defaultTestOptions, +}); + Deno.test({ name: "[channel] clone a new voice channel", async fn() { @@ -81,6 +115,21 @@ Deno.test({ ...defaultTestOptions, }); +Deno.test({ + name: "[channel] clone a new voice channel w/reason", + async fn() { + await ifItFailsBlameWolf( + { + name: "Discordeno-clone-test", + type: DiscordChannelTypes.GuildVoice, + }, + false, + "w/reason", + ); + }, + ...defaultTestOptions, +}); + Deno.test({ name: "[channel] clone a new voice channel with a bitrate", async fn() { @@ -95,6 +144,22 @@ Deno.test({ ...defaultTestOptions, }); +Deno.test({ + name: "[channel] clone a new voice channel with a bitrate w/reason", + async fn() { + await ifItFailsBlameWolf( + { + name: "discordeno-clone-test", + type: DiscordChannelTypes.GuildVoice, + bitrate: 32000, + }, + false, + "w/reason", + ); + }, + ...defaultTestOptions, +}); + Deno.test({ name: "[channel] clone a new voice channel with a user limit", async fn() { @@ -109,6 +174,22 @@ Deno.test({ ...defaultTestOptions, }); +Deno.test({ + name: "[channel] clone a new voice channel with a user limit w/reason", + async fn() { + await ifItFailsBlameWolf( + { + name: "Discordeno-clone-test", + type: DiscordChannelTypes.GuildVoice, + userLimit: 32, + }, + false, + "w/reason", + ); + }, + ...defaultTestOptions, +}); + Deno.test({ name: "[channel] clone a new text channel with a rate limit per user", async fn() { @@ -122,6 +203,22 @@ Deno.test({ ...defaultTestOptions, }); +Deno.test({ + name: + "[channel] clone a new text channel with a rate limit per user w/reason", + async fn() { + await ifItFailsBlameWolf( + { + name: "Discordeno-clone-test", + rateLimitPerUser: 2423, + }, + false, + "w/reason", + ); + }, + ...defaultTestOptions, +}); + Deno.test({ name: "[channel] clone a new text channel with NSFW", async fn() { @@ -132,6 +229,18 @@ Deno.test({ ...defaultTestOptions, }); +Deno.test({ + name: "[channel] clone a new text channel with NSFW w/reason", + async fn() { + await ifItFailsBlameWolf( + { name: "Discordeno-clone-test", nsfw: true }, + false, + "w/reason", + ); + }, + ...defaultTestOptions, +}); + Deno.test({ name: "[channel] clone a new text channel with permission overwrites", async fn() { @@ -151,3 +260,263 @@ Deno.test({ }, ...defaultTestOptions, }); + +Deno.test({ + name: "[channel] clone a new text channel with permission overwrites", + async fn() { + await ifItFailsBlameWolf( + { + name: "Discordeno-clone-test", + permissionOverwrites: [ + { + id: bigintToSnowflake(botId), + type: DiscordOverwriteTypes.Member, + allow: ["VIEW_CHANNEL"], + deny: [], + }, + ], + }, + false, + "w/reason", + ); + }, + ...defaultTestOptions, +}); + +// GETTERS + +Deno.test({ + name: "[channel] clone() a new text channel", + async fn() { + await ifItFailsBlameWolf({ name: "Discordeno-clone-test" }, true); + }, + ...defaultTestOptions, +}); + +Deno.test({ + name: "[channel] clone() a new text channel w/reason", + async fn() { + await ifItFailsBlameWolf( + { name: "Discordeno-clone-test" }, + true, + "w/reason", + ); + }, + ...defaultTestOptions, +}); + +Deno.test({ + name: "[channel] clone() a new category channel", + async fn() { + await ifItFailsBlameWolf( + { + name: "Discordeno-clone-test", + type: DiscordChannelTypes.GuildCategory, + }, + true, + ); + }, + ...defaultTestOptions, +}); + +Deno.test({ + name: "[channel] clone() a new category channel w/reason", + async fn() { + await ifItFailsBlameWolf( + { + name: "Discordeno-clone-test", + type: DiscordChannelTypes.GuildCategory, + }, + true, + "w/reason", + ); + }, + ...defaultTestOptions, +}); + +Deno.test({ + name: "[channel] clone() a new voice channel", + async fn() { + await ifItFailsBlameWolf( + { + name: "Discordeno-clone-test", + type: DiscordChannelTypes.GuildVoice, + }, + true, + ); + }, + ...defaultTestOptions, +}); + +Deno.test({ + name: "[channel] clone() a new voice channel w/reason", + async fn() { + await ifItFailsBlameWolf( + { + name: "Discordeno-clone-test", + type: DiscordChannelTypes.GuildVoice, + }, + true, + "w/reason", + ); + }, + ...defaultTestOptions, +}); + +Deno.test({ + name: "[channel] clone() a new voice channel with a bitrate", + async fn() { + await ifItFailsBlameWolf( + { + name: "discordeno-clone-test", + type: DiscordChannelTypes.GuildVoice, + bitrate: 32000, + }, + true, + ); + }, + ...defaultTestOptions, +}); + +Deno.test({ + name: "[channel] clone() a new voice channel with a bitrate w/reason", + async fn() { + await ifItFailsBlameWolf( + { + name: "discordeno-clone-test", + type: DiscordChannelTypes.GuildVoice, + bitrate: 32000, + }, + true, + "w/reason", + ); + }, + ...defaultTestOptions, +}); + +Deno.test({ + name: "[channel] clone() a new voice channel with a user limit", + async fn() { + await ifItFailsBlameWolf( + { + name: "Discordeno-clone-test", + type: DiscordChannelTypes.GuildVoice, + userLimit: 32, + }, + true, + ); + }, + ...defaultTestOptions, +}); + +Deno.test({ + name: "[channel] clone() a new voice channel with a user limit w/reason", + async fn() { + await ifItFailsBlameWolf( + { + name: "Discordeno-clone-test", + type: DiscordChannelTypes.GuildVoice, + userLimit: 32, + }, + true, + "w/reason", + ); + }, + ...defaultTestOptions, +}); + +Deno.test({ + name: "[channel] clone() a new text channel with a rate limit per user", + async fn() { + await ifItFailsBlameWolf( + { + name: "Discordeno-clone-test", + rateLimitPerUser: 2423, + }, + true, + ); + }, + ...defaultTestOptions, +}); + +Deno.test({ + name: + "[channel] clone() a new text channel with a rate limit per user w/reason", + async fn() { + await ifItFailsBlameWolf( + { + name: "Discordeno-clone-test", + rateLimitPerUser: 2423, + }, + true, + "w/reason", + ); + }, + ...defaultTestOptions, +}); + +Deno.test({ + name: "[channel] clone() a new text channel with NSFW", + async fn() { + await ifItFailsBlameWolf( + { name: "Discordeno-clone-test", nsfw: true }, + true, + ); + }, + ...defaultTestOptions, +}); + +Deno.test({ + name: "[channel] clone() a new text channel with NSFW w/reason", + async fn() { + await ifItFailsBlameWolf( + { name: "Discordeno-clone-test", nsfw: true }, + true, + "w/reason", + ); + }, + ...defaultTestOptions, +}); + +Deno.test({ + name: "[channel] clone() a new text channel with permission overwrites", + async fn() { + await ifItFailsBlameWolf( + { + name: "Discordeno-clone-test", + permissionOverwrites: [ + { + id: bigintToSnowflake(botId), + type: DiscordOverwriteTypes.Member, + allow: ["VIEW_CHANNEL"], + deny: [], + }, + ], + }, + true, + ); + }, + ...defaultTestOptions, +}); + +Deno.test({ + name: "[channel] clone() a new text channel with permission overwrites", + async fn() { + await ifItFailsBlameWolf( + { + name: "Discordeno-clone-test", + permissionOverwrites: [ + { + id: bigintToSnowflake(botId), + type: DiscordOverwriteTypes.Member, + allow: ["VIEW_CHANNEL"], + deny: [], + }, + ], + }, + true, + "w/reason", + ); + }, + ...defaultTestOptions, +});