mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
tests: use delayUntil instead of delay
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { cache } from "../../src/cache.ts";
|
||||
import { createChannel } from "../../src/helpers/channels/create_channel.ts";
|
||||
import { deleteChannel } from "../../src/helpers/channels/delete_channel.ts";
|
||||
import { delay } from "../../src/util/utils.ts";
|
||||
import { defaultTestOptions, tempData } from "../ws/start_bot.ts";
|
||||
import { delayUntil } from "../util/delay_until.ts";
|
||||
|
||||
Deno.test({
|
||||
name: "[channel] delete a channel without a reason.",
|
||||
@@ -12,22 +12,22 @@ Deno.test({
|
||||
name: "delete-channel",
|
||||
});
|
||||
// wait 5 seconds to give it time for CHANNEL_CREATE event
|
||||
await delay(3000);
|
||||
delayUntil(3000, () => cache.channels.has(channel.id));
|
||||
// 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.",
|
||||
);
|
||||
}
|
||||
|
||||
// Delete the channel now without a reason
|
||||
await deleteChannel(tempData.guildId, channel.id);
|
||||
// wait 5 seconds to give it time for CHANNEL_DELETE event
|
||||
await delay(3000);
|
||||
delayUntil(3000, () => !cache.channels.has(channel.id));
|
||||
// Make sure it is gone from cache
|
||||
if (cache.channels.has(channel.id)) {
|
||||
throw new Error(
|
||||
"The channel should have been deleted but it is still in cache."
|
||||
"The channel should have been deleted but it is still in cache.",
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -42,22 +42,22 @@ Deno.test({
|
||||
name: "delete-channel",
|
||||
});
|
||||
// wait 5 seconds to give it time for CHANNEL_CREATE event
|
||||
await delay(3000);
|
||||
delayUntil(3000, () => cache.channels.has(channel.id));
|
||||
// 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.",
|
||||
);
|
||||
}
|
||||
|
||||
// Delete the channel now without a reason
|
||||
await deleteChannel(tempData.guildId, channel.id, "with a reason");
|
||||
// wait 5 seconds to give it time for CHANNEL_DELETE event
|
||||
await delay(3000);
|
||||
delayUntil(3000, () => !cache.channels.has(channel.id));
|
||||
// Make sure it is gone from cache
|
||||
if (cache.channels.has(channel.id)) {
|
||||
throw new Error(
|
||||
"The channel should have been deleted but it is still in cache."
|
||||
"The channel should have been deleted but it is still in cache.",
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user