tests: add more clone channel tests

This commit is contained in:
Skillz4Killz
2021-05-13 17:37:50 +00:00
committed by GitHub
parent a0bd415cbe
commit 4da861babe

View File

@@ -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,
});