fix: improve unit tests style

This commit is contained in:
Skillz4Killz
2021-11-22 16:34:30 +00:00
committed by GitHub
parent 70e9ef29ac
commit d23ff868c7
46 changed files with 1048 additions and 545 deletions
+1 -28
View File
@@ -35,32 +35,5 @@ export async function removeRoleTest(
options: { reason?: string },
t: Deno.TestContext
) {
const role = await bot.helpers.createRole(guildId, {
name: "hoti",
});
assertExists(role);
// Delay the execution to allow event to be processed
await delayUntil(10000, () => bot.cache.guilds.get(guildId)?.roles.has(role.id));
assertExists(bot.cache.guilds.get(guildId)?.roles.has(role.id));
bot.events.guildMemberUpdate = function (bot, member, user) {
roleChanges.set(user.id, member.roles);
};
await bot.helpers.addRole(guildId, bot.id, role.id, options.reason);
// Delay the execution to allow event to be processed
await delayUntil(10000, () => roleChanges.get(bot.id)?.includes(role.id));
assertEquals(roleChanges.get(bot.id)?.includes(role.id), true);
await bot.helpers.removeRole(guildId, bot.id, role.id, options.reason);
// Delay the execution to allow event to be processed
await delayUntil(10000, () => !roleChanges.get(bot.id)?.includes(role.id));
assertEquals(roleChanges.get(bot.id)?.includes(role.id), false);
}