Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update assertions to expectations #753

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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();

Check warning on line 6 in test/commands/author.spec.ts

View workflow job for this annotation

GitHub Actions / Lint and Test (22.x)

Expect requires atleast 2 arguments
});
});
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 @@
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 @@
) 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");

Check warning on line 16 in test/commands/community.spec.ts

View workflow job for this annotation

GitHub Actions / Lint and Test (22.x)

Expect requires atleast 2 arguments
expect(community.data.description).toBe("Commands related to our community.");

Check warning on line 17 in test/commands/community.spec.ts

View workflow job for this annotation

GitHub Actions / Lint and Test (22.x)

This line has a length of 82. Maximum allowed is 80

Check warning on line 17 in test/commands/community.spec.ts

View workflow job for this annotation

GitHub Actions / Lint and Test (22.x)

Expect requires atleast 2 arguments
expect(subcommands).toHaveLength(7);

Check warning on line 18 in test/commands/community.spec.ts

View workflow job for this annotation

GitHub Actions / Lint and Test (22.x)

Expect requires atleast 2 arguments
});

it("has correct code of conduct", () => {
Expand All @@ -27,79 +24,72 @@
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();

Check warning on line 27 in test/commands/community.spec.ts

View workflow job for this annotation

GitHub Actions / Lint and Test (22.x)

Expect requires atleast 2 arguments
expect(codeOfConduct).not.toBeNull();

Check warning on line 28 in test/commands/community.spec.ts

View workflow job for this annotation

GitHub Actions / Lint and Test (22.x)

Expect requires atleast 2 arguments
expect(codeOfConduct?.name).toBe("code-of-conduct");

Check warning on line 29 in test/commands/community.spec.ts

View workflow job for this annotation

GitHub Actions / Lint and Test (22.x)

Expect requires atleast 2 arguments
expect(codeOfConduct?.description).toBe("Returns information on freeCodeCamp's Code of Conduct.");

Check warning on line 30 in test/commands/community.spec.ts

View workflow job for this annotation

GitHub Actions / Lint and Test (22.x)

This line has a length of 102. Maximum allowed is 80

Check warning on line 30 in test/commands/community.spec.ts

View workflow job for this annotation

GitHub Actions / Lint and Test (22.x)

Expect requires atleast 2 arguments
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
Loading