Skip to content

Commit

Permalink
Tests: Gist card: Add more render tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty541 committed Aug 17, 2023
1 parent 6c15843 commit fefbf06
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/renderGistCard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
);
});
});

0 comments on commit fefbf06

Please sign in to comment.