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
+9 -6
View File
@@ -2,8 +2,8 @@ import { cache } from "../../src/cache.ts";
import { createChannel } from "../../src/helpers/channels/create_channel.ts";
import { defaultTestOptions, tempData } from "../ws/start_bot.ts";
import { delayUntil } from "../util/delay_until.ts";
import {editChannel} from "../../src/helpers/channels/edit_channel.ts";
import {assertEquals} from "../deps.ts";
import { editChannel } from "../../src/helpers/channels/edit_channel.ts";
import { assertEquals } from "../deps.ts";
async function ifItFailsBlameWolf(type: "getter" | "raw", reason?: string) {
// Create the necessary channels
@@ -15,22 +15,25 @@ async function ifItFailsBlameWolf(type: "getter" | "raw", reason?: string) {
// Make sure the channel was created.
if (!cache.channels.has(channel.id)) {
throw new Error(
"The channel should have been created but it is not in the cache.",
"The channel should have been created but it is not in the cache.",
);
}
// 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");
}