From 3a73f443ca69cf4053b174621ffdbcdd5d0658f6 Mon Sep 17 00:00:00 2001 From: A Cottrill Date: Sat, 4 Jan 2025 16:25:55 -0500 Subject: [PATCH 1/3] chore: update assertions to expectations --- test/commands/author.spec.ts | 4 +- test/commands/community.spec.ts | 18 +++---- test/commands/github.spec.ts | 38 +++++++------- test/commands/management.spec.ts | 24 ++++----- test/commands/moderation.spec.ts | 52 +++++++++---------- test/commands/report.spec.ts | 4 +- .../community/handleCodeOfConduct.spec.ts | 2 +- .../community/handleContribute.spec.ts | 2 +- .../subcommands/community/handleForum.spec.ts | 4 +- .../community/handleLeaderboard.spec.ts | 4 +- .../community/handleProfile.spec.ts | 4 +- .../subcommands/community/handleQuote.spec.ts | 4 +- .../community/handleTruism.spec.ts | 4 +- .../github/handleAddLabels.spec.ts | 2 +- .../subcommands/github/handleClose.spec.ts | 2 +- .../subcommands/github/handleComment.spec.ts | 2 +- .../github/handleSyncLabels.spec.ts | 2 +- .../management/handlePrivate.spec.ts | 2 +- .../subcommands/management/handleRole.spec.ts | 2 +- .../subcommands/moderation/handleBan.spec.ts | 2 +- .../moderation/handleHistory.spec.ts | 2 +- .../subcommands/moderation/handleKick.spec.ts | 2 +- .../subcommands/moderation/handleMute.spec.ts | 2 +- .../moderation/handlePrune.spec.ts | 2 +- .../moderation/handleUnban.spec.ts | 2 +- .../moderation/handleUnmute.spec.ts | 2 +- .../subcommands/moderation/handleWarn.spec.ts | 2 +- test/commands/supporter.spec.ts | 4 +- test/commands/translator.spec.ts | 4 +- test/commands/userSettings.spec.ts | 2 +- test/config/badges.spec.ts | 2 +- test/config/intentOptions.spec.ts | 2 +- test/config/languages.spec.ts | 2 +- test/config/levelScale.spec.ts | 2 +- test/config/pullComments.spec.ts | 2 +- test/config/roles.spec.ts | 2 +- test/config/tags.spec.ts | 2 +- test/config/truisms.spec.ts | 2 +- test/contexts/bookmark.spec.ts | 10 ++-- test/contexts/format.spec.ts | 10 ++-- test/contexts/report.spec.ts | 10 ++-- test/contexts/snippet.spec.ts | 4 +- test/contexts/translate.spec.ts | 10 ++-- test/database/connectDatabase.spec.ts | 6 +-- .../handleGuildScheduledEvents.spec.ts | 4 +- .../handlers/handleInteractionCreate.spec.ts | 4 +- test/events/handlers/handleMemberAdd.spec.ts | 4 +- .../handlers/handleMemberRemove.spec.ts | 4 +- .../handlers/handleMessageCreate.spec.ts | 4 +- .../handlers/handleMessageDelete.spec.ts | 4 +- .../events/handlers/handleMessageEdit.spec.ts | 4 +- test/events/handlers/handleReady.spec.ts | 4 +- .../handlers/handleThreadCreate.spec.ts | 4 +- .../handlers/handleVoiceStateUpdate.spec.ts | 4 +- test/events/registerEvents.spec.ts | 4 +- test/modules/addFormatting.spec.ts | 8 +-- test/modules/closePrivateChannel.spec.ts | 9 ++-- test/modules/createLogFile.spec.ts | 10 ++-- test/modules/formatCodeblock.spec.ts | 6 +-- test/modules/formatter.spec.ts | 6 +-- test/modules/generateCertSvg.spec.ts | 4 +- test/modules/generateConfig.spec.ts | 6 +-- test/modules/generateLogs.spec.ts | 12 ++--- test/modules/generateProfileImage.spec.ts | 7 +-- test/modules/isSupportedByPrettier.spec.ts | 15 +++--- test/modules/levelListener.spec.ts | 4 +- test/modules/loadRoles.spec.ts | 4 +- test/modules/messageCounter.spec.ts | 4 +- test/modules/reactionRoleClick.spec.ts | 4 +- test/modules/send100DaysOfCode.spec.ts | 4 +- test/modules/sendModerationDm.spec.ts | 4 +- test/modules/settingsValidation.spec.ts | 2 +- test/modules/updateHistory.spec.ts | 8 +-- test/utils/calculateMilliseconds.spec.ts | 6 +-- test/utils/customSubstring.spec.ts | 6 +-- test/utils/errorHandler.spec.ts | 6 +-- test/utils/fetchLearnRecord.spec.ts | 6 +-- test/utils/formatText.spec.ts | 9 ++-- test/utils/generateDiff.spec.ts | 6 +-- test/utils/isModerator.spec.ts | 12 ++--- test/utils/loadCommands.spec.ts | 6 +-- test/utils/loadContexts.spec.ts | 6 +-- test/utils/loadQuotes.spec.ts | 10 ++-- test/utils/logHandler.spec.ts | 10 ++-- test/utils/registerCommands.spec.ts | 6 +-- 85 files changed, 253 insertions(+), 265 deletions(-) diff --git a/test/commands/author.spec.ts b/test/commands/author.spec.ts index 88ecfd26..40f2279a 100644 --- a/test/commands/author.spec.ts +++ b/test/commands/author.spec.ts @@ -1,8 +1,8 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { author } from "../../src/commands/author.js"; describe("author command", () => { it("is defined", () => { - assert.isDefined(author); + expect(author).toBeDefined(); }); }); diff --git a/test/commands/community.spec.ts b/test/commands/community.spec.ts index c885008c..15b3c631 100644 --- a/test/commands/community.spec.ts +++ b/test/commands/community.spec.ts @@ -2,7 +2,7 @@ import { ApplicationCommandOptionType, type SlashCommandSubcommandBuilder, } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { community } from "../../src/commands/community.js"; describe("community command", () => { @@ -18,7 +18,7 @@ describe("community command", () => { community.data.description, "Commands related to our community.", ); - assert.lengthOf(subcommands, 7); + expect(subcommands).toHaveLength(7); }); it("has correct code of conduct", () => { @@ -33,7 +33,7 @@ describe("community command", () => { codeOfConduct?.description, "Returns information on freeCodeCamp's Code of Conduct.", ); - assert.lengthOf(codeOfConduct?.options || "hi", 0); + expect(codeOfConduct?.options || "hi").toHaveLength(0); }); it("has correct contribute", () => { @@ -46,7 +46,7 @@ describe("community command", () => { contribute?.description, "Returns helpful links for folks interested in contributing.", ); - assert.lengthOf(contribute?.options || "hi", 0); + expect(contribute?.options || "hi").toHaveLength(0); }); it("has correct forum", () => { @@ -59,7 +59,7 @@ describe("community command", () => { forum?.description, "Returns the latest activity on the forum.", ); - assert.lengthOf(forum?.options || "hi", 0); + expect(forum?.options || "hi").toHaveLength(0); }); it("has correct leaderboard", () => { @@ -69,7 +69,7 @@ describe("community command", () => { assert.exists(leaderboard); assert.equal(leaderboard?.name, "leaderboard"); assert.equal(leaderboard?.description, "View the server leaderboard."); - assert.lengthOf(leaderboard?.options || "hi", 0); + expect(leaderboard?.options || "hi").toHaveLength(0); }); it("has correct quote", () => { @@ -79,7 +79,7 @@ describe("community command", () => { assert.exists(quote); assert.equal(quote?.name, "quote"); assert.equal(quote?.description, "Returns a motivational quote."); - assert.lengthOf(quote?.options || "hi", 0); + expect(quote?.options || "hi").toHaveLength(0); }); it("has correct profile", () => { @@ -88,7 +88,7 @@ describe("community command", () => { }); assert.equal(rank?.name, "profile"); assert.equal(rank?.description, "See your community profile."); - assert.lengthOf(rank?.options || "hi", 0); + expect(rank?.options || "hi").toHaveLength(0); }); it("has correct truism", () => { @@ -100,6 +100,6 @@ describe("community command", () => { truism?.description, "Provides a random difficult-to-swallow truth about coding.", ); - assert.lengthOf(truism?.options || "hi", 0); + expect(truism?.options || "hi").toHaveLength(0); }); }); diff --git a/test/commands/github.spec.ts b/test/commands/github.spec.ts index 5e403239..31c0f184 100644 --- a/test/commands/github.spec.ts +++ b/test/commands/github.spec.ts @@ -2,7 +2,7 @@ import { ApplicationCommandOptionType, type SlashCommandSubcommandBuilder, } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { github } from "../../src/commands/github.js"; describe("github command", () => { @@ -18,7 +18,7 @@ describe("github command", () => { github.data.description, "Commands related to managing github", ); - assert.lengthOf(subcommands, 4); + expect(subcommands).toHaveLength(4); }); it("has correct close", () => { @@ -31,13 +31,13 @@ describe("github command", () => { close?.description, "Close an issue or pull request under the freeCodeCamp organisation.", ); - assert.lengthOf(close?.options || "hi", 4); + expect(close?.options || "hi").toHaveLength(4); assert.strictEqual(close?.options?.[0].name, "repository"); assert.strictEqual( close?.options?.[0].description, `The name of the repository, under freeCodeCamp's GitHub org, to comment on`, ); - assert.isTrue(close?.options?.[0].required); + expect(close?.options?.[0].required).toBeTruthy(); assert.strictEqual( close?.options?.[0].type, ApplicationCommandOptionType.String, @@ -47,7 +47,7 @@ describe("github command", () => { close?.options?.[1].description, "The number of the issue or pull to close.", ); - assert.isTrue(close?.options?.[1].required); + expect(close?.options?.[1].required).toBeTruthy(); assert.strictEqual( close?.options?.[1].type, ApplicationCommandOptionType.Integer, @@ -57,7 +57,7 @@ describe("github command", () => { close?.options?.[2].description, `The comment to leave when closing. Defaults to the standard close message.`, ); - assert.isFalse(close?.options?.[2].required); + expect(close?.options?.[2].required).toBeFalsy(); assert.strictEqual( close?.options?.[2].type, ApplicationCommandOptionType.String, @@ -67,7 +67,7 @@ describe("github command", () => { close?.options?.[3].description, "Label the PR as spam for Hacktoberfest?", ); - assert.isFalse(close?.options?.[3].required); + expect(close?.options?.[3].required).toBeFalsy(); assert.strictEqual( close?.options?.[3].type, ApplicationCommandOptionType.Boolean, @@ -84,13 +84,13 @@ describe("github command", () => { comment?.description, `Adds a friendly comment to an issue or pull request. Scoped to the freeCodeCamp organisation.`, ); - assert.lengthOf(comment?.options || "hi", 3); + expect(comment?.options || "hi").toHaveLength(3); assert.strictEqual(comment?.options?.[0].name, "repository"); assert.strictEqual( comment?.options?.[0].description, `The name of the repository, under freeCodeCamp's GitHub org, to comment on`, ); - assert.isTrue(comment?.options?.[0].required); + expect(comment?.options?.[0].required).toBeTruthy(); assert.strictEqual( comment?.options?.[0].type, ApplicationCommandOptionType.String, @@ -100,7 +100,7 @@ describe("github command", () => { comment?.options?.[1].description, "The number of the pull request to comment on.", ); - assert.isTrue(comment?.options?.[1].required); + expect(comment?.options?.[1].required).toBeTruthy(); assert.strictEqual( comment?.options?.[1].type, ApplicationCommandOptionType.Integer, @@ -110,7 +110,7 @@ describe("github command", () => { comment?.options?.[2].description, "The message to post.", ); - assert.isTrue(comment?.options?.[2].required); + expect(comment?.options?.[2].required).toBeTruthy(); assert.strictEqual( comment?.options?.[2].type, ApplicationCommandOptionType.String, @@ -127,13 +127,13 @@ describe("github command", () => { command?.description, `Specify a list of labels to add to an issue/PR. Existing labels will not be removed.`, ); - assert.lengthOf(command?.options || "hi", 3); + expect(command?.options || "hi").toHaveLength(3); assert.strictEqual(command?.options?.[0].name, "repository"); assert.strictEqual( command?.options?.[0].description, "The name of the repository, under freeCodeCamp's GitHub org, to label", ); - assert.isTrue(command?.options?.[0].required); + expect(command?.options?.[0].required).toBeTruthy(); assert.strictEqual( command?.options?.[0].type, ApplicationCommandOptionType.String, @@ -143,7 +143,7 @@ describe("github command", () => { command?.options?.[1].description, "The number of the pull request to label.", ); - assert.isTrue(command?.options?.[1].required); + expect(command?.options?.[1].required).toBeTruthy(); assert.strictEqual( command?.options?.[1].type, ApplicationCommandOptionType.Integer, @@ -153,7 +153,7 @@ describe("github command", () => { command?.options?.[2].description, "The comma separated list of labels to add", ); - assert.isTrue(command?.options?.[2].required); + expect(command?.options?.[2].required).toBeTruthy(); assert.strictEqual( command?.options?.[2].type, ApplicationCommandOptionType.String, @@ -170,13 +170,13 @@ describe("github command", () => { command?.description, `Specify the exact list of labels an issue/PR should have. Labels not on the list will be removed.`, ); - assert.lengthOf(command?.options || "hi", 3); + expect(command?.options || "hi").toHaveLength(3); assert.strictEqual(command?.options?.[0].name, "repository"); assert.strictEqual( command?.options?.[0].description, "The name of the repository, under freeCodeCamp's GitHub org, to label", ); - assert.isTrue(command?.options?.[0].required); + expect(command?.options?.[0].required).toBeTruthy(); assert.strictEqual( command?.options?.[0].type, ApplicationCommandOptionType.String, @@ -186,7 +186,7 @@ describe("github command", () => { command?.options?.[1].description, "The number of the pull request to label.", ); - assert.isTrue(command?.options?.[1].required); + expect(command?.options?.[1].required).toBeTruthy(); assert.strictEqual( command?.options?.[1].type, ApplicationCommandOptionType.Integer, @@ -196,7 +196,7 @@ describe("github command", () => { command?.options?.[2].description, "The comma separated list of labels to sync", ); - assert.isTrue(command?.options?.[2].required); + expect(command?.options?.[2].required).toBeTruthy(); assert.strictEqual( command?.options?.[2].type, ApplicationCommandOptionType.String, diff --git a/test/commands/management.spec.ts b/test/commands/management.spec.ts index b5c1621e..555b91d7 100644 --- a/test/commands/management.spec.ts +++ b/test/commands/management.spec.ts @@ -2,7 +2,7 @@ import { ApplicationCommandOptionType, type SlashCommandSubcommandBuilder, } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { management } from "../../src/commands/management.js"; describe("management command", () => { @@ -18,7 +18,7 @@ describe("management command", () => { management.data.description, "Commands related to server management.", ); - assert.lengthOf(subcommands, 3); + expect(subcommands).toHaveLength(3); }); it("has correct private", () => { @@ -29,13 +29,13 @@ describe("management command", () => { privateC?.description, "Creates a private discussion channel with a user.", ); - assert.lengthOf(privateC?.options || "hi", 1); + expect(privateC?.options || "hi").toHaveLength(1); assert.strictEqual(privateC?.options[0].name, "target"); assert.strictEqual( privateC?.options[0].description, "The user to create a private channel with.", ); - assert.isTrue(privateC?.options[0].required); + expect(privateC?.options[0].required).toBeTruthy(); assert.strictEqual( privateC?.options[0].type, ApplicationCommandOptionType.User, @@ -50,19 +50,19 @@ describe("management command", () => { role?.description, "Creates a post with buttons for self-assignable roles.", ); - assert.lengthOf(role?.options || "hi", 7); + expect(role?.options || "hi").toHaveLength(7); assert.strictEqual(role?.options[0].name, "channel"); assert.strictEqual( role?.options[0].description, "Channel to create the post in.", ); - assert.isTrue(role?.options[0].required); + expect(role?.options[0].required).toBeTruthy(); assert.strictEqual(role?.options[1].name, "header"); assert.strictEqual( role?.options[1].description, "Text to include at the top of the post.", ); - assert.isTrue(role?.options[1].required); + expect(role?.options[1].required).toBeTruthy(); assert.strictEqual( role?.options[1].type, ApplicationCommandOptionType.String, @@ -72,7 +72,7 @@ describe("management command", () => { role?.options[2].description, "Role to create a button for.", ); - assert.isTrue(role?.options[2].required); + expect(role?.options[2].required).toBeTruthy(); assert.strictEqual( role?.options[2].type, ApplicationCommandOptionType.Role, @@ -82,7 +82,7 @@ describe("management command", () => { role?.options[3].description, "Role to create a button for.", ); - assert.isFalse(role?.options[3].required); + expect(role?.options[3].required).toBeFalsy(); assert.strictEqual( role?.options[3].type, ApplicationCommandOptionType.Role, @@ -92,7 +92,7 @@ describe("management command", () => { role?.options[4].description, "Role to create a button for.", ); - assert.isFalse(role?.options[4].required); + expect(role?.options[4].required).toBeFalsy(); assert.strictEqual( role?.options[4].type, ApplicationCommandOptionType.Role, @@ -102,7 +102,7 @@ describe("management command", () => { role?.options[5].description, "Role to create a button for.", ); - assert.isFalse(role?.options[5].required); + expect(role?.options[5].required).toBeFalsy(); assert.strictEqual( role?.options[5].type, ApplicationCommandOptionType.Role, @@ -112,7 +112,7 @@ describe("management command", () => { role?.options[6].description, "Role to create a button for.", ); - assert.isFalse(role?.options[6].required); + expect(role?.options[6].required).toBeFalsy(); assert.strictEqual( role?.options[6].type, ApplicationCommandOptionType.Role, diff --git a/test/commands/moderation.spec.ts b/test/commands/moderation.spec.ts index 5c1cb50a..4bb65b42 100644 --- a/test/commands/moderation.spec.ts +++ b/test/commands/moderation.spec.ts @@ -2,7 +2,7 @@ import { ApplicationCommandOptionType, type SlashCommandSubcommandBuilder, } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { moderation } from "../../src/commands/moderation.js"; describe("moderation command", () => { @@ -15,7 +15,7 @@ describe("moderation command", () => { it("has correct data", () => { assert.strictEqual(moderation.data.name, "moderation"); assert.strictEqual(moderation.data.description, "Moderation commands."); - assert.lengthOf(subcommands, 8); + expect(subcommands).toHaveLength(8); }); it("has correct ban", () => { @@ -24,10 +24,10 @@ describe("moderation command", () => { }); assert.exists(ban); assert.strictEqual(ban?.description, "Bans a user from the server."); - assert.lengthOf(ban?.options || "hello", 2); + expect(ban?.options || "hello").toHaveLength(2); assert.strictEqual(ban?.options?.[0].name, "target"); assert.strictEqual(ban?.options?.[0].description, "The user to ban."); - assert.isTrue(ban?.options?.[0].required); + expect(ban?.options?.[0].required).toBeTruthy(); assert.strictEqual( ban?.options?.[0].type, ApplicationCommandOptionType.User, @@ -37,7 +37,7 @@ describe("moderation command", () => { ban?.options?.[1].description, "The reason for banning the user.", ); - assert.isTrue(ban?.options?.[1].required); + expect(ban?.options?.[1].required).toBeTruthy(); assert.strictEqual( ban?.options?.[1].type, ApplicationCommandOptionType.String, @@ -53,13 +53,13 @@ describe("moderation command", () => { history?.description, "Views the moderation history of a user.", ); - assert.lengthOf(history?.options || "hello", 1); + expect(history?.options || "hello").toHaveLength(1); assert.strictEqual(history?.options?.[0].name, "target"); assert.strictEqual( history?.options?.[0].description, "The user to view the moderation history of.", ); - assert.isTrue(history?.options?.[0].required); + expect(history?.options?.[0].required).toBeTruthy(); assert.strictEqual( history?.options?.[0].type, ApplicationCommandOptionType.User, @@ -72,10 +72,10 @@ describe("moderation command", () => { }); assert.exists(kick); assert.strictEqual(kick?.description, "Kicks a user from the server."); - assert.lengthOf(kick?.options || "hello", 2); + expect(kick?.options || "hello").toHaveLength(2); assert.strictEqual(kick?.options?.[0].name, "target"); assert.strictEqual(kick?.options?.[0].description, "The user to kick."); - assert.isTrue(kick?.options?.[0].required); + expect(kick?.options?.[0].required).toBeTruthy(); assert.strictEqual( kick?.options?.[0].type, ApplicationCommandOptionType.User, @@ -85,7 +85,7 @@ describe("moderation command", () => { kick?.options?.[1].description, "The reason for kicking the user.", ); - assert.isTrue(kick?.options?.[1].required); + expect(kick?.options?.[1].required).toBeTruthy(); assert.strictEqual( kick?.options?.[1].type, ApplicationCommandOptionType.String, @@ -98,10 +98,10 @@ describe("moderation command", () => { }); assert.exists(mute); assert.strictEqual(mute?.description, "Mutes a user."); - assert.lengthOf(mute?.options || "hello", 4); + expect(mute?.options || "hello").toHaveLength(4); assert.strictEqual(mute?.options?.[0].name, "target"); assert.strictEqual(mute?.options?.[0].description, "The user to mute."); - assert.isTrue(mute?.options?.[0].required); + expect(mute?.options?.[0].required).toBeTruthy(); assert.strictEqual( mute?.options?.[0].type, ApplicationCommandOptionType.User, @@ -111,7 +111,7 @@ describe("moderation command", () => { mute?.options?.[1].description, "The length of time to mute the user.", ); - assert.isTrue(mute?.options?.[1].required); + expect(mute?.options?.[1].required).toBeTruthy(); assert.strictEqual( mute?.options?.[1].type, ApplicationCommandOptionType.Integer, @@ -121,7 +121,7 @@ describe("moderation command", () => { mute?.options?.[2].description, "The unit of time for the duration.", ); - assert.isTrue(mute?.options?.[2].required); + expect(mute?.options?.[2].required).toBeTruthy(); assert.strictEqual( mute?.options?.[2].type, ApplicationCommandOptionType.String, @@ -131,7 +131,7 @@ describe("moderation command", () => { mute?.options?.[3].description, "The reason for muting the user.", ); - assert.isTrue(mute?.options?.[3].required); + expect(mute?.options?.[3].required).toBeTruthy(); assert.strictEqual( mute?.options?.[3].type, ApplicationCommandOptionType.String, @@ -147,13 +147,13 @@ describe("moderation command", () => { prune?.description, "Prunes messages from THIS channel.", ); - assert.lengthOf(prune?.options || "hello", 1); + expect(prune?.options || "hello").toHaveLength(1); assert.strictEqual(prune?.options?.[0].name, "count"); assert.strictEqual( prune?.options?.[0].description, "Number of messages to delete. Maximum of 100.", ); - assert.isTrue(prune?.options?.[0].required); + expect(prune?.options?.[0].required).toBeTruthy(); assert.strictEqual( prune?.options?.[0].type, ApplicationCommandOptionType.Integer, @@ -166,10 +166,10 @@ describe("moderation command", () => { }); assert.exists(unban); assert.strictEqual(unban?.description, "Removes a user's ban."); - assert.lengthOf(unban?.options || "hello", 2); + expect(unban?.options || "hello").toHaveLength(2); assert.strictEqual(unban?.options?.[0].name, "target"); assert.strictEqual(unban?.options?.[0].description, "The user to unban."); - assert.isTrue(unban?.options?.[0].required); + expect(unban?.options?.[0].required).toBeTruthy(); assert.strictEqual( unban?.options?.[0].type, ApplicationCommandOptionType.User, @@ -179,7 +179,7 @@ describe("moderation command", () => { unban?.options?.[1].description, "The reason for unbanning the user.", ); - assert.isTrue(unban?.options?.[1].required); + expect(unban?.options?.[1].required).toBeTruthy(); assert.strictEqual( unban?.options?.[1].type, ApplicationCommandOptionType.String, @@ -192,10 +192,10 @@ describe("moderation command", () => { }); assert.exists(unmute); assert.strictEqual(unmute?.description, "Unmutes a user."); - assert.lengthOf(unmute?.options || "hello", 2); + expect(unmute?.options || "hello").toHaveLength(2); assert.strictEqual(unmute?.options?.[0].name, "target"); assert.strictEqual(unmute?.options?.[0].description, "The user to unmute."); - assert.isTrue(unmute?.options?.[0].required); + expect(unmute?.options?.[0].required).toBeTruthy(); assert.strictEqual( unmute?.options?.[0].type, ApplicationCommandOptionType.User, @@ -205,7 +205,7 @@ describe("moderation command", () => { unmute?.options?.[1].description, "The reason for unmuting the user.", ); - assert.isTrue(unmute?.options?.[1].required); + expect(unmute?.options?.[1].required).toBeTruthy(); assert.strictEqual( unmute?.options?.[1].type, ApplicationCommandOptionType.String, @@ -218,10 +218,10 @@ describe("moderation command", () => { }); assert.exists(warn); assert.strictEqual(warn?.description, "Issues a warning to a user."); - assert.lengthOf(warn?.options || "hello", 2); + expect(warn?.options || "hello").toHaveLength(2); assert.strictEqual(warn?.options?.[0].name, "target"); assert.strictEqual(warn?.options?.[0].description, "The user to warn."); - assert.isTrue(warn?.options?.[0].required); + expect(warn?.options?.[0].required).toBeTruthy(); assert.strictEqual( warn?.options?.[0].type, ApplicationCommandOptionType.User, @@ -231,7 +231,7 @@ describe("moderation command", () => { warn?.options?.[1].description, "The reason for issuing this warning.", ); - assert.isTrue(warn?.options?.[1].required); + expect(warn?.options?.[1].required).toBeTruthy(); assert.strictEqual( warn?.options?.[1].type, ApplicationCommandOptionType.String, diff --git a/test/commands/report.spec.ts b/test/commands/report.spec.ts index 9bb73af9..a9763dff 100644 --- a/test/commands/report.spec.ts +++ b/test/commands/report.spec.ts @@ -1,8 +1,8 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { report } from "../../src/commands/report.js"; describe("report command", () => { it("is defined", () => { - assert.isDefined(report); + expect(report).toBeDefined(); }); }); diff --git a/test/commands/subcommands/community/handleCodeOfConduct.spec.ts b/test/commands/subcommands/community/handleCodeOfConduct.spec.ts index df6348d0..820677a5 100644 --- a/test/commands/subcommands/community/handleCodeOfConduct.spec.ts +++ b/test/commands/subcommands/community/handleCodeOfConduct.spec.ts @@ -7,7 +7,7 @@ import { MockMember, MockUser, } from "discordjs-testing"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleCodeOfConduct } from "../../../../src/commands/subcommands/community/handleCodeOfConduct.js"; const guild = new MockGuild({ diff --git a/test/commands/subcommands/community/handleContribute.spec.ts b/test/commands/subcommands/community/handleContribute.spec.ts index f98fb825..334aec46 100644 --- a/test/commands/subcommands/community/handleContribute.spec.ts +++ b/test/commands/subcommands/community/handleContribute.spec.ts @@ -6,7 +6,7 @@ import { MockMember, MockUser, } from "discordjs-testing"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleContribute } from "../../../../src/commands/subcommands/community/handleContribute.js"; diff --git a/test/commands/subcommands/community/handleForum.spec.ts b/test/commands/subcommands/community/handleForum.spec.ts index f347d683..9ac63504 100644 --- a/test/commands/subcommands/community/handleForum.spec.ts +++ b/test/commands/subcommands/community/handleForum.spec.ts @@ -1,9 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleForum } from "../../../../src/commands/subcommands/community/handleForum.js"; describe("forum handler", () => { it("is defined", () => { - assert.isDefined(handleForum); + expect(handleForum).toBeDefined(); }); }); diff --git a/test/commands/subcommands/community/handleLeaderboard.spec.ts b/test/commands/subcommands/community/handleLeaderboard.spec.ts index 3076cc6c..da137892 100644 --- a/test/commands/subcommands/community/handleLeaderboard.spec.ts +++ b/test/commands/subcommands/community/handleLeaderboard.spec.ts @@ -1,9 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleLeaderboard } from "../../../../src/commands/subcommands/community/handleLeaderboard.js"; describe("leaderboard handler", () => { it("is defined", () => { - assert.isDefined(handleLeaderboard); + expect(handleLeaderboard).toBeDefined(); }); }); diff --git a/test/commands/subcommands/community/handleProfile.spec.ts b/test/commands/subcommands/community/handleProfile.spec.ts index c5933025..13add842 100644 --- a/test/commands/subcommands/community/handleProfile.spec.ts +++ b/test/commands/subcommands/community/handleProfile.spec.ts @@ -1,9 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleProfile } from "../../../../src/commands/subcommands/community/handleProfile.js"; describe("profile handler", () => { it("profile command is defined", () => { - assert.isDefined(handleProfile); + expect(handleProfile).toBeDefined(); }); }); diff --git a/test/commands/subcommands/community/handleQuote.spec.ts b/test/commands/subcommands/community/handleQuote.spec.ts index 263d9737..487b3981 100644 --- a/test/commands/subcommands/community/handleQuote.spec.ts +++ b/test/commands/subcommands/community/handleQuote.spec.ts @@ -1,9 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleQuote } from "../../../../src/commands/subcommands/community/handleQuote.js"; describe("quote handler", () => { it("is defined", () => { - assert.isDefined(handleQuote); + expect(handleQuote).toBeDefined(); }); }); diff --git a/test/commands/subcommands/community/handleTruism.spec.ts b/test/commands/subcommands/community/handleTruism.spec.ts index 834ca8d3..4af39b51 100644 --- a/test/commands/subcommands/community/handleTruism.spec.ts +++ b/test/commands/subcommands/community/handleTruism.spec.ts @@ -1,9 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleTruism } from "../../../../src/commands/subcommands/community/handleTruism.js"; describe("truism handler", () => { it("truism command is defined", () => { - assert.isDefined(handleTruism); + expect(handleTruism).toBeDefined(); }); }); diff --git a/test/commands/subcommands/github/handleAddLabels.spec.ts b/test/commands/subcommands/github/handleAddLabels.spec.ts index 884129e5..49b06553 100644 --- a/test/commands/subcommands/github/handleAddLabels.spec.ts +++ b/test/commands/subcommands/github/handleAddLabels.spec.ts @@ -1,5 +1,5 @@ import { PermissionFlagsBits } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleAddLabels } from "../../../../src/commands/subcommands/github/handleAddLabels.js"; diff --git a/test/commands/subcommands/github/handleClose.spec.ts b/test/commands/subcommands/github/handleClose.spec.ts index 9c77c822..7cb7b086 100644 --- a/test/commands/subcommands/github/handleClose.spec.ts +++ b/test/commands/subcommands/github/handleClose.spec.ts @@ -1,5 +1,5 @@ import { PermissionFlagsBits } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleClose } from "../../../../src/commands/subcommands/github/handleClose.js"; diff --git a/test/commands/subcommands/github/handleComment.spec.ts b/test/commands/subcommands/github/handleComment.spec.ts index 91326053..a8751c67 100644 --- a/test/commands/subcommands/github/handleComment.spec.ts +++ b/test/commands/subcommands/github/handleComment.spec.ts @@ -1,5 +1,5 @@ import { PermissionFlagsBits } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleComment } from "../../../../src/commands/subcommands/github/handleComment.js"; diff --git a/test/commands/subcommands/github/handleSyncLabels.spec.ts b/test/commands/subcommands/github/handleSyncLabels.spec.ts index 9c778589..86b63df7 100644 --- a/test/commands/subcommands/github/handleSyncLabels.spec.ts +++ b/test/commands/subcommands/github/handleSyncLabels.spec.ts @@ -1,5 +1,5 @@ import { PermissionFlagsBits } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleSyncLabels } from "../../../../src/commands/subcommands/github/handleSyncLabels.js"; diff --git a/test/commands/subcommands/management/handlePrivate.spec.ts b/test/commands/subcommands/management/handlePrivate.spec.ts index 16d528fc..0e11e685 100644 --- a/test/commands/subcommands/management/handlePrivate.spec.ts +++ b/test/commands/subcommands/management/handlePrivate.spec.ts @@ -1,5 +1,5 @@ import { PermissionFlagsBits } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handlePrivate } from "../../../../src/commands/subcommands/management/handlePrivate.js"; diff --git a/test/commands/subcommands/management/handleRole.spec.ts b/test/commands/subcommands/management/handleRole.spec.ts index 65072157..bb01e407 100644 --- a/test/commands/subcommands/management/handleRole.spec.ts +++ b/test/commands/subcommands/management/handleRole.spec.ts @@ -1,5 +1,5 @@ import { PermissionFlagsBits } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleRole } from "../../../../src/commands/subcommands/management/handleRole.js"; diff --git a/test/commands/subcommands/moderation/handleBan.spec.ts b/test/commands/subcommands/moderation/handleBan.spec.ts index cbf1a2fe..e9f69c24 100644 --- a/test/commands/subcommands/moderation/handleBan.spec.ts +++ b/test/commands/subcommands/moderation/handleBan.spec.ts @@ -1,5 +1,5 @@ import { PermissionFlagsBits } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleBan } from "../../../../src/commands/subcommands/moderation/handleBan.js"; diff --git a/test/commands/subcommands/moderation/handleHistory.spec.ts b/test/commands/subcommands/moderation/handleHistory.spec.ts index 4bf0d455..e7055cb2 100644 --- a/test/commands/subcommands/moderation/handleHistory.spec.ts +++ b/test/commands/subcommands/moderation/handleHistory.spec.ts @@ -1,5 +1,5 @@ import { PermissionFlagsBits } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleHistory } from "../../../../src/commands/subcommands/moderation/handleHistory.js"; diff --git a/test/commands/subcommands/moderation/handleKick.spec.ts b/test/commands/subcommands/moderation/handleKick.spec.ts index b75ce6f5..5e9a1ba4 100644 --- a/test/commands/subcommands/moderation/handleKick.spec.ts +++ b/test/commands/subcommands/moderation/handleKick.spec.ts @@ -1,5 +1,5 @@ import { PermissionFlagsBits } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleKick } from "../../../../src/commands/subcommands/moderation/handleKick.js"; diff --git a/test/commands/subcommands/moderation/handleMute.spec.ts b/test/commands/subcommands/moderation/handleMute.spec.ts index d2abe8df..d88c02e0 100644 --- a/test/commands/subcommands/moderation/handleMute.spec.ts +++ b/test/commands/subcommands/moderation/handleMute.spec.ts @@ -1,5 +1,5 @@ import { PermissionFlagsBits } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleMute } from "../../../../src/commands/subcommands/moderation/handleMute.js"; diff --git a/test/commands/subcommands/moderation/handlePrune.spec.ts b/test/commands/subcommands/moderation/handlePrune.spec.ts index 9a8ba46f..21c9fe8a 100644 --- a/test/commands/subcommands/moderation/handlePrune.spec.ts +++ b/test/commands/subcommands/moderation/handlePrune.spec.ts @@ -1,5 +1,5 @@ import { PermissionFlagsBits } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handlePrune } from "../../../../src/commands/subcommands/moderation/handlePrune.js"; diff --git a/test/commands/subcommands/moderation/handleUnban.spec.ts b/test/commands/subcommands/moderation/handleUnban.spec.ts index 832c5348..e32f9102 100644 --- a/test/commands/subcommands/moderation/handleUnban.spec.ts +++ b/test/commands/subcommands/moderation/handleUnban.spec.ts @@ -1,5 +1,5 @@ import { PermissionFlagsBits } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleUnban } from "../../../../src/commands/subcommands/moderation/handleUnban.js"; diff --git a/test/commands/subcommands/moderation/handleUnmute.spec.ts b/test/commands/subcommands/moderation/handleUnmute.spec.ts index 220134df..8941642d 100644 --- a/test/commands/subcommands/moderation/handleUnmute.spec.ts +++ b/test/commands/subcommands/moderation/handleUnmute.spec.ts @@ -1,5 +1,5 @@ import { PermissionFlagsBits } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleUnmute } from "../../../../src/commands/subcommands/moderation/handleUnmute.js"; diff --git a/test/commands/subcommands/moderation/handleWarn.spec.ts b/test/commands/subcommands/moderation/handleWarn.spec.ts index bdb72a20..b4fbe448 100644 --- a/test/commands/subcommands/moderation/handleWarn.spec.ts +++ b/test/commands/subcommands/moderation/handleWarn.spec.ts @@ -1,5 +1,5 @@ import { PermissionFlagsBits } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleWarn } from "../../../../src/commands/subcommands/moderation/handleWarn.js"; diff --git a/test/commands/supporter.spec.ts b/test/commands/supporter.spec.ts index 15f13e76..83989309 100644 --- a/test/commands/supporter.spec.ts +++ b/test/commands/supporter.spec.ts @@ -1,8 +1,8 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { supporter } from "../../src/commands/supporter.js"; describe("supporter command", () => { it("is defined", () => { - assert.isDefined(supporter); + expect(supporter).toBeDefined(); }); }); diff --git a/test/commands/translator.spec.ts b/test/commands/translator.spec.ts index fbfe84d2..1d49b9a9 100644 --- a/test/commands/translator.spec.ts +++ b/test/commands/translator.spec.ts @@ -1,8 +1,8 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { translator } from "../../src/commands/translator.js"; describe("translator command", () => { it("is defined", () => { - assert.isDefined(translator); + expect(translator).toBeDefined(); }); }); diff --git a/test/commands/userSettings.spec.ts b/test/commands/userSettings.spec.ts index a6856624..a5b577d6 100644 --- a/test/commands/userSettings.spec.ts +++ b/test/commands/userSettings.spec.ts @@ -1,4 +1,4 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { userSettings } from "../../src/commands/userSettings.js"; describe("user settings command", () => { diff --git a/test/config/badges.spec.ts b/test/config/badges.spec.ts index e47a66af..5988221b 100644 --- a/test/config/badges.spec.ts +++ b/test/config/badges.spec.ts @@ -1,4 +1,4 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { badges } from "../../src/config/badges.js"; diff --git a/test/config/intentOptions.spec.ts b/test/config/intentOptions.spec.ts index 8100cbcc..fa90b991 100644 --- a/test/config/intentOptions.spec.ts +++ b/test/config/intentOptions.spec.ts @@ -1,5 +1,5 @@ import { GatewayIntentBits } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { intentOptions } from "../../src/config/intentOptions.js"; describe("intentOptions", () => { diff --git a/test/config/languages.spec.ts b/test/config/languages.spec.ts index 96d5e6cb..93f10787 100644 --- a/test/config/languages.spec.ts +++ b/test/config/languages.spec.ts @@ -1,4 +1,4 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { languages } from "../../src/config/languages.js"; describe("languages Config", () => { diff --git a/test/config/levelScale.spec.ts b/test/config/levelScale.spec.ts index c1ca4886..789f55b2 100644 --- a/test/config/levelScale.spec.ts +++ b/test/config/levelScale.spec.ts @@ -1,4 +1,4 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { levelScale } from "../../src/config/levelScale.js"; describe("levelScale", () => { diff --git a/test/config/pullComments.spec.ts b/test/config/pullComments.spec.ts index fcf44e0d..dec1dd13 100644 --- a/test/config/pullComments.spec.ts +++ b/test/config/pullComments.spec.ts @@ -1,4 +1,4 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { pullComments } from "../../src/config/pullComments.js"; describe("pullComments", () => { diff --git a/test/config/roles.spec.ts b/test/config/roles.spec.ts index 7b1adbef..6d564d5b 100644 --- a/test/config/roles.spec.ts +++ b/test/config/roles.spec.ts @@ -1,4 +1,4 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { authorRoleId, supporterRoleId } from "../../src/config/roles.js"; describe("roles config", () => { diff --git a/test/config/tags.spec.ts b/test/config/tags.spec.ts index b12ad47d..025bae6c 100644 --- a/test/config/tags.spec.ts +++ b/test/config/tags.spec.ts @@ -1,4 +1,4 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { tags } from "../../src/config/tags.js"; describe("tags", () => { diff --git a/test/config/truisms.spec.ts b/test/config/truisms.spec.ts index 3d101936..eeefa941 100644 --- a/test/config/truisms.spec.ts +++ b/test/config/truisms.spec.ts @@ -1,4 +1,4 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { truisms } from "../../src/config/truisms.js"; describe("truisms", () => { diff --git a/test/contexts/bookmark.spec.ts b/test/contexts/bookmark.spec.ts index f8706477..309cc073 100644 --- a/test/contexts/bookmark.spec.ts +++ b/test/contexts/bookmark.spec.ts @@ -1,13 +1,13 @@ import { ApplicationCommandType } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { bookmark } from "../../src/contexts/bookmark.js"; describe("bookmark context", () => { it("bookmark context should be a context object.", () => { - assert.isDefined(bookmark.data); - assert.isObject(bookmark.data); - assert.isDefined(bookmark.run); - assert.isFunction(bookmark.run); + expect(bookmark.data).toBeDefined(); + expect(bookmark.data).toBeTypeOf("object"); + expect(bookmark.run).toBeDefined(); + expect(bookmark.run).toBeTypeOf("function"); }); it("bookmark context should be formatted correctly.", () => { assert.equal(bookmark.data.name, "bookmark"); diff --git a/test/contexts/format.spec.ts b/test/contexts/format.spec.ts index 524b6654..fdc457a5 100644 --- a/test/contexts/format.spec.ts +++ b/test/contexts/format.spec.ts @@ -1,13 +1,13 @@ import { ApplicationCommandType } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { format } from "../../src/contexts/format.js"; describe("format context", () => { it("format context should be a context object.", () => { - assert.isDefined(format.data); - assert.isObject(format.data); - assert.isDefined(format.run); - assert.isFunction(format.run); + expect(format.data).toBeDefined(); + expect(format.data).toBeTypeOf("object"); + expect(format.run).toBeDefined(); + expect(format.run).toBeTypeOf("function"); }); it("format context should be formatted correctly.", () => { assert.equal(format.data.name, "format"); diff --git a/test/contexts/report.spec.ts b/test/contexts/report.spec.ts index c9503c35..90371513 100644 --- a/test/contexts/report.spec.ts +++ b/test/contexts/report.spec.ts @@ -1,13 +1,13 @@ import { ApplicationCommandType } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { report } from "../../src/contexts/report.js"; describe("report context", () => { it("report context should be a context object.", () => { - assert.isDefined(report.data); - assert.isObject(report.data); - assert.isDefined(report.run); - assert.isFunction(report.run); + expect(report.data).toBeDefined(); + expect(report.data).toBeTypeOf("object"); + expect(report.run).toBeDefined(); + expect(report.run).toBeTypeOf("function"); }); it("report context should be formatted correctly.", () => { assert.equal(report.data.name, "report"); diff --git a/test/contexts/snippet.spec.ts b/test/contexts/snippet.spec.ts index cfc98147..cc3731dc 100644 --- a/test/contexts/snippet.spec.ts +++ b/test/contexts/snippet.spec.ts @@ -1,8 +1,8 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { snippet } from "../../src/contexts/snippet.js"; describe("snippet context", () => { it("is defined", () => { - assert.isDefined(snippet); + expect(snippet).toBeDefined(); }); }); diff --git a/test/contexts/translate.spec.ts b/test/contexts/translate.spec.ts index 49eefdba..91078ce1 100644 --- a/test/contexts/translate.spec.ts +++ b/test/contexts/translate.spec.ts @@ -1,13 +1,13 @@ import { ApplicationCommandType } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { translate } from "../../src/contexts/translate.js"; describe("translate context", () => { it("translate context should be a context object.", () => { - assert.isDefined(translate.data); - assert.isObject(translate.data); - assert.isDefined(translate.run); - assert.isFunction(translate.run); + expect(translate.data).toBeDefined(); + expect(translate.data).toBeTypeOf("object"); + expect(translate.run).toBeDefined(); + expect(translate.run).toBeTypeOf("function"); }); it("translate context should be formatted correctly.", () => { assert.equal(translate.data.name, "translate"); diff --git a/test/database/connectDatabase.spec.ts b/test/database/connectDatabase.spec.ts index 5d5a72c2..54dd5257 100644 --- a/test/database/connectDatabase.spec.ts +++ b/test/database/connectDatabase.spec.ts @@ -1,9 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, it, expect } from "vitest"; import { connectDatabase } from "../../src/database/connectDatabase.js"; describe("connectDatabase", () => { it("should be defined", () => { - assert.isDefined(connectDatabase, "connectDatabase is not defined"); - assert.isFunction(connectDatabase, "connectDatabase is not a function"); + expect(connectDatabase, "connectDatabase is not defined").toBeDefined(); + expect(connectDatabase, "connectDatabase is not a function").toBeTypeOf("function"); }); }); diff --git a/test/events/handlers/handleGuildScheduledEvents.spec.ts b/test/events/handlers/handleGuildScheduledEvents.spec.ts index 2ce0c712..315778e1 100644 --- a/test/events/handlers/handleGuildScheduledEvents.spec.ts +++ b/test/events/handlers/handleGuildScheduledEvents.spec.ts @@ -1,9 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleGuildScheduledEvents } from "../../../src/events/handlers/handleGuildScheduledEvents.js"; describe("handleGuildScheduledEvents", () => { it("handleGuildScheduledEvents is a function", () => { - assert.isFunction(handleGuildScheduledEvents); + expect(handleGuildScheduledEvents).toBeTypeOf("function"); }); }); diff --git a/test/events/handlers/handleInteractionCreate.spec.ts b/test/events/handlers/handleInteractionCreate.spec.ts index a55c957d..c602bccf 100644 --- a/test/events/handlers/handleInteractionCreate.spec.ts +++ b/test/events/handlers/handleInteractionCreate.spec.ts @@ -1,9 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleInteractionCreate } from "../../../src/events/handlers/handleInteractionCreate.js"; describe("handleInteractionCreate", () => { it("handleInteractionCreate is a function", () => { - assert.isFunction(handleInteractionCreate); + expect(handleInteractionCreate).toBeTypeOf("function"); }); }); diff --git a/test/events/handlers/handleMemberAdd.spec.ts b/test/events/handlers/handleMemberAdd.spec.ts index d6c9a743..6fdcce9f 100644 --- a/test/events/handlers/handleMemberAdd.spec.ts +++ b/test/events/handlers/handleMemberAdd.spec.ts @@ -1,9 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleMemberAdd } from "../../../src/events/handlers/handleMemberAdd.js"; describe("handleMemberAdd", () => { it("handleMemberAdd is a function", () => { - assert.isFunction(handleMemberAdd); + expect(handleMemberAdd).toBeTypeOf("function"); }); }); diff --git a/test/events/handlers/handleMemberRemove.spec.ts b/test/events/handlers/handleMemberRemove.spec.ts index 40cf440b..fbffe392 100644 --- a/test/events/handlers/handleMemberRemove.spec.ts +++ b/test/events/handlers/handleMemberRemove.spec.ts @@ -1,9 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleMemberRemove } from "../../../src/events/handlers/handleMemberRemove.js"; describe("handleMemberRemove", () => { it("handleMemberRemove is a function", () => { - assert.isFunction(handleMemberRemove); + expect(handleMemberRemove).toBeTypeOf("function"); }); }); diff --git a/test/events/handlers/handleMessageCreate.spec.ts b/test/events/handlers/handleMessageCreate.spec.ts index 54a3361b..58e3b7b7 100644 --- a/test/events/handlers/handleMessageCreate.spec.ts +++ b/test/events/handlers/handleMessageCreate.spec.ts @@ -1,9 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleMessageCreate } from "../../../src/events/handlers/handleMessageCreate.js"; describe("handleMessageCreate", () => { it("handleMessageCreate is a function", () => { - assert.isFunction(handleMessageCreate); + expect(handleMessageCreate).toBeTypeOf("function"); }); }); diff --git a/test/events/handlers/handleMessageDelete.spec.ts b/test/events/handlers/handleMessageDelete.spec.ts index 12608ded..1592db26 100644 --- a/test/events/handlers/handleMessageDelete.spec.ts +++ b/test/events/handlers/handleMessageDelete.spec.ts @@ -1,9 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleMessageDelete } from "../../../src/events/handlers/handleMessageDelete.js"; describe("handleMessageDelete", () => { it("handleMessageDelete is a function", () => { - assert.isFunction(handleMessageDelete); + expect(handleMessageDelete).toBeTypeOf("function"); }); }); diff --git a/test/events/handlers/handleMessageEdit.spec.ts b/test/events/handlers/handleMessageEdit.spec.ts index a41eceb7..912ab879 100644 --- a/test/events/handlers/handleMessageEdit.spec.ts +++ b/test/events/handlers/handleMessageEdit.spec.ts @@ -1,9 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleMessageEdit } from "../../../src/events/handlers/handleMessageEdit.js"; describe("handleMessageEdit", () => { it("handleMessageEdit is a function", () => { - assert.isFunction(handleMessageEdit); + expect(handleMessageEdit).toBeTypeOf("function"); }); }); diff --git a/test/events/handlers/handleReady.spec.ts b/test/events/handlers/handleReady.spec.ts index 20b69ee1..984806c4 100644 --- a/test/events/handlers/handleReady.spec.ts +++ b/test/events/handlers/handleReady.spec.ts @@ -1,10 +1,10 @@ -import { describe, assert, it, vi } from "vitest"; +import { describe, expect, it, vi } from "vitest"; import { handleReady } from "../../../src/events/handlers/handleReady.js"; vi.mock("discord.js"); describe("handleReady", () => { it("handleReady is a function", () => { - assert.isFunction(handleReady); + expect(handleReady).toBeTypeOf("function"); }); }); diff --git a/test/events/handlers/handleThreadCreate.spec.ts b/test/events/handlers/handleThreadCreate.spec.ts index deefdba1..b78f84ac 100644 --- a/test/events/handlers/handleThreadCreate.spec.ts +++ b/test/events/handlers/handleThreadCreate.spec.ts @@ -1,9 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleThreadCreate } from "../../../src/events/handlers/handleThreadCreate.js"; describe("handleThreadCreate", () => { it("handleThreadCreate is a function", () => { - assert.isFunction(handleThreadCreate); + expect(handleThreadCreate).toBeTypeOf("function"); }); }); diff --git a/test/events/handlers/handleVoiceStateUpdate.spec.ts b/test/events/handlers/handleVoiceStateUpdate.spec.ts index 29515897..942598f6 100644 --- a/test/events/handlers/handleVoiceStateUpdate.spec.ts +++ b/test/events/handlers/handleVoiceStateUpdate.spec.ts @@ -1,9 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { handleVoiceStateUpdate } from "../../../src/events/handlers/handleVoiceStateUpdate.js"; describe("handleVoiceStateUpdate", () => { it("handleVoiceStateUpdate is a function", () => { - assert.isFunction(handleVoiceStateUpdate); + expect(handleVoiceStateUpdate).toBeTypeOf("function"); }); }); diff --git a/test/events/registerEvents.spec.ts b/test/events/registerEvents.spec.ts index f704a883..d669fb11 100644 --- a/test/events/registerEvents.spec.ts +++ b/test/events/registerEvents.spec.ts @@ -1,4 +1,4 @@ -import { describe, assert, it, vi } from "vitest"; +import { describe, expect, it, vi, expect } from "vitest"; import { registerEvents } from "../../src/events/registerEvents.js"; vi.mock("discord.js"); @@ -12,7 +12,7 @@ const bot = { describe("registerEvents", () => { it("registerEvents is a function", () => { - assert.isFunction(registerEvents); + expect(registerEvents).toBeTypeOf("function"); }); it("should register all events", async() => { diff --git a/test/modules/addFormatting.spec.ts b/test/modules/addFormatting.spec.ts index 53f2cafe..e5b8a5bd 100644 --- a/test/modules/addFormatting.spec.ts +++ b/test/modules/addFormatting.spec.ts @@ -1,4 +1,4 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { addFormatting } from "../../src/modules/addFormatting.js"; import type { Message } from "discord.js"; @@ -8,8 +8,8 @@ const typeCoerce = (object: unknown): Message => { describe("addFormatting", () => { it("is defined", () => { - assert.isDefined(addFormatting, "addFormatting is not defined"); - assert.isFunction(addFormatting, "addFormatting is not a function"); + expect(addFormatting, "addFormatting is not defined").toBeDefined(); + expect(addFormatting, "addFormatting is not a function").toBeTypeOf("function"); }); it("should format HTML", async() => { @@ -58,7 +58,7 @@ describe("addFormatting", () => { }); /* - * TODO: Python is currently throwing a CSS sytnax error? + * TODO: Python is currently throwing a CSS syntax error? * it("should format Python", async () => { * const content = `for i in range(10):\n print(i)`; * const output = await addFormatting(typeCoerce({ content })); diff --git a/test/modules/closePrivateChannel.spec.ts b/test/modules/closePrivateChannel.spec.ts index 591c00de..11532806 100644 --- a/test/modules/closePrivateChannel.spec.ts +++ b/test/modules/closePrivateChannel.spec.ts @@ -1,12 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { closePrivateChannel } from "../../src/modules/closePrivateChannel.js"; describe("closePrivateChannel", () => { it("is defined", () => { - assert.isDefined(closePrivateChannel, "closePrivateChannel is not defined"); - assert.isFunction( - closePrivateChannel, - "closePrivateChannel is not a function", - ); + expect(closePrivateChannel,"closePrivateChannel is not defined").toBeDefined(); + expect(closePrivateChannel, "closePrivateChannel is not a function").toBeTypeOf("function"); }); }); diff --git a/test/modules/createLogFile.spec.ts b/test/modules/createLogFile.spec.ts index ee7690d8..90b0f51d 100644 --- a/test/modules/createLogFile.spec.ts +++ b/test/modules/createLogFile.spec.ts @@ -1,23 +1,23 @@ import { stat, unlink } from "node:fs/promises"; import { join } from "node:path"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { createLogFile } from "../../src/modules/createLogFile.js"; import type { ExtendedClient } from "../../src/interfaces/extendedClient.js"; describe("createLogFile", () => { it("is defined", () => { - assert.isDefined(createLogFile, "createLogFile is not defined"); - assert.isFunction(createLogFile, "createLogFile is not a function"); + expect(createLogFile, "createLogFile is not defined").toBeDefined(); + expect(createLogFile, "createLogFile is not a function").toBeTypeOf("function"); }); it("returns the expected data structure", async() => { const mockBot = { privateLogs: {} } as ExtendedClient; await createLogFile(mockBot, "Naomi"); - assert.property(mockBot.privateLogs, "Naomi", "Naomi is not defined"); + expect(mockBot.privateLogs, "Naomi is not defined").toHaveProperty("Naomi"); assert.equal(mockBot.privateLogs.Naomi, "Naomi", "Naomi is not Naomi"); const logPath = join(process.cwd(), "logs", "Naomi.txt"); const status = await stat(logPath); - assert.isTrue(status.isFile(), "Naomi.txt is not a file"); + expect(status.isFile(), "Naomi.txt is not a file").toBeTruthy(); await unlink(logPath); }); }); diff --git a/test/modules/formatCodeblock.spec.ts b/test/modules/formatCodeblock.spec.ts index edeae0b7..524f2b91 100644 --- a/test/modules/formatCodeblock.spec.ts +++ b/test/modules/formatCodeblock.spec.ts @@ -1,10 +1,10 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { formatCodeBlock } from "../../src/modules/formatCodeblock.js"; describe("formatCodeBlock", () => { it("is defined", () => { - assert.isDefined(formatCodeBlock, "formatCodeBlock is not defined"); - assert.isFunction(formatCodeBlock, "formatCodeBlock is not a function"); + expect(formatCodeBlock, "formatCodeBlock is not defined").toBeDefined(); + expect(formatCodeBlock, "formatCodeBlock is not a function").toBeTypeOf("function"); }); it("formats string as expected", () => { diff --git a/test/modules/formatter.spec.ts b/test/modules/formatter.spec.ts index e85a075e..d7d87942 100644 --- a/test/modules/formatter.spec.ts +++ b/test/modules/formatter.spec.ts @@ -1,10 +1,10 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { formatter } from "../../src/modules/formatter.js"; describe("formatter", () => { it("is defined", () => { - assert.isDefined(formatter, "formatter is not defined"); - assert.isFunction(formatter, "formatter is not a function"); + expect(formatter,"formatter is not defined").toBeDefined(); + expect(formatter, "formatter is not a function").toBeTypeOf("function"); }); it("should format HTML", async() => { diff --git a/test/modules/generateCertSvg.spec.ts b/test/modules/generateCertSvg.spec.ts index d2f2568a..3125d451 100644 --- a/test/modules/generateCertSvg.spec.ts +++ b/test/modules/generateCertSvg.spec.ts @@ -1,8 +1,8 @@ -import { describe, assert, it } from "vitest"; +import { describe, it, expect } from "vitest"; import { generatorMap } from "../../src/modules/generateCertSvg.js"; describe("generateCertSvg", () => { it("has generator map object", () => { - assert.isObject(generatorMap); + expect(generatorMap).toBeTypeOf("object"); }); }); diff --git a/test/modules/generateConfig.spec.ts b/test/modules/generateConfig.spec.ts index 7f609a03..95f37ccd 100644 --- a/test/modules/generateConfig.spec.ts +++ b/test/modules/generateConfig.spec.ts @@ -1,11 +1,11 @@ import { WebhookClient } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { generateConfig } from "../../src/modules/generateConfig.js"; describe("generateConfig", () => { it("is defined", () => { - assert.isDefined(generateConfig, "generateConfig is not defined"); - assert.isFunction(generateConfig, "generateConfig is not a function"); + expect(generateConfig, "generateConfig is not defined").toBeDefined(); + expect(generateConfig, "generateConfig is not a function").toBeTypeOf("function"); }); it("should throw an error on missing environment", () => { diff --git a/test/modules/generateLogs.spec.ts b/test/modules/generateLogs.spec.ts index 07b7316d..167d8453 100644 --- a/test/modules/generateLogs.spec.ts +++ b/test/modules/generateLogs.spec.ts @@ -1,6 +1,6 @@ import { stat } from "node:fs/promises"; import { join } from "node:path"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { createLogFile } from "../../src/modules/createLogFile.js"; import { generateLogs } from "../../src/modules/generateLogs.js"; import type { ExtendedClient } from "../../src/interfaces/extendedClient.js"; @@ -9,16 +9,16 @@ const mockBot = { privateLogs: {} } as ExtendedClient; describe("generateLogs", () => { it("is defined", () => { - assert.isDefined(generateLogs, "generateLogs is not defined"); - assert.isFunction(generateLogs, "generateLogs is not a function"); + expect(generateLogs, "generateLogs is not defined").toBeDefined(); + expect(generateLogs, "generateLogs is not a function").toBeTypeOf("function"); }); it("generates logs as expected", async() => { await createLogFile(mockBot, "Naomi"); - assert.property(mockBot.privateLogs, "Naomi", "Naomi is not defined"); + expect(mockBot.privateLogs, "Naomi is not defined").toHaveProperty("Naomi"); const attachment = await generateLogs(mockBot, "Naomi"); - assert.property(attachment, "name", "attachment is not defined"); - assert.property(attachment, "attachment", "attachment is not defined"); + expect(attachment, "attachment is not defined").toHaveProperty("name"); + expect(attachment, "attachment is not defined").toHaveProperty("attachment"); const logPath = join(process.cwd(), "logs", "Naomi.txt"); const status = await stat(logPath).catch(() => { return null; diff --git a/test/modules/generateProfileImage.spec.ts b/test/modules/generateProfileImage.spec.ts index 67c4f8fd..0881130c 100644 --- a/test/modules/generateProfileImage.spec.ts +++ b/test/modules/generateProfileImage.spec.ts @@ -1,4 +1,4 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { generateProfileImage } from "../../src/modules/generateProfileImage.js"; @@ -8,9 +8,6 @@ describe("generateProfileImage", () => { generateProfileImage, "generateProfileImage is not defined", ); - assert.isFunction( - generateProfileImage, - "generateProfileImage is not a function", - ); + expect(generateProfileImage, "generateProfileImage is not a function").toBeTypeOf("function"); }); }); diff --git a/test/modules/isSupportedByPrettier.spec.ts b/test/modules/isSupportedByPrettier.spec.ts index fac86b95..37bb2012 100644 --- a/test/modules/isSupportedByPrettier.spec.ts +++ b/test/modules/isSupportedByPrettier.spec.ts @@ -1,4 +1,4 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { isSupportedByPrettier } from "../../src/modules/isSupportedByPrettier.js"; @@ -8,14 +8,11 @@ describe("isSupportedByPrettier", () => { isSupportedByPrettier, "isSupportedByPrettier is not defined", ); - assert.isFunction( - isSupportedByPrettier, - "isSupportedByPrettier is not a function", - ); + expect(isSupportedByPrettier, "isSupportedByPrettier is not a function").toBeTypeOf("function"); }); it("returns false on empty language name", () => { - assert.isFalse(isSupportedByPrettier("")); + expect(isSupportedByPrettier("")).toBeFalsy(); }); it("returns expected language names for supported langs", () => { @@ -30,8 +27,8 @@ describe("isSupportedByPrettier", () => { }); it("returns false for unsupported languages", () => { - assert.isFalse(isSupportedByPrettier("Python")); - assert.isFalse(isSupportedByPrettier("Ruby")); - assert.isFalse(isSupportedByPrettier("C++")); + expect(isSupportedByPrettier("Python")).toBeFalsy(); + expect(isSupportedByPrettier("Ruby")).toBeFalsy(); + expect(isSupportedByPrettier("C++")).toBeFalsy(); }); }); diff --git a/test/modules/levelListener.spec.ts b/test/modules/levelListener.spec.ts index fdbcea05..b0cc9b67 100644 --- a/test/modules/levelListener.spec.ts +++ b/test/modules/levelListener.spec.ts @@ -1,8 +1,8 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { levelListener } from "../../src/modules/levelListener.js"; describe("levelListener", () => { it("levelListener is a function", () => { - assert.isFunction(levelListener); + expect(levelListener).toBeTypeOf("function"); }); }); diff --git a/test/modules/loadRoles.spec.ts b/test/modules/loadRoles.spec.ts index 8cf82bd9..d4b84441 100644 --- a/test/modules/loadRoles.spec.ts +++ b/test/modules/loadRoles.spec.ts @@ -1,8 +1,8 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { loadRoles } from "../../src/modules/loadRoles.js"; describe("load roles module", () => { it("is defined", () => { - assert.isDefined(loadRoles); + expect(loadRoles).toBeDefined(); }); }); diff --git a/test/modules/messageCounter.spec.ts b/test/modules/messageCounter.spec.ts index 42b9574c..83a8c1f5 100644 --- a/test/modules/messageCounter.spec.ts +++ b/test/modules/messageCounter.spec.ts @@ -1,8 +1,8 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { messageCounter } from "../../src/modules/messageCounter.js"; describe("message counter module", () => { it("is defined", () => { - assert.isDefined(messageCounter); + expect(messageCounter).toBeDefined(); }); }); diff --git a/test/modules/reactionRoleClick.spec.ts b/test/modules/reactionRoleClick.spec.ts index 25a4f15d..04d689b4 100644 --- a/test/modules/reactionRoleClick.spec.ts +++ b/test/modules/reactionRoleClick.spec.ts @@ -1,8 +1,8 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { reactionRoleClick } from "../../src/modules/reactionRoleClick.js"; describe("reactionRoleClick", () => { it("reactionRoleClick is a function", () => { - assert.isFunction(reactionRoleClick); + expect(reactionRoleClick).toBeTypeOf("function"); }); }); diff --git a/test/modules/send100DaysOfCode.spec.ts b/test/modules/send100DaysOfCode.spec.ts index 5a3e8261..5fb53202 100644 --- a/test/modules/send100DaysOfCode.spec.ts +++ b/test/modules/send100DaysOfCode.spec.ts @@ -1,8 +1,8 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { send100DaysOfCode } from "../../src/modules/send100DaysOfCode.js"; describe("send100DaysOfCode", () => { it("send100DaysOfCode is a function", () => { - assert.isFunction(send100DaysOfCode); + expect(send100DaysOfCode).toBeTypeOf("function"); }); }); diff --git a/test/modules/sendModerationDm.spec.ts b/test/modules/sendModerationDm.spec.ts index fc088b3a..6ee89447 100644 --- a/test/modules/sendModerationDm.spec.ts +++ b/test/modules/sendModerationDm.spec.ts @@ -1,8 +1,8 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { sendModerationDm } from "../../src/modules/sendModerationDm.js"; describe("sendModerationDm", () => { it("sendModerationDm is a function", () => { - assert.isFunction(sendModerationDm); + expect(sendModerationDm).toBeTypeOf("function"); }); }); diff --git a/test/modules/settingsValidation.spec.ts b/test/modules/settingsValidation.spec.ts index 4a40ab94..5ec273cd 100644 --- a/test/modules/settingsValidation.spec.ts +++ b/test/modules/settingsValidation.spec.ts @@ -1,4 +1,4 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { validateColour, validateImage, diff --git a/test/modules/updateHistory.spec.ts b/test/modules/updateHistory.spec.ts index d5a3d65e..94b91ab7 100644 --- a/test/modules/updateHistory.spec.ts +++ b/test/modules/updateHistory.spec.ts @@ -1,4 +1,4 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { updateHistory } from "../../src/modules/updateHistory.js"; import { Database } from "../__mocks__/Database.mock.js"; @@ -6,7 +6,7 @@ const database = new Database(); describe("updateHistory", () => { it("updateHistory is a function", () => { - assert.isFunction(updateHistory); + expect(updateHistory).toBeTypeOf("function"); }); it("should create a new history when user does not exist", async() => { @@ -16,7 +16,7 @@ describe("updateHistory", () => { userId: "123", }, }); - assert.isObject(history); + expect(history).toBeTypeOf("object"); assert.equal(history?.bans, 1); assert.equal(history?.kicks, 0); assert.equal(history?.mutes, 0); @@ -33,7 +33,7 @@ describe("updateHistory", () => { userId: "123", }, }); - assert.isObject(history); + expect(history).toBeTypeOf("object"); assert.equal(history?.bans, 2); assert.equal(history?.kicks, 0); assert.equal(history?.mutes, 1); diff --git a/test/utils/calculateMilliseconds.spec.ts b/test/utils/calculateMilliseconds.spec.ts index dcf65574..e980ad6d 100644 --- a/test/utils/calculateMilliseconds.spec.ts +++ b/test/utils/calculateMilliseconds.spec.ts @@ -1,4 +1,4 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { calculateMilliseconds, isValidTimeUnit, @@ -33,10 +33,10 @@ describe("calculateMilliseconds", () => { describe("isValidTimeUnit", () => { it("should return true for valid time units", () => { - assert.isTrue(isValidTimeUnit("seconds")); + expect(isValidTimeUnit("seconds")).toBeTruthy(); }); it("should return false for invalid time units", () => { - assert.isFalse(isValidTimeUnit("invalid")); + expect(isValidTimeUnit("invalid")).toBeFalsy(); }); }); diff --git a/test/utils/customSubstring.spec.ts b/test/utils/customSubstring.spec.ts index 2c619982..aa986a68 100644 --- a/test/utils/customSubstring.spec.ts +++ b/test/utils/customSubstring.spec.ts @@ -1,10 +1,10 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { customSubstring } from "../../src/utils/customSubstring.js"; describe("customSubstring", () => { it("is defined", () => { - assert.isDefined(customSubstring, "customSubstring is not defined"); - assert.isFunction(customSubstring, "customSubstring is not a function"); + expect(customSubstring,"customSubstring is not defined").toBeDefined(); + expect(customSubstring, "customSubstring is not a function").toBeTypeOf("function"); }); it("returns original string when shorter", () => { diff --git a/test/utils/errorHandler.spec.ts b/test/utils/errorHandler.spec.ts index d689fc85..d797af60 100644 --- a/test/utils/errorHandler.spec.ts +++ b/test/utils/errorHandler.spec.ts @@ -1,9 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { errorHandler } from "../../src/utils/errorHandler.js"; describe("errorHandler", () => { it("is defined", () => { - assert.isDefined(errorHandler, "errorHandler is not defined"); - assert.isFunction(errorHandler, "errorHandler is not a function"); + expect(errorHandler,"errorHandler is not defined").toBeDefined(); + expect(errorHandler, "errorHandler is not a function").toBeTypeOf("function"); }); }); diff --git a/test/utils/fetchLearnRecord.spec.ts b/test/utils/fetchLearnRecord.spec.ts index bd9c7fe8..0829a37e 100644 --- a/test/utils/fetchLearnRecord.spec.ts +++ b/test/utils/fetchLearnRecord.spec.ts @@ -1,9 +1,9 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { fetchLearnRecord } from "../../src/utils/fetchLearnRecord.js"; describe("fetchLearnRecord", () => { it("is defined", () => { - assert.isDefined(fetchLearnRecord, "fetchLearnRecord is not defined"); - assert.isFunction(fetchLearnRecord, "fetchLearnRecord is not a function"); + expect(fetchLearnRecord,"fetchLearnRecord is not defined").toBeDefined(); + expect(fetchLearnRecord, "fetchLearnRecord is not a function").toBeTypeOf("function"); }); }); diff --git a/test/utils/formatText.spec.ts b/test/utils/formatText.spec.ts index 842f5124..b314a241 100644 --- a/test/utils/formatText.spec.ts +++ b/test/utils/formatText.spec.ts @@ -1,13 +1,10 @@ -import { describe, assert, it } from "vitest"; +import { describe, it, expect } from "vitest"; import { formatTextToTable } from "../../src/utils/formatText.js"; describe("formatTextToTable", () => { it("is defined", () => { - assert.isDefined(formatTextToTable, "formatTextToTable is not defined!"); - assert.isFunction( - formatTextToTable, - "formatTextToTable is not a function!", - ); + expect(formatTextToTable, "formatTextToTable is not defined!").toBeDefined(); + expect(formatTextToTable, "formatTextToTable is not a function!").toBeTypeOf("function"); }); it("given empty array returns empty string", () => { assert.deepEqual( diff --git a/test/utils/generateDiff.spec.ts b/test/utils/generateDiff.spec.ts index 90c0c051..92b778b9 100644 --- a/test/utils/generateDiff.spec.ts +++ b/test/utils/generateDiff.spec.ts @@ -1,10 +1,10 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { generateDiff } from "../../src/utils/generateDiff.js"; describe("generateDiff", () => { it("is defined", () => { - assert.isDefined(generateDiff, "generateDiff is not defined"); - assert.isFunction(generateDiff, "generateDiff is not a function"); + expect(generateDiff,"generateDiff is not defined").toBeDefined(); + expect(generateDiff, "generateDiff is not a function").toBeTypeOf("function"); }); it("returns an expected diff string", () => { diff --git a/test/utils/isModerator.spec.ts b/test/utils/isModerator.spec.ts index d5a2ab69..205b3e24 100644 --- a/test/utils/isModerator.spec.ts +++ b/test/utils/isModerator.spec.ts @@ -1,5 +1,5 @@ import { type GuildMember, PermissionFlagsBits } from "discord.js"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { isModerator } from "../../src/utils/isModerator.js"; const typeCoerce = (object: unknown): GuildMember => { @@ -30,14 +30,14 @@ const moderateMembersSet = typeCoerce({ describe("isModerator", () => { it("is defined", () => { - assert.isDefined(isModerator, "isModerator is not defined"); - assert.isFunction(isModerator, "isModerator is not a function"); + expect(isModerator, "isModerator is not defined").toBeDefined(); + expect(isModerator, "isModerator is not a function").toBeTypeOf("function"); }); it("returns true when moderator", () => { - assert.isTrue(isModerator(kickMembersSet), "isModerator returned false"); - assert.isTrue(isModerator(banMembersSet), "isModerator returned false"); - assert.isTrue(isModerator(manageMessagesSet), "isModerator returned false"); + expect(isModerator(kickMembersSet), "isModerator returned false").toBeTruthy(); + expect(isModerator(banMembersSet), "isModerator returned false").toBeTruthy(); + expect(isModerator(manageMessagesSet), "isModerator returned false").toBeTruthy(); assert.isTrue( isModerator(moderateMembersSet), "isModerator returned false", diff --git a/test/utils/loadCommands.spec.ts b/test/utils/loadCommands.spec.ts index 6189ab34..c150d614 100644 --- a/test/utils/loadCommands.spec.ts +++ b/test/utils/loadCommands.spec.ts @@ -1,14 +1,14 @@ import { readdir } from "node:fs/promises"; import { join } from "node:path"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { loadCommands } from "../../src/utils/loadCommands.js"; import type { Command } from "../../src/interfaces/command.js"; import type { ExtendedClient } from "../../src/interfaces/extendedClient.js"; describe("loadCommands", () => { it("is defined", () => { - assert.isDefined(loadCommands, "loadCommands is not defined"); - assert.isFunction(loadCommands, "loadCommands is not a function"); + expect(loadCommands,"loadCommands is not defined").toBeDefined(); + expect(loadCommands, "loadCommands is not a function").toBeTypeOf("function"); }); it("returns array of commands", async() => { diff --git a/test/utils/loadContexts.spec.ts b/test/utils/loadContexts.spec.ts index ddcf517e..77fc0f1b 100644 --- a/test/utils/loadContexts.spec.ts +++ b/test/utils/loadContexts.spec.ts @@ -1,14 +1,14 @@ import { readdir } from "node:fs/promises"; import { join } from "node:path"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { loadContexts } from "../../src/utils/loadContexts.js"; import type { Context } from "../../src/interfaces/context.js"; import type { ExtendedClient } from "../../src/interfaces/extendedClient.js"; describe("loadContexts", () => { it("is defined", () => { - assert.isDefined(loadContexts, "loadContexts is not defined"); - assert.isFunction(loadContexts, "loadContexts is not a function"); + expect(loadContexts,"loadContexts is not defined").toBeDefined(); + expect(loadContexts, "loadContexts is not a function").toBeTypeOf("function"); }); it("returns array of commands", async() => { diff --git a/test/utils/loadQuotes.spec.ts b/test/utils/loadQuotes.spec.ts index 2c52990c..b4d8953b 100644 --- a/test/utils/loadQuotes.spec.ts +++ b/test/utils/loadQuotes.spec.ts @@ -1,16 +1,16 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { loadQuotes } from "../../src/utils/loadQuotes.js"; import type { ExtendedClient } from "../../src/interfaces/extendedClient.js"; describe("loadQuotes", () => { it("is defined", () => { - assert.isDefined(loadQuotes, "loadQuotes is not defined"); - assert.isFunction(loadQuotes, "loadQuotes is not a function"); + expect(loadQuotes,"loadQuotes is not defined").toBeDefined(); + expect(loadQuotes, "loadQuotes is not a function").toBeTypeOf("function"); }); it("returns the expected data structure", async() => { const quotes = await loadQuotes({} as ExtendedClient); - assert.property(quotes, "motivationalQuotes", "quotes is not defined"); + expect(quotes, "quotes is not defined").toHaveProperty("motivationalQuotes"); assert.isArray(quotes.motivationalQuotes, "quotes is not an array"); assert.property( quotes.motivationalQuotes[0], @@ -22,7 +22,7 @@ describe("loadQuotes", () => { "author", "quotes are not in correct structure", ); - assert.property(quotes, "compliments", "compliments is not defined"); + expect(quotes, "compliments is not defined").toHaveProperty("compliments"); assert.isArray(quotes.compliments, "compliments is not an array"); }); }); diff --git a/test/utils/logHandler.spec.ts b/test/utils/logHandler.spec.ts index f61e410e..5ff0c3e8 100644 --- a/test/utils/logHandler.spec.ts +++ b/test/utils/logHandler.spec.ts @@ -1,14 +1,14 @@ -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { logHandler } from "../../src/utils/logHandler.js"; describe("logHandler", () => { it("is defined", () => { - assert.isDefined(logHandler, "logHandler is not defined"); - assert.isObject(logHandler, "logHandler is not an object"); + expect(logHandler,"logHandler is not defined").toBeDefined(); + expect(logHandler).toBeTypeOf("object", "logHandler is not an object"); }); it("has log function", () => { - assert.isDefined(logHandler.log, "log is not defined"); - assert.isFunction(logHandler.log, "log is not a function"); + expect(logHandler.log,"log is not defined").toBeDefined(); + expect(logHandler.log, "log is not a function").toBeTypeOf("function"); }); }); diff --git a/test/utils/registerCommands.spec.ts b/test/utils/registerCommands.spec.ts index 7ab6b2b8..ba24471f 100644 --- a/test/utils/registerCommands.spec.ts +++ b/test/utils/registerCommands.spec.ts @@ -1,5 +1,5 @@ import { MockRest } from "discordjs-testing"; -import { describe, assert, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { loadCommands } from "../../src/utils/loadCommands.js"; import { registerCommands } from "../../src/utils/registerCommands.js"; import type { Command } from "../../src/interfaces/command.js"; @@ -11,7 +11,7 @@ describe("registerCommands", () => { await registerCommands({} as never).catch(() => { threw = true; }); - assert.isTrue(threw); + expect(threw).toBeTruthy(); }); it("registers the command payload", async() => { const bot: { @@ -29,7 +29,7 @@ describe("registerCommands", () => { MockRest as never, )) as never as MockRest; assert.isNotNull(result); - assert.lengthOf(result.requests, 1); + expect(result.requests).toHaveLength(1); const request = result.requests[0]; assert.strictEqual(request.method, "PUT"); assert.strictEqual( From 0cca62b81a56518d9863e68b8ec42b5ff89ad141 Mon Sep 17 00:00:00 2001 From: A Cottrill Date: Sat, 4 Jan 2025 20:35:48 -0500 Subject: [PATCH 2/3] batch 2 complete --- test/commands/community.spec.ts | 40 +++++++------------ .../community/handleCodeOfConduct.spec.ts | 25 ++++-------- .../community/handleContribute.spec.ts | 26 +++++------- .../github/handleAddLabels.spec.ts | 24 ++++------- .../subcommands/github/handleClose.spec.ts | 24 ++++------- .../subcommands/github/handleComment.spec.ts | 24 ++++------- .../github/handleSyncLabels.spec.ts | 24 ++++------- .../management/handlePrivate.spec.ts | 24 ++++------- .../subcommands/management/handleRole.spec.ts | 30 +++++--------- .../subcommands/moderation/handleBan.spec.ts | 24 ++++------- .../moderation/handleHistory.spec.ts | 24 ++++------- .../subcommands/moderation/handleKick.spec.ts | 24 ++++------- .../subcommands/moderation/handleMute.spec.ts | 24 ++++------- .../moderation/handlePrune.spec.ts | 30 +++++--------- .../moderation/handleUnban.spec.ts | 24 ++++------- .../moderation/handleUnmute.spec.ts | 32 ++++++--------- .../subcommands/moderation/handleWarn.spec.ts | 30 +++++--------- test/config/badges.spec.ts | 2 +- test/config/languages.spec.ts | 2 +- test/config/levelScale.spec.ts | 10 ++--- test/contexts/bookmark.spec.ts | 4 +- test/contexts/format.spec.ts | 4 +- test/contexts/report.spec.ts | 4 +- test/contexts/translate.spec.ts | 4 +- test/modules/addFormatting.spec.ts | 29 +++++--------- test/modules/createLogFile.spec.ts | 2 +- test/modules/formatter.spec.ts | 22 +++++----- test/modules/generateConfig.spec.ts | 32 +++++++-------- test/modules/generateLogs.spec.ts | 2 +- test/modules/isSupportedByPrettier.spec.ts | 16 ++++---- test/modules/updateHistory.spec.ts | 24 +++++------ test/utils/generateDiff.spec.ts | 2 +- test/utils/isModerator.spec.ts | 4 +- test/utils/loadCommands.spec.ts | 4 +- test/utils/loadContexts.spec.ts | 2 +- 35 files changed, 233 insertions(+), 389 deletions(-) diff --git a/test/commands/community.spec.ts b/test/commands/community.spec.ts index 15b3c631..962b8cf0 100644 --- a/test/commands/community.spec.ts +++ b/test/commands/community.spec.ts @@ -28,11 +28,8 @@ describe("community command", () => { }, ); assert.exists(codeOfConduct); - assert.equal(codeOfConduct?.name, "code-of-conduct"); - assert.equal( - codeOfConduct?.description, - "Returns information on freeCodeCamp's Code of Conduct.", - ); + expect(codeOfConduct?.name).toBe("code-of-conduct"); + expect(codeOfConduct?.description).toBe("Returns information on freeCodeCamp's Code of Conduct."); expect(codeOfConduct?.options || "hi").toHaveLength(0); }); @@ -41,11 +38,8 @@ describe("community command", () => { return sub.name === "contribute"; }); assert.exists(contribute); - assert.equal(contribute?.name, "contribute"); - assert.equal( - contribute?.description, - "Returns helpful links for folks interested in contributing.", - ); + expect(contribute?.name).toBe("contribute"); + expect(contribute?.description).toBe("Returns helpful links for folks interested in contributing."); expect(contribute?.options || "hi").toHaveLength(0); }); @@ -54,11 +48,8 @@ describe("community command", () => { return sub.name === "forum"; }); assert.exists(forum); - assert.equal(forum?.name, "forum"); - assert.equal( - forum?.description, - "Returns the latest activity on the forum.", - ); + expect(forum?.name).toBe("forum"); + expect(forum?.description).toBe("Returns the latest activity on the forum."); expect(forum?.options || "hi").toHaveLength(0); }); @@ -67,8 +58,8 @@ describe("community command", () => { return sub.name === "leaderboard"; }); assert.exists(leaderboard); - assert.equal(leaderboard?.name, "leaderboard"); - assert.equal(leaderboard?.description, "View the server leaderboard."); + expect(leaderboard?.name).toBe("leaderboard"); + expect(leaderboard?.description).toBe("View the server leaderboard."); expect(leaderboard?.options || "hi").toHaveLength(0); }); @@ -77,8 +68,8 @@ describe("community command", () => { return sub.name === "quote"; }); assert.exists(quote); - assert.equal(quote?.name, "quote"); - assert.equal(quote?.description, "Returns a motivational quote."); + expect(quote?.name).toBe("quote"); + expect(quote?.description).toBe("Returns a motivational quote."); expect(quote?.options || "hi").toHaveLength(0); }); @@ -86,8 +77,8 @@ describe("community command", () => { const rank = subcommands.find((sub) => { return sub.name === "profile"; }); - assert.equal(rank?.name, "profile"); - assert.equal(rank?.description, "See your community profile."); + expect(rank?.name).toBe("profile"); + expect(rank?.description).toBe("See your community profile."); expect(rank?.options || "hi").toHaveLength(0); }); @@ -95,11 +86,8 @@ describe("community command", () => { const truism = subcommands.find((sub) => { return sub.name === "truism"; }); - assert.equal(truism?.name, "truism"); - assert.equal( - truism?.description, - "Provides a random difficult-to-swallow truth about coding.", - ); + expect(truism?.name).toBe("truism"); + expect(truism?.description).toBe("Provides a random difficult-to-swallow truth about coding."); expect(truism?.options || "hi").toHaveLength(0); }); }); diff --git a/test/commands/subcommands/community/handleCodeOfConduct.spec.ts b/test/commands/subcommands/community/handleCodeOfConduct.spec.ts index 820677a5..2ebfb4df 100644 --- a/test/commands/subcommands/community/handleCodeOfConduct.spec.ts +++ b/test/commands/subcommands/community/handleCodeOfConduct.spec.ts @@ -49,25 +49,19 @@ describe("codeOfConduct Handler", () => { user: user, }); await handleCodeOfConduct.execute({} as never, command as never); - assert.equal(command.replies.length, 1); + expect(command.replies).toHaveLength(1); const embed = command.replies?.[0]?.embeds?.[0] as EmbedBuilder; - assert.equal(embed.data.title, "freeCodeCamp Code of Conduct"); - assert.equal( - embed.data.description, - "These are the basic rules for interacting with the FreeCodeCamp community on any platform, including this Discord server. You can read the full document on the [FreeCodeCamp article](https://freecodecamp.org/news/code-of-conduct)", - ); + expect(embed.data.title).toBe("freeCodeCamp Code of Conduct"); + expect(embed.data.description).toBe("These are the basic rules for interacting with the FreeCodeCamp community on any platform, including this Discord server. You can read the full document on the [FreeCodeCamp article](https://freecodecamp.org/news/code-of-conduct)"); const [ first, second, third ] = embed.data.fields || []; - assert.equal(first.name, "No harassment"); - assert.equal( - first.value, - "Harassment includes sexual language and imagery, deliberate intimidation, stalking, name-calling, unwelcome attention, libel, and any malicious hacking or social engineering. freeCodeCamp should be a harassment-free experience for everyone, regardless of gender, gender identity and expression, age, sexual orientation, disability, physical appearance, body size, race, national origin, or religion (or lack thereof).", - ); - assert.equal(second.name, "No trolling"); + expect(first.name).toBe("No harassment"); + expect(first.value).toBe("Harassment includes sexual language and imagery, deliberate intimidation, stalking, name-calling, unwelcome attention, libel, and any malicious hacking or social engineering. freeCodeCamp should be a harassment-free experience for everyone, regardless of gender, gender identity and expression, age, sexual orientation, disability, physical appearance, body size, race, national origin, or religion (or lack thereof)."); + expect(second.name).toBe("No trolling"); assert.equal( second.value, "Trolling includes posting inflammatory comments to provoke an emotional response or disrupt discussions.", ); - assert.equal(third.name, "No spamming"); + expect(third.name).toBe("No spamming"); assert.equal( third.value, "Spamming includes posting off-topic messages to disrupt discussions, promoting a product, soliciting donations, advertising a job / internship / gig, or flooding discussions with files or text.", @@ -76,9 +70,6 @@ describe("codeOfConduct Handler", () => { embed.data.footer?.text, "Thank you for following freeCodeCamp's Code of Conduct", ); - assert.equal( - embed.data.url, - "https://freecodecamp.org/news/code-of-conduct", - ); + expect(embed.data.url).toBe("https://freecodecamp.org/news/code-of-conduct"); }); }); diff --git a/test/commands/subcommands/community/handleContribute.spec.ts b/test/commands/subcommands/community/handleContribute.spec.ts index 334aec46..1c026961 100644 --- a/test/commands/subcommands/community/handleContribute.spec.ts +++ b/test/commands/subcommands/community/handleContribute.spec.ts @@ -49,25 +49,21 @@ describe("contribute Handler", () => { user: user, }); await handleContribute.execute({} as never, command as never); - assert.equal(command.replies.length, 1); + expect(command.replies).toHaveLength(1); const embed = command.replies?.[0]?.embeds?.[0] as EmbedBuilder; - assert.equal(embed.data.title, "Helpful Links!"); + expect(embed.data.title).toBe("Helpful Links!"); const [ first, second, third, fourth, fifth ] = embed.data.fields || []; - assert.equal(first.name, "Code of Conduct"); - assert.equal(first.value, "https://freecodecamp.org/news/code-of-conduct"); - assert.equal(second.name, "Moderator Handbook"); - assert.equal( - second.value, - "https://contribute.freecodecamp.org/#/flight-manuals/moderator-handbook", + expect(first.name).toBe("Code of Conduct"); + expect(first.value).toBe("https://freecodecamp.org/news/code-of-conduct"); + expect(second.name).toBe("Moderator Handbook"); + expect(second.value).toBe("https://contribute.freecodecamp.org/#/flight-manuals/moderator-handbook", ); - assert.equal(third.name, "Contributing Guidelines"); - assert.equal(third.value, "https://contribute.freecodecamp.org/"); - assert.equal(fourth.name, "News Contributing"); - assert.equal( - fourth.value, - "https://www.freecodecamp.org/news/developer-news-style-guide/", + expect(third.name).toBe("Contributing Guidelines"); + expect(third.value).toBe("https://contribute.freecodecamp.org/"); + expect(fourth.name).toBe("News Contributing"); + expect(fourth.value).toBe("https://www.freecodecamp.org/news/developer-news-style-guide/", ); - assert.equal(fifth.name, "Pull Request Reviews"); + expect(fifth.name).toBe("Pull Request Reviews"); assert.equal( fifth.value, `[PRs Ready for Review](https://github.com/freeCodeCamp/freeCodeCamp/pulls?q=is%3Aopen+is%3Apr+-label%3A%22status%3A+blocked%22+-label%3A%22status%3A+merge+conflict%22+status%3Asuccess+draft%3Afalse)`, diff --git a/test/commands/subcommands/github/handleAddLabels.spec.ts b/test/commands/subcommands/github/handleAddLabels.spec.ts index 49b06553..d1c7db56 100644 --- a/test/commands/subcommands/github/handleAddLabels.spec.ts +++ b/test/commands/subcommands/github/handleAddLabels.spec.ts @@ -5,34 +5,26 @@ import { handleAddLabels } describe("add labels handler", () => { it("does not allow non-moderators permission", () => { - assert.isFalse( - handleAddLabels.permissionValidator({ + expect(handleAddLabels.permissionValidator({ permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("allows moderate members permission", () => { - assert.isTrue( - handleAddLabels.permissionValidator({ + expect(handleAddLabels.permissionValidator({ permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); it("allows kick members permission", () => { - assert.isTrue( - handleAddLabels.permissionValidator({ + expect(handleAddLabels.permissionValidator({ permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); it("allows ban members permission", () => { - assert.isTrue( - handleAddLabels.permissionValidator({ + expect(handleAddLabels.permissionValidator({ permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/github/handleClose.spec.ts b/test/commands/subcommands/github/handleClose.spec.ts index 7cb7b086..7d8924a1 100644 --- a/test/commands/subcommands/github/handleClose.spec.ts +++ b/test/commands/subcommands/github/handleClose.spec.ts @@ -5,34 +5,26 @@ import { handleClose } describe("close handler", () => { it("does not allow non-moderators permission", () => { - assert.isFalse( - handleClose.permissionValidator({ + expect(handleClose.permissionValidator({ permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("allows moderate members permission", () => { - assert.isTrue( - handleClose.permissionValidator({ + expect(handleClose.permissionValidator({ permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); it("allows kick members permission", () => { - assert.isTrue( - handleClose.permissionValidator({ + expect(handleClose.permissionValidator({ permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); it("allows ban members permission", () => { - assert.isTrue( - handleClose.permissionValidator({ + expect(handleClose.permissionValidator({ permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/github/handleComment.spec.ts b/test/commands/subcommands/github/handleComment.spec.ts index a8751c67..e0cad131 100644 --- a/test/commands/subcommands/github/handleComment.spec.ts +++ b/test/commands/subcommands/github/handleComment.spec.ts @@ -5,34 +5,26 @@ import { handleComment } describe("comment command", () => { it("does not allow non-moderators permission", () => { - assert.isFalse( - handleComment.permissionValidator({ + expect(handleComment.permissionValidator({ permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("allows moderate members permission", () => { - assert.isTrue( - handleComment.permissionValidator({ + expect(handleComment.permissionValidator({ permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); it("allows kick members permission", () => { - assert.isTrue( - handleComment.permissionValidator({ + expect(handleComment.permissionValidator({ permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); it("allows ban members permission", () => { - assert.isTrue( - handleComment.permissionValidator({ + expect(handleComment.permissionValidator({ permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/github/handleSyncLabels.spec.ts b/test/commands/subcommands/github/handleSyncLabels.spec.ts index 86b63df7..9a292dde 100644 --- a/test/commands/subcommands/github/handleSyncLabels.spec.ts +++ b/test/commands/subcommands/github/handleSyncLabels.spec.ts @@ -5,34 +5,26 @@ import { handleSyncLabels } describe("sync labels handler", () => { it("does not allow non-moderators permission", () => { - assert.isFalse( - handleSyncLabels.permissionValidator({ + expect(handleSyncLabels.permissionValidator({ permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("allows moderate members permission", () => { - assert.isTrue( - handleSyncLabels.permissionValidator({ + expect(handleSyncLabels.permissionValidator({ permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); it("allows kick members permission", () => { - assert.isTrue( - handleSyncLabels.permissionValidator({ + expect(handleSyncLabels.permissionValidator({ permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); it("allows ban members permission", () => { - assert.isTrue( - handleSyncLabels.permissionValidator({ + expect(handleSyncLabels.permissionValidator({ permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/management/handlePrivate.spec.ts b/test/commands/subcommands/management/handlePrivate.spec.ts index 0e11e685..0ea9c7b1 100644 --- a/test/commands/subcommands/management/handlePrivate.spec.ts +++ b/test/commands/subcommands/management/handlePrivate.spec.ts @@ -5,34 +5,26 @@ import { handlePrivate } describe("handlePrivate command", () => { it("does not allow non-moderators permission", () => { - assert.isFalse( - handlePrivate.permissionValidator({ + expect(handlePrivate.permissionValidator({ permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("allows moderate members permission", () => { - assert.isTrue( - handlePrivate.permissionValidator({ + expect(handlePrivate.permissionValidator({ permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); it("allows kick members permission", () => { - assert.isTrue( - handlePrivate.permissionValidator({ + expect(handlePrivate.permissionValidator({ permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); it("allows ban members permission", () => { - assert.isTrue( - handlePrivate.permissionValidator({ + expect(handlePrivate.permissionValidator({ permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/management/handleRole.spec.ts b/test/commands/subcommands/management/handleRole.spec.ts index bb01e407..2f8e43bf 100644 --- a/test/commands/subcommands/management/handleRole.spec.ts +++ b/test/commands/subcommands/management/handleRole.spec.ts @@ -5,42 +5,32 @@ import { handleRole } describe("handleRole command", () => { it("does not allow non-moderators permission", () => { - assert.isFalse( - handleRole.permissionValidator({ + expect(handleRole.permissionValidator({ permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("does not allow moderate members permission", () => { - assert.isFalse( - handleRole.permissionValidator({ + expect(handleRole.permissionValidator({ permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("does not allow kick members permission", () => { - assert.isFalse( - handleRole.permissionValidator({ + expect(handleRole.permissionValidator({ permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("does not allow ban members permission", () => { - assert.isFalse( - handleRole.permissionValidator({ + expect(handleRole.permissionValidator({ permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("allows manage server permission", () => { - assert.isTrue( - handleRole.permissionValidator({ + expect(handleRole.permissionValidator({ permissions: new Set([ PermissionFlagsBits.ManageGuild ]), - } as never), - ); + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/moderation/handleBan.spec.ts b/test/commands/subcommands/moderation/handleBan.spec.ts index e9f69c24..7fcfbb04 100644 --- a/test/commands/subcommands/moderation/handleBan.spec.ts +++ b/test/commands/subcommands/moderation/handleBan.spec.ts @@ -5,34 +5,26 @@ import { handleBan } describe("ban handler", () => { it("does not allow non-moderators permission", () => { - assert.isFalse( - handleBan.permissionValidator({ + expect(handleBan.permissionValidator({ permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("does not allow moderate members permission", () => { - assert.isFalse( - handleBan.permissionValidator({ + expect(handleBan.permissionValidator({ permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("does not allow kick members permission", () => { - assert.isFalse( - handleBan.permissionValidator({ + expect(handleBan.permissionValidator({ permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("allows ban members permission", () => { - assert.isTrue( - handleBan.permissionValidator({ + expect(handleBan.permissionValidator({ permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/moderation/handleHistory.spec.ts b/test/commands/subcommands/moderation/handleHistory.spec.ts index e7055cb2..4a6b51a2 100644 --- a/test/commands/subcommands/moderation/handleHistory.spec.ts +++ b/test/commands/subcommands/moderation/handleHistory.spec.ts @@ -5,34 +5,26 @@ import { handleHistory } describe("history handler", () => { it("does not allow non-moderators permission", () => { - assert.isFalse( - handleHistory.permissionValidator({ + expect(handleHistory.permissionValidator({ permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("allows moderate members permission", () => { - assert.isTrue( - handleHistory.permissionValidator({ + expect(handleHistory.permissionValidator({ permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); it("allows kick members permission", () => { - assert.isTrue( - handleHistory.permissionValidator({ + expect(handleHistory.permissionValidator({ permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); it("allows ban members permission", () => { - assert.isTrue( - handleHistory.permissionValidator({ + expect(handleHistory.permissionValidator({ permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/moderation/handleKick.spec.ts b/test/commands/subcommands/moderation/handleKick.spec.ts index 5e9a1ba4..e08052b6 100644 --- a/test/commands/subcommands/moderation/handleKick.spec.ts +++ b/test/commands/subcommands/moderation/handleKick.spec.ts @@ -5,34 +5,26 @@ import { handleKick } describe("kick handler", () => { it("does not allow non-moderators permission", () => { - assert.isFalse( - handleKick.permissionValidator({ + expect(handleKick.permissionValidator({ permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("does not allow moderate members permission", () => { - assert.isFalse( - handleKick.permissionValidator({ + expect(handleKick.permissionValidator({ permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("allows kick members permission", () => { - assert.isTrue( - handleKick.permissionValidator({ + expect(handleKick.permissionValidator({ permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); it("does not allow ban members permission", () => { - assert.isFalse( - handleKick.permissionValidator({ + expect(handleKick.permissionValidator({ permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never), - ); + } as never)).toBeFalsy(); }); }); diff --git a/test/commands/subcommands/moderation/handleMute.spec.ts b/test/commands/subcommands/moderation/handleMute.spec.ts index d88c02e0..f0d5e92a 100644 --- a/test/commands/subcommands/moderation/handleMute.spec.ts +++ b/test/commands/subcommands/moderation/handleMute.spec.ts @@ -5,34 +5,26 @@ import { handleMute } describe("mute handler", () => { it("does not allow non-moderators permission", () => { - assert.isFalse( - handleMute.permissionValidator({ + expect(handleMute.permissionValidator({ permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("allows moderate members permission", () => { - assert.isTrue( - handleMute.permissionValidator({ + expect(handleMute.permissionValidator({ permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); it("does not allow kick members permission", () => { - assert.isFalse( - handleMute.permissionValidator({ + expect(handleMute.permissionValidator({ permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("does not allow ban members permission", () => { - assert.isFalse( - handleMute.permissionValidator({ + expect(handleMute.permissionValidator({ permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never), - ); + } as never)).toBeFalsy(); }); }); diff --git a/test/commands/subcommands/moderation/handlePrune.spec.ts b/test/commands/subcommands/moderation/handlePrune.spec.ts index 21c9fe8a..9bb11369 100644 --- a/test/commands/subcommands/moderation/handlePrune.spec.ts +++ b/test/commands/subcommands/moderation/handlePrune.spec.ts @@ -5,42 +5,32 @@ import { handlePrune } describe("prune handler", () => { it("does not allow non-moderators permission", () => { - assert.isFalse( - handlePrune.permissionValidator({ + expect(handlePrune.permissionValidator({ permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("allows manage messages permission", () => { - assert.isTrue( - handlePrune.permissionValidator({ + expect(handlePrune.permissionValidator({ permissions: new Set([ PermissionFlagsBits.ManageMessages ]), - } as never), - ); + } as never)).toBeTruthy(); }); it("does not allow moderate members permission", () => { - assert.isFalse( - handlePrune.permissionValidator({ + expect(handlePrune.permissionValidator({ permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("does not allow kick members permission", () => { - assert.isFalse( - handlePrune.permissionValidator({ + expect(handlePrune.permissionValidator({ permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("does not allow ban members permission", () => { - assert.isFalse( - handlePrune.permissionValidator({ + expect(handlePrune.permissionValidator({ permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never), - ); + } as never)).toBeFalsy(); }); }); diff --git a/test/commands/subcommands/moderation/handleUnban.spec.ts b/test/commands/subcommands/moderation/handleUnban.spec.ts index e32f9102..8a0da9cb 100644 --- a/test/commands/subcommands/moderation/handleUnban.spec.ts +++ b/test/commands/subcommands/moderation/handleUnban.spec.ts @@ -5,34 +5,26 @@ import { handleUnban } describe("unban handler", () => { it("does not allow non-moderators permission", () => { - assert.isFalse( - handleUnban.permissionValidator({ + expect(handleUnban.permissionValidator({ permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("does not allow moderate members permission", () => { - assert.isFalse( - handleUnban.permissionValidator({ + expect(handleUnban.permissionValidator({ permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("does not allow kick members permission", () => { - assert.isFalse( - handleUnban.permissionValidator({ + expect(handleUnban.permissionValidator({ permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("allows ban members permission", () => { - assert.isTrue( - handleUnban.permissionValidator({ + expect(handleUnban.permissionValidator({ permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never), - ); + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/moderation/handleUnmute.spec.ts b/test/commands/subcommands/moderation/handleUnmute.spec.ts index 8941642d..187756b3 100644 --- a/test/commands/subcommands/moderation/handleUnmute.spec.ts +++ b/test/commands/subcommands/moderation/handleUnmute.spec.ts @@ -5,34 +5,26 @@ import { handleUnmute } describe("unmute handler", () => { it("does not allow non-moderators permission", () => { - assert.isFalse( - handleUnmute.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never), - ); + expect(handleUnmute.permissionValidator({ + permissions: new Set([ PermissionFlagsBits.SendMessages ]), + } as never)).toBeFalsy(); }); it("allows moderate members permission", () => { - assert.isTrue( - handleUnmute.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never), - ); + expect(handleUnmute.permissionValidator({ + permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), + } as never)).toBeTruthy(); }); it("does not allow kick members permission", () => { - assert.isFalse( - handleUnmute.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never), - ); + expect(handleUnmute.permissionValidator({ + permissions: new Set([ PermissionFlagsBits.KickMembers ]), + } as never)).toBeFalsy(); }); it("does not allow ban members permission", () => { - assert.isFalse( - handleUnmute.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never), - ); + expect(handleUnmute.permissionValidator({ + permissions: new Set([ PermissionFlagsBits.BanMembers ]), + } as never)).toBeFalsy(); }); }); diff --git a/test/commands/subcommands/moderation/handleWarn.spec.ts b/test/commands/subcommands/moderation/handleWarn.spec.ts index b4fbe448..78c46f93 100644 --- a/test/commands/subcommands/moderation/handleWarn.spec.ts +++ b/test/commands/subcommands/moderation/handleWarn.spec.ts @@ -5,34 +5,26 @@ import { handleWarn } describe("warn handler", () => { it("does not allow non-moderators permission", () => { - assert.isFalse( - handleWarn.permissionValidator({ + expect(handleWarn.permissionValidator({ permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never), - ); + } as never)).toBeFalsy(); }); it("allows moderate members permission", () => { - assert.isTrue( - handleWarn.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never), - ); + expect(handleWarn.permissionValidator({ + permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), + } as never)).toBeTruthy(); }); it("allows kick members permission", () => { - assert.isTrue( - handleWarn.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never), - ); + expect(handleWarn.permissionValidator({ + permissions: new Set([ PermissionFlagsBits.KickMembers ]), + } as never)).toBeTruthy(); }); it("allows ban members permission", () => { - assert.isTrue( - handleWarn.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never), - ); + expect(handleWarn.permissionValidator({ + permissions: new Set([ PermissionFlagsBits.BanMembers ]), + } as never)).toBeTruthy(); }); }); diff --git a/test/config/badges.spec.ts b/test/config/badges.spec.ts index 5988221b..d97fd45a 100644 --- a/test/config/badges.spec.ts +++ b/test/config/badges.spec.ts @@ -7,6 +7,6 @@ describe("badges Config", () => { const set = new Set(badges.map((b) => { return b.name; })); - assert.equal(set.size, badges.length); + expect(set.size).toBe(badges.length); }); }); diff --git a/test/config/languages.spec.ts b/test/config/languages.spec.ts index 93f10787..b56a7725 100644 --- a/test/config/languages.spec.ts +++ b/test/config/languages.spec.ts @@ -4,6 +4,6 @@ import { languages } from "../../src/config/languages.js"; describe("languages Config", () => { it("should be unique", () => { const set = new Set(languages); - assert.equal(set.size, languages.length); + expect(set.size).toBe(languages.length); }); }); diff --git a/test/config/levelScale.spec.ts b/test/config/levelScale.spec.ts index 789f55b2..55f191d8 100644 --- a/test/config/levelScale.spec.ts +++ b/test/config/levelScale.spec.ts @@ -3,10 +3,10 @@ import { levelScale } from "../../src/config/levelScale.js"; describe("levelScale", () => { it("level scale should return the correct values", () => { - assert.equal(levelScale[0], 0); - assert.equal(levelScale[1], 100); - assert.equal(levelScale[2], 300); - assert.equal(levelScale[50], 127_500); - assert.equal(levelScale[100], 505_000); + expect(levelScale[0]).toBe(0); + expect(levelScale[1]).toBe(100); + expect(levelScale[2]).toBe(300); + expect(levelScale[50]).toBe(127_500); + expect(levelScale[100]).toBe(505_000); }); }); diff --git a/test/contexts/bookmark.spec.ts b/test/contexts/bookmark.spec.ts index 309cc073..1be5fcd0 100644 --- a/test/contexts/bookmark.spec.ts +++ b/test/contexts/bookmark.spec.ts @@ -10,7 +10,7 @@ describe("bookmark context", () => { expect(bookmark.run).toBeTypeOf("function"); }); it("bookmark context should be formatted correctly.", () => { - assert.equal(bookmark.data.name, "bookmark"); - assert.equal(bookmark.data.type, ApplicationCommandType.Message); + expect(bookmark.data.name).toBe("bookmark"); + expect(bookmark.data.type).toBe(ApplicationCommandType.Message); }); }); diff --git a/test/contexts/format.spec.ts b/test/contexts/format.spec.ts index fdc457a5..21edcc6b 100644 --- a/test/contexts/format.spec.ts +++ b/test/contexts/format.spec.ts @@ -10,7 +10,7 @@ describe("format context", () => { expect(format.run).toBeTypeOf("function"); }); it("format context should be formatted correctly.", () => { - assert.equal(format.data.name, "format"); - assert.equal(format.data.type, ApplicationCommandType.Message); + expect(format.data.name).toBe("format"); + expect(format.data.type).toBe(ApplicationCommandType.Message); }); }); diff --git a/test/contexts/report.spec.ts b/test/contexts/report.spec.ts index 90371513..4182ddee 100644 --- a/test/contexts/report.spec.ts +++ b/test/contexts/report.spec.ts @@ -10,7 +10,7 @@ describe("report context", () => { expect(report.run).toBeTypeOf("function"); }); it("report context should be formatted correctly.", () => { - assert.equal(report.data.name, "report"); - assert.equal(report.data.type, ApplicationCommandType.Message); + expect(report.data.name).toBe("report"); + expect(report.data.type).toBe(ApplicationCommandType.Message); }); }); diff --git a/test/contexts/translate.spec.ts b/test/contexts/translate.spec.ts index 91078ce1..c7b2a153 100644 --- a/test/contexts/translate.spec.ts +++ b/test/contexts/translate.spec.ts @@ -10,7 +10,7 @@ describe("translate context", () => { expect(translate.run).toBeTypeOf("function"); }); it("translate context should be formatted correctly.", () => { - assert.equal(translate.data.name, "translate"); - assert.equal(translate.data.type, ApplicationCommandType.Message); + expect(translate.data.name).toBe("translate"); + expect(translate.data.type).toBe(ApplicationCommandType.Message); }); }); diff --git a/test/modules/addFormatting.spec.ts b/test/modules/addFormatting.spec.ts index e5b8a5bd..7cb84095 100644 --- a/test/modules/addFormatting.spec.ts +++ b/test/modules/addFormatting.spec.ts @@ -15,46 +15,43 @@ describe("addFormatting", () => { it("should format HTML", async() => { const content = "

Hello

"; const output = await addFormatting(typeCoerce({ content })); - assert.equal(output, "```XML\n

Hello

\n```"); + expect(output).toBe("```XML\n

Hello

\n```"); }); it("should format CSS", async() => { const content = "body { color: red }"; const output = await addFormatting(typeCoerce({ content })); - assert.equal(output, "```css\nbody {\n color: red;\n}\n```"); + expect(output).toBe("```css\nbody {\n color: red;\n}\n```"); }); it("should format SCSS", async() => { const content = "body { color: red }"; const output = await addFormatting(typeCoerce({ content })); - assert.equal(output, "```css\nbody {\n color: red;\n}\n```"); + expect(output).toBe("```css\nbody {\n color: red;\n}\n```"); }); it("should format JS", async() => { const content = "const foo = 'bar';"; const output = await addFormatting(typeCoerce({ content })); - assert.equal(output, `\`\`\`js\nconst foo = "bar";\n\`\`\``); + expect(output).toBe(`\`\`\`js\nconst foo = "bar";\n\`\`\``); }); it("should format TS", async() => { const content = "const foo: string = 'bar';"; const output = await addFormatting(typeCoerce({ content })); - assert.equal(output, "```TypeScript\nconst foo: string = 'bar';\n```"); + expect(output).toBe("```TypeScript\nconst foo: string = 'bar';\n```"); }); it("should format JSX", async() => { const content = `let jsxElement=(

Welcome To freeCodeCamp

Hello World

);`; const output = await addFormatting(typeCoerce({ content })); - assert.equal( - output, - `\`\`\`js\nlet jsxElement = (\n
\n

Welcome To freeCodeCamp

\n

Hello World

\n
\n);\n\`\`\``, - ); + expect(output).toBe(`\`\`\`js\nlet jsxElement = (\n
\n

Welcome To freeCodeCamp

\n

Hello World

\n
\n);\n\`\`\``); }); it("should format PHP", async() => { const content = ``; const output = await addFormatting(typeCoerce({ content })); - assert.equal(output, `\`\`\`PHP\n\n\`\`\``); + expect(output).toBe( `\`\`\`PHP\n\n\`\`\``); }); /* @@ -62,31 +59,27 @@ describe("addFormatting", () => { * it("should format Python", async () => { * const content = `for i in range(10):\n print(i)`; * const output = await addFormatting(typeCoerce({ content })); - * assert.equal(output, `\`\`\`Python\nprint("Hello World")\n\`\`\``); + * expect(output).toBe( `\`\`\`Python\nprint("Hello World")\n\`\`\``); * }); */ it("should format Markdown", async() => { const content = `# Hello World\n\n## Subheading\n\n- List Item`; const output = await addFormatting(typeCoerce({ content })); - assert.equal( - output, - `\`\`\`markdown\n# Hello World\n\n## Subheading\n\n- List Item\n\`\`\``, + expect(output).toBe(`\`\`\`markdown\n# Hello World\n\n## Subheading\n\n- List Item\n\`\`\``, ); }); it("should format JSON", async() => { const content = `{"name": "Naomi"}`; const output = await addFormatting(typeCoerce({ content })); - assert.equal(output, `\`\`\`json\n{ "name": "Naomi" }\n\`\`\``); + expect(output).toBe(`\`\`\`json\n{ "name": "Naomi" }\n\`\`\``); }); it("should format HTTP", async() => { const content = `GET / HTTP/1.1\nHost: example.com\n\n`; const output = await addFormatting(typeCoerce({ content })); - assert.equal( - output, - `\`\`\`HTTP\nGET / HTTP/1.1\nHost: example.com\n\n\`\`\``, + expect(output).toBe(`\`\`\`HTTP\nGET / HTTP/1.1\nHost: example.com\n\n\`\`\``, ); }); }); diff --git a/test/modules/createLogFile.spec.ts b/test/modules/createLogFile.spec.ts index 90b0f51d..eda3f47c 100644 --- a/test/modules/createLogFile.spec.ts +++ b/test/modules/createLogFile.spec.ts @@ -14,7 +14,7 @@ describe("createLogFile", () => { const mockBot = { privateLogs: {} } as ExtendedClient; await createLogFile(mockBot, "Naomi"); expect(mockBot.privateLogs, "Naomi is not defined").toHaveProperty("Naomi"); - assert.equal(mockBot.privateLogs.Naomi, "Naomi", "Naomi is not Naomi"); + expect(mockBot.privateLogs.Naomi, "Naomi is not Naomi").toBe("Naomi"); const logPath = join(process.cwd(), "logs", "Naomi.txt"); const status = await stat(logPath); expect(status.isFile(), "Naomi.txt is not a file").toBeTruthy(); diff --git a/test/modules/formatter.spec.ts b/test/modules/formatter.spec.ts index d7d87942..5217ec8f 100644 --- a/test/modules/formatter.spec.ts +++ b/test/modules/formatter.spec.ts @@ -11,60 +11,56 @@ describe("formatter", () => { const content = `

Hello world this is a very long string from Naomi to force a line break.

`; const output = await formatter(content, "html"); - assert.equal( - output, - `
\n

\n Hello world this is a very long string from Naomi to force a line break.\n

\n
\n`, + expect(output).toBe(`
\n

\n Hello world this is a very long string from Naomi to force a line break.\n

\n
\n`, ); }); it("should format CSS", async() => { const content = "body { color: red }"; const output = await formatter(content, "css"); - assert.equal(output, "body {\n color: red;\n}\n"); + expect(output).toBe("body {\n color: red;\n}\n"); }); it("should format SCSS", async() => { const content = "@mixin center {margin: 0}"; const output = await formatter(content, "css"); - assert.equal(output, "@mixin center {\n margin: 0;\n}\n"); + expect(output).toBe("@mixin center {\n margin: 0;\n}\n"); }); it("should format JS", async() => { const content = "const foo = 'bar';"; const output = await formatter(content, "js"); - assert.equal(output, `const foo = "bar";\n`); + expect(output).toBe( `const foo = "bar";\n`); }); it("should format TS", async() => { const content = "const foo: string = 'bar';"; const output = await formatter(content, "ts"); - assert.equal(output, `const foo: string = "bar";\n`); + expect(output).toBe( `const foo: string = "bar";\n`); }); it("should format JSX", async() => { const content = `let jsxElement=(

Welcome To freeCodeCamp

Hello World

);`; const output = await formatter(content, "js"); - assert.equal( - output, - `let jsxElement = (\n
\n

Welcome To freeCodeCamp

\n

Hello World

\n
\n);\n`, + expect(output).toBe(`let jsxElement = (\n
\n

Welcome To freeCodeCamp

\n

Hello World

\n
\n);\n`, ); }); it("should format Markdown", async() => { const content = `# Hello World\n\n## Subheading\n\n- List Item`; const output = await formatter(content, "markdown"); - assert.equal(output, `# Hello World\n\n## Subheading\n\n- List Item\n`); + expect(output).toBe( `# Hello World\n\n## Subheading\n\n- List Item\n`); }); it("should format JSON", async() => { const content = `{"name": "Naomi"}`; const output = await formatter(content, "json"); - assert.equal(output, `{ "name": "Naomi" }\n`); + expect(output).toBe( `{ "name": "Naomi" }\n`); }); it("should format YAML", async() => { const content = `name: Naomi\nuse:\n - Naomi`; const output = await formatter(content, "yaml"); - assert.equal(output, `name: Naomi\nuse:\n - Naomi\n`); + expect(output).toBe( `name: Naomi\nuse:\n - Naomi\n`); }); }); diff --git a/test/modules/generateConfig.spec.ts b/test/modules/generateConfig.spec.ts index 95f37ccd..48fb647b 100644 --- a/test/modules/generateConfig.spec.ts +++ b/test/modules/generateConfig.spec.ts @@ -32,25 +32,23 @@ describe("generateConfig", () => { process.env.GITHUB_APP_ID = "1"; process.env.GITHUB_INSTALLATION_ID = "7"; const result = generateConfig(); - assert.equal(result.token, process.env.TOKEN); - assert.equal(result.mongoUrl, process.env.MONGO_URI); - assert.equal(result.homeGuild, process.env.HOME_GUILD); - assert.equal(result.botId, process.env.BOT_ID); - assert.equal(result.reportChannel, process.env.REPORT_CHANNEL); - assert.instanceOf(result.debugHook, WebhookClient); - assert.instanceOf(result.modHook, WebhookClient); - assert.instanceOf(result.messageHook, WebhookClient); - assert.instanceOf(result.welcomeHook, WebhookClient); - assert.equal(result.debugHook.url, process.env.DEBUG_HOOK); - assert.equal(result.modHook.url, process.env.MOD_HOOK); - assert.equal(result.welcomeHook.url, process.env.WELCOME_HOOK); - assert.equal(result.githubToken, process.env.GITHUB_TOKEN); - assert.equal(result.ghostKey, process.env.GHOST_KEY); + expect(result.token).toBe(process.env.TOKEN); + expect(result.mongoUrl).toBe(process.env.MONGO_URI); + expect(result.homeGuild).toBe(process.env.HOME_GUILD); + expect(result.botId).toBe(process.env.BOT_ID); + expect(result.reportChannel).toBe(process.env.REPORT_CHANNEL); + expect(result.debugHook).toBeInstanceOf(WebhookClient); + expect(result.modHook).toBeInstanceOf(WebhookClient); + expect(result.messageHook).toBeInstanceOf(WebhookClient); + expect(result.welcomeHook).toBeInstanceOf(WebhookClient); + expect(result.debugHook.url).toBe(process.env.DEBUG_HOOK); + expect(result.modHook.url).toBe(process.env.MOD_HOOK); + expect(result.welcomeHook.url).toBe(process.env.WELCOME_HOOK); + expect(result.githubToken).toBe(process.env.GITHUB_TOKEN); + expect(result.ghostKey).toBe(process.env.GHOST_KEY); assert.equal(result.githubAppId, Number.parseInt(process.env.GITHUB_APP_ID, 10)); - assert.equal( - result.githubInstallationId, - Number.parseInt(process.env.GITHUB_INSTALLATION_ID, 10), + expect(result.githubInstallationId).toBe(Number.parseInt(process.env.GITHUB_INSTALLATION_ID, 10), ); }); }); diff --git a/test/modules/generateLogs.spec.ts b/test/modules/generateLogs.spec.ts index 167d8453..1e97e418 100644 --- a/test/modules/generateLogs.spec.ts +++ b/test/modules/generateLogs.spec.ts @@ -23,6 +23,6 @@ describe("generateLogs", () => { const status = await stat(logPath).catch(() => { return null; }); - assert.isNull(status, "Log file was not deleted."); + expect(status, "Log file was not deleted.").toBeNull(); }); }); diff --git a/test/modules/isSupportedByPrettier.spec.ts b/test/modules/isSupportedByPrettier.spec.ts index 37bb2012..958a6fb3 100644 --- a/test/modules/isSupportedByPrettier.spec.ts +++ b/test/modules/isSupportedByPrettier.spec.ts @@ -16,14 +16,14 @@ describe("isSupportedByPrettier", () => { }); it("returns expected language names for supported langs", () => { - assert.equal(isSupportedByPrettier("HTML"), "html"); - assert.equal(isSupportedByPrettier("CSS"), "css"); - assert.equal(isSupportedByPrettier("SCSS"), "css"); - assert.equal(isSupportedByPrettier("JavaScript"), "js"); - assert.equal(isSupportedByPrettier("JS"), "js"); - assert.equal(isSupportedByPrettier("JSON"), "json"); - assert.equal(isSupportedByPrettier("MarkDown"), "markdown"); - assert.equal(isSupportedByPrettier("YAML"), "yaml"); + expect(isSupportedByPrettier("HTML")).toBe("html"); + expect(isSupportedByPrettier("CSS")).toBe("css"); + expect(isSupportedByPrettier("SCSS")).toBe("css"); + expect(isSupportedByPrettier("JavaScript")).toBe("js"); + expect(isSupportedByPrettier("JS")).toBe("js"); + expect(isSupportedByPrettier("JSON")).toBe("json"); + expect(isSupportedByPrettier("MarkDown")).toBe("markdown"); + expect(isSupportedByPrettier("YAML")).toBe("yaml"); }); it("returns false for unsupported languages", () => { diff --git a/test/modules/updateHistory.spec.ts b/test/modules/updateHistory.spec.ts index 94b91ab7..67e1a270 100644 --- a/test/modules/updateHistory.spec.ts +++ b/test/modules/updateHistory.spec.ts @@ -17,12 +17,12 @@ describe("updateHistory", () => { }, }); expect(history).toBeTypeOf("object"); - assert.equal(history?.bans, 1); - assert.equal(history?.kicks, 0); - assert.equal(history?.mutes, 0); - assert.equal(history?.unmutes, 0); - assert.equal(history?.warns, 0); - assert.equal(history?.unbans, 0); + expect(history?.bans).toBe(1); + expect(history?.kicks).toBe(0); + expect(history?.mutes).toBe(0); + expect(history?.unmutes).toBe(0); + expect(history?.warns).toBe(0); + expect(history?.unbans).toBe(0); }); it("should update an existing history", async() => { @@ -34,11 +34,11 @@ describe("updateHistory", () => { }, }); expect(history).toBeTypeOf("object"); - assert.equal(history?.bans, 2); - assert.equal(history?.kicks, 0); - assert.equal(history?.mutes, 1); - assert.equal(history?.unmutes, 0); - assert.equal(history?.warns, 0); - assert.equal(history?.unbans, 0); + expect(history?.bans).toBe(2); + expect(history?.kicks).toBe(0); + expect(history?.mutes).toBe(1); + expect(history?.unmutes).toBe(0); + expect(history?.warns).toBe(0); + expect(history?.unbans).toBe(0); }); }); diff --git a/test/utils/generateDiff.spec.ts b/test/utils/generateDiff.spec.ts index 92b778b9..615d5e09 100644 --- a/test/utils/generateDiff.spec.ts +++ b/test/utils/generateDiff.spec.ts @@ -12,6 +12,6 @@ describe("generateDiff", () => { const updated = "this is a it, but different"; const expected = "- this is a it\n+ this is a it, but different"; const actual = generateDiff(old, updated); - assert.equal(actual, expected); + expect(actual).toBe(expected); }); }); diff --git a/test/utils/isModerator.spec.ts b/test/utils/isModerator.spec.ts index 205b3e24..d60913f9 100644 --- a/test/utils/isModerator.spec.ts +++ b/test/utils/isModerator.spec.ts @@ -45,8 +45,6 @@ describe("isModerator", () => { }); it("returns false when not moderator", () => { - assert.isFalse( - isModerator(typeCoerce({ permissions: new Set(basePermissions) })), - ); + expect(isModerator(typeCoerce({ permissions: new Set(basePermissions) }))).toBeFalsy(); }); }); diff --git a/test/utils/loadCommands.spec.ts b/test/utils/loadCommands.spec.ts index c150d614..95b1a45a 100644 --- a/test/utils/loadCommands.spec.ts +++ b/test/utils/loadCommands.spec.ts @@ -7,7 +7,7 @@ import type { ExtendedClient } from "../../src/interfaces/extendedClient.js"; describe("loadCommands", () => { it("is defined", () => { - expect(loadCommands,"loadCommands is not defined").toBeDefined(); + expect(loadCommands, "loadCommands is not defined").toBeDefined(); expect(loadCommands, "loadCommands is not a function").toBeTypeOf("function"); }); @@ -29,7 +29,7 @@ describe("loadCommands", () => { return file.split(".")[0]; }); bot.commands = await loadCommands(bot as never); - assert.equal(bot.commands.length, commandNames.length); + expect(bot.commands).toHaveLength(commandNames.length); for (const name of commandNames) { assert.exists( bot.commands.find( diff --git a/test/utils/loadContexts.spec.ts b/test/utils/loadContexts.spec.ts index 77fc0f1b..66d64309 100644 --- a/test/utils/loadContexts.spec.ts +++ b/test/utils/loadContexts.spec.ts @@ -23,7 +23,7 @@ describe("loadContexts", () => { return file.split(".")[0]; }); bot.contexts = await loadContexts(bot as never); - assert.equal(bot.contexts.length, contextNames.length); + expect(bot.contexts.length).toBe(contextNames.length); for (const name of contextNames) { assert.exists(bot.contexts.find((context) => { return context.data.name === name; From 99326dfb0db8d6d2a654aadc130e4b3a10668016 Mon Sep 17 00:00:00 2001 From: A Cottrill Date: Sun, 5 Jan 2025 21:29:05 -0500 Subject: [PATCH 3/3] finish conversion --- test/commands/community.spec.ts | 22 +- test/commands/github.spec.ts | 203 +++++----------- test/commands/management.spec.ts | 108 +++------ test/commands/moderation.spec.ts | 225 ++++++------------ .../community/handleCodeOfConduct.spec.ts | 15 +- .../community/handleContribute.spec.ts | 11 +- .../github/handleAddLabels.spec.ts | 16 +- .../subcommands/github/handleClose.spec.ts | 16 +- .../subcommands/github/handleComment.spec.ts | 16 +- .../github/handleSyncLabels.spec.ts | 16 +- .../management/handlePrivate.spec.ts | 16 +- .../subcommands/management/handleRole.spec.ts | 20 +- .../subcommands/moderation/handleBan.spec.ts | 16 +- .../moderation/handleHistory.spec.ts | 16 +- .../subcommands/moderation/handleKick.spec.ts | 16 +- .../subcommands/moderation/handleMute.spec.ts | 16 +- .../moderation/handlePrune.spec.ts | 20 +- .../moderation/handleUnban.spec.ts | 16 +- .../subcommands/moderation/handleWarn.spec.ts | 4 +- test/commands/userSettings.spec.ts | 3 +- test/config/intentOptions.spec.ts | 14 +- test/config/pullComments.spec.ts | 6 +- test/config/roles.spec.ts | 4 +- test/config/tags.spec.ts | 10 +- test/config/truisms.spec.ts | 2 +- test/events/registerEvents.spec.ts | 18 +- test/modules/addFormatting.spec.ts | 8 +- test/modules/closePrivateChannel.spec.ts | 2 +- test/modules/formatCodeblock.spec.ts | 4 +- test/modules/formatter.spec.ts | 18 +- test/modules/generateConfig.spec.ts | 8 +- test/modules/generateLogs.spec.ts | 2 +- test/modules/generateProfileImage.spec.ts | 4 +- test/modules/isSupportedByPrettier.spec.ts | 4 +- test/modules/settingsValidation.spec.ts | 6 +- test/utils/calculateMilliseconds.spec.ts | 12 +- test/utils/customSubstring.spec.ts | 10 +- test/utils/errorHandler.spec.ts | 2 +- test/utils/fetchLearnRecord.spec.ts | 2 +- test/utils/formatText.spec.ts | 58 ++--- test/utils/generateDiff.spec.ts | 2 +- test/utils/isModerator.spec.ts | 5 +- test/utils/loadCommands.spec.ts | 22 +- test/utils/loadContexts.spec.ts | 15 +- test/utils/loadQuotes.spec.ts | 18 +- test/utils/logHandler.spec.ts | 4 +- test/utils/registerCommands.spec.ts | 18 +- 47 files changed, 407 insertions(+), 662 deletions(-) diff --git a/test/commands/community.spec.ts b/test/commands/community.spec.ts index 962b8cf0..730944f9 100644 --- a/test/commands/community.spec.ts +++ b/test/commands/community.spec.ts @@ -13,11 +13,8 @@ describe("community command", () => { ) as Array; it("has correct data", () => { - assert.strictEqual(community.data.name, "community"); - assert.strictEqual( - community.data.description, - "Commands related to our community.", - ); + expect(community.data.name).toBe("community"); + expect(community.data.description).toBe("Commands related to our community."); expect(subcommands).toHaveLength(7); }); @@ -27,7 +24,8 @@ describe("community command", () => { return sub.name === "code-of-conduct"; }, ); - assert.exists(codeOfConduct); + expect(codeOfConduct).toBeDefined(); + expect(codeOfConduct).not.toBeNull(); expect(codeOfConduct?.name).toBe("code-of-conduct"); expect(codeOfConduct?.description).toBe("Returns information on freeCodeCamp's Code of Conduct."); expect(codeOfConduct?.options || "hi").toHaveLength(0); @@ -37,7 +35,8 @@ describe("community command", () => { const contribute = subcommands.find((sub) => { return sub.name === "contribute"; }); - assert.exists(contribute); + expect(contribute).toBeDefined(); + expect(contribute).not.toBeNull(); expect(contribute?.name).toBe("contribute"); expect(contribute?.description).toBe("Returns helpful links for folks interested in contributing."); expect(contribute?.options || "hi").toHaveLength(0); @@ -47,7 +46,8 @@ describe("community command", () => { const forum = subcommands.find((sub) => { return sub.name === "forum"; }); - assert.exists(forum); + expect(forum).toBeDefined(); + expect(forum).not.toBeNull(); expect(forum?.name).toBe("forum"); expect(forum?.description).toBe("Returns the latest activity on the forum."); expect(forum?.options || "hi").toHaveLength(0); @@ -57,7 +57,8 @@ describe("community command", () => { const leaderboard = subcommands.find((sub) => { return sub.name === "leaderboard"; }); - assert.exists(leaderboard); + expect(leaderboard).toBeDefined(); + expect(leaderboard).not.toBeNull(); expect(leaderboard?.name).toBe("leaderboard"); expect(leaderboard?.description).toBe("View the server leaderboard."); expect(leaderboard?.options || "hi").toHaveLength(0); @@ -67,7 +68,8 @@ describe("community command", () => { const quote = subcommands.find((sub) => { return sub.name === "quote"; }); - assert.exists(quote); + expect(quote).toBeDefined(); + expect(quote).not.toBeNull(); expect(quote?.name).toBe("quote"); expect(quote?.description).toBe("Returns a motivational quote."); expect(quote?.options || "hi").toHaveLength(0); diff --git a/test/commands/github.spec.ts b/test/commands/github.spec.ts index 31c0f184..b128a75d 100644 --- a/test/commands/github.spec.ts +++ b/test/commands/github.spec.ts @@ -13,11 +13,8 @@ describe("github command", () => { ) as Array; it("has correct data", () => { - assert.strictEqual(github.data.name, "github"); - assert.strictEqual( - github.data.description, - "Commands related to managing github", - ); + expect(github.data.name).toBe("github"); + expect(github.data.description).toBe("Commands related to managing github"); expect(subcommands).toHaveLength(4); }); @@ -25,181 +22,95 @@ describe("github command", () => { const close = subcommands.find((sub) => { return sub.name === "close"; }); - assert.exists(close); - assert.strictEqual(close?.name, "close"); - assert.strictEqual( - close?.description, - "Close an issue or pull request under the freeCodeCamp organisation.", - ); + expect(close).toBeDefined(); + expect(close).not.toBeNull(); + expect(close?.name).toBe("close"); + expect(close?.description).toBe("Close an issue or pull request under the freeCodeCamp organisation."); expect(close?.options || "hi").toHaveLength(4); - assert.strictEqual(close?.options?.[0].name, "repository"); - assert.strictEqual( - close?.options?.[0].description, - `The name of the repository, under freeCodeCamp's GitHub org, to comment on`, - ); + expect(close?.options?.[0].name).toBe("repository"); + expect(close?.options?.[0].description).toBe(`The name of the repository, under freeCodeCamp's GitHub org, to comment on`); expect(close?.options?.[0].required).toBeTruthy(); - assert.strictEqual( - close?.options?.[0].type, - ApplicationCommandOptionType.String, - ); - assert.strictEqual(close?.options?.[1].name, "number"); - assert.strictEqual( - close?.options?.[1].description, - "The number of the issue or pull to close.", - ); + expect(close?.options?.[0].type).toBe(ApplicationCommandOptionType.String); + expect(close?.options?.[1].name).toBe("number"); + expect(close?.options?.[1].description).toBe("The number of the issue or pull to close."); expect(close?.options?.[1].required).toBeTruthy(); - assert.strictEqual( - close?.options?.[1].type, - ApplicationCommandOptionType.Integer, - ); - assert.strictEqual(close?.options?.[2].name, "comment"); - assert.strictEqual( - close?.options?.[2].description, - `The comment to leave when closing. Defaults to the standard close message.`, - ); + expect(close?.options?.[1].type).toBe(ApplicationCommandOptionType.Integer); + expect(close?.options?.[2].name).toBe("comment"); + expect(close?.options?.[2].description).toBe(`The comment to leave when closing. Defaults to the standard close message.`); expect(close?.options?.[2].required).toBeFalsy(); - assert.strictEqual( - close?.options?.[2].type, - ApplicationCommandOptionType.String, - ); - assert.strictEqual(close?.options?.[3].name, "spam"); - assert.strictEqual( - close?.options?.[3].description, - "Label the PR as spam for Hacktoberfest?", - ); + expect(close?.options?.[2].type).toBe(ApplicationCommandOptionType.String); + expect(close?.options?.[3].name).toBe("spam"); + expect(close?.options?.[3].description).toBe("Label the PR as spam for Hacktoberfest?"); expect(close?.options?.[3].required).toBeFalsy(); - assert.strictEqual( - close?.options?.[3].type, - ApplicationCommandOptionType.Boolean, - ); + expect(close?.options?.[3].type).toBe(ApplicationCommandOptionType.Boolean); }); it("has correct comment", () => { const comment = subcommands.find((sub) => { return sub.name === "comment"; }); - assert.exists(comment); - assert.strictEqual(comment?.name, "comment"); - assert.strictEqual( - comment?.description, - `Adds a friendly comment to an issue or pull request. Scoped to the freeCodeCamp organisation.`, - ); + expect(comment).toBeDefined(); + expect(comment).not.toBeNull(); + expect(comment?.name).toBe("comment"); + expect(comment?.description).toBe(`Adds a friendly comment to an issue or pull request. Scoped to the freeCodeCamp organisation.`); expect(comment?.options || "hi").toHaveLength(3); - assert.strictEqual(comment?.options?.[0].name, "repository"); - assert.strictEqual( - comment?.options?.[0].description, - `The name of the repository, under freeCodeCamp's GitHub org, to comment on`, - ); + expect(comment?.options?.[0].name).toBe("repository"); + expect(comment?.options?.[0].description).toBe(`The name of the repository, under freeCodeCamp's GitHub org, to comment on`); expect(comment?.options?.[0].required).toBeTruthy(); - assert.strictEqual( - comment?.options?.[0].type, - ApplicationCommandOptionType.String, - ); - assert.strictEqual(comment?.options?.[1].name, "number"); - assert.strictEqual( - comment?.options?.[1].description, - "The number of the pull request to comment on.", - ); + expect(comment?.options?.[0].type).toBe(ApplicationCommandOptionType.String); + expect(comment?.options?.[1].name).toBe("number"); + expect(comment?.options?.[1].description).toBe("The number of the pull request to comment on."); expect(comment?.options?.[1].required).toBeTruthy(); - assert.strictEqual( - comment?.options?.[1].type, - ApplicationCommandOptionType.Integer, - ); - assert.strictEqual(comment?.options?.[2].name, "message"); - assert.strictEqual( - comment?.options?.[2].description, - "The message to post.", - ); + expect(comment?.options?.[1].type).toBe(ApplicationCommandOptionType.Integer); + expect(comment?.options?.[2].name).toBe("message"); + expect(comment?.options?.[2].description).toBe("The message to post."); expect(comment?.options?.[2].required).toBeTruthy(); - assert.strictEqual( - comment?.options?.[2].type, - ApplicationCommandOptionType.String, - ); + expect(comment?.options?.[2].type).toBe(ApplicationCommandOptionType.String); }); it("has correct add labels", () => { const command = subcommands.find((sub) => { return sub.name === "add-labels"; }); - assert.exists(command); - assert.strictEqual(command?.name, "add-labels"); - assert.strictEqual( - command?.description, - `Specify a list of labels to add to an issue/PR. Existing labels will not be removed.`, - ); + expect(command).toBeDefined(); + expect(command).not.toBeNull(); + expect(command?.name).toBe("add-labels"); + expect(command?.description).toBe("Specify a list of labels to add to an issue/PR. Existing labels will not be removed."); expect(command?.options || "hi").toHaveLength(3); - assert.strictEqual(command?.options?.[0].name, "repository"); - assert.strictEqual( - command?.options?.[0].description, - "The name of the repository, under freeCodeCamp's GitHub org, to label", - ); + expect(command?.options?.[0].name).toBe("repository"); + expect(command?.options?.[0].description).toBe("The name of the repository, under freeCodeCamp's GitHub org, to label"); expect(command?.options?.[0].required).toBeTruthy(); - assert.strictEqual( - command?.options?.[0].type, - ApplicationCommandOptionType.String, - ); - assert.strictEqual(command?.options?.[1].name, "number"); - assert.strictEqual( - command?.options?.[1].description, - "The number of the pull request to label.", - ); + expect(command?.options?.[0].type).toBe(ApplicationCommandOptionType.String); + expect(command?.options?.[1].name).toBe("number"); + expect(command?.options?.[1].description).toBe("The number of the pull request to label."); expect(command?.options?.[1].required).toBeTruthy(); - assert.strictEqual( - command?.options?.[1].type, - ApplicationCommandOptionType.Integer, - ); - assert.strictEqual(command?.options?.[2].name, "labels"); - assert.strictEqual( - command?.options?.[2].description, - "The comma separated list of labels to add", - ); + expect(command?.options?.[1].type).toBe(ApplicationCommandOptionType.Integer); + expect(command?.options?.[2].name).toBe("labels"); + expect(command?.options?.[2].description).toBe("The comma separated list of labels to add"); expect(command?.options?.[2].required).toBeTruthy(); - assert.strictEqual( - command?.options?.[2].type, - ApplicationCommandOptionType.String, - ); + expect(command?.options?.[2].type).toBe(ApplicationCommandOptionType.String); }); it("has correct sync labels", () => { const command = subcommands.find((sub) => { return sub.name === "sync-labels"; }); - assert.exists(command); - assert.strictEqual(command?.name, "sync-labels"); - assert.strictEqual( - command?.description, - `Specify the exact list of labels an issue/PR should have. Labels not on the list will be removed.`, - ); + expect(command).toBeDefined(); + expect(command).not.toBeNull(); + expect(command?.name).toBe("sync-labels"); + expect(command?.description).toBe(`Specify the exact list of labels an issue/PR should have. Labels not on the list will be removed.`); expect(command?.options || "hi").toHaveLength(3); - assert.strictEqual(command?.options?.[0].name, "repository"); - assert.strictEqual( - command?.options?.[0].description, - "The name of the repository, under freeCodeCamp's GitHub org, to label", - ); + expect(command?.options?.[0].name).toBe("repository"); + expect(command?.options?.[0].description).toBe("The name of the repository, under freeCodeCamp's GitHub org, to label"); expect(command?.options?.[0].required).toBeTruthy(); - assert.strictEqual( - command?.options?.[0].type, - ApplicationCommandOptionType.String, - ); - assert.strictEqual(command?.options?.[1].name, "number"); - assert.strictEqual( - command?.options?.[1].description, - "The number of the pull request to label.", - ); + expect(command?.options?.[0].type).toBe(ApplicationCommandOptionType.String); + expect(command?.options?.[1].name).toBe("number"); + expect(command?.options?.[1].description).toBe("The number of the pull request to label."); expect(command?.options?.[1].required).toBeTruthy(); - assert.strictEqual( - command?.options?.[1].type, - ApplicationCommandOptionType.Integer, - ); - assert.strictEqual(command?.options?.[2].name, "labels"); - assert.strictEqual( - command?.options?.[2].description, - "The comma separated list of labels to sync", - ); + expect(command?.options?.[1].type).toBe(ApplicationCommandOptionType.Integer); + expect(command?.options?.[2].name).toBe("labels"); + expect(command?.options?.[2].description).toBe("The comma separated list of labels to sync"); expect(command?.options?.[2].required).toBeTruthy(); - assert.strictEqual( - command?.options?.[2].type, - ApplicationCommandOptionType.String, - ); + expect(command?.options?.[2].type).toBe(ApplicationCommandOptionType.String); }); }); diff --git a/test/commands/management.spec.ts b/test/commands/management.spec.ts index 555b91d7..bb1dcaa8 100644 --- a/test/commands/management.spec.ts +++ b/test/commands/management.spec.ts @@ -13,11 +13,8 @@ describe("management command", () => { ) as Array; it("has correct data", () => { - assert.strictEqual(management.data.name, "management"); - assert.strictEqual( - management.data.description, - "Commands related to server management.", - ); + expect(management.data.name).toBe("management"); + expect(management.data.description).toBe("Commands related to server management."); expect(subcommands).toHaveLength(3); }); @@ -25,97 +22,46 @@ describe("management command", () => { const privateC = subcommands.find((sub) => { return sub.name === "private"; }); - assert.strictEqual( - privateC?.description, - "Creates a private discussion channel with a user.", - ); + expect(privateC?.description).toBe("Creates a private discussion channel with a user."); expect(privateC?.options || "hi").toHaveLength(1); - assert.strictEqual(privateC?.options[0].name, "target"); - assert.strictEqual( - privateC?.options[0].description, - "The user to create a private channel with.", - ); + expect(privateC?.options[0].name).toBe("target"); + expect(privateC?.options[0].description).toBe("The user to create a private channel with."); expect(privateC?.options[0].required).toBeTruthy(); - assert.strictEqual( - privateC?.options[0].type, - ApplicationCommandOptionType.User, - ); + expect(privateC?.options[0].type).toBe(ApplicationCommandOptionType.User); }); it("has correct role", () => { const role = subcommands.find((sub) => { return sub.name === "role"; }); - assert.strictEqual( - role?.description, - "Creates a post with buttons for self-assignable roles.", - ); + expect(role?.description).toBe("Creates a post with buttons for self-assignable roles."); expect(role?.options || "hi").toHaveLength(7); - assert.strictEqual(role?.options[0].name, "channel"); - assert.strictEqual( - role?.options[0].description, - "Channel to create the post in.", - ); + expect(role?.options[0].name).toBe("channel"); + expect(role?.options[0].description).toBe("Channel to create the post in."); expect(role?.options[0].required).toBeTruthy(); - assert.strictEqual(role?.options[1].name, "header"); - assert.strictEqual( - role?.options[1].description, - "Text to include at the top of the post.", - ); + expect(role?.options[1].name).toBe("header"); + expect(role?.options[1].description).toBe("Text to include at the top of the post."); expect(role?.options[1].required).toBeTruthy(); - assert.strictEqual( - role?.options[1].type, - ApplicationCommandOptionType.String, - ); - assert.strictEqual(role?.options[2].name, "role1"); - assert.strictEqual( - role?.options[2].description, - "Role to create a button for.", - ); + expect(role?.options[1].type).toBe(ApplicationCommandOptionType.String); + expect(role?.options[2].name).toBe("role1"); + expect(role?.options[2].description).toBe("Role to create a button for."); expect(role?.options[2].required).toBeTruthy(); - assert.strictEqual( - role?.options[2].type, - ApplicationCommandOptionType.Role, - ); - assert.strictEqual(role?.options[3].name, "role2"); - assert.strictEqual( - role?.options[3].description, - "Role to create a button for.", - ); + expect(role?.options[2].type).toBe(ApplicationCommandOptionType.Role); + expect(role?.options[3].name).toBe("role2"); + expect(role?.options[3].description).toBe("Role to create a button for."); expect(role?.options[3].required).toBeFalsy(); - assert.strictEqual( - role?.options[3].type, - ApplicationCommandOptionType.Role, - ); - assert.strictEqual(role?.options[4].name, "role3"); - assert.strictEqual( - role?.options[4].description, - "Role to create a button for.", - ); + expect(role?.options[3].type).toBe(ApplicationCommandOptionType.Role); + expect(role?.options[4].name).toBe("role3"); + expect(role?.options[4].description).toBe("Role to create a button for."); expect(role?.options[4].required).toBeFalsy(); - assert.strictEqual( - role?.options[4].type, - ApplicationCommandOptionType.Role, - ); - assert.strictEqual(role?.options[5].name, "role4"); - assert.strictEqual( - role?.options[5].description, - "Role to create a button for.", - ); + expect(role?.options[4].type).toBe(ApplicationCommandOptionType.Role); + expect(role?.options[5].name).toBe("role4"); + expect(role?.options[5].description).toBe("Role to create a button for."); expect(role?.options[5].required).toBeFalsy(); - assert.strictEqual( - role?.options[5].type, - ApplicationCommandOptionType.Role, - ); - assert.strictEqual(role?.options[6].name, "role5"); - assert.strictEqual( - role?.options[6].description, - "Role to create a button for.", - ); + expect(role?.options[5].type).toBe(ApplicationCommandOptionType.Role); + expect(role?.options[6].name).toBe("role5"); + expect(role?.options[6].description).toBe("Role to create a button for."); expect(role?.options[6].required).toBeFalsy(); - assert.strictEqual( - role?.options[6].type, - ApplicationCommandOptionType.Role, - ); + expect(role?.options[6].type).toBe(ApplicationCommandOptionType.Role); }); }); diff --git a/test/commands/moderation.spec.ts b/test/commands/moderation.spec.ts index 4bb65b42..6c729045 100644 --- a/test/commands/moderation.spec.ts +++ b/test/commands/moderation.spec.ts @@ -13,8 +13,8 @@ describe("moderation command", () => { ) as Array; it("has correct data", () => { - assert.strictEqual(moderation.data.name, "moderation"); - assert.strictEqual(moderation.data.description, "Moderation commands."); + expect(moderation.data.name).toBe("moderation"); + expect(moderation.data.description).toBe("Moderation commands."); expect(subcommands).toHaveLength(8); }); @@ -22,219 +22,144 @@ describe("moderation command", () => { const ban = subcommands.find((sub) => { return sub.name === "ban"; }); - assert.exists(ban); - assert.strictEqual(ban?.description, "Bans a user from the server."); + + expect(ban).toBeDefined(); + expect(ban).not.toBeNull(); + expect(ban?.description).toBe("Bans a user from the server."); expect(ban?.options || "hello").toHaveLength(2); - assert.strictEqual(ban?.options?.[0].name, "target"); - assert.strictEqual(ban?.options?.[0].description, "The user to ban."); + expect(ban?.options?.[0].name).toBe("target"); + expect(ban?.options?.[0].description).toBe("The user to ban."); expect(ban?.options?.[0].required).toBeTruthy(); - assert.strictEqual( - ban?.options?.[0].type, - ApplicationCommandOptionType.User, - ); - assert.strictEqual(ban?.options?.[1].name, "reason"); - assert.strictEqual( - ban?.options?.[1].description, - "The reason for banning the user.", - ); + expect(ban?.options?.[0].type).toBe(ApplicationCommandOptionType.User); + expect(ban?.options?.[1].name).toBe("reason"); + expect(ban?.options?.[1].description).toBe("The reason for banning the user."); expect(ban?.options?.[1].required).toBeTruthy(); - assert.strictEqual( - ban?.options?.[1].type, - ApplicationCommandOptionType.String, - ); + expect(ban?.options?.[1].type).toBe(ApplicationCommandOptionType.String); }); it("has correct history", () => { const history = subcommands.find((sub) => { return sub.name === "history"; }); - assert.exists(history); - assert.strictEqual( - history?.description, - "Views the moderation history of a user.", - ); + expect(history).toBeDefined(); + expect(history).not.toBeNull(); + expect(history?.description).toBe("Views the moderation history of a user."); expect(history?.options || "hello").toHaveLength(1); - assert.strictEqual(history?.options?.[0].name, "target"); - assert.strictEqual( - history?.options?.[0].description, - "The user to view the moderation history of.", - ); + expect(history?.options?.[0].name).toBe("target"); + expect(history?.options?.[0].description).toBe("The user to view the moderation history of."); expect(history?.options?.[0].required).toBeTruthy(); - assert.strictEqual( - history?.options?.[0].type, - ApplicationCommandOptionType.User, - ); + expect(history?.options?.[0].type).toBe(ApplicationCommandOptionType.User); }); it("has correct kick", () => { const kick = subcommands.find((sub) => { return sub.name === "kick"; }); - assert.exists(kick); - assert.strictEqual(kick?.description, "Kicks a user from the server."); + expect(kick).toBeDefined(); + expect(kick).not.toBeNull(); + expect(kick?.description).toBe("Kicks a user from the server."); expect(kick?.options || "hello").toHaveLength(2); - assert.strictEqual(kick?.options?.[0].name, "target"); - assert.strictEqual(kick?.options?.[0].description, "The user to kick."); + expect(kick?.options?.[0].name).toBe("target"); + expect(kick?.options?.[0].description).toBe("The user to kick."); expect(kick?.options?.[0].required).toBeTruthy(); - assert.strictEqual( - kick?.options?.[0].type, - ApplicationCommandOptionType.User, - ); - assert.strictEqual(kick?.options?.[1].name, "reason"); - assert.strictEqual( - kick?.options?.[1].description, - "The reason for kicking the user.", - ); + expect(kick?.options?.[0].type).toBe(ApplicationCommandOptionType.User); + expect(kick?.options?.[1].name).toBe("reason"); + expect(kick?.options?.[1].description).toBe("The reason for kicking the user."); expect(kick?.options?.[1].required).toBeTruthy(); - assert.strictEqual( - kick?.options?.[1].type, - ApplicationCommandOptionType.String, - ); + expect(kick?.options?.[1].type).toBe(ApplicationCommandOptionType.String); }); it("has correct mute", () => { const mute = subcommands.find((sub) => { return sub.name === "mute"; }); - assert.exists(mute); - assert.strictEqual(mute?.description, "Mutes a user."); + expect(mute).toBeDefined(); + expect(mute).not.toBeNull(); + expect(mute?.description).toBe("Mutes a user."); expect(mute?.options || "hello").toHaveLength(4); - assert.strictEqual(mute?.options?.[0].name, "target"); - assert.strictEqual(mute?.options?.[0].description, "The user to mute."); + expect(mute?.options?.[0].name).toBe("target"); + expect(mute?.options?.[0].description).toBe("The user to mute."); expect(mute?.options?.[0].required).toBeTruthy(); - assert.strictEqual( - mute?.options?.[0].type, - ApplicationCommandOptionType.User, - ); - assert.strictEqual(mute?.options?.[1].name, "duration"); - assert.strictEqual( - mute?.options?.[1].description, - "The length of time to mute the user.", - ); + expect(mute?.options?.[0].type).toBe(ApplicationCommandOptionType.User); + expect(mute?.options?.[1].name).toBe("duration"); + expect(mute?.options?.[1].description).toBe("The length of time to mute the user."); expect(mute?.options?.[1].required).toBeTruthy(); - assert.strictEqual( - mute?.options?.[1].type, - ApplicationCommandOptionType.Integer, - ); - assert.strictEqual(mute?.options?.[2].name, "unit"); - assert.strictEqual( - mute?.options?.[2].description, - "The unit of time for the duration.", - ); + expect(mute?.options?.[1].type).toBe(ApplicationCommandOptionType.Integer); + expect(mute?.options?.[2].name).toBe("unit"); + expect(mute?.options?.[2].description).toBe("The unit of time for the duration."); expect(mute?.options?.[2].required).toBeTruthy(); - assert.strictEqual( - mute?.options?.[2].type, - ApplicationCommandOptionType.String, - ); - assert.strictEqual(mute?.options?.[3].name, "reason"); - assert.strictEqual( - mute?.options?.[3].description, - "The reason for muting the user.", - ); + expect(mute?.options?.[2].type).toBe(ApplicationCommandOptionType.String); + expect(mute?.options?.[3].name).toBe("reason"); + expect(mute?.options?.[3].description).toBe("The reason for muting the user."); expect(mute?.options?.[3].required).toBeTruthy(); - assert.strictEqual( - mute?.options?.[3].type, - ApplicationCommandOptionType.String, - ); + expect(mute?.options?.[3].type).toBe(ApplicationCommandOptionType.String); }); it("has correct prune", () => { const prune = subcommands.find((sub) => { return sub.name === "prune"; }); - assert.exists(prune); - assert.strictEqual( - prune?.description, - "Prunes messages from THIS channel.", - ); + expect(prune).toBeDefined(); + expect(prune).not.toBeNull(); + expect(prune?.description).toBe("Prunes messages from THIS channel."); expect(prune?.options || "hello").toHaveLength(1); - assert.strictEqual(prune?.options?.[0].name, "count"); - assert.strictEqual( - prune?.options?.[0].description, - "Number of messages to delete. Maximum of 100.", - ); + expect(prune?.options?.[0].name).toBe("count"); + expect(prune?.options?.[0].description).toBe("Number of messages to delete. Maximum of 100."); expect(prune?.options?.[0].required).toBeTruthy(); - assert.strictEqual( - prune?.options?.[0].type, - ApplicationCommandOptionType.Integer, - ); + expect(prune?.options?.[0].type).toBe(ApplicationCommandOptionType.Integer); }); it("has correct unban", () => { const unban = subcommands.find((sub) => { return sub.name === "unban"; }); - assert.exists(unban); - assert.strictEqual(unban?.description, "Removes a user's ban."); + expect(unban).toBeDefined(); + expect(unban).not.toBeNull(); + expect(unban?.description).toBe("Removes a user's ban."); expect(unban?.options || "hello").toHaveLength(2); - assert.strictEqual(unban?.options?.[0].name, "target"); - assert.strictEqual(unban?.options?.[0].description, "The user to unban."); + expect(unban?.options?.[0].name).toBe("target"); + expect(unban?.options?.[0].description).toBe("The user to unban."); expect(unban?.options?.[0].required).toBeTruthy(); - assert.strictEqual( - unban?.options?.[0].type, - ApplicationCommandOptionType.User, - ); - assert.strictEqual(unban?.options?.[1].name, "reason"); - assert.strictEqual( - unban?.options?.[1].description, - "The reason for unbanning the user.", - ); + expect(unban?.options?.[0].type).toBe(ApplicationCommandOptionType.User); + expect(unban?.options?.[1].name).toBe("reason"); + expect(unban?.options?.[1].description).toBe("The reason for unbanning the user."); expect(unban?.options?.[1].required).toBeTruthy(); - assert.strictEqual( - unban?.options?.[1].type, - ApplicationCommandOptionType.String, - ); + expect(unban?.options?.[1].type).toBe(ApplicationCommandOptionType.String); }); it("has correct unmute", () => { const unmute = subcommands.find((sub) => { return sub.name === "unmute"; }); - assert.exists(unmute); - assert.strictEqual(unmute?.description, "Unmutes a user."); + expect(unmute).toBeDefined(); + expect(unmute).not.toBeNull(); + expect(unmute?.description).toBe("Unmutes a user."); expect(unmute?.options || "hello").toHaveLength(2); - assert.strictEqual(unmute?.options?.[0].name, "target"); - assert.strictEqual(unmute?.options?.[0].description, "The user to unmute."); + expect(unmute?.options?.[0].name).toBe("target"); + expect(unmute?.options?.[0].description).toBe("The user to unmute."); expect(unmute?.options?.[0].required).toBeTruthy(); - assert.strictEqual( - unmute?.options?.[0].type, - ApplicationCommandOptionType.User, - ); - assert.strictEqual(unmute?.options?.[1].name, "reason"); - assert.strictEqual( - unmute?.options?.[1].description, - "The reason for unmuting the user.", - ); + expect(unmute?.options?.[0].type).toBe(ApplicationCommandOptionType.User); + expect(unmute?.options?.[1].name).toBe("reason"); + expect(unmute?.options?.[1].description).toBe("The reason for unmuting the user."); expect(unmute?.options?.[1].required).toBeTruthy(); - assert.strictEqual( - unmute?.options?.[1].type, - ApplicationCommandOptionType.String, - ); + expect(unmute?.options?.[1].type).toBe(ApplicationCommandOptionType.String); }); it("has correct warn", () => { const warn = subcommands.find((sub) => { return sub.name === "warn"; }); - assert.exists(warn); - assert.strictEqual(warn?.description, "Issues a warning to a user."); + expect(warn).toBeDefined(); + expect(warn).not.toBeNull(); + expect(warn?.description).toBe("Issues a warning to a user."); expect(warn?.options || "hello").toHaveLength(2); - assert.strictEqual(warn?.options?.[0].name, "target"); - assert.strictEqual(warn?.options?.[0].description, "The user to warn."); + expect(warn?.options?.[0].name).toBe("target"); + expect(warn?.options?.[0].description).toBe("The user to warn."); expect(warn?.options?.[0].required).toBeTruthy(); - assert.strictEqual( - warn?.options?.[0].type, - ApplicationCommandOptionType.User, - ); - assert.strictEqual(warn?.options?.[1].name, "reason"); - assert.strictEqual( - warn?.options?.[1].description, - "The reason for issuing this warning.", - ); + expect(warn?.options?.[0].type).toBe(ApplicationCommandOptionType.User); + expect(warn?.options?.[1].name).toBe("reason"); + expect(warn?.options?.[1].description).toBe("The reason for issuing this warning."); expect(warn?.options?.[1].required).toBeTruthy(); - assert.strictEqual( - warn?.options?.[1].type, - ApplicationCommandOptionType.String, - ); + expect(warn?.options?.[1].type).toBe(ApplicationCommandOptionType.String); }); }); diff --git a/test/commands/subcommands/community/handleCodeOfConduct.spec.ts b/test/commands/subcommands/community/handleCodeOfConduct.spec.ts index 2ebfb4df..ea268384 100644 --- a/test/commands/subcommands/community/handleCodeOfConduct.spec.ts +++ b/test/commands/subcommands/community/handleCodeOfConduct.spec.ts @@ -57,19 +57,10 @@ describe("codeOfConduct Handler", () => { expect(first.name).toBe("No harassment"); expect(first.value).toBe("Harassment includes sexual language and imagery, deliberate intimidation, stalking, name-calling, unwelcome attention, libel, and any malicious hacking or social engineering. freeCodeCamp should be a harassment-free experience for everyone, regardless of gender, gender identity and expression, age, sexual orientation, disability, physical appearance, body size, race, national origin, or religion (or lack thereof)."); expect(second.name).toBe("No trolling"); - assert.equal( - second.value, - "Trolling includes posting inflammatory comments to provoke an emotional response or disrupt discussions.", - ); + expect(second.value).toBe("Trolling includes posting inflammatory comments to provoke an emotional response or disrupt discussions."); expect(third.name).toBe("No spamming"); - assert.equal( - third.value, - "Spamming includes posting off-topic messages to disrupt discussions, promoting a product, soliciting donations, advertising a job / internship / gig, or flooding discussions with files or text.", - ); - assert.equal( - embed.data.footer?.text, - "Thank you for following freeCodeCamp's Code of Conduct", - ); + expect(third.value).toBe("Spamming includes posting off-topic messages to disrupt discussions promoting a product, soliciting donations, advertising a job / internship / gig, or flooding discussions with files or text."); + expect(embed.data.footer?.text).toBe("Thank you for following freeCodeCamp's Code of Conduct"); expect(embed.data.url).toBe("https://freecodecamp.org/news/code-of-conduct"); }); }); diff --git a/test/commands/subcommands/community/handleContribute.spec.ts b/test/commands/subcommands/community/handleContribute.spec.ts index 1c026961..8d1304d7 100644 --- a/test/commands/subcommands/community/handleContribute.spec.ts +++ b/test/commands/subcommands/community/handleContribute.spec.ts @@ -56,17 +56,12 @@ describe("contribute Handler", () => { expect(first.name).toBe("Code of Conduct"); expect(first.value).toBe("https://freecodecamp.org/news/code-of-conduct"); expect(second.name).toBe("Moderator Handbook"); - expect(second.value).toBe("https://contribute.freecodecamp.org/#/flight-manuals/moderator-handbook", - ); + expect(second.value).toBe("https://contribute.freecodecamp.org/#/flight-manuals/moderator-handbook"); expect(third.name).toBe("Contributing Guidelines"); expect(third.value).toBe("https://contribute.freecodecamp.org/"); expect(fourth.name).toBe("News Contributing"); - expect(fourth.value).toBe("https://www.freecodecamp.org/news/developer-news-style-guide/", - ); + expect(fourth.value).toBe("https://www.freecodecamp.org/news/developer-news-style-guide/"); expect(fifth.name).toBe("Pull Request Reviews"); - assert.equal( - fifth.value, - `[PRs Ready for Review](https://github.com/freeCodeCamp/freeCodeCamp/pulls?q=is%3Aopen+is%3Apr+-label%3A%22status%3A+blocked%22+-label%3A%22status%3A+merge+conflict%22+status%3Asuccess+draft%3Afalse)`, - ); + expect(fifth.value).toBe(`[PRs Ready for Review](https://github.com/freeCodeCamp/freeCodeCamp/pulls?q=is%3Aopen+is%3Apr+-label%3A%22status%3A+blocked%22+-label%3A%22status%3A+merge+conflict%22+status%3Asuccess+draft%3Afalse)`); }); }); diff --git a/test/commands/subcommands/github/handleAddLabels.spec.ts b/test/commands/subcommands/github/handleAddLabels.spec.ts index d1c7db56..7dbbab2f 100644 --- a/test/commands/subcommands/github/handleAddLabels.spec.ts +++ b/test/commands/subcommands/github/handleAddLabels.spec.ts @@ -6,25 +6,25 @@ import { handleAddLabels } describe("add labels handler", () => { it("does not allow non-moderators permission", () => { expect(handleAddLabels.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.SendMessages ]), + } as never)).toBeFalsy(); }); it("allows moderate members permission", () => { expect(handleAddLabels.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), + } as never)).toBeTruthy(); }); it("allows kick members permission", () => { expect(handleAddLabels.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.KickMembers ]), + } as never)).toBeTruthy(); }); it("allows ban members permission", () => { expect(handleAddLabels.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.BanMembers ]), + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/github/handleClose.spec.ts b/test/commands/subcommands/github/handleClose.spec.ts index 7d8924a1..609bc2c5 100644 --- a/test/commands/subcommands/github/handleClose.spec.ts +++ b/test/commands/subcommands/github/handleClose.spec.ts @@ -6,25 +6,25 @@ import { handleClose } describe("close handler", () => { it("does not allow non-moderators permission", () => { expect(handleClose.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.SendMessages ]), + } as never)).toBeFalsy(); }); it("allows moderate members permission", () => { expect(handleClose.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), + } as never)).toBeTruthy(); }); it("allows kick members permission", () => { expect(handleClose.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.KickMembers ]), + } as never)).toBeTruthy(); }); it("allows ban members permission", () => { expect(handleClose.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.BanMembers ]), + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/github/handleComment.spec.ts b/test/commands/subcommands/github/handleComment.spec.ts index e0cad131..684e961d 100644 --- a/test/commands/subcommands/github/handleComment.spec.ts +++ b/test/commands/subcommands/github/handleComment.spec.ts @@ -6,25 +6,25 @@ import { handleComment } describe("comment command", () => { it("does not allow non-moderators permission", () => { expect(handleComment.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.SendMessages ]), + } as never)).toBeFalsy(); }); it("allows moderate members permission", () => { expect(handleComment.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), + } as never)).toBeTruthy(); }); it("allows kick members permission", () => { expect(handleComment.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.KickMembers ]), + } as never)).toBeTruthy(); }); it("allows ban members permission", () => { expect(handleComment.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.BanMembers ]), + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/github/handleSyncLabels.spec.ts b/test/commands/subcommands/github/handleSyncLabels.spec.ts index 9a292dde..797e2f20 100644 --- a/test/commands/subcommands/github/handleSyncLabels.spec.ts +++ b/test/commands/subcommands/github/handleSyncLabels.spec.ts @@ -6,25 +6,25 @@ import { handleSyncLabels } describe("sync labels handler", () => { it("does not allow non-moderators permission", () => { expect(handleSyncLabels.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.SendMessages ]), + } as never)).toBeFalsy(); }); it("allows moderate members permission", () => { expect(handleSyncLabels.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), + } as never)).toBeTruthy(); }); it("allows kick members permission", () => { expect(handleSyncLabels.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.KickMembers ]), + } as never)).toBeTruthy(); }); it("allows ban members permission", () => { expect(handleSyncLabels.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.BanMembers ]), + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/management/handlePrivate.spec.ts b/test/commands/subcommands/management/handlePrivate.spec.ts index 0ea9c7b1..6adb5fe1 100644 --- a/test/commands/subcommands/management/handlePrivate.spec.ts +++ b/test/commands/subcommands/management/handlePrivate.spec.ts @@ -6,25 +6,25 @@ import { handlePrivate } describe("handlePrivate command", () => { it("does not allow non-moderators permission", () => { expect(handlePrivate.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.SendMessages ]), + } as never)).toBeFalsy(); }); it("allows moderate members permission", () => { expect(handlePrivate.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), + } as never)).toBeTruthy(); }); it("allows kick members permission", () => { expect(handlePrivate.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.KickMembers ]), + } as never)).toBeTruthy(); }); it("allows ban members permission", () => { expect(handlePrivate.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.BanMembers ]), + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/management/handleRole.spec.ts b/test/commands/subcommands/management/handleRole.spec.ts index 2f8e43bf..4ba57330 100644 --- a/test/commands/subcommands/management/handleRole.spec.ts +++ b/test/commands/subcommands/management/handleRole.spec.ts @@ -6,31 +6,31 @@ import { handleRole } describe("handleRole command", () => { it("does not allow non-moderators permission", () => { expect(handleRole.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.SendMessages ]), + } as never)).toBeFalsy(); }); it("does not allow moderate members permission", () => { expect(handleRole.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), + } as never)).toBeFalsy(); }); it("does not allow kick members permission", () => { expect(handleRole.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.KickMembers ]), + } as never)).toBeFalsy(); }); it("does not allow ban members permission", () => { expect(handleRole.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.BanMembers ]), + } as never)).toBeFalsy(); }); it("allows manage server permission", () => { expect(handleRole.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.ManageGuild ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.ManageGuild ]), + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/moderation/handleBan.spec.ts b/test/commands/subcommands/moderation/handleBan.spec.ts index 7fcfbb04..de2fe966 100644 --- a/test/commands/subcommands/moderation/handleBan.spec.ts +++ b/test/commands/subcommands/moderation/handleBan.spec.ts @@ -6,25 +6,25 @@ import { handleBan } describe("ban handler", () => { it("does not allow non-moderators permission", () => { expect(handleBan.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.SendMessages ]), + } as never)).toBeFalsy(); }); it("does not allow moderate members permission", () => { expect(handleBan.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), + } as never)).toBeFalsy(); }); it("does not allow kick members permission", () => { expect(handleBan.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.KickMembers ]), + } as never)).toBeFalsy(); }); it("allows ban members permission", () => { expect(handleBan.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.BanMembers ]), + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/moderation/handleHistory.spec.ts b/test/commands/subcommands/moderation/handleHistory.spec.ts index 4a6b51a2..1e86bd23 100644 --- a/test/commands/subcommands/moderation/handleHistory.spec.ts +++ b/test/commands/subcommands/moderation/handleHistory.spec.ts @@ -6,25 +6,25 @@ import { handleHistory } describe("history handler", () => { it("does not allow non-moderators permission", () => { expect(handleHistory.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.SendMessages ]), + } as never)).toBeFalsy(); }); it("allows moderate members permission", () => { expect(handleHistory.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), + } as never)).toBeTruthy(); }); it("allows kick members permission", () => { expect(handleHistory.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.KickMembers ]), + } as never)).toBeTruthy(); }); it("allows ban members permission", () => { expect(handleHistory.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.BanMembers ]), + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/moderation/handleKick.spec.ts b/test/commands/subcommands/moderation/handleKick.spec.ts index e08052b6..ff35f069 100644 --- a/test/commands/subcommands/moderation/handleKick.spec.ts +++ b/test/commands/subcommands/moderation/handleKick.spec.ts @@ -6,25 +6,25 @@ import { handleKick } describe("kick handler", () => { it("does not allow non-moderators permission", () => { expect(handleKick.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.SendMessages ]), + } as never)).toBeFalsy(); }); it("does not allow moderate members permission", () => { expect(handleKick.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), + } as never)).toBeFalsy(); }); it("allows kick members permission", () => { expect(handleKick.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.KickMembers ]), + } as never)).toBeTruthy(); }); it("does not allow ban members permission", () => { expect(handleKick.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.BanMembers ]), + } as never)).toBeFalsy(); }); }); diff --git a/test/commands/subcommands/moderation/handleMute.spec.ts b/test/commands/subcommands/moderation/handleMute.spec.ts index f0d5e92a..cb0944af 100644 --- a/test/commands/subcommands/moderation/handleMute.spec.ts +++ b/test/commands/subcommands/moderation/handleMute.spec.ts @@ -6,25 +6,25 @@ import { handleMute } describe("mute handler", () => { it("does not allow non-moderators permission", () => { expect(handleMute.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.SendMessages ]), + } as never)).toBeFalsy(); }); it("allows moderate members permission", () => { expect(handleMute.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), + } as never)).toBeTruthy(); }); it("does not allow kick members permission", () => { expect(handleMute.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.KickMembers ]), + } as never)).toBeFalsy(); }); it("does not allow ban members permission", () => { expect(handleMute.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.BanMembers ]), + } as never)).toBeFalsy(); }); }); diff --git a/test/commands/subcommands/moderation/handlePrune.spec.ts b/test/commands/subcommands/moderation/handlePrune.spec.ts index 9bb11369..f5bb94d7 100644 --- a/test/commands/subcommands/moderation/handlePrune.spec.ts +++ b/test/commands/subcommands/moderation/handlePrune.spec.ts @@ -6,31 +6,31 @@ import { handlePrune } describe("prune handler", () => { it("does not allow non-moderators permission", () => { expect(handlePrune.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.SendMessages ]), + } as never)).toBeFalsy(); }); it("allows manage messages permission", () => { expect(handlePrune.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.ManageMessages ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.ManageMessages ]), + } as never)).toBeTruthy(); }); it("does not allow moderate members permission", () => { expect(handlePrune.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), + } as never)).toBeFalsy(); }); it("does not allow kick members permission", () => { expect(handlePrune.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.KickMembers ]), + } as never)).toBeFalsy(); }); it("does not allow ban members permission", () => { expect(handlePrune.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.BanMembers ]), + } as never)).toBeFalsy(); }); }); diff --git a/test/commands/subcommands/moderation/handleUnban.spec.ts b/test/commands/subcommands/moderation/handleUnban.spec.ts index 8a0da9cb..18ffda82 100644 --- a/test/commands/subcommands/moderation/handleUnban.spec.ts +++ b/test/commands/subcommands/moderation/handleUnban.spec.ts @@ -6,25 +6,25 @@ import { handleUnban } describe("unban handler", () => { it("does not allow non-moderators permission", () => { expect(handleUnban.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.SendMessages ]), + } as never)).toBeFalsy(); }); it("does not allow moderate members permission", () => { expect(handleUnban.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.ModerateMembers ]), + } as never)).toBeFalsy(); }); it("does not allow kick members permission", () => { expect(handleUnban.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.KickMembers ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.KickMembers ]), + } as never)).toBeFalsy(); }); it("allows ban members permission", () => { expect(handleUnban.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.BanMembers ]), - } as never)).toBeTruthy(); + permissions: new Set([ PermissionFlagsBits.BanMembers ]), + } as never)).toBeTruthy(); }); }); diff --git a/test/commands/subcommands/moderation/handleWarn.spec.ts b/test/commands/subcommands/moderation/handleWarn.spec.ts index 78c46f93..f4d5582c 100644 --- a/test/commands/subcommands/moderation/handleWarn.spec.ts +++ b/test/commands/subcommands/moderation/handleWarn.spec.ts @@ -6,8 +6,8 @@ import { handleWarn } describe("warn handler", () => { it("does not allow non-moderators permission", () => { expect(handleWarn.permissionValidator({ - permissions: new Set([ PermissionFlagsBits.SendMessages ]), - } as never)).toBeFalsy(); + permissions: new Set([ PermissionFlagsBits.SendMessages ]), + } as never)).toBeFalsy(); }); it("allows moderate members permission", () => { diff --git a/test/commands/userSettings.spec.ts b/test/commands/userSettings.spec.ts index a5b577d6..6943e6fc 100644 --- a/test/commands/userSettings.spec.ts +++ b/test/commands/userSettings.spec.ts @@ -3,6 +3,7 @@ import { userSettings } from "../../src/commands/userSettings.js"; describe("user settings command", () => { it("exists", () => { - assert.exists(userSettings); + expect(userSettings).toBeDefined(); + expect(userSettings).not.toBeNull(); }); }); diff --git a/test/config/intentOptions.spec.ts b/test/config/intentOptions.spec.ts index fa90b991..6e9eebda 100644 --- a/test/config/intentOptions.spec.ts +++ b/test/config/intentOptions.spec.ts @@ -4,12 +4,12 @@ import { intentOptions } from "../../src/config/intentOptions.js"; describe("intentOptions", () => { it("all necessary intents should be declared.", () => { - assert.include(intentOptions, GatewayIntentBits.Guilds); - assert.include(intentOptions, GatewayIntentBits.GuildMembers); - assert.include(intentOptions, GatewayIntentBits.GuildModeration); - assert.include(intentOptions, GatewayIntentBits.GuildMessages); - assert.include(intentOptions, GatewayIntentBits.GuildMessageReactions); - assert.include(intentOptions, GatewayIntentBits.MessageContent); - assert.include(intentOptions, GatewayIntentBits.GuildVoiceStates); + expect(intentOptions).toContain(GatewayIntentBits.Guilds); + expect(intentOptions).toContain(GatewayIntentBits.GuildMembers); + expect(intentOptions).toContain(GatewayIntentBits.GuildModeration); + expect(intentOptions).toContain(GatewayIntentBits.GuildMessages); + expect(intentOptions).toContain(GatewayIntentBits.GuildMessageReactions); + expect(intentOptions).toContain(GatewayIntentBits.MessageContent); + expect(intentOptions).toContain(GatewayIntentBits.GuildVoiceStates); }); }); diff --git a/test/config/pullComments.spec.ts b/test/config/pullComments.spec.ts index dec1dd13..06ffca8e 100644 --- a/test/config/pullComments.spec.ts +++ b/test/config/pullComments.spec.ts @@ -4,11 +4,7 @@ import { pullComments } from "../../src/config/pullComments.js"; describe("pullComments", () => { it("all keys should be under 100 characters (Discord limitation)", () => { for (const object of pullComments) { - assert.isBelow( - object.key.length, - 100, - `${object.key} is ${object.key.length} characters long`, - ); + expect(object.key.length, `${object.key} is ${object.key.length} characters long`).toBeLessThan(100); } }); }); diff --git a/test/config/roles.spec.ts b/test/config/roles.spec.ts index 6d564d5b..f36741ac 100644 --- a/test/config/roles.spec.ts +++ b/test/config/roles.spec.ts @@ -3,10 +3,10 @@ import { authorRoleId, supporterRoleId } from "../../src/config/roles.js"; describe("roles config", () => { it("supporter role should be id", () => { - assert.match(supporterRoleId, /^\d{16,19}$/); + expect(supporterRoleId).toMatch(/^\d{16,19}$/); }); it("author role should be id", () => { - assert.match(authorRoleId, /^\d{16,19}$/); + expect(authorRoleId).toMatch(/^\d{16,19}$/); }); }); diff --git a/test/config/tags.spec.ts b/test/config/tags.spec.ts index 025bae6c..b22527f9 100644 --- a/test/config/tags.spec.ts +++ b/test/config/tags.spec.ts @@ -3,14 +3,10 @@ import { tags } from "../../src/config/tags.js"; describe("tags", () => { it("quantity", () => { - assert.isAtMost(tags.length, 25, "Cannot have more than 25 tags."); + expect(tags.length, "Cannot have more than 25 tags.").toBeLessThanOrEqual(25); }); it.each(tags)(`%s should be formatted correctly.`, (tag) => { - assert.isAtMost(tag.name.length, 100, "Name is too long."); - assert.isAtMost( - tag.message.length, - 4000, - "Message exceeds Discord limits.", - ); + expect(tag.name.length, "Name is too long.").toBeLessThanOrEqual(100); + expect(tag.message.length, "Message exceeds Discord limits.").toBeLessThanOrEqual(4000); }); }); diff --git a/test/config/truisms.spec.ts b/test/config/truisms.spec.ts index eeefa941..649b0f41 100644 --- a/test/config/truisms.spec.ts +++ b/test/config/truisms.spec.ts @@ -4,7 +4,7 @@ import { truisms } from "../../src/config/truisms.js"; describe("truisms", () => { it("truisms should be formatted correctly.", () => { for (const truism of truisms) { - assert.isAtMost(truism.length, 4000, "Truism exceeds Discord limits."); + expect(truism.length, "Truism exceeds Discord limits.").toBeLessThanOrEqual(4000); } }); }); diff --git a/test/events/registerEvents.spec.ts b/test/events/registerEvents.spec.ts index d669fb11..869dad05 100644 --- a/test/events/registerEvents.spec.ts +++ b/test/events/registerEvents.spec.ts @@ -1,4 +1,4 @@ -import { describe, expect, it, vi, expect } from "vitest"; +import { describe, expect, it, vi } from "vitest"; import { registerEvents } from "../../src/events/registerEvents.js"; vi.mock("discord.js"); @@ -17,13 +17,13 @@ describe("registerEvents", () => { it("should register all events", async() => { await registerEvents(bot as never); - assert.property(bot.events, "ready"); - assert.property(bot.events, "messageCreate"); - assert.property(bot.events, "messageUpdate"); - assert.property(bot.events, "messageDelete"); - assert.property(bot.events, "interactionCreate"); - assert.property(bot.events, "threadCreate"); - assert.property(bot.events, "guildMemberAdd"); - assert.property(bot.events, "guildMemberRemove"); + expect(bot.events).toHaveProperty("ready"); + expect(bot.events).toHaveProperty("messageCreate"); + expect(bot.events).toHaveProperty("messageUpdate"); + expect(bot.events).toHaveProperty("messageDelete"); + expect(bot.events).toHaveProperty("interactionCreate"); + expect(bot.events).toHaveProperty("threadCreate"); + expect(bot.events).toHaveProperty("guildMemberAdd"); + expect(bot.events).toHaveProperty("guildMemberRemove"); }); }); diff --git a/test/modules/addFormatting.spec.ts b/test/modules/addFormatting.spec.ts index 7cb84095..216e54dc 100644 --- a/test/modules/addFormatting.spec.ts +++ b/test/modules/addFormatting.spec.ts @@ -51,7 +51,7 @@ describe("addFormatting", () => { it("should format PHP", async() => { const content = ``; const output = await addFormatting(typeCoerce({ content })); - expect(output).toBe( `\`\`\`PHP\n\n\`\`\``); + expect(output).toBe(`\`\`\`PHP\n\n\`\`\``); }); /* @@ -66,8 +66,7 @@ describe("addFormatting", () => { it("should format Markdown", async() => { const content = `# Hello World\n\n## Subheading\n\n- List Item`; const output = await addFormatting(typeCoerce({ content })); - expect(output).toBe(`\`\`\`markdown\n# Hello World\n\n## Subheading\n\n- List Item\n\`\`\``, - ); + expect(output).toBe(`\`\`\`markdown\n# Hello World\n\n## Subheading\n\n- List Item\n\`\`\``); }); it("should format JSON", async() => { @@ -79,7 +78,6 @@ describe("addFormatting", () => { it("should format HTTP", async() => { const content = `GET / HTTP/1.1\nHost: example.com\n\n`; const output = await addFormatting(typeCoerce({ content })); - expect(output).toBe(`\`\`\`HTTP\nGET / HTTP/1.1\nHost: example.com\n\n\`\`\``, - ); + expect(output).toBe(`\`\`\`HTTP\nGET / HTTP/1.1\nHost: example.com\n\n\`\`\``); }); }); diff --git a/test/modules/closePrivateChannel.spec.ts b/test/modules/closePrivateChannel.spec.ts index 11532806..d6efba8e 100644 --- a/test/modules/closePrivateChannel.spec.ts +++ b/test/modules/closePrivateChannel.spec.ts @@ -3,7 +3,7 @@ import { closePrivateChannel } from "../../src/modules/closePrivateChannel.js"; describe("closePrivateChannel", () => { it("is defined", () => { - expect(closePrivateChannel,"closePrivateChannel is not defined").toBeDefined(); + expect(closePrivateChannel, "closePrivateChannel is not defined").toBeDefined(); expect(closePrivateChannel, "closePrivateChannel is not a function").toBeTypeOf("function"); }); }); diff --git a/test/modules/formatCodeblock.spec.ts b/test/modules/formatCodeblock.spec.ts index 524f2b91..c6c46a32 100644 --- a/test/modules/formatCodeblock.spec.ts +++ b/test/modules/formatCodeblock.spec.ts @@ -10,12 +10,12 @@ describe("formatCodeBlock", () => { it("formats string as expected", () => { const code = "const foo = 'bar';"; const lang = "ts"; - assert.equal(formatCodeBlock(lang, code), "```ts\nconst foo = 'bar';\n```"); + expect(formatCodeBlock(lang, code)).toBe("```ts\nconst foo = 'bar';\n```"); }); it("does not add trailing new line if present", () => { const code = "const foo = 'bar';\n"; const lang = "ts"; - assert.equal(formatCodeBlock(lang, code), "```ts\nconst foo = 'bar';\n```"); + expect(formatCodeBlock(lang, code)).toBe("```ts\nconst foo = 'bar';\n```"); }); }); diff --git a/test/modules/formatter.spec.ts b/test/modules/formatter.spec.ts index 5217ec8f..29da5405 100644 --- a/test/modules/formatter.spec.ts +++ b/test/modules/formatter.spec.ts @@ -3,7 +3,7 @@ import { formatter } from "../../src/modules/formatter.js"; describe("formatter", () => { it("is defined", () => { - expect(formatter,"formatter is not defined").toBeDefined(); + expect(formatter, "formatter is not defined").toBeDefined(); expect(formatter, "formatter is not a function").toBeTypeOf("function"); }); @@ -11,8 +11,7 @@ describe("formatter", () => { const content = `

Hello world this is a very long string from Naomi to force a line break.

`; const output = await formatter(content, "html"); - expect(output).toBe(`
\n

\n Hello world this is a very long string from Naomi to force a line break.\n

\n
\n`, - ); + expect(output).toBe(`
\n

\n Hello world this is a very long string from Naomi to force a line break.\n

\n
\n`); }); it("should format CSS", async() => { @@ -30,37 +29,36 @@ describe("formatter", () => { it("should format JS", async() => { const content = "const foo = 'bar';"; const output = await formatter(content, "js"); - expect(output).toBe( `const foo = "bar";\n`); + expect(output).toBe(`const foo = "bar";\n`); }); it("should format TS", async() => { const content = "const foo: string = 'bar';"; const output = await formatter(content, "ts"); - expect(output).toBe( `const foo: string = "bar";\n`); + expect(output).toBe(`const foo: string = "bar";\n`); }); it("should format JSX", async() => { const content = `let jsxElement=(

Welcome To freeCodeCamp

Hello World

);`; const output = await formatter(content, "js"); - expect(output).toBe(`let jsxElement = (\n
\n

Welcome To freeCodeCamp

\n

Hello World

\n
\n);\n`, - ); + expect(output).toBe(`let jsxElement = (\n
\n

Welcome To freeCodeCamp

\n

Hello World

\n
\n);\n`); }); it("should format Markdown", async() => { const content = `# Hello World\n\n## Subheading\n\n- List Item`; const output = await formatter(content, "markdown"); - expect(output).toBe( `# Hello World\n\n## Subheading\n\n- List Item\n`); + expect(output).toBe(`# Hello World\n\n## Subheading\n\n- List Item\n`); }); it("should format JSON", async() => { const content = `{"name": "Naomi"}`; const output = await formatter(content, "json"); - expect(output).toBe( `{ "name": "Naomi" }\n`); + expect(output).toBe(`{ "name": "Naomi" }\n`); }); it("should format YAML", async() => { const content = `name: Naomi\nuse:\n - Naomi`; const output = await formatter(content, "yaml"); - expect(output).toBe( `name: Naomi\nuse:\n - Naomi\n`); + expect(output).toBe(`name: Naomi\nuse:\n - Naomi\n`); }); }); diff --git a/test/modules/generateConfig.spec.ts b/test/modules/generateConfig.spec.ts index 48fb647b..08e14ed6 100644 --- a/test/modules/generateConfig.spec.ts +++ b/test/modules/generateConfig.spec.ts @@ -10,7 +10,7 @@ describe("generateConfig", () => { it("should throw an error on missing environment", () => { delete process.env.TOKEN; - assert.throw(generateConfig, "Missing required config variables"); + expect(generateConfig).toThrow("Missing required config variables"); }); it("should return expected object on valid environment", () => { @@ -46,9 +46,7 @@ describe("generateConfig", () => { expect(result.welcomeHook.url).toBe(process.env.WELCOME_HOOK); expect(result.githubToken).toBe(process.env.GITHUB_TOKEN); expect(result.ghostKey).toBe(process.env.GHOST_KEY); - assert.equal(result.githubAppId, - Number.parseInt(process.env.GITHUB_APP_ID, 10)); - expect(result.githubInstallationId).toBe(Number.parseInt(process.env.GITHUB_INSTALLATION_ID, 10), - ); + expect(result.githubAppId).toBe(Number.parseInt(process.env.GITHUB_APP_ID, 10)); + expect(result.githubInstallationId).toBe(Number.parseInt(process.env.GITHUB_INSTALLATION_ID, 10)); }); }); diff --git a/test/modules/generateLogs.spec.ts b/test/modules/generateLogs.spec.ts index 1e97e418..1d4ad485 100644 --- a/test/modules/generateLogs.spec.ts +++ b/test/modules/generateLogs.spec.ts @@ -23,6 +23,6 @@ describe("generateLogs", () => { const status = await stat(logPath).catch(() => { return null; }); - expect(status, "Log file was not deleted.").toBeNull(); + expect(status, "Log file was not deleted.").toBeNull(); }); }); diff --git a/test/modules/generateProfileImage.spec.ts b/test/modules/generateProfileImage.spec.ts index 0881130c..1dae3b2f 100644 --- a/test/modules/generateProfileImage.spec.ts +++ b/test/modules/generateProfileImage.spec.ts @@ -4,10 +4,10 @@ import { generateProfileImage } describe("generateProfileImage", () => { it("is defined", () => { - assert.isDefined( + expect( generateProfileImage, "generateProfileImage is not defined", - ); + ).toBeDefined(); expect(generateProfileImage, "generateProfileImage is not a function").toBeTypeOf("function"); }); }); diff --git a/test/modules/isSupportedByPrettier.spec.ts b/test/modules/isSupportedByPrettier.spec.ts index 958a6fb3..68611992 100644 --- a/test/modules/isSupportedByPrettier.spec.ts +++ b/test/modules/isSupportedByPrettier.spec.ts @@ -4,10 +4,10 @@ import { isSupportedByPrettier } from describe("isSupportedByPrettier", () => { it("is defined", () => { - assert.isDefined( + expect( isSupportedByPrettier, "isSupportedByPrettier is not defined", - ); + ).toBeDefined(); expect(isSupportedByPrettier, "isSupportedByPrettier is not a function").toBeTypeOf("function"); }); diff --git a/test/modules/settingsValidation.spec.ts b/test/modules/settingsValidation.spec.ts index 5ec273cd..46624386 100644 --- a/test/modules/settingsValidation.spec.ts +++ b/test/modules/settingsValidation.spec.ts @@ -6,10 +6,12 @@ import { describe("settings validation", () => { it("validateColour", () => { - assert.exists(validateColour); + expect(validateColour).toBeDefined(); + expect(validateColour).not.toBeNull(); }); it("validateImage", () => { - assert.exists(validateImage); + expect(validateImage).toBeDefined(); + expect(validateImage).not.toBeNull(); }); }); diff --git a/test/utils/calculateMilliseconds.spec.ts b/test/utils/calculateMilliseconds.spec.ts index e980ad6d..c98e2c0d 100644 --- a/test/utils/calculateMilliseconds.spec.ts +++ b/test/utils/calculateMilliseconds.spec.ts @@ -6,28 +6,28 @@ import { describe("calculateMilliseconds", () => { it("10 seconds equals 10,000 milliseconds", () => { - assert.equal(calculateMilliseconds(10, "seconds"), 10_000); + expect(calculateMilliseconds(10, "seconds")).toBe(10_000); }); it("10 minutes equals 60,000 milliseconds", () => { - assert.equal(calculateMilliseconds(10, "minutes"), 600_000); + expect(calculateMilliseconds(10, "minutes")).toBe(600_000); }); it("10 hours equals 36,000,000 milliseconds", () => { - assert.equal(calculateMilliseconds(10, "hours"), 36_000_000); + expect(calculateMilliseconds(10, "hours")).toBe(36_000_000); }); it("10 days equals 864,000,000 milliseconds", () => { - assert.equal(calculateMilliseconds(10, "days"), 864_000_000); + expect(calculateMilliseconds(10, "days")).toBe(864_000_000); }); it("10 weeks equals 6,048,000,000 milliseconds", () => { - assert.equal(calculateMilliseconds(10, "weeks"), 6_048_000_000); + expect(calculateMilliseconds(10, "weeks")).toBe(6_048_000_000); }); it("should handle invalid time units", () => { // @ts-expect-error intentionally ignoring type for testing - assert.equal(calculateMilliseconds(10, "invalid"), 0); + expect(calculateMilliseconds(10, "invalid")).toBe(0); }); }); diff --git a/test/utils/customSubstring.spec.ts b/test/utils/customSubstring.spec.ts index aa986a68..2d6d4709 100644 --- a/test/utils/customSubstring.spec.ts +++ b/test/utils/customSubstring.spec.ts @@ -3,17 +3,17 @@ import { customSubstring } from "../../src/utils/customSubstring.js"; describe("customSubstring", () => { it("is defined", () => { - expect(customSubstring,"customSubstring is not defined").toBeDefined(); + expect(customSubstring, "customSubstring is not defined").toBeDefined(); expect(customSubstring, "customSubstring is not a function").toBeTypeOf("function"); }); it("returns original string when shorter", () => { - assert.equal(customSubstring("long", 9), "long"); - assert.equal(customSubstring("short", 5), "short"); + expect(customSubstring("long", 9)).toBe(9); + expect(customSubstring("short", 5)).toBe(5); }); it("returns truncated string when longer", () => { - assert.equal(customSubstring("longer", 2), "..."); - assert.equal(customSubstring("longer", 5), "lo..."); + expect(customSubstring("longer", 2)).toBe("..."); + expect(customSubstring("longer", 5)).toBe("lo..."); }); }); diff --git a/test/utils/errorHandler.spec.ts b/test/utils/errorHandler.spec.ts index d797af60..0e096704 100644 --- a/test/utils/errorHandler.spec.ts +++ b/test/utils/errorHandler.spec.ts @@ -3,7 +3,7 @@ import { errorHandler } from "../../src/utils/errorHandler.js"; describe("errorHandler", () => { it("is defined", () => { - expect(errorHandler,"errorHandler is not defined").toBeDefined(); + expect(errorHandler, "errorHandler is not defined").toBeDefined(); expect(errorHandler, "errorHandler is not a function").toBeTypeOf("function"); }); }); diff --git a/test/utils/fetchLearnRecord.spec.ts b/test/utils/fetchLearnRecord.spec.ts index 0829a37e..ec017f65 100644 --- a/test/utils/fetchLearnRecord.spec.ts +++ b/test/utils/fetchLearnRecord.spec.ts @@ -3,7 +3,7 @@ import { fetchLearnRecord } from "../../src/utils/fetchLearnRecord.js"; describe("fetchLearnRecord", () => { it("is defined", () => { - expect(fetchLearnRecord,"fetchLearnRecord is not defined").toBeDefined(); + expect(fetchLearnRecord, "fetchLearnRecord is not defined").toBeDefined(); expect(fetchLearnRecord, "fetchLearnRecord is not a function").toBeTypeOf("function"); }); }); diff --git a/test/utils/formatText.spec.ts b/test/utils/formatText.spec.ts index b314a241..740e3943 100644 --- a/test/utils/formatText.spec.ts +++ b/test/utils/formatText.spec.ts @@ -7,43 +7,31 @@ describe("formatTextToTable", () => { expect(formatTextToTable, "formatTextToTable is not a function!").toBeTypeOf("function"); }); it("given empty array returns empty string", () => { - assert.deepEqual( - formatTextToTable([]), - "", - "function did not return empty string", - ); + expect(formatTextToTable([]), "function did not return empty string").toBe(""); }); it("given 2d empty array, returns empty string", () => { - assert.deepEqual( - formatTextToTable([ [] ]), - "", - "function did not return empty string", - ); + expect(formatTextToTable([ [] ]), "function did not return empty string").toBe(""); }); it("given 2d empty array, with separate defined headers, returns headers", () => { - assert.deepEqual( + expect( formatTextToTable([], { headers: [ "one", "two" ], - }), - "one | two\n---------", - "did not return headers", - ); + }), "did not return headers", + ).toBe("one | two\n---------"); }); it(`given 2d empty array, with separate defined headers and a custom column delimiter, returns headers`, () => { - assert.deepEqual( + expect( formatTextToTable([], { columnDelimiter: "l", headers: [ "one", "two" ], - }), - "one l two\n---------", - "did not return headers", - ); + }), "did not return headers", + ).toBe("one l two\n---------"); }); it(`given 2d array, with separate defined headers and a custom column delimiter, returns table`, () => { - assert.deepEqual( + expect( formatTextToTable( [ [ "chicken", "egg" ], @@ -53,24 +41,20 @@ describe("formatTextToTable", () => { columnDelimiter: "l", headers: [ "one", "two" ], }, - ), - "one l two \n---------------\nchicken l egg \ntrue l false", - "did not return headers", - ); + ), "did not return headers", + ).toBe("one l two \n---------------\nchicken l egg \ntrue l false"); }); it(`given 2d empty array, with empty separate defined headers, returns empty string`, () => { - assert.deepEqual( + expect( formatTextToTable([ [] ], { headers: [], - }), - "", - "did not return empty string", - ); + }), "did not return empty string", + ).toBe(""); }); it(`given 2d array with data with headers and custom row delimiter, display table`, () => { - assert.deepEqual( + expect( formatTextToTable( [ [ "brad", "100" ], @@ -80,13 +64,11 @@ describe("formatTextToTable", () => { headers: [ "name", "score" ], rowDelimiter: "_", }, - ), - "name | score\n____________\nbrad | 100 \nfoo | 50 ", - "did not return table", - ); + ), "did not return table", + ).toBe("name | score\n____________\nbrad | 100 \nfoo | 50 "); }); it("given 2d array with data with long headers, display table", () => { - assert.deepEqual( + expect( formatTextToTable( [ [ "brad", "100" ], @@ -95,9 +77,9 @@ describe("formatTextToTable", () => { { headers: [ "name", "aggeeeeeeeee" ], }, - ), + ), "did not return table", + ).toBe( `name | aggeeeeeeeee\n-------------------\nbrad | 100 \nfoo | bar `, - "did not return table", ); }); }); diff --git a/test/utils/generateDiff.spec.ts b/test/utils/generateDiff.spec.ts index 615d5e09..ef44a091 100644 --- a/test/utils/generateDiff.spec.ts +++ b/test/utils/generateDiff.spec.ts @@ -3,7 +3,7 @@ import { generateDiff } from "../../src/utils/generateDiff.js"; describe("generateDiff", () => { it("is defined", () => { - expect(generateDiff,"generateDiff is not defined").toBeDefined(); + expect(generateDiff, "generateDiff is not defined").toBeDefined(); expect(generateDiff, "generateDiff is not a function").toBeTypeOf("function"); }); diff --git a/test/utils/isModerator.spec.ts b/test/utils/isModerator.spec.ts index d60913f9..acb727ed 100644 --- a/test/utils/isModerator.spec.ts +++ b/test/utils/isModerator.spec.ts @@ -38,10 +38,7 @@ describe("isModerator", () => { expect(isModerator(kickMembersSet), "isModerator returned false").toBeTruthy(); expect(isModerator(banMembersSet), "isModerator returned false").toBeTruthy(); expect(isModerator(manageMessagesSet), "isModerator returned false").toBeTruthy(); - assert.isTrue( - isModerator(moderateMembersSet), - "isModerator returned false", - ); + expect(isModerator(moderateMembersSet), "isModerator returned false").toBeTruthy(); }); it("returns false when not moderator", () => { diff --git a/test/utils/loadCommands.spec.ts b/test/utils/loadCommands.spec.ts index 95b1a45a..622a65a6 100644 --- a/test/utils/loadCommands.spec.ts +++ b/test/utils/loadCommands.spec.ts @@ -13,7 +13,7 @@ describe("loadCommands", () => { it("returns array of commands", async() => { const result = await loadCommands({} as ExtendedClient); - assert.isArray(result, "loadCommands did not return an array"); + expect(result, "loadCommands did not return an array").toBeInstanceOf(Array); }); it("returns the expected command list", async() => { @@ -31,7 +31,7 @@ describe("loadCommands", () => { bot.commands = await loadCommands(bot as never); expect(bot.commands).toHaveLength(commandNames.length); for (const name of commandNames) { - assert.exists( + expect( bot.commands.find( (command) => { return command.data.name. @@ -49,7 +49,23 @@ describe("loadCommands", () => { ) === name; }, ), - ); + ).toBeDefined(); + expect( + bot.commands.find((command) => { + return ( + command.data.name. + split("-"). + // eslint-disable-next-line unicorn/no-array-reduce + reduce((accumulator, element, index) => { + return index === 0 + ? accumulator + element + : accumulator + + (element[0].toUpperCase() + + element.slice(1).toLowerCase()); + }, "") === name + ); + }), + ).not.toBeNull(); } }); }); diff --git a/test/utils/loadContexts.spec.ts b/test/utils/loadContexts.spec.ts index 66d64309..2ed4788c 100644 --- a/test/utils/loadContexts.spec.ts +++ b/test/utils/loadContexts.spec.ts @@ -7,13 +7,13 @@ import type { ExtendedClient } from "../../src/interfaces/extendedClient.js"; describe("loadContexts", () => { it("is defined", () => { - expect(loadContexts,"loadContexts is not defined").toBeDefined(); + expect(loadContexts, "loadContexts is not defined").toBeDefined(); expect(loadContexts, "loadContexts is not a function").toBeTypeOf("function"); }); it("returns array of commands", async() => { const result = await loadContexts({} as ExtendedClient); - assert.isArray(result, "loadContexts did not return an array"); + expect(result, "loadContexts did not return an array").toBeInstanceOf(Array); }); it("returns the expected command list", async() => { @@ -23,11 +23,16 @@ describe("loadContexts", () => { return file.split(".")[0]; }); bot.contexts = await loadContexts(bot as never); - expect(bot.contexts.length).toBe(contextNames.length); + expect(bot.contexts).toHaveLength(contextNames.length); for (const name of contextNames) { - assert.exists(bot.contexts.find((context) => { + expect(bot.contexts.find((context) => { return context.data.name === name; - })); + })).toBeDefined(); + expect( + bot.contexts.find((context) => { + return context.data.name === name; + }), + ).not.toBeNull(); } }); }); diff --git a/test/utils/loadQuotes.spec.ts b/test/utils/loadQuotes.spec.ts index b4d8953b..36014d0e 100644 --- a/test/utils/loadQuotes.spec.ts +++ b/test/utils/loadQuotes.spec.ts @@ -4,25 +4,17 @@ import type { ExtendedClient } from "../../src/interfaces/extendedClient.js"; describe("loadQuotes", () => { it("is defined", () => { - expect(loadQuotes,"loadQuotes is not defined").toBeDefined(); + expect(loadQuotes, "loadQuotes is not defined").toBeDefined(); expect(loadQuotes, "loadQuotes is not a function").toBeTypeOf("function"); }); it("returns the expected data structure", async() => { const quotes = await loadQuotes({} as ExtendedClient); expect(quotes, "quotes is not defined").toHaveProperty("motivationalQuotes"); - assert.isArray(quotes.motivationalQuotes, "quotes is not an array"); - assert.property( - quotes.motivationalQuotes[0], - "quote", - "quotes are not in correct structure", - ); - assert.property( - quotes.motivationalQuotes[0], - "author", - "quotes are not in correct structure", - ); + expect(quotes.motivationalQuotes, "quotes is not an array").toBeInstanceOf(Array); + expect(quotes.motivationalQuotes[0], "quotes are not in correct structure").toHaveProperty("quote"); + expect(quotes.motivationalQuotes[0], "quotes are not in correct structure").toHaveProperty("author"); expect(quotes, "compliments is not defined").toHaveProperty("compliments"); - assert.isArray(quotes.compliments, "compliments is not an array"); + expect(quotes.compliments, "compliments is not an array").toBeInstanceOf(Array); }); }); diff --git a/test/utils/logHandler.spec.ts b/test/utils/logHandler.spec.ts index 5ff0c3e8..edea1e4e 100644 --- a/test/utils/logHandler.spec.ts +++ b/test/utils/logHandler.spec.ts @@ -3,12 +3,12 @@ import { logHandler } from "../../src/utils/logHandler.js"; describe("logHandler", () => { it("is defined", () => { - expect(logHandler,"logHandler is not defined").toBeDefined(); + expect(logHandler, "logHandler is not defined").toBeDefined(); expect(logHandler).toBeTypeOf("object", "logHandler is not an object"); }); it("has log function", () => { - expect(logHandler.log,"log is not defined").toBeDefined(); + expect(logHandler.log, "log is not defined").toBeDefined(); expect(logHandler.log, "log is not a function").toBeTypeOf("function"); }); }); diff --git a/test/utils/registerCommands.spec.ts b/test/utils/registerCommands.spec.ts index ba24471f..880eb1b7 100644 --- a/test/utils/registerCommands.spec.ts +++ b/test/utils/registerCommands.spec.ts @@ -28,19 +28,13 @@ describe("registerCommands", () => { bot as never, MockRest as never, )) as never as MockRest; - assert.isNotNull(result); + expect(result).not.toBeNull(); expect(result.requests).toHaveLength(1); const request = result.requests[0]; - assert.strictEqual(request.method, "PUT"); - assert.strictEqual( - request.route, - "/applications/user/guilds/home/commands", - ); - assert.deepEqual( - request.body, - bot.commands.map((c) => { - return c.data.toJSON(); - }) as never, - ); + expect(request.method).toBe("PUT"); + expect(request.route).toBe("/applications/user/guilds/home/commands"); + expect(request.body).toBe(bot.commands.map((c) => { + return c.data.toJSON(); + }) as never); }); });