Files
discordeno/tests/guilds/delete_server.ts
TriForMine 309785f847 fix(test): delayUntil use setTimeout instead of while loop & addReaction test (#817)
* fix: guild create tests
* fix(test): use setTimeout instead of while loop and fix some tests
* fix(test): fix some test and fix maxMs

Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
2021-04-11 10:44:01 +01:00

25 lines
802 B
TypeScript

import { cache } from "../../src/cache.ts";
import { deleteServer } from "../../src/helpers/guilds/delete_server.ts";
import { defaultTestOptions, tempData } from "../ws/start_bot.ts";
import { delayUntil } from "../util/delay_until.ts";
Deno.test({
name: "[guild] delete a guild",
async fn() {
if (!tempData.guildId) {
throw new Error("The guild id was not available to be deleted.");
}
if (!cache.guilds.has(tempData.guildId)) {
throw new Error("The guild was not cached so impossible to delete.");
}
await deleteServer(tempData.guildId);
await delayUntil(10000, () => !cache.guilds.has(tempData.guildId));
if (cache.guilds.has(tempData.guildId)) {
throw new Error("The guild was not able to be deleted.");
}
},
...defaultTestOptions,
});