This commit is contained in:
itohatweb
2021-04-13 07:26:23 +00:00
parent 174ec859f1
commit 5afa6f2c13
10 changed files with 132 additions and 86 deletions
@@ -36,9 +36,14 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel, save = false) {
}
assertEquals(
channelOverwriteHasPermission(channel.guildId, botId, cache.channels.get(channel.id)?.permissionOverwrites, options.permissionOverwrites ? options.permissionOverwrites[0].allow : []),
true
)
channelOverwriteHasPermission(
channel.guildId,
botId,
cache.channels.get(channel.id)?.permissionOverwrites,
options.permissionOverwrites ? options.permissionOverwrites[0].allow : [],
),
true,
);
}
Deno.test({
+6 -3
View File
@@ -22,15 +22,18 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", reason?: string) {
// Edit the channel now
if (type === "raw") {
await editChannel(channel.id, {
name: "new-name"
name: "new-name",
}, reason);
} else {
await channel.edit({
name: "new-name"
name: "new-name",
});
}
// wait 5 seconds to give it time for CHANNEL_UPDATE event
await delayUntil(3000, () => cache.channels.get(channel.id)?.name === "new-name");
await delayUntil(
3000,
() => cache.channels.get(channel.id)?.name === "new-name",
);
assertEquals(cache.channels.get(channel.id)?.name, "new-name");
}
+15 -4
View File
@@ -43,13 +43,24 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel, save = false) {
await delayUntil(
10000,
() => channelOverwriteHasPermission(channel.guildId, botId, cache.channels.get(channel.id)?.permissionOverwrites, ["VIEW_CHANNEL", "ADD_REACTIONS"]),
() =>
channelOverwriteHasPermission(
channel.guildId,
botId,
cache.channels.get(channel.id)?.permissionOverwrites,
["VIEW_CHANNEL", "ADD_REACTIONS"],
),
);
assertEquals(
channelOverwriteHasPermission(channel.guildId, botId, cache.channels.get(channel.id)?.permissionOverwrites, ["VIEW_CHANNEL", "ADD_REACTIONS"]),
true
)
channelOverwriteHasPermission(
channel.guildId,
botId,
cache.channels.get(channel.id)?.permissionOverwrites,
["VIEW_CHANNEL", "ADD_REACTIONS"],
),
true,
);
}
Deno.test({
+13 -4
View File
@@ -12,7 +12,7 @@ Deno.test({
name: "[channel] get pins.",
async fn() {
const channel = await createChannel(tempData.guildId, {
name: 'pins-channel'
name: "pins-channel",
});
// Assertions
@@ -22,14 +22,23 @@ Deno.test({
await delayUntil(10000, () => cache.channels.has(channel.id));
if (!cache.channels.has(channel.id)) {
throw new Error("The channel seemed to be created but it was not cached.");
throw new Error(
"The channel seemed to be created but it was not cached.",
);
}
const message = await sendMessage(tempData.channelId, "Hello World!");
const secondMessage = await sendMessage(tempData.channelId, "Goodbye World!");
const secondMessage = await sendMessage(
tempData.channelId,
"Goodbye World!",
);
// Delay the execution by 5 seconds to allow MESSAGE_CREATE event to be processed
await delayUntil(10000, () => cache.messages.has(message.id) && cache.messages.has(secondMessage.id));
await delayUntil(
10000,
() =>
cache.messages.has(message.id) && cache.messages.has(secondMessage.id),
);
await message.pin();
await secondMessage.pin();
+8 -4
View File
@@ -31,12 +31,14 @@ Deno.test({
await delayUntil(10000, () => cache.channels.has(category.id));
if (!cache.channels.has(category.id)) {
throw new Error("The channel seemed to be created but it was not cached.");
throw new Error(
"The channel seemed to be created but it was not cached.",
);
}
const channel = await createChannel(tempData.guildId, {
name: 'synced-channel',
parentId: category.id
name: "synced-channel",
parentId: category.id,
});
// Assertions
@@ -46,7 +48,9 @@ Deno.test({
await delayUntil(10000, () => cache.channels.has(channel.id));
if (!cache.channels.has(channel.id)) {
throw new Error("The channel seemed to be created but it was not cached.");
throw new Error(
"The channel seemed to be created but it was not cached.",
);
}
const isSynced = await isChannelSynced(channel.id);
+4 -2
View File
@@ -13,7 +13,7 @@ Deno.test({
name: "[channel] is typing.",
async fn() {
const channel = await createChannel(tempData.guildId, {
name: 'typing-channel',
name: "typing-channel",
});
// Assertions
@@ -23,7 +23,9 @@ Deno.test({
await delayUntil(10000, () => cache.channels.has(channel.id));
if (!cache.channels.has(channel.id)) {
throw new Error("The channel seemed to be created but it was not cached.");
throw new Error(
"The channel seemed to be created but it was not cached.",
);
}
await startTyping(channel.id);
+26 -13
View File
@@ -14,49 +14,62 @@ Deno.test({
name: "[channel] swap channels",
async fn() {
const channel = await createChannel(tempData.guildId, {
name: 'channel-1',
name: "channel-1",
});
// Assertions
assertExists(channel);
const secondChannel = await createChannel(tempData.guildId, {
name: 'channel-2',
name: "channel-2",
});
// Assertions
assertExists(channel);
// Delay the execution by 5 seconds to allow CHANNEL_CREATE event to be processed
await delayUntil(10000, () => cache.channels.has(channel.id) && cache.channels.has(secondChannel.id));
await delayUntil(
10000,
() =>
cache.channels.has(channel.id) && cache.channels.has(secondChannel.id),
);
if (!cache.channels.has(channel.id) || !cache.channels.has(secondChannel.id)) {
throw new Error("The channel seemed to be created but it was not cached.");
if (
!cache.channels.has(channel.id) || !cache.channels.has(secondChannel.id)
) {
throw new Error(
"The channel seemed to be created but it was not cached.",
);
}
await swapChannels(tempData.guildId, [
{
id: channel.id,
position: secondChannel.position!
position: secondChannel.position!,
},
{
id: secondChannel.id,
position: channel.position!
}
position: channel.position!,
},
]);
// Delay the execution by 5 seconds to allow CHANNEL_UPDATE event to be processed
await delayUntil(10000, () => cache.channels.get(channel.id)?.position === secondChannel.position && cache.channels.get(secondChannel.id)?.position === channel.position);
await delayUntil(
10000,
() =>
cache.channels.get(channel.id)?.position === secondChannel.position &&
cache.channels.get(secondChannel.id)?.position === channel.position,
);
assertEquals(
cache.channels.get(channel.id)?.position,
secondChannel.position
)
secondChannel.position,
);
assertEquals(
cache.channels.get(secondChannel.id)?.position,
channel.position
)
channel.position,
);
},
...defaultTestOptions,
});
-1
View File
@@ -26,7 +26,6 @@ import "./channels/is_channel_synced.ts";
import "./channels/start_typing.ts";
import "./channels/swap_channels.ts";
// Emojis tests
import "./emojis/create_emoji.ts";
import "./emojis/delete_emoji.ts";