Skip to content

Commit

Permalink
fix: proper apostrophe in stats card's header
Browse files Browse the repository at this point in the history
* fix: remove 's' after apostrophe if name ends with 's'

* fix: respect GITHUB_TOKEN env var before PAT_s

* revert: verbose console log for retries

* Revert "fix: respect GITHUB_TOKEN env var before PAT_s"

This reverts commit 2becbe5.

* test: added test for title apostrophe

Co-authored-by: anuraghazra <[email protected]>
  • Loading branch information
sreetamdas and anuraghazra authored Jul 19, 2020
1 parent 9a7ed8f commit dd2c7ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/renderStatsCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,11 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
});

// Conditionally rendered elements

const apostrophe = ["x", "s"].includes(name.slice(-1)) ? "" : "s";
const title = hide_title
? ""
: `<text x="25" y="35" class="header">${name}'s GitHub Stats</text>`;
: `<text x="25" y="35" class="header">${name}'${apostrophe} GitHub Stats</text>`;

const border = hide_border
? ""
Expand Down
14 changes: 14 additions & 0 deletions tests/renderStatsCard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ describe("Test renderStatsCard", () => {
expect(queryByTestId(document.body, "rank-circle")).toBeInTheDocument();
});

it("should have proper name apostrophe", () => {
document.body.innerHTML = renderStatsCard({ ...stats, name: "Anil Das" });

expect(document.getElementsByClassName("header")[0].textContent).toBe(
"Anil Das' GitHub Stats"
);

document.body.innerHTML = renderStatsCard({ ...stats, name: "Felix" });

expect(document.getElementsByClassName("header")[0].textContent).toBe(
"Felix' GitHub Stats"
);
});

it("should hide individual stats", () => {
document.body.innerHTML = renderStatsCard(stats, {
hide: "['issues', 'prs', 'contribs']",
Expand Down

0 comments on commit dd2c7ed

Please sign in to comment.