Revise rank calculation

This commit is contained in:
François Rozet
2021-07-13 16:46:51 +02:00
parent 112efb4b92
commit 2c4331d061
2 changed files with 72 additions and 77 deletions
+37 -9
View File
@@ -2,17 +2,45 @@ require("@testing-library/jest-dom");
const calculateRank = require("../src/calculateRank");
describe("Test calculateRank", () => {
it("should calculate rank correctly", () => {
it("new user gets B rank", () => {
expect(
calculateRank({
totalCommits: 100,
totalRepos: 5,
followers: 100,
contributions: 61,
stargazers: 400,
prs: 300,
issues: 200,
totalRepos: 0,
totalCommits: 0,
contributions: 0,
followers: 0,
prs: 0,
issues: 0,
stargazers: 0,
}),
).toStrictEqual({ level: "A+", score: 49.16605417270399 });
).toStrictEqual({level: "B", score: 100.});
});
it("average user gets A rank", () => {
expect(
calculateRank({
totalRepos: 10,
totalCommits: 1000,
contributions: 1000,
followers: 50,
prs: 25,
issues: 25,
stargazers: 100,
}),
).toStrictEqual({"A", score: 36.787944117144235});
});
it("Linus Torvalds gets S rank", () => {
expect(
calculateRank({
totalRepos: 4, // few repos
totalCommits: 20000,
contributions: 20000,
followers: 132000,
prs: 71,
issues: 2,
stargazers: 109100,
}),
).toStrictEqual({ level: "S", score: 7.092453734726941});
});
});