diff --git a/R/utils.R b/R/utils.R index 410ad9d1ef..918f8534d8 100644 --- a/R/utils.R +++ b/R/utils.R @@ -25,14 +25,21 @@ get_client_timezone <- function(ns) { #' @keywords internal get_teal_bs_theme <- function() { bs_theme <- getOption("teal.bs_theme") + if (is.null(bs_theme)) { - NULL - } else if (!inherits(bs_theme, "bs_theme")) { - warning("teal.bs_theme has to be of a bslib::bs_theme class, the default shiny bootstrap is used.") - NULL - } else { - bs_theme + return(NULL) + } + + if (!checkmate::test_class(bs_theme, "bs_theme")) { + warning( + "Assertion on 'teal.bs_theme' option value failed: ", + checkmate::check_class(bs_theme, "bs_theme"), + ". The default Shiny Bootstrap theme will be used." + ) + return(NULL) } + + bs_theme } #' Return parentnames along with datanames. diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 628f389162..dc171b5bf3 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -4,10 +4,10 @@ testthat::test_that("get_teal_bs_theme", { testthat::expect_s3_class(get_teal_bs_theme(), "bs_theme") }) withr::with_options(list("teal.bs_theme" = 1), { - testthat::expect_warning(get_teal_bs_theme(), "the default shiny bootstrap is used") + testthat::expect_warning(get_teal_bs_theme(), ".*The default Shiny Bootstrap theme will be used.") }) withr::with_options(list("teal.bs_theme" = "bs_theme"), { - testthat::expect_warning(get_teal_bs_theme(), "the default shiny bootstrap is used") + testthat::expect_warning(get_teal_bs_theme(), ".*The default Shiny Bootstrap theme will be used.") }) })