Added pr reviews to stats (#1404)

* Added pr reviews to stats

* Add 'show' query parameter

* Fix show test

* refactoring

* cleanup

* refactor: restructure stats-card code

---------

Co-authored-by: Markus <markus.tyrkko@gmail.com>
Co-authored-by: Alexandr <qwerty541zxc@gmail.com>
Co-authored-by: rickstaa <rick.staa@outlook.com>
This commit is contained in:
Markus Tyrkkö
2023-06-15 09:35:09 +02:00
committed by GitHub
co-authored by Markus Alexandr rickstaa
parent c86cc72df2
commit 1bb65ddc29
10 changed files with 112 additions and 34 deletions
+22
View File
@@ -16,6 +16,7 @@ const stats = {
totalCommits: 200,
totalIssues: 300,
totalPRs: 400,
totalReviews: 50,
contributedTo: 500,
rank: { level: "A+", score: 40 },
};
@@ -38,6 +39,9 @@ describe("Test renderStatsCard", () => {
expect(getByTestId(document.body, "contribs").textContent).toBe("500");
expect(queryByTestId(document.body, "card-bg")).toBeInTheDocument();
expect(queryByTestId(document.body, "rank-circle")).toBeInTheDocument();
// Default hidden stats
expect(queryByTestId(document.body, "reviews")).not.toBeInTheDocument();
});
it("should have proper name apostrophe", () => {
@@ -68,6 +72,24 @@ describe("Test renderStatsCard", () => {
expect(queryByTestId(document.body, "issues")).toBeNull();
expect(queryByTestId(document.body, "prs")).toBeNull();
expect(queryByTestId(document.body, "contribs")).toBeNull();
expect(queryByTestId(document.body, "reviews")).toBeNull();
});
it("should show total reviews", () => {
document.body.innerHTML = renderStatsCard(stats, {
show_total_reviews: true,
});
expect(
document.body.getElementsByTagName("svg")[0].getAttribute("height"),
).toBe("220");
expect(queryByTestId(document.body, "stars")).toBeDefined();
expect(queryByTestId(document.body, "commits")).toBeDefined();
expect(queryByTestId(document.body, "issues")).toBeDefined();
expect(queryByTestId(document.body, "prs")).toBeDefined();
expect(queryByTestId(document.body, "contribs")).toBeDefined();
expect(queryByTestId(document.body, "reviews")).toBeDefined();
});
it("should hide_rank", () => {