Merge remote-tracking branch 'origin/unit-tests-invites' into unit-tests-invites

# Conflicts:
#	tests/mod.ts
This commit is contained in:
Quentin Nicolini
2021-11-01 10:05:14 +01:00
6 changed files with 70 additions and 70 deletions
+8 -8
View File
@@ -2,13 +2,13 @@ import { Bot } from "../../../src/bot.ts";
import { assertExists } from "../../deps.ts";
export async function createInviteTest(bot: Bot, channelId: bigint, t: Deno.TestContext) {
const invite = await bot.helpers.createInvite(channelId, {
maxAge: 86400,
maxUses: 0,
temporary: false,
unique: false,
});
const invite = await bot.helpers.createInvite(channelId, {
maxAge: 86400,
maxUses: 0,
temporary: false,
unique: false,
});
// Assertions
assertExists(invite);
// Assertions
assertExists(invite);
}
+11 -11
View File
@@ -2,18 +2,18 @@ import { Bot } from "../../../src/bot.ts";
import { assertExists } from "../../deps.ts";
export async function deleteInviteTest(bot: Bot, channelId: bigint, t: Deno.TestContext) {
const invite = await bot.helpers.createInvite(channelId, {
maxAge: 86400,
maxUses: 0,
temporary: false,
unique: false,
});
const invite = await bot.helpers.createInvite(channelId, {
maxAge: 86400,
maxUses: 0,
temporary: false,
unique: false,
});
// Assertions
assertExists(invite);
// Assertions
assertExists(invite);
const deletedInvite = await bot.helpers.deleteInvite(channelId, invite.code);
const deletedInvite = await bot.helpers.deleteInvite(channelId, invite.code);
// Assertions
assertExists(deletedInvite);
// Assertions
assertExists(deletedInvite);
}
+20 -20
View File
@@ -2,29 +2,29 @@ import { Bot } from "../../../src/bot.ts";
import { assertExists } from "../../deps.ts";
export async function getChannelInvitesTest(bot: Bot, channelId: bigint, t: Deno.TestContext) {
const invite = await bot.helpers.createInvite(channelId, {
maxAge: 86400,
maxUses: 0,
temporary: false,
unique: false,
});
const invite = await bot.helpers.createInvite(channelId, {
maxAge: 86400,
maxUses: 0,
temporary: false,
unique: false,
});
// Assertions
assertExists(invite);
// Assertions
assertExists(invite);
const secondInvite = await bot.helpers.createInvite(channelId, {
maxAge: 86400,
maxUses: 0,
temporary: false,
unique: false,
});
const secondInvite = await bot.helpers.createInvite(channelId, {
maxAge: 86400,
maxUses: 0,
temporary: false,
unique: false,
});
// Assertions
assertExists(secondInvite);
// Assertions
assertExists(secondInvite);
const invites = await bot.helpers.getChannelInvites(channelId);
const invites = await bot.helpers.getChannelInvites(channelId);
if (invites.size < 2) {
throw new Error("The function getChannelInvites didn't return all the invites");
}
if (invites.size < 2) {
throw new Error("The function getChannelInvites didn't return all the invites");
}
}
+12 -12
View File
@@ -1,19 +1,19 @@
import { Bot } from "../../../src/bot.ts";
import {assertEquals, assertExists} from "../../deps.ts";
import { assertEquals, assertExists } from "../../deps.ts";
export async function getInviteTest(bot: Bot, channelId: bigint, t: Deno.TestContext) {
const invite = await bot.helpers.createInvite(channelId, {
maxAge: 86400,
maxUses: 0,
temporary: false,
unique: false,
});
const invite = await bot.helpers.createInvite(channelId, {
maxAge: 86400,
maxUses: 0,
temporary: false,
unique: false,
});
// Assertions
assertExists(invite);
// Assertions
assertExists(invite);
const fetchedInvite = await bot.helpers.getInvite(invite.code);
const fetchedInvite = await bot.helpers.getInvite(invite.code);
assertExists(fetchedInvite);
assertEquals(fetchedInvite.code, invite.code);
assertExists(fetchedInvite);
assertEquals(fetchedInvite.code, invite.code);
}
+14 -14
View File
@@ -1,22 +1,22 @@
import { Bot } from "../../../src/bot.ts";
import {assertEquals, assertExists} from "../../deps.ts";
import { assertEquals, assertExists } from "../../deps.ts";
export async function getInvitesTest(bot: Bot, channelId: bigint, guildId: bigint, t: Deno.TestContext) {
const invite = await bot.helpers.createInvite(channelId, {
maxAge: 86400,
maxUses: 0,
temporary: false,
unique: false,
});
const invite = await bot.helpers.createInvite(channelId, {
maxAge: 86400,
maxUses: 0,
temporary: false,
unique: false,
});
// Assertions
assertExists(invite);
// Assertions
assertExists(invite);
const fetchedInvites = await bot.helpers.getInvites(guildId);
const fetchedInvites = await bot.helpers.getInvites(guildId);
assertExists(fetchedInvites);
assertExists(fetchedInvites);
if (fetchedInvites.size === 0) {
throw new Error("The function getInvites didn't return any invites");
}
if (fetchedInvites.size === 0) {
throw new Error("The function getInvites didn't return any invites");
}
}
+5 -5
View File
@@ -28,11 +28,11 @@ import { pinMessageTests } from "./helpers/messages/pin.ts";
import { removeAllReactionTests, removeReactionEmojiTest, removeReactionTest } from "./helpers/messages/reactions.ts";
import { createChannelTests } from "./helpers/channels/createChannel.ts";
import { deleteChannelTests } from "./helpers/channels/deleteChannel.ts";
import {createInviteTest} from "./helpers/invites/create_invite.ts";
import {deleteInviteTest} from "./helpers/invites/delete_invite.ts";
import {getChannelInvitesTest} from "./helpers/invites/get_channels_invites.ts";
import {getInviteTest} from "./helpers/invites/get_invite.ts";
import {getInvitesTest} from "./helpers/invites/get_invites.ts";
import { createInviteTest } from "./helpers/invites/create_invite.ts";
import { deleteInviteTest } from "./helpers/invites/delete_invite.ts";
import { getChannelInvitesTest } from "./helpers/invites/get_channels_invites.ts";
import { getInviteTest } from "./helpers/invites/get_invite.ts";
import { getInvitesTest } from "./helpers/invites/get_invites.ts";
Deno.test("[Bot] - Starting Tests", async (t) => {
// CHANGE TO TRUE WHEN DEBUGGING SANITIZATION ERRORS