-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests(card_image): Add snapshot tests
- Loading branch information
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# card_image() | ||
|
||
Code | ||
show_raw_html(card(card_image("https://example.com/image.jpg"), card_body( | ||
"image cap on top of card"))) | ||
Output | ||
<div class="card bslib-card bslib-mb-spacing html-fill-item html-fill-container" data-bslib-card-init data-require-bs-caller="card()" data-require-bs-version="5"> | ||
<img class="img-fluid card-img-top" src="https://example.com/image.jpg"/> | ||
<div class="card-body bslib-gap-spacing html-fill-item html-fill-container" style="margin-top:auto;margin-bottom:auto;flex:1 1 auto;">image cap on top of card</div> | ||
<script data-bslib-card-init>bslib.Card.initializeAllCards();</script> | ||
</div> | ||
|
||
--- | ||
|
||
Code | ||
show_raw_html(card(card_body("image cap on bottom of card"), card_image( | ||
"https://example.com/image.jpg"))) | ||
Output | ||
<div class="card bslib-card bslib-mb-spacing html-fill-item html-fill-container" data-bslib-card-init data-require-bs-caller="card()" data-require-bs-version="5"> | ||
<div class="card-body bslib-gap-spacing html-fill-item html-fill-container" style="margin-top:auto;margin-bottom:auto;flex:1 1 auto;">image cap on bottom of card</div> | ||
<img class="img-fluid card-img-bottom" src="https://example.com/image.jpg"/> | ||
<script data-bslib-card-init>bslib.Card.initializeAllCards();</script> | ||
</div> | ||
|
||
--- | ||
|
||
Code | ||
show_raw_html(card(card_header("header"), card_image( | ||
"https://example.com/image.jpg"), card_body("image not a cap"))) | ||
Output | ||
<div class="card bslib-card bslib-mb-spacing html-fill-item html-fill-container" data-bslib-card-init data-require-bs-caller="card()" data-require-bs-version="5"> | ||
<div class="card-header">header</div> | ||
<img src="https://example.com/image.jpg" class="img-fluid"/> | ||
<div class="card-body bslib-gap-spacing html-fill-item html-fill-container" style="margin-top:auto;margin-bottom:auto;flex:1 1 auto;">image not a cap</div> | ||
<script data-bslib-card-init>bslib.Card.initializeAllCards();</script> | ||
</div> | ||
|
||
--- | ||
|
||
Code | ||
show_raw_html(card(card_image("https://example.com/image.jpg", alt = "card-img"))) | ||
Output | ||
<div class="card bslib-card bslib-mb-spacing html-fill-item html-fill-container" data-bslib-card-init data-require-bs-caller="card()" data-require-bs-version="5"> | ||
<img alt="card-img" class="img-fluid card-img" src="https://example.com/image.jpg"/> | ||
<script data-bslib-card-init>bslib.Card.initializeAllCards();</script> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
test_that("card_image()", { | ||
show_raw_html <- function(x) { | ||
cat(format(x)) | ||
} | ||
|
||
expect_snapshot( | ||
show_raw_html( | ||
card( | ||
card_image("https://example.com/image.jpg"), | ||
card_body("image cap on top of card") | ||
) | ||
) | ||
) | ||
|
||
expect_snapshot( | ||
show_raw_html( | ||
card( | ||
card_body("image cap on bottom of card"), | ||
card_image("https://example.com/image.jpg") | ||
) | ||
) | ||
) | ||
|
||
expect_snapshot( | ||
show_raw_html( | ||
card( | ||
card_header("header"), | ||
card_image("https://example.com/image.jpg"), | ||
card_body("image not a cap") | ||
) | ||
) | ||
) | ||
|
||
expect_snapshot( | ||
show_raw_html( | ||
card( | ||
card_image("https://example.com/image.jpg", alt = "card-img") | ||
) | ||
) | ||
) | ||
}) |