diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R new file mode 100644 index 000000000..bcc3ca619 --- /dev/null +++ b/tests/testthat/test-utils.R @@ -0,0 +1,15 @@ +testthat::test_that("card_template function returns TealReportCard object with appropriate content and labels", { + + fd <- teal.slice::init_filtered_data(list(iris = list(dataset = iris))) + filter_panel_api <- teal.slice::FilterPanelAPI$new(fd) + + card <- shiny::isolate(card_template("Card title", "Card label", TRUE, filter_panel_api)) + testthat::expect_s3_class(card, c("TealReportCard")) + testthat::expect_equal(card$get_name(), "Card label") + testthat::expect_length(card$get_content(), 3) + + card <- shiny::isolate(card_template("Card title", "", FALSE, filter_panel_api)) + testthat::expect_s3_class(card, c("TealReportCard")) + testthat::expect_equal(card$get_name(), "Card title") + testthat::expect_length(card$get_content(), 1) +})