context("test-components") # Messages ---------------------------------------------------------------- msg_with_title_delete <- '
Hello World
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
' msg_with_title_delete_color <- '
Colors Test
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
' msg_body_only <- '
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
' msg_with_size <- '
Size Test
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
' test_that("message full with title and delete button", { expect_html_chr( bulma_message("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", header = "Hello World", delete = TRUE), msg_with_title_delete ) }) test_that("message full with title no delete button", { expect_html_chr( bulma_message("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", delete = TRUE), sub("Hello World", "

", msg_with_title_delete, perl = TRUE) ) }) test_that("message errors with bad header", { expect_error(bulma_message("Test", header = TRUE)) }) test_that("message with colors", { for (color in bulma_constants("colors")[1:10]) { expect_html_chr( bulma_message("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", header = "Colors Test", delete = TRUE, color = color), glue::glue(msg_with_title_delete_color) ) } }) test_that("message body only", { expect_html_chr( bulma_message("Lorem ipsum dolor sit amet, consectetur adipiscing elit."), msg_body_only ) }) test_that("message with size", { for (size in c("small", "medium", "large")) { expect_html_chr( bulma_message("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", header = "Size Test", delete = TRUE, size = size), glue::glue(msg_with_size, size = paste0("is-", size)) ) } }) test_that("message with maximum width", { # Centered by default expect_html_chr( bulma_message("Lorem ipsum dolor sit amet.", width = "half"), '
Lorem ipsum dolor sit amet.
' ) # Not centered expect_html_chr( bulma_message("Lorem ipsum dolor sit amet.", width = "half", centered = FALSE), '
Lorem ipsum dolor sit amet.
' ) })