mirror of
https://github.com/tiennm99/github-readme-stats.git
synced 2026-09-02 22:17:41 +00:00
refactor: refactor repo card (#1325)
* refactor: refactored repo-card * test: fix tests * test: fixed tests * fix: unprovided description error
This commit is contained in:
@@ -9,13 +9,13 @@ const data_repo = {
|
||||
repository: {
|
||||
nameWithOwner: "anuraghazra/convoychat",
|
||||
name: "convoychat",
|
||||
stargazers: { totalCount: 38000 },
|
||||
description: "Help us take over the world! React + TS + GraphQL Chat App",
|
||||
primaryLanguage: {
|
||||
color: "#2b7489",
|
||||
id: "MDg6TGFuZ3VhZ2UyODc=",
|
||||
name: "TypeScript",
|
||||
},
|
||||
starCount: 38000,
|
||||
forkCount: 100,
|
||||
},
|
||||
};
|
||||
@@ -231,7 +231,7 @@ describe("Test renderRepoCard", () => {
|
||||
it("should not render star count or fork count if either of the are zero", () => {
|
||||
document.body.innerHTML = renderRepoCard({
|
||||
...data_repo.repository,
|
||||
stargazers: { totalCount: 0 },
|
||||
starCount: 0,
|
||||
});
|
||||
|
||||
expect(queryByTestId(document.body, "stargazers")).toBeNull();
|
||||
@@ -239,7 +239,7 @@ describe("Test renderRepoCard", () => {
|
||||
|
||||
document.body.innerHTML = renderRepoCard({
|
||||
...data_repo.repository,
|
||||
stargazers: { totalCount: 1 },
|
||||
starCount: 1,
|
||||
forkCount: 0,
|
||||
});
|
||||
|
||||
@@ -248,7 +248,7 @@ describe("Test renderRepoCard", () => {
|
||||
|
||||
document.body.innerHTML = renderRepoCard({
|
||||
...data_repo.repository,
|
||||
stargazers: { totalCount: 0 },
|
||||
starCount: 0,
|
||||
forkCount: 0,
|
||||
});
|
||||
|
||||
@@ -311,4 +311,15 @@ describe("Test renderRepoCard", () => {
|
||||
document.body.innerHTML = renderRepoCard(data_repo.repository, {});
|
||||
expect(document.querySelector("rect")).toHaveAttribute("rx", "4.5");
|
||||
});
|
||||
|
||||
it("should fallback to default description", () => {
|
||||
document.body.innerHTML = renderRepoCard({
|
||||
...data_repo.repository,
|
||||
description: undefined,
|
||||
isArchived: true,
|
||||
});
|
||||
expect(document.getElementsByClassName("description")[0]).toHaveTextContent(
|
||||
"No description provided",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user