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

Add more tests for calculateRank #459

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion src/fetchers/stats-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async function fetchStats(
rank: { level: "C", score: 0 },
};

let res = await retryer(fetcher, { login: username });
const res = await retryer(fetcher, { login: username });

let experimental_totalCommits = 0;
if (include_all_commits) {
Expand Down
32 changes: 32 additions & 0 deletions tests/calculateRank.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,35 @@ describe("Test calculateRank", () => {
).toStrictEqual({ level: "A+", score: 49.16605417270399 });
});
});

describe("Test A++ calculateRank", () => {
it("should calculate rank correctly", () => {
expect(
calculateRank({
totalCommits: 1000,
totalRepos: 50,
followers: 1000,
contributions: 610,
stargazers: 4000,
prs: 3000,
issues: 2000,
})
).toStrictEqual({ level: "A++", score: 32.89583911952869 });
});
});

describe("Test calculateRank for new account", () => {
it("should calculate rank correctly", () => {
expect(
calculateRank({
totalCommits: 0,
totalRepos: 0,
followers: 0,
contributions: 0,
stargazers: 0,
prs: 0,
issues: 0,
})
).toStrictEqual({ level: "A+", score: 51.03597635931825 });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have seen that there are other ranks like B+ and C. This test means that the lowest rank is A+ which was not intended, I think.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, looks like calculateRank is broken. Will wait for input from @anuraghazra

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it maybe make sense to propose the score to be "0" in this case, with the lowest possible rank (C)?

});
});