diff --git a/R/summarize-expr-block.R b/R/summarize-expr-block.R index 10e9065..ed650e1 100644 --- a/R/summarize-expr-block.R +++ b/R/summarize-expr-block.R @@ -32,7 +32,7 @@ new_summarize_expr_block <- function(new_cols = NULL, if (inherits(ans, "try-error")) { return(expression()) } - res + ans } parse_cols <- function(new_cols) { diff --git a/tests/testthat/test-admiral-dpc-block.R b/tests/testthat/test-admiral-dpc-block.R index 4c1091f..5dfe39a 100644 --- a/tests/testthat/test-admiral-dpc-block.R +++ b/tests/testthat/test-admiral-dpc-block.R @@ -2,8 +2,7 @@ test_that("admiral-dpc-block", { data <- datasets::BOD data$PARAMCD <- as.character(seq_len(nrow(data))) - block <- admiral_dpc_block( - data, + block <- new_admiral_dpc_block( by_vars = "Time", parameters = c("4", "5"), set_values_to = c( @@ -12,6 +11,8 @@ test_that("admiral-dpc-block", { ) ) + block <- initialize_block(block, data) + expect_s3_class(block, "admiral_dpc_block") expect_type(block, "list") diff --git a/tests/testthat/test-filter-expr-block.R b/tests/testthat/test-filter-expr-block.R index 0642202..6b4c406 100644 --- a/tests/testthat/test-filter-expr-block.R +++ b/tests/testthat/test-filter-expr-block.R @@ -1,6 +1,7 @@ test_that("filter-expr-block", { data <- datasets::iris - block <- filter_expr_block(data, value = c("Species == 'virginica'")) + block <- new_filter_expr_block(value = c("Species == 'virginica'")) + block <- initialize_block(block, data) expect_s3_class(block, "filter_expr_block") expect_type(block, "list") @@ -10,7 +11,7 @@ test_that("filter-expr-block", { res <- evaluate_block(block, data) expect_identical(unique(as.character(res$Species)), "virginica") - res_ui <- generate_ui(filter_expr_block(data = datasets::iris), id = "test") + res_ui <- generate_ui(new_filter_expr_block(data = datasets::iris), id = "test") expect_s3_class(res_ui, "shiny.tag") }) @@ -18,8 +19,8 @@ test_that("filter-expr-block module_server handles input correctly", { # wrap generate_server # id as first argument, so we can test via shiny::testSever - module_server_test <- function(id, x, in_dat, ...) { - generate_server(x = x, in_dat = in_dat, id = id) + module_server_test <- function(id, x, in_dat, is_prev_valid, ...) { + generate_server(x = x, in_dat = in_dat, id = id, is_prev_valid = is_prev_valid) } shiny::testServer( @@ -39,8 +40,9 @@ test_that("filter-expr-block module_server handles input correctly", { }, args = list( id = "test", - x = filter_expr_block(data = datasets::iris), - in_dat = reactive(datasets::iris) + x = new_filter_expr_block(data = datasets::iris), + in_dat = reactive(datasets::iris), + is_prev_valid = shiny::reactive(TRUE) ) ) }) diff --git a/tests/testthat/test-summarize-expr-block.R b/tests/testthat/test-summarize-expr-block.R index 274b09e..6ca9597 100644 --- a/tests/testthat/test-summarize-expr-block.R +++ b/tests/testthat/test-summarize-expr-block.R @@ -1,14 +1,15 @@ test_that("summarize-expr-block", { data <- datasets::iris - block <- summarize_expr_block( - data, + block <- new_summarize_expr_block( group_by = "Species", new_cols = c( Mean.Sepal.Width = "mean(Sepal.Width)" ) ) + block <- initialize_block(block, data) + expect_true(is_initialized(block)) expect_s3_class(block, "summarize_expr_block") expect_type(block, "list")