Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/commands/author.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
80 changes: 35 additions & 45 deletions test/commands/community.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand All @@ -13,12 +13,9 @@ describe("community command", () => {
) as Array<SlashCommandSubcommandBuilder>;

it("has correct data", () => {
assert.strictEqual(community.data.name, "community");
assert.strictEqual(
community.data.description,
"Commands related to our community.",
);
assert.lengthOf(subcommands, 7);
expect(community.data.name).toBe("community");
expect(community.data.description).toBe("Commands related to our community.");
expect(subcommands).toHaveLength(7);
});

it("has correct code of conduct", () => {
Expand All @@ -27,79 +24,72 @@ describe("community command", () => {
return sub.name === "code-of-conduct";
},
);
assert.exists(codeOfConduct);
assert.equal(codeOfConduct?.name, "code-of-conduct");
assert.equal(
codeOfConduct?.description,
"Returns information on freeCodeCamp's Code of Conduct.",
);
assert.lengthOf(codeOfConduct?.options || "hi", 0);
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);
});

it("has correct contribute", () => {
const contribute = subcommands.find((sub) => {
return sub.name === "contribute";
});
assert.exists(contribute);
assert.equal(contribute?.name, "contribute");
assert.equal(
contribute?.description,
"Returns helpful links for folks interested in contributing.",
);
assert.lengthOf(contribute?.options || "hi", 0);
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);
});

it("has correct forum", () => {
const forum = subcommands.find((sub) => {
return sub.name === "forum";
});
assert.exists(forum);
assert.equal(forum?.name, "forum");
assert.equal(
forum?.description,
"Returns the latest activity on the forum.",
);
assert.lengthOf(forum?.options || "hi", 0);
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);
});

it("has correct leaderboard", () => {
const leaderboard = subcommands.find((sub) => {
return sub.name === "leaderboard";
});
assert.exists(leaderboard);
assert.equal(leaderboard?.name, "leaderboard");
assert.equal(leaderboard?.description, "View the server leaderboard.");
assert.lengthOf(leaderboard?.options || "hi", 0);
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);
});

it("has correct quote", () => {
const quote = subcommands.find((sub) => {
return sub.name === "quote";
});
assert.exists(quote);
assert.equal(quote?.name, "quote");
assert.equal(quote?.description, "Returns a motivational quote.");
assert.lengthOf(quote?.options || "hi", 0);
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);
});

it("has correct profile", () => {
const rank = subcommands.find((sub) => {
return sub.name === "profile";
});
assert.equal(rank?.name, "profile");
assert.equal(rank?.description, "See your community profile.");
assert.lengthOf(rank?.options || "hi", 0);
expect(rank?.name).toBe("profile");
expect(rank?.description).toBe("See your community profile.");
expect(rank?.options || "hi").toHaveLength(0);
});

it("has correct truism", () => {
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.",
);
assert.lengthOf(truism?.options || "hi", 0);
expect(truism?.name).toBe("truism");
expect(truism?.description).toBe("Provides a random difficult-to-swallow truth about coding.");
expect(truism?.options || "hi").toHaveLength(0);
});
});
Loading