diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml deleted file mode 100644 index 727adcd04..000000000 --- a/.github/workflows/format.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Check Formatting - -on: - push: - pull_request: - -jobs: - test: - runs-on: ubuntu-latest - strategy: - matrix: - deno: ["v1.x"] - steps: - - uses: actions/checkout@v2 - - uses: denoland/setup-deno@main - with: - deno-version: ${{ matrix.deno }} - - name: Check Formatting - run: deno fmt --check diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 35eee4020..a93b99fc2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,40 +3,70 @@ name: Test on: pull_request: push: - paths: - - "handlers/**" - - "helpers/**" - - "plugins/**" - - "packages/**" - - "rest/**" - - "tests/**" - - "transformers/**" - - "template/**" - - "types/**" - - "util/**" - - "gateway/**" jobs: - test: + format-test: + name: Format Test runs-on: ubuntu-latest - strategy: - matrix: - deno: ["v1.x"] steps: - - uses: actions/checkout@v2 - - run: git submodule update --init --recursive + - uses: actions/checkout@v3 - uses: denoland/setup-deno@main with: - deno-version: ${{ matrix.deno }} + deno-version: v1.x + - name: Check Formatting + run: deno fmt --check + type-test: + name: Type Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: denoland/setup-deno@main + with: + deno-version: v1.x - name: Check dependencies run: deno check mod.ts - name: Check plugins run: deno check plugins/mod.ts - name: Check Templates run: deno check template/beginner/mod.ts template/minimal/mod.ts - - name: Run test script for maintainers + integration-test: + name: Integration Test + runs-on: ubuntu-latest + concurrency: integration-test + steps: + - uses: actions/checkout@v3 + - uses: denoland/setup-deno@main + with: + deno-version: v1.x + - name: Run integration # if: ${{ github.actor == 'Skillz4Killz' || github.actor == 'itohatweb' }} run: deno test --coverage=coverage -A tests/ + env: + DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }} + UNIT_TEST_GUILD_ID: ${{ secrets.UNIT_TEST_GUILD_ID }} + TEST_ENV: INTEGRATION + PROXY_REST_SECRET: ${{ secrets.PROXY_REST_SECRET }} + PROXY_REST_URL: ${{ secrets.PROXY_REST_URL }} + - name: Create coverage report + if: github.ref == 'refs/heads/main' + run: deno coverage --exclude=tests ./coverage --lcov > coverage.lcov + - name: Collect and upload the coverage report + if: github.ref == 'refs/heads/main' + uses: codecov/codecov-action@v1.0.10 + with: + file: ./coverage.lcov + unit-test: + name: Unit Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: denoland/setup-deno@main + with: + deno-version: v1.x + - name: Run integration + run: deno test --coverage=coverage --parallel -A tests/ + env: + TEST_ENV: UNIT - name: Create coverage report if: github.ref == 'refs/heads/main' run: deno coverage --exclude=tests ./coverage --lcov > coverage.lcov @@ -45,7 +75,3 @@ jobs: uses: codecov/codecov-action@v1.0.10 with: file: ./coverage.lcov - env: - DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }} - PROXY_REST_SECRET: ${{ secrets.PROXY_REST_SECRET }} - PROXY_REST_URL: ${{ secrets.PROXY_REST_URL }} diff --git a/tests/channels/createCategory.test.ts b/tests/channels/createCategory.test.ts index d12894cee..79d7829e3 100644 --- a/tests/channels/createCategory.test.ts +++ b/tests/channels/createCategory.test.ts @@ -5,6 +5,7 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[channel] create a new category channel", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { diff --git a/tests/channels/createNews.test.ts b/tests/channels/createNews.test.ts index 500b50f8a..e7d68dc6d 100644 --- a/tests/channels/createNews.test.ts +++ b/tests/channels/createNews.test.ts @@ -5,6 +5,7 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[channel] create a new news channel", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { diff --git a/tests/channels/createText.test.ts b/tests/channels/createText.test.ts index 127692470..598b180ae 100644 --- a/tests/channels/createText.test.ts +++ b/tests/channels/createText.test.ts @@ -5,6 +5,7 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[channel] create a new text channel", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "Discordeno-test" }); diff --git a/tests/channels/createTextWithNsfw.test.ts b/tests/channels/createTextWithNsfw.test.ts index 352d8fe08..7478733eb 100644 --- a/tests/channels/createTextWithNsfw.test.ts +++ b/tests/channels/createTextWithNsfw.test.ts @@ -5,6 +5,7 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[channel] create a new text channel with NSFW", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { diff --git a/tests/channels/createTextWithPerms.test.ts b/tests/channels/createTextWithPerms.test.ts index ee1b96b5e..a80f2c956 100644 --- a/tests/channels/createTextWithPerms.test.ts +++ b/tests/channels/createTextWithPerms.test.ts @@ -5,6 +5,7 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[channel] create a new text channel with permission overwrites", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { diff --git a/tests/channels/createTextWithRateLimit.test.ts b/tests/channels/createTextWithRateLimit.test.ts index 597f66167..acc19e310 100644 --- a/tests/channels/createTextWithRateLimit.test.ts +++ b/tests/channels/createTextWithRateLimit.test.ts @@ -5,6 +5,7 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[channel] create a new text channel with a rate limit per user", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { diff --git a/tests/channels/createVoice.test.ts b/tests/channels/createVoice.test.ts index 10ab285fc..e58387d13 100644 --- a/tests/channels/createVoice.test.ts +++ b/tests/channels/createVoice.test.ts @@ -5,6 +5,7 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[channel] create a new voice channel", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { diff --git a/tests/channels/createVoiceWithBitrate.test.ts b/tests/channels/createVoiceWithBitrate.test.ts index da1764350..65d014061 100644 --- a/tests/channels/createVoiceWithBitrate.test.ts +++ b/tests/channels/createVoiceWithBitrate.test.ts @@ -5,6 +5,7 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[channel] create a new voice channel with a bitrate", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { diff --git a/tests/channels/createVoiceWithUserLimit.test.ts b/tests/channels/createVoiceWithUserLimit.test.ts index fdc63c331..e3b448de7 100644 --- a/tests/channels/createVoiceWithUserLimit.test.ts +++ b/tests/channels/createVoiceWithUserLimit.test.ts @@ -5,6 +5,7 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[channel] create a new voice channel with a user limit", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { diff --git a/tests/channels/deleteWithReason.test.ts b/tests/channels/deleteWithReason.test.ts index 697d9e632..55ac19397 100644 --- a/tests/channels/deleteWithReason.test.ts +++ b/tests/channels/deleteWithReason.test.ts @@ -4,6 +4,7 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[channel] delete a channel with a reason", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { diff --git a/tests/channels/deleteWithoutReason.test.ts b/tests/channels/deleteWithoutReason.test.ts index 448dc7a25..34be7a86e 100644 --- a/tests/channels/deleteWithoutReason.test.ts +++ b/tests/channels/deleteWithoutReason.test.ts @@ -4,6 +4,7 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[channel] delete a channel without a reason", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); // Create a channel to delete diff --git a/tests/channels/editChannelWithReason.test.ts b/tests/channels/editChannelWithReason.test.ts index 7c1384c43..d5e747680 100644 --- a/tests/channels/editChannelWithReason.test.ts +++ b/tests/channels/editChannelWithReason.test.ts @@ -5,6 +5,7 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[channel] edit a channel", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "editChannel" }); diff --git a/tests/channels/getChannel.test.ts b/tests/channels/getChannel.test.ts index 650e981f2..7cc9c74ea 100644 --- a/tests/channels/getChannel.test.ts +++ b/tests/channels/getChannel.test.ts @@ -4,6 +4,7 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[channel] Get a channel", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { diff --git a/tests/channels/getChannels.test.ts b/tests/channels/getChannels.test.ts index a097ec47d..b26bf2e23 100644 --- a/tests/channels/getChannels.test.ts +++ b/tests/channels/getChannels.test.ts @@ -4,7 +4,8 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[channel] Get all channels", - async fn() { + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { const bot = loadBot(); const [first, second] = await Promise.all([ bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "first" }), diff --git a/tests/channels/invites/invite.test.ts b/tests/channels/invites/invite.test.ts index 4098e5d03..8d6265c30 100644 --- a/tests/channels/invites/invite.test.ts +++ b/tests/channels/invites/invite.test.ts @@ -5,6 +5,7 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../../utils.ts"; Deno.test({ name: "[invite] create an invite", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { diff --git a/tests/channels/messages/message.test.ts b/tests/channels/messages/message.test.ts index 79e5a9c52..81f944858 100644 --- a/tests/channels/messages/message.test.ts +++ b/tests/channels/messages/message.test.ts @@ -1,10 +1,11 @@ import { ButtonStyles, ChannelTypes, delay, MessageComponentTypes } from "../../../mod.ts"; -import { assertEquals, assertExists, assertNotEquals, assertRejects } from "../../deps.ts"; +import { assertEquals, assertExists, assertRejects } from "../../deps.ts"; import { loadBot } from "../../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../../utils.ts"; Deno.test({ name: "[messages] Run message related unit tests", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { diff --git a/tests/channels/messages/reactions.test.ts b/tests/channels/messages/reactions.test.ts index d073d1bb4..db2e098a1 100644 --- a/tests/channels/messages/reactions.test.ts +++ b/tests/channels/messages/reactions.test.ts @@ -4,7 +4,8 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../../utils.ts"; Deno.test({ name: "[message] reaction related unit tests", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "reactions" }); diff --git a/tests/channels/permissions/deleteChannelOverwrite.test.ts b/tests/channels/permissions/deleteChannelOverwrite.test.ts index d7e2ff575..00742bd99 100644 --- a/tests/channels/permissions/deleteChannelOverwrite.test.ts +++ b/tests/channels/permissions/deleteChannelOverwrite.test.ts @@ -5,6 +5,7 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../../utils.ts"; Deno.test({ name: "[channel] Delete a channel overwrite", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { diff --git a/tests/channels/stageInstances.test.ts b/tests/channels/stageInstances.test.ts index 7aa936721..9d6a39965 100644 --- a/tests/channels/stageInstances.test.ts +++ b/tests/channels/stageInstances.test.ts @@ -5,6 +5,7 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[stage] Create a stage instance", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); const stage = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { diff --git a/tests/channels/threads/deleteThread.test.ts b/tests/channels/threads/deleteThread.test.ts index e87552afc..e6285f195 100644 --- a/tests/channels/threads/deleteThread.test.ts +++ b/tests/channels/threads/deleteThread.test.ts @@ -2,21 +2,25 @@ import { assertExists } from "../../deps.ts"; import { loadBot } from "../../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../../utils.ts"; -Deno.test("[thread] Delete a thread", async (t) => { - const bot = loadBot(); - const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "threads" }); - const message = await bot.helpers.sendMessage(channel.id, { content: "thread message" }); - const thread = await bot.helpers.startThreadWithMessage(channel.id, message.id, { - reason: "idk", - rateLimitPerUser: 5, - name: "tread carefully", - autoArchiveDuration: 60, - }); +Deno.test({ + name: "[thread] Delete a thread", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "threads" }); + const message = await bot.helpers.sendMessage(channel.id, { content: "thread message" }); + const thread = await bot.helpers.startThreadWithMessage(channel.id, message.id, { + reason: "idk", + rateLimitPerUser: 5, + name: "tread carefully", + autoArchiveDuration: 60, + }); - const threadMessage = await bot.helpers.sendMessage(thread.id, { content: "message in a bottle" }); - assertExists(threadMessage.id); + const threadMessage = await bot.helpers.sendMessage(thread.id, { content: "message in a bottle" }); + assertExists(threadMessage.id); - await bot.helpers.deleteChannel(thread.id); + await bot.helpers.deleteChannel(thread.id); - await bot.helpers.deleteChannel(channel.id); + await bot.helpers.deleteChannel(channel.id); + }, }); diff --git a/tests/channels/threads/editThread.test.ts b/tests/channels/threads/editThread.test.ts index 1db1d4155..752b66e5f 100644 --- a/tests/channels/threads/editThread.test.ts +++ b/tests/channels/threads/editThread.test.ts @@ -2,32 +2,36 @@ import { assertExists, assertNotEquals } from "../../deps.ts"; import { loadBot } from "../../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../../utils.ts"; -Deno.test("[thread] Edit and archive a thread", async (t) => { - const bot = loadBot(); - const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "threads" }); - const message = await bot.helpers.sendMessage(channel.id, { content: "thread message" }); - const thread = await bot.helpers.startThreadWithMessage(channel.id, message.id, { - reason: "idk", - rateLimitPerUser: 5, - name: "tread carefully", - autoArchiveDuration: 60, - }); +Deno.test({ + name: "[thread] Edit and archive a thread", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "threads" }); + const message = await bot.helpers.sendMessage(channel.id, { content: "thread message" }); + const thread = await bot.helpers.startThreadWithMessage(channel.id, message.id, { + reason: "idk", + rateLimitPerUser: 5, + name: "tread carefully", + autoArchiveDuration: 60, + }); - const threadMessage = await bot.helpers.sendMessage(thread.id, { content: "message in a bottle" }); - assertExists(threadMessage.id); + const threadMessage = await bot.helpers.sendMessage(thread.id, { content: "message in a bottle" }); + assertExists(threadMessage.id); - const edited = await bot.helpers.editChannel(thread.id, { - archived: true, - name: "new name", - autoArchiveDuration: 1440, - locked: !thread.locked, - rateLimitPerUser: (thread.rateLimitPerUser || 0) + 1, - }); - assertNotEquals(thread.archived, edited.archived); - assertNotEquals(thread.name, edited.name); - assertNotEquals(thread.rateLimitPerUser, edited.rateLimitPerUser); - assertNotEquals(thread.autoArchiveDuration, edited.autoArchiveDuration); - assertNotEquals(thread.locked, edited.locked); + const edited = await bot.helpers.editChannel(thread.id, { + archived: true, + name: "new name", + autoArchiveDuration: 1440, + locked: !thread.locked, + rateLimitPerUser: (thread.rateLimitPerUser || 0) + 1, + }); + assertNotEquals(thread.archived, edited.archived); + assertNotEquals(thread.name, edited.name); + assertNotEquals(thread.rateLimitPerUser, edited.rateLimitPerUser); + assertNotEquals(thread.autoArchiveDuration, edited.autoArchiveDuration); + assertNotEquals(thread.locked, edited.locked); - await bot.helpers.deleteChannel(channel.id); + await bot.helpers.deleteChannel(channel.id); + }, }); diff --git a/tests/channels/threads/getActiveThreads.test.ts b/tests/channels/threads/getActiveThreads.test.ts index 42de6a547..d9d2d88a7 100644 --- a/tests/channels/threads/getActiveThreads.test.ts +++ b/tests/channels/threads/getActiveThreads.test.ts @@ -1,23 +1,27 @@ -import { assertEquals, assertExists, assertNotEquals } from "../../deps.ts"; +import { assertEquals, assertExists } from "../../deps.ts"; import { loadBot } from "../../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../../utils.ts"; -Deno.test("[thread] Get active threads", async (t) => { - const bot = loadBot(); - const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "threads" }); - const message = await bot.helpers.sendMessage(channel.id, { content: "thread message" }); - const thread = await bot.helpers.startThreadWithMessage(channel.id, message.id, { - reason: "idk", - rateLimitPerUser: 5, - name: "tread carefully", - autoArchiveDuration: 60, - }); +Deno.test({ + name: "[thread] Get active threads", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "threads" }); + const message = await bot.helpers.sendMessage(channel.id, { content: "thread message" }); + const thread = await bot.helpers.startThreadWithMessage(channel.id, message.id, { + reason: "idk", + rateLimitPerUser: 5, + name: "tread carefully", + autoArchiveDuration: 60, + }); - const threadMessage = await bot.helpers.sendMessage(thread.id, { content: "message in a bottle" }); - assertExists(threadMessage.id); + const threadMessage = await bot.helpers.sendMessage(thread.id, { content: "message in a bottle" }); + assertExists(threadMessage.id); - const activeThreads = await bot.helpers.getActiveThreads(CACHED_COMMUNITY_GUILD_ID); - assertEquals(Boolean(activeThreads.threads.size), true); + const activeThreads = await bot.helpers.getActiveThreads(CACHED_COMMUNITY_GUILD_ID); + assertEquals(Boolean(activeThreads.threads.size), true); - await bot.helpers.deleteChannel(channel.id); + await bot.helpers.deleteChannel(channel.id); + }, }); diff --git a/tests/channels/threads/getArchivedThreads.test.ts b/tests/channels/threads/getArchivedThreads.test.ts index 2ae9f1ac8..25fb1d6ea 100644 --- a/tests/channels/threads/getArchivedThreads.test.ts +++ b/tests/channels/threads/getArchivedThreads.test.ts @@ -2,32 +2,36 @@ import { assertEquals, assertExists, assertNotEquals } from "../../deps.ts"; import { loadBot } from "../../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../../utils.ts"; -Deno.test("[thread] Get archived threads", async (t) => { - const bot = loadBot(); - const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "threads" }); - const message = await bot.helpers.sendMessage(channel.id, { content: "thread message" }); - const thread = await bot.helpers.startThreadWithMessage(channel.id, message.id, { - reason: "idk", - rateLimitPerUser: 5, - name: "tread carefully", - autoArchiveDuration: 60, - }); +Deno.test({ + name: "[thread] Get archived threads", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "threads" }); + const message = await bot.helpers.sendMessage(channel.id, { content: "thread message" }); + const thread = await bot.helpers.startThreadWithMessage(channel.id, message.id, { + reason: "idk", + rateLimitPerUser: 5, + name: "tread carefully", + autoArchiveDuration: 60, + }); - const archived = await bot.helpers.getPublicArchivedThreads(channel.id); - assertEquals(archived.threads.size, 0); - assertEquals(archived.members.size, 0); + const archived = await bot.helpers.getPublicArchivedThreads(channel.id); + assertEquals(archived.threads.size, 0); + assertEquals(archived.members.size, 0); - const threadMessage = await bot.helpers.sendMessage(thread.id, { content: "message in a bottle" }); - assertExists(threadMessage.id); + const threadMessage = await bot.helpers.sendMessage(thread.id, { content: "message in a bottle" }); + assertExists(threadMessage.id); - const edited = await bot.helpers.editChannel(thread.id, { - archived: true, - }); - assertNotEquals(thread.archived, edited.archived); + const edited = await bot.helpers.editChannel(thread.id, { + archived: true, + }); + assertNotEquals(thread.archived, edited.archived); - const archivedNow = await bot.helpers.getPublicArchivedThreads(channel.id); - assertEquals(Boolean(archivedNow.threads.size), true); - assertEquals(Boolean(archivedNow.members.size), true); + const archivedNow = await bot.helpers.getPublicArchivedThreads(channel.id); + assertEquals(Boolean(archivedNow.threads.size), true); + assertEquals(Boolean(archivedNow.members.size), true); - await bot.helpers.deleteChannel(channel.id); + await bot.helpers.deleteChannel(channel.id); + }, }); diff --git a/tests/channels/threads/joinAndLeaveThread.test.ts b/tests/channels/threads/joinAndLeaveThread.test.ts index 9c7acace7..4e3cc2a98 100644 --- a/tests/channels/threads/joinAndLeaveThread.test.ts +++ b/tests/channels/threads/joinAndLeaveThread.test.ts @@ -2,27 +2,31 @@ import { assertExists } from "../../deps.ts"; import { loadBot } from "../../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../../utils.ts"; -Deno.test("[thread] join and leave a thread", async (t) => { - const bot = loadBot(); - const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "threads" }); - const message = await bot.helpers.sendMessage(channel.id, { content: "thread message" }); - const thread = await bot.helpers.startThreadWithMessage(channel.id, message.id, { - reason: "idk", - rateLimitPerUser: 5, - name: "tread carefully", - autoArchiveDuration: 60, - }); +Deno.test({ + name: "[thread] join and leave a thread", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "threads" }); + const message = await bot.helpers.sendMessage(channel.id, { content: "thread message" }); + const thread = await bot.helpers.startThreadWithMessage(channel.id, message.id, { + reason: "idk", + rateLimitPerUser: 5, + name: "tread carefully", + autoArchiveDuration: 60, + }); - const threadMessage = await bot.helpers.sendMessage(thread.id, { content: "message in a bottle" }); - assertExists(threadMessage.id); + const threadMessage = await bot.helpers.sendMessage(thread.id, { content: "message in a bottle" }); + assertExists(threadMessage.id); - await t.step("[thread] leave a thread", async () => { - await bot.helpers.leaveThread(thread.id); - }); + await t.step("[thread] leave a thread", async () => { + await bot.helpers.leaveThread(thread.id); + }); - await t.step("[thread] join a thread", async () => { - await bot.helpers.joinThread(thread.id); - }); + await t.step("[thread] join a thread", async () => { + await bot.helpers.joinThread(thread.id); + }); - await bot.helpers.deleteChannel(channel.id); + await bot.helpers.deleteChannel(channel.id); + }, }); diff --git a/tests/channels/threads/startThread.test.ts b/tests/channels/threads/startThread.test.ts index fa32babd3..2f60001cc 100644 --- a/tests/channels/threads/startThread.test.ts +++ b/tests/channels/threads/startThread.test.ts @@ -1,19 +1,23 @@ -import { assertEquals, assertExists, assertNotEquals } from "../../deps.ts"; +import { assertExists } from "../../deps.ts"; import { loadBot } from "../../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../../utils.ts"; -Deno.test("[thread] Start a thread", async (t) => { - const bot = loadBot(); - const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "threads" }); - const message = await bot.helpers.sendMessage(channel.id, { content: "thread message" }); - const thread = await bot.helpers.startThreadWithMessage(channel.id, message.id, { - reason: "idk", - rateLimitPerUser: 5, - name: "tread carefully", - autoArchiveDuration: 60, - }); +Deno.test({ + name: "[thread] Start a thread", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "threads" }); + const message = await bot.helpers.sendMessage(channel.id, { content: "thread message" }); + const thread = await bot.helpers.startThreadWithMessage(channel.id, message.id, { + reason: "idk", + rateLimitPerUser: 5, + name: "tread carefully", + autoArchiveDuration: 60, + }); - assertExists(thread.id); + assertExists(thread.id); - await bot.helpers.deleteChannel(channel.id); + await bot.helpers.deleteChannel(channel.id); + }, }); diff --git a/tests/delay.test.ts b/tests/delay.test.ts index 4a37c8c4d..2ca1cd7ca 100644 --- a/tests/delay.test.ts +++ b/tests/delay.test.ts @@ -3,7 +3,8 @@ import { assertEquals } from "./deps.ts"; Deno.test({ name: "[utils] delay 2000 ms", - async fn() { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { const before = Date.now(); await delay(2000); const after = Date.now(); diff --git a/tests/guilds/automod.test.ts b/tests/guilds/automod.test.ts index c1e8cbcbc..427892b96 100644 --- a/tests/guilds/automod.test.ts +++ b/tests/guilds/automod.test.ts @@ -3,186 +3,46 @@ import { assertEquals, assertExists } from "../deps.ts"; import { loadBot } from "../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; -Deno.test("[automod] Run automod tests", async (t) => { - const bot = loadBot(); +Deno.test({ + name: "[automod] Run automod tests", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); - await t.step("[automod] Create a MessageSend rule for Keyword with BlockMessage action.", async () => { - const rule = await bot.helpers.createAutomodRule(CACHED_COMMUNITY_GUILD_ID, { - name: "test", - eventType: AutoModerationEventTypes.MessageSend, - triggerType: AutoModerationTriggerTypes.Keyword, - triggerMetadata: { - keywordFilter: ["iblamewolf"], - }, - actions: [ - { - type: AutoModerationActionType.BlockMessage, + await t.step("[automod] Create a MessageSend rule for Keyword with BlockMessage action.", async () => { + const rule = await bot.helpers.createAutomodRule(CACHED_COMMUNITY_GUILD_ID, { + name: "test", + eventType: AutoModerationEventTypes.MessageSend, + triggerType: AutoModerationTriggerTypes.Keyword, + triggerMetadata: { + keywordFilter: ["iblamewolf"], }, - ], - }); - - assertExists(rule.id); - - const fetchedRule = await bot.helpers.getAutomodRule( - CACHED_COMMUNITY_GUILD_ID, - rule.id, - ); - assertExists(fetchedRule.id); - assertEquals(fetchedRule.name, rule.name); - assertEquals(fetchedRule.eventType, AutoModerationEventTypes.MessageSend); - assertEquals(fetchedRule.triggerType, AutoModerationTriggerTypes.Keyword); - assertEquals(fetchedRule.triggerMetadata?.keywordFilter?.[0], "iblamewolf"); - assertExists(fetchedRule.actions); - assertExists(fetchedRule.actions[0]); - assertEquals(fetchedRule.actions[0].type, AutoModerationActionType.BlockMessage); - - await bot.helpers.deleteAutomodRule(CACHED_COMMUNITY_GUILD_ID, rule.id); - }); - - await t.step("[automod] Create a MessageSend rule for Keyword with SendAlertMessage action.", async () => { - const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { - name: "test", - }); - assertExists(channel.id); - - const rule = await bot.helpers.createAutomodRule(CACHED_COMMUNITY_GUILD_ID, { - name: "test", - eventType: AutoModerationEventTypes.MessageSend, - triggerType: AutoModerationTriggerTypes.Keyword, - triggerMetadata: { - keywordFilter: ["iblamewolf"], - }, - actions: [ - { - type: AutoModerationActionType.SendAlertMessage, - metadata: { - channelId: channel.id, + actions: [ + { + type: AutoModerationActionType.BlockMessage, }, - }, - ], + ], + }); + + assertExists(rule.id); + + const fetchedRule = await bot.helpers.getAutomodRule( + CACHED_COMMUNITY_GUILD_ID, + rule.id, + ); + assertExists(fetchedRule.id); + assertEquals(fetchedRule.name, rule.name); + assertEquals(fetchedRule.eventType, AutoModerationEventTypes.MessageSend); + assertEquals(fetchedRule.triggerType, AutoModerationTriggerTypes.Keyword); + assertEquals(fetchedRule.triggerMetadata?.keywordFilter?.[0], "iblamewolf"); + assertExists(fetchedRule.actions); + assertExists(fetchedRule.actions[0]); + assertEquals(fetchedRule.actions[0].type, AutoModerationActionType.BlockMessage); + + await bot.helpers.deleteAutomodRule(CACHED_COMMUNITY_GUILD_ID, rule.id); }); - assertExists(rule.id); - - const fetchedRule = await bot.helpers.getAutomodRule( - CACHED_COMMUNITY_GUILD_ID, - rule.id, - ); - assertExists(fetchedRule.id); - assertEquals(fetchedRule.name, rule.name); - assertEquals(fetchedRule.eventType, AutoModerationEventTypes.MessageSend); - assertEquals(fetchedRule.triggerType, AutoModerationTriggerTypes.Keyword); - assertEquals(fetchedRule.triggerMetadata?.keywordFilter?.[0], "iblamewolf"); - assertExists(fetchedRule.actions); - assertExists(fetchedRule.actions[0]); - assertEquals(fetchedRule.actions[0].type, AutoModerationActionType.SendAlertMessage); - assertEquals(fetchedRule.actions[0].metadata?.channelId, channel.id); - - await bot.helpers.deleteAutomodRule(CACHED_COMMUNITY_GUILD_ID, rule.id); - await bot.helpers.deleteChannel(channel.id); - }); - - await t.step("[automod] Create a MessageSend rule for Keyword with Timeout action.", async () => { - const rule = await bot.helpers.createAutomodRule(CACHED_COMMUNITY_GUILD_ID, { - name: "test", - eventType: AutoModerationEventTypes.MessageSend, - triggerType: AutoModerationTriggerTypes.Keyword, - triggerMetadata: { - keywordFilter: ["iblamewolf"], - }, - actions: [ - { - type: AutoModerationActionType.Timeout, - metadata: { - durationSeconds: 10, - }, - }, - ], - }); - - assertExists(rule.id); - - const fetchedRule = await bot.helpers.getAutomodRule( - CACHED_COMMUNITY_GUILD_ID, - rule.id, - ); - assertExists(fetchedRule.id); - assertEquals(fetchedRule.name, rule.name); - assertEquals(fetchedRule.eventType, AutoModerationEventTypes.MessageSend); - assertEquals(fetchedRule.triggerType, AutoModerationTriggerTypes.Keyword); - assertEquals(fetchedRule.triggerMetadata?.keywordFilter?.[0], "iblamewolf"); - assertExists(fetchedRule.actions); - assertExists(fetchedRule.actions[0]); - assertEquals(fetchedRule.actions[0].type, AutoModerationActionType.Timeout); - assertEquals(fetchedRule.actions[0].metadata?.durationSeconds, 10); - - await bot.helpers.deleteAutomodRule(CACHED_COMMUNITY_GUILD_ID, rule.id); - }); - - await t.step("[automod] Create a MessageSend rule for Keyword with BlockMessage & Timeout action.", async () => { - const rule = await bot.helpers.createAutomodRule(CACHED_COMMUNITY_GUILD_ID, { - name: "test", - eventType: AutoModerationEventTypes.MessageSend, - triggerType: AutoModerationTriggerTypes.Keyword, - triggerMetadata: { - keywordFilter: ["iblamewolf"], - }, - actions: [ - { - type: AutoModerationActionType.BlockMessage, - }, - { - type: AutoModerationActionType.Timeout, - metadata: { - durationSeconds: 10, - }, - }, - ], - }); - - assertExists(rule.id); - - await bot.helpers.deleteAutomodRule(CACHED_COMMUNITY_GUILD_ID, rule.id); - }); - - await t.step("[automod] Create a MessageSend rule for Keyword with SendAlertMessage & Timeout action.", async () => { - const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { - name: "test", - }); - assertExists(channel.id); - - const rule = await bot.helpers.createAutomodRule(CACHED_COMMUNITY_GUILD_ID, { - name: "test", - eventType: AutoModerationEventTypes.MessageSend, - triggerType: AutoModerationTriggerTypes.Keyword, - triggerMetadata: { - keywordFilter: ["iblamewolf"], - }, - actions: [ - { - type: AutoModerationActionType.SendAlertMessage, - metadata: { - channelId: channel.id, - }, - }, - { - type: AutoModerationActionType.Timeout, - metadata: { - durationSeconds: 10, - }, - }, - ], - }); - - assertExists(rule.id); - - await bot.helpers.deleteAutomodRule(CACHED_COMMUNITY_GUILD_ID, rule.id); - await bot.helpers.deleteChannel(channel.id); - }); - - await t.step( - "[automod] Create a MessageSend rule for Keyword with BlockMessage & SendAlertMessage & Timeout action.", - async (t) => { + await t.step("[automod] Create a MessageSend rule for Keyword with SendAlertMessage action.", async () => { const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "test", }); @@ -196,15 +56,84 @@ Deno.test("[automod] Run automod tests", async (t) => { keywordFilter: ["iblamewolf"], }, actions: [ - { - type: AutoModerationActionType.BlockMessage, - }, { type: AutoModerationActionType.SendAlertMessage, metadata: { channelId: channel.id, }, }, + ], + }); + + assertExists(rule.id); + + const fetchedRule = await bot.helpers.getAutomodRule( + CACHED_COMMUNITY_GUILD_ID, + rule.id, + ); + assertExists(fetchedRule.id); + assertEquals(fetchedRule.name, rule.name); + assertEquals(fetchedRule.eventType, AutoModerationEventTypes.MessageSend); + assertEquals(fetchedRule.triggerType, AutoModerationTriggerTypes.Keyword); + assertEquals(fetchedRule.triggerMetadata?.keywordFilter?.[0], "iblamewolf"); + assertExists(fetchedRule.actions); + assertExists(fetchedRule.actions[0]); + assertEquals(fetchedRule.actions[0].type, AutoModerationActionType.SendAlertMessage); + assertEquals(fetchedRule.actions[0].metadata?.channelId, channel.id); + + await bot.helpers.deleteAutomodRule(CACHED_COMMUNITY_GUILD_ID, rule.id); + await bot.helpers.deleteChannel(channel.id); + }); + + await t.step("[automod] Create a MessageSend rule for Keyword with Timeout action.", async () => { + const rule = await bot.helpers.createAutomodRule(CACHED_COMMUNITY_GUILD_ID, { + name: "test", + eventType: AutoModerationEventTypes.MessageSend, + triggerType: AutoModerationTriggerTypes.Keyword, + triggerMetadata: { + keywordFilter: ["iblamewolf"], + }, + actions: [ + { + type: AutoModerationActionType.Timeout, + metadata: { + durationSeconds: 10, + }, + }, + ], + }); + + assertExists(rule.id); + + const fetchedRule = await bot.helpers.getAutomodRule( + CACHED_COMMUNITY_GUILD_ID, + rule.id, + ); + assertExists(fetchedRule.id); + assertEquals(fetchedRule.name, rule.name); + assertEquals(fetchedRule.eventType, AutoModerationEventTypes.MessageSend); + assertEquals(fetchedRule.triggerType, AutoModerationTriggerTypes.Keyword); + assertEquals(fetchedRule.triggerMetadata?.keywordFilter?.[0], "iblamewolf"); + assertExists(fetchedRule.actions); + assertExists(fetchedRule.actions[0]); + assertEquals(fetchedRule.actions[0].type, AutoModerationActionType.Timeout); + assertEquals(fetchedRule.actions[0].metadata?.durationSeconds, 10); + + await bot.helpers.deleteAutomodRule(CACHED_COMMUNITY_GUILD_ID, rule.id); + }); + + await t.step("[automod] Create a MessageSend rule for Keyword with BlockMessage & Timeout action.", async () => { + const rule = await bot.helpers.createAutomodRule(CACHED_COMMUNITY_GUILD_ID, { + name: "test", + eventType: AutoModerationEventTypes.MessageSend, + triggerType: AutoModerationTriggerTypes.Keyword, + triggerMetadata: { + keywordFilter: ["iblamewolf"], + }, + actions: [ + { + type: AutoModerationActionType.BlockMessage, + }, { type: AutoModerationActionType.Timeout, metadata: { @@ -216,30 +145,108 @@ Deno.test("[automod] Run automod tests", async (t) => { assertExists(rule.id); - // Get the rule again to make sure it was created correctly - await t.step("[automod] Get a automod rule", async () => { - const fetchedRule = await bot.helpers.getAutomodRule( - CACHED_COMMUNITY_GUILD_ID, - rule.id, - ); - assertExists(fetchedRule.id); - assertEquals(fetchedRule.name, rule.name); - assertEquals(fetchedRule.eventType, AutoModerationEventTypes.MessageSend); - assertEquals(fetchedRule.triggerType, AutoModerationTriggerTypes.Keyword); - assertEquals(fetchedRule.triggerMetadata?.keywordFilter?.[0], "iblamewolf"); - assertExists(fetchedRule.actions); - assertExists(fetchedRule.actions[0]); - assertExists(fetchedRule.actions[1].metadata); - assertExists(fetchedRule.actions[2].metadata); - assertEquals(fetchedRule.actions[1].metadata.channelId, channel.id); - assertEquals(fetchedRule.actions[2].metadata.durationSeconds, 10); - assertEquals(fetchedRule.actions[0].type, AutoModerationActionType.BlockMessage); - assertEquals(fetchedRule.actions[1].type, AutoModerationActionType.SendAlertMessage); - assertEquals(fetchedRule.actions[2].type, AutoModerationActionType.Timeout); - }); - await bot.helpers.deleteAutomodRule(CACHED_COMMUNITY_GUILD_ID, rule.id); - await bot.helpers.deleteChannel(channel.id); - }, - ); + }); + + await t.step( + "[automod] Create a MessageSend rule for Keyword with SendAlertMessage & Timeout action.", + async () => { + const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { + name: "test", + }); + assertExists(channel.id); + + const rule = await bot.helpers.createAutomodRule(CACHED_COMMUNITY_GUILD_ID, { + name: "test", + eventType: AutoModerationEventTypes.MessageSend, + triggerType: AutoModerationTriggerTypes.Keyword, + triggerMetadata: { + keywordFilter: ["iblamewolf"], + }, + actions: [ + { + type: AutoModerationActionType.SendAlertMessage, + metadata: { + channelId: channel.id, + }, + }, + { + type: AutoModerationActionType.Timeout, + metadata: { + durationSeconds: 10, + }, + }, + ], + }); + + assertExists(rule.id); + + await bot.helpers.deleteAutomodRule(CACHED_COMMUNITY_GUILD_ID, rule.id); + await bot.helpers.deleteChannel(channel.id); + }, + ); + + await t.step( + "[automod] Create a MessageSend rule for Keyword with BlockMessage & SendAlertMessage & Timeout action.", + async (t) => { + const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { + name: "test", + }); + assertExists(channel.id); + + const rule = await bot.helpers.createAutomodRule(CACHED_COMMUNITY_GUILD_ID, { + name: "test", + eventType: AutoModerationEventTypes.MessageSend, + triggerType: AutoModerationTriggerTypes.Keyword, + triggerMetadata: { + keywordFilter: ["iblamewolf"], + }, + actions: [ + { + type: AutoModerationActionType.BlockMessage, + }, + { + type: AutoModerationActionType.SendAlertMessage, + metadata: { + channelId: channel.id, + }, + }, + { + type: AutoModerationActionType.Timeout, + metadata: { + durationSeconds: 10, + }, + }, + ], + }); + + assertExists(rule.id); + + // Get the rule again to make sure it was created correctly + await t.step("[automod] Get a automod rule", async () => { + const fetchedRule = await bot.helpers.getAutomodRule( + CACHED_COMMUNITY_GUILD_ID, + rule.id, + ); + assertExists(fetchedRule.id); + assertEquals(fetchedRule.name, rule.name); + assertEquals(fetchedRule.eventType, AutoModerationEventTypes.MessageSend); + assertEquals(fetchedRule.triggerType, AutoModerationTriggerTypes.Keyword); + assertEquals(fetchedRule.triggerMetadata?.keywordFilter?.[0], "iblamewolf"); + assertExists(fetchedRule.actions); + assertExists(fetchedRule.actions[0]); + assertExists(fetchedRule.actions[1].metadata); + assertExists(fetchedRule.actions[2].metadata); + assertEquals(fetchedRule.actions[1].metadata.channelId, channel.id); + assertEquals(fetchedRule.actions[2].metadata.durationSeconds, 10); + assertEquals(fetchedRule.actions[0].type, AutoModerationActionType.BlockMessage); + assertEquals(fetchedRule.actions[1].type, AutoModerationActionType.SendAlertMessage); + assertEquals(fetchedRule.actions[2].type, AutoModerationActionType.Timeout); + }); + + await bot.helpers.deleteAutomodRule(CACHED_COMMUNITY_GUILD_ID, rule.id); + await bot.helpers.deleteChannel(channel.id); + }, + ); + }, }); diff --git a/tests/guilds/editGuildMfaLevel.test.ts b/tests/guilds/editGuildMfaLevel.test.ts index e737b27e0..730609a11 100644 --- a/tests/guilds/editGuildMfaLevel.test.ts +++ b/tests/guilds/editGuildMfaLevel.test.ts @@ -2,12 +2,16 @@ import { MfaLevels } from "../../mod.ts"; import { assertEquals } from "../deps.ts"; import { loadBot } from "../mod.ts"; -Deno.test("[guild] edit guild mfa level", async () => { - const bot = loadBot(); - const guild = await bot.helpers.createGuild({ name: "test" }); - await bot.helpers.editGuildMfaLevel(guild.id, MfaLevels.Elevated, "test"); - assertEquals((await bot.helpers.getGuild(guild.id)).mfaLevel, MfaLevels.Elevated); - await bot.helpers.editGuildMfaLevel(guild.id, MfaLevels.None, "revert test"); - assertEquals((await bot.helpers.getGuild(guild.id)).mfaLevel, MfaLevels.None); - await bot.helpers.deleteGuild(guild.id); +Deno.test({ + name: "[guild] edit guild mfa level", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const guild = await bot.helpers.createGuild({ name: "test" }); + await bot.helpers.editGuildMfaLevel(guild.id, MfaLevels.Elevated, "test"); + assertEquals((await bot.helpers.getGuild(guild.id)).mfaLevel, MfaLevels.Elevated); + await bot.helpers.editGuildMfaLevel(guild.id, MfaLevels.None, "revert test"); + assertEquals((await bot.helpers.getGuild(guild.id)).mfaLevel, MfaLevels.None); + await bot.helpers.deleteGuild(guild.id); + }, }); diff --git a/tests/guilds/events/events.test.ts b/tests/guilds/events/events.test.ts index b4a6683d1..221ef9240 100644 --- a/tests/guilds/events/events.test.ts +++ b/tests/guilds/events/events.test.ts @@ -5,7 +5,8 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../../utils.ts"; Deno.test({ name: "[events] unit tests for events", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { const bot = loadBot(); // create a guild scheduled event with external entity with an end time @@ -191,7 +192,7 @@ Deno.test({ await t.step( { name: "[scheduled event] edit a scheduled event", - fn: async (t) => { + async fn(t) { const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "entity", type: ChannelTypes.GuildStageVoice, diff --git a/tests/guilds/getVoiceRegions.test.ts b/tests/guilds/getVoiceRegions.test.ts index d9fde55e1..7c1eb9595 100644 --- a/tests/guilds/getVoiceRegions.test.ts +++ b/tests/guilds/getVoiceRegions.test.ts @@ -2,8 +2,12 @@ import { assertEquals } from "../deps.ts"; import { loadBot } from "../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; -Deno.test("[voice] Get voice regions", async () => { - const bot = loadBot(); - const regions = await bot.helpers.getVoiceRegions(CACHED_COMMUNITY_GUILD_ID); - assertEquals(regions.size > 1, true); +Deno.test({ + name: "[voice] Get voice regions", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const regions = await bot.helpers.getVoiceRegions(CACHED_COMMUNITY_GUILD_ID); + assertEquals(regions.size > 1, true); + }, }); diff --git a/tests/guilds/guild.test.ts b/tests/guilds/guild.test.ts index a38a6a636..8fa6f7dcf 100644 --- a/tests/guilds/guild.test.ts +++ b/tests/guilds/guild.test.ts @@ -4,6 +4,7 @@ import { loadBot } from "../mod.ts"; Deno.test({ name: "[guild] Create a guild", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); @@ -96,7 +97,7 @@ Deno.test({ // Create an emoji await t.step({ name: "[emoji] create an emoji", - fn: async (t) => { + async fn(t) { const bot = loadBot(); const emoji = await bot.helpers.createEmoji(guild.id, { name: "blamewolf", @@ -114,7 +115,7 @@ Deno.test({ // delete an emoji without a reason await t.step({ name: "[emoji] delete an emoji without a reason", - fn: async (t) => { + async fn(t) { const bot = loadBot(); const emoji = await bot.helpers.createEmoji(guild.id, { name: "blamewolf", @@ -134,7 +135,7 @@ Deno.test({ // delete an emoji with a reason await t.step({ name: "[emoji] delete an emoji with a reason", - fn: async (t) => { + async fn(t) { const bot = loadBot(); const emoji = await bot.helpers.createEmoji(guild.id, { name: "blamewolf", @@ -154,7 +155,7 @@ Deno.test({ // edit an emoji name await t.step({ name: "[emoji] Edit an emoji name", - fn: async (t) => { + async fn(t) { const bot = loadBot(); const emoji = await bot.helpers.createEmoji(guild.id, { name: "blamewolf", @@ -181,7 +182,7 @@ Deno.test({ // edit an emoji roles await t.step({ name: "[emoji] Edit an emoji's roles", - fn: async (t) => { + async fn(t) { const bot = loadBot(); const emoji = await bot.helpers.createEmoji(guild.id, { name: "blamewolf", @@ -212,7 +213,7 @@ Deno.test({ // get an emoji await t.step({ name: "[emoji] get an emoji", - fn: async (t) => { + async fn(t) { const bot = loadBot(); const emoji = await bot.helpers.createEmoji(guild.id, { name: "blamewolf", @@ -233,7 +234,7 @@ Deno.test({ await t.step({ name: "[emoji] get all guild emojis", - fn: async (t) => { + async fn(t) { const bot = loadBot(); const emoji = await bot.helpers.createEmoji(guild.id, { name: "blamewolf", diff --git a/tests/guilds/members/bans.test.ts b/tests/guilds/members/bans.test.ts index e3299d7a9..58b17f8f8 100644 --- a/tests/guilds/members/bans.test.ts +++ b/tests/guilds/members/bans.test.ts @@ -12,19 +12,21 @@ const ltsID = 379643682984296448n; // THESE BAN TESTS SHOULD BE DONE ONE BY ONE Deno.test({ name: "[member] ban member test group", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { const bot = loadBot(); // ban user from guild without reason await t.step({ name: "[member] ban user from guild without reason", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { await bot.helpers.banMember(CACHED_COMMUNITY_GUILD_ID, wolfID); // get a single user's ban await t.step({ name: "[member] get a single user's ban", - fn: async () => { + async fn(t) { assertExists(await bot.helpers.getBan(CACHED_COMMUNITY_GUILD_ID, wolfID)); }, }); @@ -34,7 +36,8 @@ Deno.test({ // ban member from guild with a reason await t.step({ name: "[member] ban member from guild with a reason", - fn: async () => { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { await bot.helpers.banMember(CACHED_COMMUNITY_GUILD_ID, ianID, { reason: "Blame Wolf" }); assertExists(await bot.helpers.getBan(CACHED_COMMUNITY_GUILD_ID, ianID)); }, @@ -49,7 +52,8 @@ Deno.test({ // get bans on a server await t.step({ name: "[member] get bans on a server", - fn: async () => { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { const bans = await bot.helpers.getBans(CACHED_COMMUNITY_GUILD_ID); assertEquals(bans.size > 1, true); }, @@ -58,7 +62,8 @@ Deno.test({ // fetch a single member by id await t.step({ name: "[member] fetch a single member by id", - fn: async () => { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { const member = await bot.helpers.getMember(CACHED_COMMUNITY_GUILD_ID, bot.id); assertExists(member?.id); @@ -68,7 +73,8 @@ Deno.test({ // unban member from guild await t.step({ name: "[member] unban member from guild", - fn: async () => { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { await Promise.all([ bot.helpers.unbanMember(CACHED_COMMUNITY_GUILD_ID, wolfID), bot.helpers.unbanMember(CACHED_COMMUNITY_GUILD_ID, ianID), diff --git a/tests/guilds/members/dms.test.ts b/tests/guilds/members/dms.test.ts index 1f94bb5bf..e86064b63 100644 --- a/tests/guilds/members/dms.test.ts +++ b/tests/guilds/members/dms.test.ts @@ -1,12 +1,16 @@ import { assertExists } from "../../deps.ts"; import { loadBot } from "../../mod.ts"; -Deno.test("[member] get dm channel and send a message", async () => { - const bot = loadBot(); - // Itoh Alt ID - const channel = await bot.helpers.getDmChannel(750661528360845322n); - assertExists(channel?.id); +Deno.test({ + name: "[member] get dm channel and send a message", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + // Itoh Alt ID + const channel = await bot.helpers.getDmChannel(750661528360845322n); + assertExists(channel?.id); - const message = await bot.helpers.sendMessage(channel.id, { content: "https://i.imgur.com/doG55NR.png" }); - assertExists(message?.content); + const message = await bot.helpers.sendMessage(channel.id, { content: "https://i.imgur.com/doG55NR.png" }); + assertExists(message?.content); + }, }); diff --git a/tests/guilds/members/editBotNickname.test.ts b/tests/guilds/members/editBotNickname.test.ts index 83987185a..9bd89a18c 100644 --- a/tests/guilds/members/editBotNickname.test.ts +++ b/tests/guilds/members/editBotNickname.test.ts @@ -2,14 +2,18 @@ import { assertEquals } from "../../deps.ts"; import { loadBot } from "../../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../../utils.ts"; -Deno.test("[misc] edit a bot's nickname", async function () { - const bot = loadBot(); +Deno.test({ + name: "[misc] edit a bot's nickname", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); - const nick = "lts20050703"; - const member = await bot.helpers.editBotMember(CACHED_COMMUNITY_GUILD_ID, { nick }); - assertEquals(member.nick, nick); + const nick = "lts20050703"; + const member = await bot.helpers.editBotMember(CACHED_COMMUNITY_GUILD_ID, { nick }); + assertEquals(member.nick, nick); - // Change nickname back - const member2 = await bot.helpers.editBotMember(CACHED_COMMUNITY_GUILD_ID, { nick: null }); - assertEquals(member2.nick, undefined); + // Change nickname back + const member2 = await bot.helpers.editBotMember(CACHED_COMMUNITY_GUILD_ID, { nick: null }); + assertEquals(member2.nick, undefined); + }, }); diff --git a/tests/guilds/members/members.test.ts b/tests/guilds/members/members.test.ts index d94d912b6..970a8f4d8 100644 --- a/tests/guilds/members/members.test.ts +++ b/tests/guilds/members/members.test.ts @@ -2,16 +2,24 @@ import { assertEquals, assertExists } from "../../deps.ts"; import { loadBot } from "../../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../../utils.ts"; -Deno.test("[member] fetches the bot and compares the bot's id with the fetched member's id", async () => { - const bot = loadBot(); - const member = await bot.helpers.getMember(CACHED_COMMUNITY_GUILD_ID, bot.id); - assertExists(member?.id); - assertEquals(member?.id, bot.id); +Deno.test({ + name: "[member] fetches the bot and compares the bot's id with the fetched member's id", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const member = await bot.helpers.getMember(CACHED_COMMUNITY_GUILD_ID, bot.id); + assertExists(member?.id); + assertEquals(member?.id, bot.id); + }, }); -Deno.test("[member] Gets a member list and checks if the bot is in the member list", async () => { - const bot = loadBot(); +Deno.test({ + name: "[member] Gets a member list and checks if the bot is in the member list", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); - const members = await bot.helpers.getMembers(CACHED_COMMUNITY_GUILD_ID, { "limit": 10 }); - assertEquals(members.has(bot.id), true); + const members = await bot.helpers.getMembers(CACHED_COMMUNITY_GUILD_ID, { "limit": 10 }); + assertEquals(members.has(bot.id), true); + }, }); diff --git a/tests/guilds/roles.test.ts b/tests/guilds/roles.test.ts index cb9442b79..51e628908 100644 --- a/tests/guilds/roles.test.ts +++ b/tests/guilds/roles.test.ts @@ -4,6 +4,7 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[role] role unit tests", + ignore: Deno.env.get("TEST_ENV") === "UNIT", async fn(t) { const bot = loadBot(); const role = await bot.helpers.createRole(CACHED_COMMUNITY_GUILD_ID, { diff --git a/tests/misc/benchmark.test.ts b/tests/misc/benchmark.test.ts index 7226146dd..8970e883b 100644 --- a/tests/misc/benchmark.test.ts +++ b/tests/misc/benchmark.test.ts @@ -4,7 +4,7 @@ // Deno.test({ // name: "[Memory] Benchmark memory tests", -// fn: async (t) => { +// async fn (t) { // const bot = enableCachePlugin(loadBot()); // await memoryBenchmarks(bot, { diff --git a/tests/misc/gatewaybot.test.ts b/tests/misc/gatewaybot.test.ts index d0122acf4..acef78c9b 100644 --- a/tests/misc/gatewaybot.test.ts +++ b/tests/misc/gatewaybot.test.ts @@ -1,13 +1,17 @@ import { assertEquals, assertExists } from "../deps.ts"; import { loadBot } from "../mod.ts"; -Deno.test("[misc] Get gateway bot information", async () => { - const bot = loadBot(); - const data = await bot.helpers.getGatewayBot(); +Deno.test({ + name: "[misc] Get gateway bot information", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const data = await bot.helpers.getGatewayBot(); - assertExists(data); - assertEquals(data.url, "wss://gateway.discord.gg"); - assertEquals(data.shards, 1); - assertEquals(data.sessionStartLimit.total, 1000); - assertEquals(data.sessionStartLimit.maxConcurrency, 1); + assertExists(data); + assertEquals(data.url, "wss://gateway.discord.gg"); + assertEquals(data.shards, 1); + assertEquals(data.sessionStartLimit.total, 1000); + assertEquals(data.sessionStartLimit.maxConcurrency, 1); + }, }); diff --git a/tests/misc/getApplicationInfo.test.ts b/tests/misc/getApplicationInfo.test.ts index 388dadafb..a22a5c069 100644 --- a/tests/misc/getApplicationInfo.test.ts +++ b/tests/misc/getApplicationInfo.test.ts @@ -1,8 +1,12 @@ import { assertEquals } from "../deps.ts"; import { loadBot } from "../mod.ts"; -Deno.test("[application] Get application info", async () => { - const bot = loadBot(); - const application = await bot.helpers.getApplicationInfo(); - assertEquals(application.id, bot.id); +Deno.test({ + name: "[application] Get application info", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const application = await bot.helpers.getApplicationInfo(); + assertEquals(application.id, bot.id); + }, }); diff --git a/tests/misc/getUser.test.ts b/tests/misc/getUser.test.ts index 9ee9ca8a3..632cb3c63 100644 --- a/tests/misc/getUser.test.ts +++ b/tests/misc/getUser.test.ts @@ -3,7 +3,8 @@ import { loadBot } from "../mod.ts"; Deno.test({ name: "[User] get a user and transform", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { const bot = loadBot(); const user = await bot.helpers.getUser(bot.id); assertExists(user?.id); diff --git a/tests/misc/rateLimit.test.ts b/tests/misc/rateLimit.test.ts index 1e40eea5f..4f59e20ad 100644 --- a/tests/misc/rateLimit.test.ts +++ b/tests/misc/rateLimit.test.ts @@ -1,9 +1,13 @@ import { loadBot } from "../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; -Deno.test("[Misc] Rate Limit Test", async () => { - const bot = loadBot(); - const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "test" }); - await Promise.all(Array(10).map(() => bot.helpers.sendMessage(channel.id, { content: "Rate Limit Test" }))); - await bot.helpers.deleteChannel(channel.id); +Deno.test({ + name: "[Misc] Rate Limit Test", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "test" }); + await Promise.all(Array(10).map(() => bot.helpers.sendMessage(channel.id, { content: "Rate Limit Test" }))); + await bot.helpers.deleteChannel(channel.id); + }, }); diff --git a/tests/misc/snowflake.test.ts b/tests/misc/snowflake.test.ts index bd5296deb..43bf4f80e 100644 --- a/tests/misc/snowflake.test.ts +++ b/tests/misc/snowflake.test.ts @@ -3,7 +3,8 @@ import { loadBot } from "../mod.ts"; Deno.test({ name: "[tranform] snowflake to bigint", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { const bot = loadBot(); assertEquals(130136895395987456n, bot.transformers.snowflake("130136895395987456")); }, diff --git a/tests/misc/startTyping.test.ts b/tests/misc/startTyping.test.ts index 86cadf7a6..9bf4a4f69 100644 --- a/tests/misc/startTyping.test.ts +++ b/tests/misc/startTyping.test.ts @@ -1,9 +1,13 @@ import { loadBot } from "../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; -Deno.test("[typing] start typing", async () => { - const bot = loadBot(); - const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "typing" }); - await bot.helpers.startTyping(channel.id); - await bot.helpers.deleteChannel(channel.id); +Deno.test({ + name: "[typing] start typing", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "typing" }); + await bot.helpers.startTyping(channel.id); + await bot.helpers.deleteChannel(channel.id); + }, }); diff --git a/tests/stickers/createGuildSticker.test.ts b/tests/stickers/createGuildSticker.test.ts index f1472675b..ef936a700 100644 --- a/tests/stickers/createGuildSticker.test.ts +++ b/tests/stickers/createGuildSticker.test.ts @@ -3,29 +3,33 @@ import { assertEquals } from "../deps.ts"; import { loadBot } from "../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; -Deno.test("[stickers] Create guild sticker", async () => { - const bot = loadBot(); - const sticker = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { - name: "sticker name", - description: "sticker description", - tags: "sticker tags", - file: { - blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), - name: "ddlogo.png", - }, - }); +Deno.test({ + name: "[stickers] Create guild sticker", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const sticker = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { + name: "sticker name", + description: "sticker description", + tags: "sticker tags", + file: { + blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), + name: "ddlogo.png", + }, + }); - assertEquals(sticker.name, "sticker name"); - assertEquals(sticker.description, "sticker description"); - assertEquals(sticker.tags, "sticker tags"); + assertEquals(sticker.name, "sticker name"); + assertEquals(sticker.description, "sticker description"); + assertEquals(sticker.tags, "sticker tags"); - const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "test" }); - const message = await bot.helpers.sendMessage(channel.id, { stickerIds: [sticker.id] }); + const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "test" }); + const message = await bot.helpers.sendMessage(channel.id, { stickerIds: [sticker.id] }); - assertEquals(message.stickerItems?.[0].formatType, StickerFormatTypes.Png); - assertEquals(message.stickerItems?.[0].id, sticker.id); - assertEquals(message.stickerItems?.[0].name, sticker.name); + assertEquals(message.stickerItems?.[0].formatType, StickerFormatTypes.Png); + assertEquals(message.stickerItems?.[0].id, sticker.id); + assertEquals(message.stickerItems?.[0].name, sticker.name); - await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker.id); - await bot.helpers.deleteChannel(channel.id); + await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker.id); + await bot.helpers.deleteChannel(channel.id); + }, }); diff --git a/tests/stickers/deleteGuildSticker.test.ts b/tests/stickers/deleteGuildSticker.test.ts index 59b5e36d9..cee6093bf 100644 --- a/tests/stickers/deleteGuildSticker.test.ts +++ b/tests/stickers/deleteGuildSticker.test.ts @@ -2,17 +2,21 @@ import { assertRejects } from "../deps.ts"; import { loadBot } from "../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; -Deno.test("[stickers] Delete guild sticker", async () => { - const bot = loadBot(); - const sticker = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { - name: "sticker name", - description: "sticker description", - tags: "sticker tags", - file: { - blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), - name: "ddlogo.png", - }, - }); - await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker.id); - await assertRejects(() => bot.helpers.getGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker.id)); +Deno.test({ + name: "[stickers] Delete guild sticker", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const sticker = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { + name: "sticker name", + description: "sticker description", + tags: "sticker tags", + file: { + blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), + name: "ddlogo.png", + }, + }); + await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker.id); + await assertRejects(() => bot.helpers.getGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker.id)); + }, }); diff --git a/tests/stickers/editGuildSticker.test.ts b/tests/stickers/editGuildSticker.test.ts index f6e28da04..87f9691ba 100644 --- a/tests/stickers/editGuildSticker.test.ts +++ b/tests/stickers/editGuildSticker.test.ts @@ -2,25 +2,29 @@ import { assertEquals } from "../deps.ts"; import { loadBot } from "../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; -Deno.test("[stickers] Edit guild sticker", async () => { - const bot = loadBot(); - const createSticker = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { - name: "test", - description: "test", - tags: "test", - file: { - blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), - name: "ddlogo.png", - }, - }); - const editSticker = await bot.helpers.editGuildSticker(CACHED_COMMUNITY_GUILD_ID, createSticker.id, { - name: "sticker name", - description: "sticker description", - tags: "sticker tags", - }); - assertEquals(editSticker.name, "sticker name"); - assertEquals(editSticker.description, "sticker description"); - assertEquals(editSticker.tags, "sticker tags"); +Deno.test({ + name: "[stickers] Edit guild sticker", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const createSticker = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { + name: "test", + description: "test", + tags: "test", + file: { + blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), + name: "ddlogo.png", + }, + }); + const editSticker = await bot.helpers.editGuildSticker(CACHED_COMMUNITY_GUILD_ID, createSticker.id, { + name: "sticker name", + description: "sticker description", + tags: "sticker tags", + }); + assertEquals(editSticker.name, "sticker name"); + assertEquals(editSticker.description, "sticker description"); + assertEquals(editSticker.tags, "sticker tags"); - await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, editSticker.id); + await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, editSticker.id); + }, }); diff --git a/tests/stickers/getGuildSticker.test.ts b/tests/stickers/getGuildSticker.test.ts index f530c2372..b3d4bb3e3 100644 --- a/tests/stickers/getGuildSticker.test.ts +++ b/tests/stickers/getGuildSticker.test.ts @@ -2,21 +2,25 @@ import { assertEquals } from "../deps.ts"; import { loadBot } from "../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; -Deno.test("[stickers] Get guild sticker", async () => { - const bot = loadBot(); - const createSticker = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { - name: "sticker name", - description: "sticker description", - tags: "sticker tags", - file: { - blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), - name: "ddlogo.png", - }, - }); - const getSticker = await bot.helpers.getGuildSticker(CACHED_COMMUNITY_GUILD_ID, createSticker.id); - assertEquals(getSticker.name, "sticker name"); - assertEquals(getSticker.description, "sticker description"); - assertEquals(getSticker.tags, "sticker tags"); +Deno.test({ + name: "[stickers] Get guild sticker", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const createSticker = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { + name: "sticker name", + description: "sticker description", + tags: "sticker tags", + file: { + blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), + name: "ddlogo.png", + }, + }); + const getSticker = await bot.helpers.getGuildSticker(CACHED_COMMUNITY_GUILD_ID, createSticker.id); + assertEquals(getSticker.name, "sticker name"); + assertEquals(getSticker.description, "sticker description"); + assertEquals(getSticker.tags, "sticker tags"); - await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, getSticker.id); + await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, getSticker.id); + }, }); diff --git a/tests/stickers/getGuildStickers.test.ts b/tests/stickers/getGuildStickers.test.ts index 5d0662b9a..c782bd008 100644 --- a/tests/stickers/getGuildStickers.test.ts +++ b/tests/stickers/getGuildStickers.test.ts @@ -2,28 +2,32 @@ import { assertEquals } from "../deps.ts"; import { loadBot } from "../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; -Deno.test("[stickers] Get guild stickers", async () => { - const bot = loadBot(); - const sticker1 = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { - name: "sticker 1", - description: "sticker 1", - tags: "sticker tags 1", - file: { - blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), - name: "ddlogo.png", - }, - }); - const sticker2 = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { - name: "sticker 2", - description: "sticker 2", - tags: "sticker tags 2", - file: { - blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), - name: "ddlogo.png", - }, - }); - const stickers = await bot.helpers.getGuildStickers(CACHED_COMMUNITY_GUILD_ID); - assertEquals(stickers.size > 1, true); - await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker1.id); - await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker2.id); +Deno.test({ + name: "[stickers] Get guild stickers", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const sticker1 = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { + name: "sticker 1", + description: "sticker 1", + tags: "sticker tags 1", + file: { + blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), + name: "ddlogo.png", + }, + }); + const sticker2 = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { + name: "sticker 2", + description: "sticker 2", + tags: "sticker tags 2", + file: { + blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), + name: "ddlogo.png", + }, + }); + const stickers = await bot.helpers.getGuildStickers(CACHED_COMMUNITY_GUILD_ID); + assertEquals(stickers.size > 1, true); + await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker1.id); + await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker2.id); + }, }); diff --git a/tests/stickers/getSticker.test.ts b/tests/stickers/getSticker.test.ts index a171b7dc1..4e897a19b 100644 --- a/tests/stickers/getSticker.test.ts +++ b/tests/stickers/getSticker.test.ts @@ -1,8 +1,12 @@ import { assertEquals } from "../deps.ts"; import { loadBot } from "../mod.ts"; -Deno.test("[stickers] Get sticker", async () => { - const bot = loadBot(); - const sticker = await bot.helpers.getSticker(749054660769218631n); - assertEquals(sticker.name, "Wave"); +Deno.test({ + name: "[stickers] Get sticker", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + const sticker = await bot.helpers.getSticker(749054660769218631n); + assertEquals(sticker.name, "Wave"); + }, }); diff --git a/tests/utils.test.ts b/tests/utils.test.ts index a3f1801df..fbd0fe89a 100644 --- a/tests/utils.test.ts +++ b/tests/utils.test.ts @@ -1,13 +1,13 @@ -import { formatImageURL, hasProperty, iconBigintToHash, iconHashToBigInt, validateLength } from "../mod.ts"; +import { Collection, formatImageURL, hasProperty, iconBigintToHash, iconHashToBigInt, validateLength } from "../mod.ts"; import { bigintToSnowflake, snowflakeToBigint } from "../util/bigint.ts"; import { removeTokenPrefix } from "../util/token.ts"; import { assertEquals, assertExists, assertNotEquals } from "./deps.ts"; import { loadBot } from "./mod.ts"; -import { Collection } from "../mod.ts"; import { delayUntil } from "./utils.ts"; Deno.test({ name: "[token] Remove token prefix when Bot is prefixed.", + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", async fn(t) { assertEquals("discordeno is best lib", removeTokenPrefix("Bot discordeno is best lib")); }, @@ -15,44 +15,58 @@ Deno.test({ Deno.test({ name: "[token] Remove token prefix when Bot is NOT prefixed.", + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", async fn(t) { assertEquals("discordeno is best lib", removeTokenPrefix("discordeno is best lib")); }, }); -Deno.test("[bigint] - Transform a snowflake string to bigint", () => { - const text = "130136895395987456"; - const big = 130136895395987456n; - const result = snowflakeToBigint(text); +Deno.test({ + name: "[bigint] - Transform a snowflake string to bigint", + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { + const text = "130136895395987456"; + const big = 130136895395987456n; + const result = snowflakeToBigint(text); - assertEquals(big, result); - assertNotEquals(text, result); + assertEquals(big, result); + assertNotEquals(text, result); + }, }); -Deno.test("[bigint] - Transform a bigint to a string", () => { - const text = "130136895395987456"; - const big = 130136895395987456n; - const result = bigintToSnowflake(big); +Deno.test({ + name: "[bigint] - Transform a bigint to a string", + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { + const text = "130136895395987456"; + const big = 130136895395987456n; + const result = bigintToSnowflake(big); - assertEquals(text, result); - assertNotEquals(big, result); + assertEquals(text, result); + assertNotEquals(big, result); + }, }); -Deno.test("[emoji] Create an emoji url", async () => { - const bot = loadBot(); - assertEquals( - bot.helpers.getEmojiURL(785403373817823272n, false), - "https://cdn.discordapp.com/emojis/785403373817823272.png", - ); - assertEquals( - bot.helpers.getEmojiURL(785403373817823272n, true), - "https://cdn.discordapp.com/emojis/785403373817823272.gif", - ); +Deno.test({ + name: "[emoji] Create an emoji url", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); + assertEquals( + bot.helpers.getEmojiURL(785403373817823272n, false), + "https://cdn.discordapp.com/emojis/785403373817823272.png", + ); + assertEquals( + bot.helpers.getEmojiURL(785403373817823272n, true), + "https://cdn.discordapp.com/emojis/785403373817823272.gif", + ); + }, }); Deno.test({ name: "[guild] format a guild's icon url", - fn: async () => { + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { const bot = loadBot(); assertEquals( bot.helpers.getGuildIconURL(785384884197392384n, 3837424427068676005442449262648382018748n), @@ -63,7 +77,8 @@ Deno.test({ Deno.test({ name: "[guild] format a guild's banner url", - fn: async () => { + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { const bot = loadBot(); assertEquals( @@ -77,7 +92,8 @@ Deno.test({ Deno.test({ name: "[guild] format a guild's splash url", - fn: async () => { + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { const bot = loadBot(); assertEquals( bot.helpers.getGuildSplashURL(785384884197392384n, 3837424427068676005442449262648382018748n), @@ -88,7 +104,8 @@ Deno.test({ Deno.test({ name: "[utils] format image url", - fn() { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(formatImageURL(`https://skillz.is.pro`), "https://skillz.is.pro.jpg?size=128"); assertEquals(formatImageURL(`https://skillz.is.pro`, 1024), "https://skillz.is.pro.jpg?size=1024"); assertEquals(formatImageURL(`https://skillz.is.pro`, 1024, "gif"), "https://skillz.is.pro.gif?size=1024"); @@ -103,70 +120,80 @@ const a_iconBigInt = 3503487521485885045056617826984736090062n; Deno.test({ name: "[utils] icon hash to bigint", - fn() { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(iconHashToBigInt(iconHash), iconBigInt); }, }); Deno.test({ name: "[utils] icon bigint to hash", - fn() { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(iconBigintToHash(iconBigInt), iconHash); }, }); Deno.test({ name: "[utils] icon hash to bigint a_ (animated)", - fn() { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(iconHashToBigInt(a_iconHash), a_iconBigInt); }, }); Deno.test({ name: "[utils] icon bigint to hash a_ (animated)", - fn() { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(iconBigintToHash(a_iconBigInt), a_iconHash); }, }); Deno.test({ name: "[utils] Validate length is too low", - fn() { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(validateLength("test", { min: 5 }), false); }, }); Deno.test({ name: "[utils] Validate length is too high", - fn() { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(validateLength("test", { max: 3 }), false); }, }); Deno.test({ name: "[utils] Validate length is NOT just right in between.", - fn() { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(validateLength("test", { min: 5, max: 3 }), false); }, }); Deno.test({ name: "[utils] Validate length is NOT too low", - fn() { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(validateLength("test", { min: 3 }), true); }, }); Deno.test({ name: "[utils] Validate length is NOT too high", - fn() { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(validateLength("test", { max: 5 }), true); }, }); Deno.test({ name: "[utils] Validate length is just right in between.", - fn() { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(validateLength("test", { min: 3, max: 6 }), true); }, }); @@ -175,21 +202,24 @@ const obj = { prop: "lts372005" }; Deno.test({ name: "[utils] hasProperty does HAVE property", - fn() { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(hasProperty(obj, "prop"), true); }, }); Deno.test({ name: "[utils] hasProperty does NOT HAVE property", - fn() { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(hasProperty(obj, "lts372005"), false); }, }); Deno.test({ name: "[member] format a members avatar url", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { const bot = loadBot(); assertEquals( @@ -203,14 +233,16 @@ Deno.test({ Deno.test({ name: "[collection] Create a collection", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { const collection = new Collection(); assertExists(collection); await t.step({ name: "[collection] collection values to array", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { const testCollection = new Collection([["best", "tri"], ["proficient", "yui"]]); assertEquals(testCollection.array(), ["tri", "yui"]); @@ -219,7 +251,8 @@ Deno.test({ await t.step({ name: "[collection] get a random value", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { const testCollection = new Collection([["best", "tri"]]); assertEquals(["best", "tri"].includes(testCollection.random() ?? ""), true); @@ -229,7 +262,8 @@ Deno.test({ await t.step({ name: "[collection] Set a value without maxSize", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { collection.set("best developer", "triformine"); assertEquals(collection.size, 1); assertEquals(collection.get("best developer"), "triformine"); @@ -238,14 +272,14 @@ Deno.test({ await t.step({ name: "[collection] get the value of the first element", - fn: async (t) => { + async fn(t) { assertEquals(collection.first(), "triformine"); }, }); await t.step({ name: "[collection] get the value of the last element", - fn: async (t) => { + async fn(t) { assertEquals(collection.last(), "yes"); }, }); @@ -254,7 +288,8 @@ Deno.test({ await t.step({ name: "[collection] Create a collection with maxSize", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { const maxSize = 2; const maxCollection = new Collection([], { @@ -267,7 +302,7 @@ Deno.test({ await t.step({ name: "[collection] Test if maxSize works properly", - fn: async (t) => { + async fn(t) { maxCollection.set("foo", "bar"); maxCollection.set("me", "you"); @@ -279,7 +314,7 @@ Deno.test({ await t.step({ name: "[collection] Test if forceSet ignore maxSize", - fn: async (t) => { + async fn(t) { maxCollection.forceSet("this", "not"); assertEquals(maxCollection.size, 3); @@ -294,7 +329,8 @@ Deno.test({ await t.step({ name: "[collection] find by key or value", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(testCollection.find((v, k) => v === 2), 2); assertEquals(testCollection.find((v, k) => k === "b"), 2); }, @@ -302,7 +338,8 @@ Deno.test({ await t.step({ name: "[collection] filter by key or value", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(testCollection.filter((v, k) => v === 3).size, 1); assertEquals(testCollection.filter((v, k) => k === "d").size, 0); }, @@ -310,14 +347,16 @@ Deno.test({ await t.step({ name: "[collection] map", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(testCollection.map((k, v) => `${v}${k}`), ["a1", "b2", "c3"]); }, }); await t.step({ name: "[collection] some", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(testCollection.some((v, _) => v === 1), true); assertEquals(testCollection.some((v, _) => v === 4), false); }, @@ -325,7 +364,8 @@ Deno.test({ await t.step({ name: "[collection] every", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(testCollection.every((v, _) => v !== 0), true); assertEquals(testCollection.every((v, _) => v === 1), false); }, @@ -333,14 +373,16 @@ Deno.test({ await t.step({ name: "[collection] reduce", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { assertEquals(testCollection.reduce((acc, val) => acc + val, 0), 6); }, }); await t.step({ name: "[collection] start sweeper", - fn: async (t) => { + ignore: Deno.env.get("TEST_ENV") === "INTEGRATION", + async fn(t) { const sweeperCollection = new Collection([["a", 1], ["b", 2]], { sweeper: { filter: (v, _) => v === 1, diff --git a/tests/webhook/deleteWebhook.test.ts b/tests/webhook/deleteWebhook.test.ts index 09d792851..3add7352b 100644 --- a/tests/webhook/deleteWebhook.test.ts +++ b/tests/webhook/deleteWebhook.test.ts @@ -1,10 +1,11 @@ -import { assertEquals, assertExists, assertRejects } from "../deps.ts"; +import { assertExists, assertRejects } from "../deps.ts"; import { loadBot } from "../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[webhook] delete a webhook", - fn: async () => { + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "deleteWebhook" }); diff --git a/tests/webhook/deleteWebhookWithToken.test.ts b/tests/webhook/deleteWebhookWithToken.test.ts index 3c20841d5..27b8ba2ea 100644 --- a/tests/webhook/deleteWebhookWithToken.test.ts +++ b/tests/webhook/deleteWebhookWithToken.test.ts @@ -4,7 +4,8 @@ import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; Deno.test({ name: "[webhook] delete a webhook", - fn: async () => { + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { const bot = loadBot(); const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "deleteWebhook" }); diff --git a/tests/webhook/messages.test.ts b/tests/webhook/messages.test.ts index 8a1513948..7937c5b3d 100644 --- a/tests/webhook/messages.test.ts +++ b/tests/webhook/messages.test.ts @@ -2,45 +2,49 @@ import { assertEquals, assertExists, assertNotEquals } from "../deps.ts"; import { loadBot } from "../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; -Deno.test("[webhooks] Send a message with a webhook", async (t) => { - const bot = loadBot(); +Deno.test({ + name: "[webhooks] Send a message with a webhook", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); - const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "webhooks" }); - assertExists(channel?.id); + const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "webhooks" }); + assertExists(channel?.id); - const webhook = await bot.helpers.createWebhook(channel.id, { - name: "gigi", - }); - - assertExists(webhook.token); - - const message = await bot.helpers.sendWebhookMessage(webhook.id, webhook.token, { - content: "discordeno is best lib", - wait: true, - }); - - assertExists(message?.id); - - await t.step("[webhooks] Get a webhook message", async () => { - const fetched = await bot.helpers.getWebhookMessage(webhook.id, webhook.token!, message.id); - - assertExists(fetched); - assertEquals(fetched.content, message.content); - }); - - await t.step("[webhooks] Edit a webhook message", async () => { - const edited = await bot.helpers.editWebhookMessage(webhook.id, webhook.token!, message.id, { - content: "different", + const webhook = await bot.helpers.createWebhook(channel.id, { + name: "gigi", }); - assertExists(edited); - assertNotEquals(edited.content, message.content); - }); - - await t.step("[webhooks] Delete a webhook message", async () => { assertExists(webhook.token); - await bot.helpers.deleteWebhookMessage(webhook.id, webhook.token, message.id); - }); - await bot.helpers.deleteChannel(channel.id); + const message = await bot.helpers.sendWebhookMessage(webhook.id, webhook.token, { + content: "discordeno is best lib", + wait: true, + }); + + assertExists(message?.id); + + await t.step("[webhooks] Get a webhook message", async () => { + const fetched = await bot.helpers.getWebhookMessage(webhook.id, webhook.token!, message.id); + + assertExists(fetched); + assertEquals(fetched.content, message.content); + }); + + await t.step("[webhooks] Edit a webhook message", async () => { + const edited = await bot.helpers.editWebhookMessage(webhook.id, webhook.token!, message.id, { + content: "different", + }); + + assertExists(edited); + assertNotEquals(edited.content, message.content); + }); + + await t.step("[webhooks] Delete a webhook message", async () => { + assertExists(webhook.token); + await bot.helpers.deleteWebhookMessage(webhook.id, webhook.token, message.id); + }); + + await bot.helpers.deleteChannel(channel.id); + }, }); diff --git a/tests/webhook/webhook.test.ts b/tests/webhook/webhook.test.ts index 74cc8a74c..84f757b30 100644 --- a/tests/webhook/webhook.test.ts +++ b/tests/webhook/webhook.test.ts @@ -2,61 +2,65 @@ import { assertEquals, assertExists, assertNotEquals } from "../deps.ts"; import { loadBot } from "../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; -Deno.test("[webhooks] Webhook related tests", async (t) => { - const bot = loadBot(); +Deno.test({ + name: "[webhooks] Webhook related tests", + ignore: Deno.env.get("TEST_ENV") === "UNIT", + async fn(t) { + const bot = loadBot(); - // Create a channel - const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "wbhook" }); + // Create a channel + const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "wbhook" }); - await t.step("[webhooks] Create a webhook", async (t) => { - const webhook = await bot.helpers.createWebhook(channel.id, { - name: "idk", - }); - assertExists(webhook); - assertEquals(webhook.name, "idk"); + await t.step("[webhooks] Create a webhook", async (t) => { + const webhook = await bot.helpers.createWebhook(channel.id, { + name: "idk", + }); + assertExists(webhook); + assertEquals(webhook.name, "idk"); - await t.step("[webhooks] Edit a webhook", async (t) => { - const edited = await bot.helpers.editWebhook(webhook.id, { - name: "edited", + await t.step("[webhooks] Edit a webhook", async (t) => { + const edited = await bot.helpers.editWebhook(webhook.id, { + name: "edited", + }); + + assertNotEquals(webhook.name, edited.name); }); - assertNotEquals(webhook.name, edited.name); - }); + await t.step("[webhooks] Edit a webhook with token", async () => { + assertExists(webhook.token); + const edited = await bot.helpers.editWebhookWithToken(webhook.id, webhook.token, { + name: "editedtoken", + }); - await t.step("[webhooks] Edit a webhook with token", async () => { - assertExists(webhook.token); - const edited = await bot.helpers.editWebhookWithToken(webhook.id, webhook.token, { - name: "editedtoken", + assertNotEquals(webhook.name, edited.name); }); - assertNotEquals(webhook.name, edited.name); + await t.step("[webhooks] Get a webhook", async () => { + const fetched = await bot.helpers.getWebhook(webhook.id); + assertExists(fetched); + assertEquals(webhook.id, fetched.id); + }); + + await t.step("[webhooks] Get a webhook with a token", async () => { + assertExists(webhook.token); + const fetched = await bot.helpers.getWebhookWithToken(webhook.id, webhook.token); + assertEquals(webhook.id, fetched.id); + }); }); - await t.step("[webhooks] Get a webhook", async () => { - const fetched = await bot.helpers.getWebhook(webhook.id); - assertExists(fetched); - assertEquals(webhook.id, fetched.id); + await t.step("[webhooks] Get channel webhooks", async (t) => { + const second = await bot.helpers.createWebhook(channel.id, { name: "what nonsense" }); + + assertExists(second); + const fetched = await bot.helpers.getChannelWebhooks(channel.id); + assertEquals(fetched.size > 1, true); + + await t.step("[webhooks] Get guild webhooks", async () => { + const guildWebhooks = await bot.helpers.getGuildWebhooks(channel.guildId); + assertEquals(guildWebhooks.size > 1, true); + }); }); - await t.step("[webhooks] Get a webhook with a token", async () => { - assertExists(webhook.token); - const fetched = await bot.helpers.getWebhookWithToken(webhook.id, webhook.token); - assertEquals(webhook.id, fetched.id); - }); - }); - - await t.step("[webhooks] Get channel webhooks", async (t) => { - const second = await bot.helpers.createWebhook(channel.id, { name: "what nonsense" }); - - assertExists(second); - const fetched = await bot.helpers.getChannelWebhooks(channel.id); - assertEquals(fetched.size > 1, true); - - await t.step("[webhooks] Get guild webhooks", async () => { - const guildWebhooks = await bot.helpers.getGuildWebhooks(channel.guildId); - assertEquals(guildWebhooks.size > 1, true); - }); - }); - - await bot.helpers.deleteChannel(channel.id); + await bot.helpers.deleteChannel(channel.id); + }, });