Skip to content

Commit

Permalink
add test and remove redundant test
Browse files Browse the repository at this point in the history
  • Loading branch information
gogonzo committed Nov 13, 2024
1 parent 4ce0fad commit 8c7273a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
33 changes: 33 additions & 0 deletions tests/testthat/test-module_teal.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
11 changes: 0 additions & 11 deletions tests/testthat/test-rcode_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

0 comments on commit 8c7273a

Please sign in to comment.