diff --git a/tests/renderGistCard.test.js b/tests/renderGistCard.test.js index 59561a78ea39a..6e636fc50de6b 100644 --- a/tests/renderGistCard.test.js +++ b/tests/renderGistCard.test.js @@ -188,4 +188,51 @@ describe("test renderGistCard", () => { `#${themes.radical.bg_color}`, ); }); + + it("should not render star count or fork count if either of the are zero", () => { + document.body.innerHTML = renderGistCard({ + ...data, + starsCount: 0, + }); + + expect(queryByTestId(document.body, "starsCount")).toBeNull(); + expect(queryByTestId(document.body, "forksCount")).toBeInTheDocument(); + + document.body.innerHTML = renderGistCard({ + ...data, + starsCount: 1, + forksCount: 0, + }); + + expect(queryByTestId(document.body, "starsCount")).toBeInTheDocument(); + expect(queryByTestId(document.body, "forksCount")).toBeNull(); + + document.body.innerHTML = renderGistCard({ + ...data, + starsCount: 0, + forksCount: 0, + }); + + expect(queryByTestId(document.body, "starsCount")).toBeNull(); + expect(queryByTestId(document.body, "forksCount")).toBeNull(); + }); + + it("should render without rounding", () => { + document.body.innerHTML = renderGistCard(data, { + border_radius: "0", + }); + expect(document.querySelector("rect")).toHaveAttribute("rx", "0"); + document.body.innerHTML = renderGistCard(data, {}); + expect(document.querySelector("rect")).toHaveAttribute("rx", "4.5"); + }); + + it("should fallback to default description", () => { + document.body.innerHTML = renderGistCard({ + ...data, + description: undefined, + }); + expect(document.getElementsByClassName("description")[0]).toHaveTextContent( + "No description provided", + ); + }); });