diff --git a/tests/testthat/_snaps/card.md b/tests/testthat/_snaps/card.md new file mode 100644 index 000000000..a5f9510f5 --- /dev/null +++ b/tests/testthat/_snaps/card.md @@ -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 +
+ +
image cap on top of card
+ +
+ +--- + + Code + show_raw_html(card(card_body("image cap on bottom of card"), card_image( + "https://example.com/image.jpg"))) + Output +
+
image cap on bottom of card
+ + +
+ +--- + + Code + show_raw_html(card(card_header("header"), card_image( + "https://example.com/image.jpg"), card_body("image not a cap"))) + Output +
+
header
+ +
image not a cap
+ +
+ +--- + + Code + show_raw_html(card(card_image("https://example.com/image.jpg", alt = "card-img"))) + Output +
+ card-img + +
+ diff --git a/tests/testthat/test-card.R b/tests/testthat/test-card.R new file mode 100644 index 000000000..ee11573c4 --- /dev/null +++ b/tests/testthat/test-card.R @@ -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") + ) + ) + ) +})