diff --git a/tests/invite/createInvite.ts b/tests/invite/createInvite.ts deleted file mode 100644 index 1b4e6770f..000000000 --- a/tests/invite/createInvite.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { assertExists } from "../deps.ts"; -import { bot, channel } from "../mod.ts"; - -Deno.test({ - name: "[invite] create an invite", - async fn(t) { - const invite = await bot.helpers.createInvite(channel.id, { - maxAge: 86400, - maxUses: 0, - temporary: false, - unique: false, - }); - - // Assertions - assertExists(invite); - }, -}); diff --git a/tests/invite/deleteInvite.ts b/tests/invite/deleteInvite.ts deleted file mode 100644 index 81e81e30f..000000000 --- a/tests/invite/deleteInvite.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { assertExists, assertRejects } from "../deps.ts"; -import { bot, channel } from "../mod.ts"; - -Deno.test({ - name: "[invite] delete an invite", - async fn(t) { - const invite = await bot.helpers.createInvite(channel.id, { - maxAge: 86400, - maxUses: 0, - temporary: false, - unique: false, - }); - - // Assertions - assertExists(invite); - - await bot.helpers.deleteInvite(invite.code); - - // Assertions - assertRejects(() => bot.helpers.getInvite(invite.code)); - }, -}); diff --git a/tests/invite/getChannelInvites.ts b/tests/invite/getChannelInvites.ts deleted file mode 100644 index a1d61094d..000000000 --- a/tests/invite/getChannelInvites.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { assertEquals, assertExists } from "../deps.ts"; -import { bot, channel } from "../mod.ts"; - -Deno.test({ - name: "[invite] get channels invites", - async fn(t) { - const invite = await bot.helpers.createInvite(channel.id, { - maxAge: 86400, - maxUses: 0, - temporary: false, - unique: true, - }); - - // Assertions - assertExists(invite); - - const secondInvite = await bot.helpers.createInvite(channel.id, { - maxAge: 0, - maxUses: 2, - temporary: true, - unique: true, - }); - - // Assertions - assertExists(secondInvite); - - const invites = await bot.helpers.getChannelInvites(channel.id); - - assertEquals(invites.size > 1, true); - }, -}); diff --git a/tests/invite/getInvite.ts b/tests/invite/getInvite.ts deleted file mode 100644 index 63a97c7a1..000000000 --- a/tests/invite/getInvite.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { assertEquals, assertExists, assertNotEquals } from "../deps.ts"; -import { bot, channel, guild } from "../mod.ts"; - -Deno.test({ - name: "[invite] get invite", - async fn(t) { - const invite = await bot.helpers.createInvite(channel.id, { - maxAge: 86400, - maxUses: 0, - temporary: false, - unique: false, - }); - - // Assertions - assertExists(invite); - - const fetchedInvite = await bot.helpers.getInvite(invite.code); - - assertExists(fetchedInvite); - assertEquals(fetchedInvite.code, invite.code); - - await t.step({ - name: "[invite] get invites", - async fn() { - const fetchedInvites = await bot.helpers.getInvites(guild.id); - - assertExists(fetchedInvites); - assertNotEquals(fetchedInvites.size, 0); - }, - }); - }, -}); diff --git a/tests/invite/getInvites.ts b/tests/invite/getInvites.ts deleted file mode 100644 index 23cea3665..000000000 --- a/tests/invite/getInvites.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { assertExists, assertNotEquals } from "../deps.ts"; -import { bot, channel, guild } from "../mod.ts"; - -Deno.test({ - name: "[invite] get invites", - async fn(t) { - const invite = await bot.helpers.createInvite(channel.id, { - maxAge: 86400, - maxUses: 0, - temporary: false, - unique: false, - }); - - // Assertions - assertExists(invite); - - const fetchedInvites = await bot.helpers.getInvites(guild.id); - - assertExists(fetchedInvites); - assertNotEquals(fetchedInvites.size, 0); - }, -}); diff --git a/testss/channels/invites/invite.test.ts b/testss/channels/invites/invite.test.ts new file mode 100644 index 000000000..6ee75c4bc --- /dev/null +++ b/testss/channels/invites/invite.test.ts @@ -0,0 +1,78 @@ +import { ChannelTypes } from "../../../mod.ts"; +import { assertEquals, assertExists, assertNotEquals } from "../../deps.ts"; +import { loadBot } from "../../mod.ts"; +import { CACHED_COMMUNITY_GUILD_ID } from "../../utils.ts"; + +Deno.test({ + name: "[invite] create an invite", + async fn(t) { + const bot = await loadBot(); + const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { + name: "Discordeno-test", + type: ChannelTypes.GuildNews, + }); + + // Assertions + assertExists(channel.id); + + const invite = await bot.helpers.createInvite(channel.id, { + maxAge: 86400, + maxUses: 0, + temporary: false, + unique: false, + }); + + // Assertions + assertExists(invite.code); + + await t.step("[invite] Get an invite", async () => { + const inv = await bot.helpers.getInvite(invite.code); + assertExists(inv.code); + }); + + await t.step("[invite] Get an invite with counts", async () => { + const inv = await bot.helpers.getInvite(invite.code, { withCounts: true }); + assertExists(inv.code); + assertExists(inv.approximateMemberCount); + assertExists(inv.approximatePresenceCount); + }); + + await t.step("[invite] Get an invite with expiration", async () => { + const inv = await bot.helpers.getInvite(invite.code, { withExpiration: true }); + assertExists(inv.code); + assertExists(invite.expiresAt); + }); + + await t.step("[invite] Get an invite with everything", async () => { + const inv = await bot.helpers.getInvite(invite.code, { withCounts: true, withExpiration: true }); + assertExists(inv.code); + assertExists(inv.approximateMemberCount); + assertExists(inv.approximatePresenceCount); + assertExists(invite.expiresAt); + }); + + await t.step("[invite] Get all guild invites.", async () => { + const fetchedInvites = await bot.helpers.getInvites(CACHED_COMMUNITY_GUILD_ID); + + assertExists(fetchedInvites); + assertNotEquals(fetchedInvites.size, 0); + }); + + await t.step("[invite] Get all channel invites.", async () => { + const fetchedInvites = await bot.helpers.getChannelInvites(channel.id); + + assertExists(fetchedInvites); + assertNotEquals(fetchedInvites.size, 0); + }); + + await t.step("[invite] Delete an invite", async () => { + await bot.helpers.deleteInvite(invite.code); + + // THERE IS NO WAY TO VALIDATE IT DELETED SO WE JUST ASSUME IT DID + // If you fetched a deleted invite, you get a full invite object. Thx discord. + }); + + // Delete the channel once test is done + await bot.helpers.deleteChannel(channel.id); + }, +});