feat: Add count_private flag to count private contributions (#148)

* Add private contributions count

* Remove unused var and add tests

* Update readme

* fix: tests & minor code formating

* docs: updated docs

Co-authored-by: anuraghazra <hazru.anurag@gmail.com>
This commit is contained in:
Fábio Rosado
2020-07-24 15:04:38 +01:00
committed by GitHub
parent 3a9ded0a09
commit 4c0518616f
5 changed files with 104 additions and 21 deletions

View File

@@ -9,7 +9,7 @@ const data = {
user: {
name: "Anurag Hazra",
repositoriesContributedTo: { totalCount: 61 },
contributionsCollection: { totalCommitContributions: 100 },
contributionsCollection: { totalCommitContributions: 100, restrictedContributionsCount: 50 },
pullRequests: { totalCount: 300 },
issues: { totalCount: 200 },
followers: { totalCount: 100 },
@@ -77,4 +77,29 @@ describe("Test fetchStats", () => {
"Could not resolve to a User with the login of 'noname'."
);
});
});
it("should fetch and add private contributions", async () => {
mock.onPost("https://api.github.com/graphql").reply(200, data);
let stats = await fetchStats("anuraghazra", true);
const rank = calculateRank({
totalCommits: 150,
totalRepos: 5,
followers: 100,
contributions: 61,
stargazers: 400,
prs: 300,
issues: 200,
});
expect(stats).toStrictEqual({
contributedTo: 61,
name: "Anurag Hazra",
totalCommits: 150,
totalIssues: 200,
totalPRs: 300,
totalStars: 400,
rank,
});
});
});