Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit03d7f85

Browse files
add image-preview tests
1 parent075add2 commit03d7f85

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

‎src/common/Card.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ class Card {
218218
return"";
219219
}
220220
return`
221-
<g transform="translate(0, 0)">
222-
<image x="0" y="0" height="${this.imageHeight}"
221+
<gdata-testid="card-image"transform="translate(0, 0)">
222+
<image x="0" y="0"width="${this.width}"height="${this.imageHeight}"
223223
href="${this.imageUrl}">
224224
</image>
225225
</g>`;

‎tests/renderRepoCard.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const data_repo = {
1818
},
1919
starCount:38000,
2020
forkCount:100,
21+
openGraphImageUrl:
22+
"https://repository-images.githubusercontent.com/266996769/1e4f2180-b194-11ea-9806-2395601f119b",
2123
},
2224
};
2325

@@ -339,4 +341,21 @@ describe("Test renderRepoCard", () => {
339341
"No description provided",
340342
);
341343
});
344+
345+
it("should render repo's social preview image, when show_image is true",()=>{
346+
document.body.innerHTML=renderRepoCard(data_repo.repository,{
347+
show_image:true,
348+
});
349+
350+
expect(queryByTestId(document.body,"card-image")).toBeInTheDocument();
351+
expect(
352+
queryByTestId(document.body,"card-image").children[0],
353+
).toHaveAttribute("href",data_repo.repository.openGraphImageUrl);
354+
});
355+
356+
it("should not render repo's social preview image by default",()=>{
357+
document.body.innerHTML=renderRepoCard(data_repo.repository);
358+
359+
expect(queryByTestId(document.body,"card-image")).not.toBeInTheDocument();
360+
});
342361
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp