add image-preview tests

This commit is contained in:
Bikrant Jajware
2023-11-02 12:44:08 +05:30
parent 075add2e59
commit 03d7f85d77
2 changed files with 21 additions and 2 deletions
+19
View File
@@ -18,6 +18,8 @@ const data_repo = {
},
starCount: 38000,
forkCount: 100,
openGraphImageUrl:
"https://repository-images.githubusercontent.com/266996769/1e4f2180-b194-11ea-9806-2395601f119b",
},
};
@@ -339,4 +341,21 @@ describe("Test renderRepoCard", () => {
"No description provided",
);
});
it("should render repo's social preview image, when show_image is true", () => {
document.body.innerHTML = renderRepoCard(data_repo.repository, {
show_image: true,
});
expect(queryByTestId(document.body, "card-image")).toBeInTheDocument();
expect(
queryByTestId(document.body, "card-image").children[0],
).toHaveAttribute("href", data_repo.repository.openGraphImageUrl);
});
it("should not render repo's social preview image by default", () => {
document.body.innerHTML = renderRepoCard(data_repo.repository);
expect(queryByTestId(document.body, "card-image")).not.toBeInTheDocument();
});
});