fix: stats hide_border bug (#151)

* fix: stats hide border bug

* fix white border on dark mode issue

* chore: refactor code & tests

Co-authored-by: anuraghazra <hazru.anurag@gmail.com>
This commit is contained in:
Liam 2020-07-24 03:37:09 -04:00 committed by GitHub
parent 7a8510641c
commit 9624cf6acd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View file

@ -130,9 +130,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
? ""
: `<text x="25" y="35" class="header">${name}'${apostrophe} GitHub Stats</text>`;
const border = hide_border
? ""
: `
const border = `
<rect
data-testid="card-bg"
x="0.5"
@ -142,6 +140,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
rx="4.5"
fill="${bgColor}"
stroke="#E4E2E2"
stroke-opacity="${hide_border ? 0 : 1}"
/>
`;

View file

@ -71,8 +71,16 @@ describe("Test renderStatsCard", () => {
it("should hide_border", () => {
document.body.innerHTML = renderStatsCard(stats, { hide_border: true });
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"stroke-opacity",
"0"
);
expect(queryByTestId(document.body, "card-bg")).not.toBeInTheDocument();
document.body.innerHTML = renderStatsCard(stats, { hide_border: false });
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"stroke-opacity",
"1"
);
});
it("should hide_rank", () => {