diff --git a/tests/testthat/test-module_teal.R b/tests/testthat/test-module_teal.R index 2e91a13f57..19e5baab2e 100644 --- a/tests/testthat/test-module_teal.R +++ b/tests/testthat/test-module_teal.R @@ -545,6 +545,39 @@ testthat::describe("srv_teal teal_modules", { ) }) + testthat::it("receives data with code limited to lines needed only for datanames", { + shiny::testServer( + app = srv_teal, + args = list( + id = "test", + data = reactive( + within(teal_data(), { + n_iris <- 10 + mtcars <- mtcars + iris <- head(iris, n_iris) + mtcars <- head(mtcars) + }) + ), + modules = modules( + module("module_1", server = function(id, data) data, datanames = c("iris")) + ) + ), + expr = { + session$setInputs(`teal_modules-active_tab` = "module_1") + testthat::expect_identical( + teal.code::get_code(modules_output$module_1()()), + paste( + "n_iris <- 10", + "iris <- head(iris, n_iris)", + "stopifnot(rlang::hash(iris) == \"3d48747b41945d02625fe9740bf8e98c\") # @linksto iris", + ".raw_data <- list2env(list(iris = iris))\nlockEnvironment(.raw_data) # @linksto .raw_data", + sep = "\n" + ) + ) + } + ) + }) + testthat::describe("warnings on missing datanames", { testthat::it("warns when dataname is not available", { testthat::skip_if_not_installed("rvest") diff --git a/tests/testthat/test-rcode_utils.R b/tests/testthat/test-rcode_utils.R index 8983355517..0dcd33d216 100644 --- a/tests/testthat/test-rcode_utils.R +++ b/tests/testthat/test-rcode_utils.R @@ -47,14 +47,3 @@ testthat::test_that("get_rcode_libraries returns current session packages", { ) ) }) - -testthat::test_that("get_datasets_code returns code only for specified datanames", { - # todo: need to use code dependency? Or test it later via public functions/modules - datasets <- teal.slice::init_filtered_data( - list( - IRIS = iris, - MTCARS = mtcars - ) - ) - testthat::expect_true(TRUE) -})