mirror of
https://github.com/tiennm99/github-readme-stats.git
synced 2026-05-19 13:26:18 +00:00
Tests: Gist card: Add more render tests (#3087)
This commit is contained in:
committed by
GitHub
parent
101f56c4bd
commit
5afd97a94b
@@ -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",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user