diff --git a/DESCRIPTION b/DESCRIPTION index 3b8219868..1bbef1220 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -71,7 +71,8 @@ Suggests: rlang (>= 1.0.0), rtables (>= 0.6.6), sparkline, - testthat (>= 3.0.4) + testthat (>= 3.0.4), + withr (>= 2.0.0) VignetteBuilder: knitr Config/Needs/verdepcheck: haleyjeppson/ggmosaic, tidyverse/ggplot2, @@ -89,7 +90,7 @@ Config/Needs/verdepcheck: haleyjeppson/ggmosaic, tidyverse/ggplot2, jeroen/jsonlite, yihui/knitr, deepayan/lattice, MASS, insightsengineering/nestcolor, r-lib/rlang, insightsengineering/rtables, sparkline, insightsengineering/teal.data, - r-lib/testthat + r-lib/testthat, r-lib/withr Config/Needs/website: insightsengineering/nesttemplate Encoding: UTF-8 Language: en-US diff --git a/tests/testthat/setup-logger.R b/tests/testthat/setup-logger.R new file mode 100644 index 000000000..f6401f548 --- /dev/null +++ b/tests/testthat/setup-logger.R @@ -0,0 +1 @@ +logger::log_appender(function(...) NULL, namespace = "teal.modules.general") diff --git a/tests/testthat/setup-options.R b/tests/testthat/setup-options.R new file mode 100644 index 000000000..78be1f9b5 --- /dev/null +++ b/tests/testthat/setup-options.R @@ -0,0 +1,20 @@ +# `opts_partial_match_old` is left for exclusions due to partial matching in dependent packages (i.e. not fixable here) +# it might happen that it is not used right now, but it is left for possible future use +# use with: `withr::with_options(opts_partial_match_old, { ... })` inside the test +opts_partial_match_old <- list( + warnPartialMatchDollar = getOption("warnPartialMatchDollar"), + warnPartialMatchArgs = getOption("warnPartialMatchArgs"), + warnPartialMatchAttr = getOption("warnPartialMatchAttr") +) +opts_partial_match_new <- list( + warnPartialMatchDollar = TRUE, + warnPartialMatchArgs = TRUE, + warnPartialMatchAttr = TRUE +) + +if (isFALSE(getFromNamespace("on_cran", "testthat")()) && requireNamespace("withr", quietly = TRUE)) { + withr::local_options( + opts_partial_match_new, + .local_envir = testthat::teardown_env() + ) +} diff --git a/tests/testthat/test-tm_g_bivariate.R b/tests/testthat/test-tm_g_bivariate.R index 1d97a37fc..b73e63896 100644 --- a/tests/testthat/test-tm_g_bivariate.R +++ b/tests/testthat/test-tm_g_bivariate.R @@ -9,7 +9,7 @@ testthat::test_that("tm_g_bivariate creates a `teal_module` object", { row_facet = mock_data_extract_spec(select_multiple = FALSE), col_facet = mock_data_extract_spec(select_multiple = FALSE), facet = TRUE, - color_setting = TRUE, + color_settings = TRUE, use_density = TRUE, free_x_scales = TRUE, free_y_scales = TRUE, @@ -229,7 +229,7 @@ testthat::test_that("tm_g_bivariate fails when `color_setting` is FALSE and `col "a label", mock_data_extract_spec(select_multiple = FALSE), mock_data_extract_spec(select_multiple = FALSE), - color_setting = FALSE, + color_settings = FALSE, color = mock_data_extract_spec() ), "'color_settings' argument needs to be set to TRUE if 'color', 'fill', and/or 'size' is/are supplied." @@ -244,7 +244,7 @@ testthat::test_that("tm_g_bivariate fails when `color_setting` is FALSE and `siz "a label", mock_data_extract_spec(select_multiple = FALSE), mock_data_extract_spec(select_multiple = FALSE), - color_setting = FALSE, + color_settings = FALSE, size = mock_data_extract_spec() ), "'color_settings' argument needs to be set to TRUE if 'color', 'fill', and/or 'size' is/are supplied." @@ -259,7 +259,7 @@ testthat::test_that("tm_g_bivariate fails when `color_setting` is FALSE and `fil "a label", mock_data_extract_spec(select_multiple = FALSE), mock_data_extract_spec(select_multiple = FALSE), - color_setting = FALSE, + color_settings = FALSE, fill = mock_data_extract_spec() ), "'color_settings' argument needs to be set to TRUE if 'color', 'fill', and/or 'size' is/are supplied." @@ -273,7 +273,7 @@ testthat::test_that("tm_g_bivariate determines `color`, `size` and `fill` when ` "a label", mock_data_extract_spec(select_multiple = FALSE), mock_data_extract_spec(select_multiple = FALSE), - color_setting = TRUE + color_settings = TRUE ) testthat::expect_contains( diff --git a/vignettes/teal-modules-general.Rmd b/vignettes/teal-modules-general.Rmd index 3d8c9a007..4ccb9a329 100644 --- a/vignettes/teal-modules-general.Rmd +++ b/vignettes/teal-modules-general.Rmd @@ -47,8 +47,8 @@ library(teal.widgets) # teal_data object data <- teal_data() data <- within(data, { - ADSL <- teal.modules.general::rADSL - ADTTE <- teal.modules.general::rADTTE + ADSL <- rADSL + ADTTE <- rADTTE }) datanames <- c("ADSL", "ADTTE") datanames(data) <- datanames @@ -91,8 +91,8 @@ Following this, we set the `datanames` and `join_keys`. ```r data <- teal_data() data <- within(data, { - ADSL <- teal.modules.general::rADSL - ADTTE <- teal.modules.general::rADTTE + ADSL <- rADSL + ADTTE <- rADTTE }) datanames <- c("ADSL", "ADTTE") datanames(data) <- datanames