mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
tests: add channel create with perms test (#825)
This commit is contained in:
@@ -5,6 +5,8 @@ import { DiscordChannelTypes } from "../../src/types/channels/channel_types.ts";
|
||||
import { CreateGuildChannel } from "../../src/types/guilds/create_guild_channel.ts";
|
||||
import { createChannel } from "../../src/helpers/channels/create_channel.ts";
|
||||
import { delayUntil } from "../util/delay_until.ts";
|
||||
import { DiscordOverwriteTypes } from "../../src/types/channels/overwrite_types.ts"
|
||||
import { botId } from "../../src/bot.ts";
|
||||
|
||||
async function ifItFailsBlameWolf(options: CreateGuildChannel, save = false) {
|
||||
const channel = await createChannel(tempData.guildId, options);
|
||||
@@ -24,13 +26,19 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel, save = false) {
|
||||
|
||||
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.",
|
||||
"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.",
|
||||
"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."
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -51,7 +59,7 @@ Deno.test({
|
||||
name: "Discordeno-test",
|
||||
type: DiscordChannelTypes.GUILD_CATEGORY,
|
||||
},
|
||||
true,
|
||||
true
|
||||
);
|
||||
},
|
||||
...defaultTestOptions,
|
||||
@@ -81,7 +89,7 @@ Deno.test({
|
||||
name: "Discordeno-test",
|
||||
type: DiscordChannelTypes.GUILD_VOICE,
|
||||
},
|
||||
true,
|
||||
true
|
||||
);
|
||||
},
|
||||
...defaultTestOptions,
|
||||
@@ -96,7 +104,7 @@ Deno.test({
|
||||
type: DiscordChannelTypes.GUILD_VOICE,
|
||||
bitrate: 32000,
|
||||
},
|
||||
true,
|
||||
true
|
||||
);
|
||||
},
|
||||
...defaultTestOptions,
|
||||
@@ -111,7 +119,7 @@ Deno.test({
|
||||
type: DiscordChannelTypes.GUILD_VOICE,
|
||||
userLimit: 32,
|
||||
},
|
||||
true,
|
||||
true
|
||||
);
|
||||
},
|
||||
...defaultTestOptions,
|
||||
@@ -125,7 +133,7 @@ Deno.test({
|
||||
name: "Discordeno-test",
|
||||
rateLimitPerUser: 2423,
|
||||
},
|
||||
true,
|
||||
true
|
||||
);
|
||||
},
|
||||
...defaultTestOptions,
|
||||
@@ -139,6 +147,26 @@ Deno.test({
|
||||
...defaultTestOptions,
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "[channel] create a new text channel with permission overwrites",
|
||||
async fn() {
|
||||
await ifItFailsBlameWolf(
|
||||
{
|
||||
name: "Discordeno-test",
|
||||
permissionOverwrites: [
|
||||
{
|
||||
id: botId,
|
||||
type: DiscordOverwriteTypes.MEMBER,
|
||||
allow: ["VIEW_CHANNEL"],
|
||||
deny: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
true
|
||||
);
|
||||
},
|
||||
...defaultTestOptions,
|
||||
});
|
||||
// TODO: Need to validate tests for these options
|
||||
// /** Sorting position of the channel */
|
||||
// position?: number;
|
||||
|
||||
Reference in New Issue
Block a user