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

@@ -30,7 +30,10 @@ const data = {
user: {
name: stats.name,
repositoriesContributedTo: { totalCount: stats.contributedTo },
contributionsCollection: { totalCommitContributions: stats.totalCommits },
contributionsCollection: {
totalCommitContributions: stats.totalCommits,
restrictedContributionsCount: 100,
},
pullRequests: { totalCount: stats.totalPRs },
issues: { totalCount: stats.totalIssues },
followers: { totalCount: 0 },
@@ -181,4 +184,36 @@ describe("Test /api/", () => {
]);
}
});
it("should add private contributions", async () => {
const { req, res } = faker(
{
username: "anuraghazra",
count_private: true,
},
data
);
await api(req, res);
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
expect(res.send).toBeCalledWith(
renderStatsCard(
{
...stats,
totalCommits: stats.totalCommits + 100,
rank: calculateRank({
totalCommits: stats.totalCommits + 100,
totalRepos: 1,
followers: 0,
contributions: stats.contributedTo,
stargazers: stats.totalStars,
prs: stats.totalPRs,
issues: stats.totalIssues,
}),
},
{}
)
);
});
});