# mng01 functions --- test_that("mng01 works as expected with default argument values", { pre_data <- mng01_pre(syn_data, dataset = "adlb") res <- mng01_main(pre_data, dataset = "adlb") expect_list(res, len = 3, types = "ggplot") vdiffr::expect_doppelganger("mng01 with default value", res[[1]]) }) test_that("mng01 works as expected with custom argument values", { col <- c( "B: Placebo" = "black", "A: Drug X" = "blue", "C: Combination" = "gray" ) pre_data <- mng01_pre(syn_data, dataset = "adlb") res <- mng01_main( pre_data, dataset = "adlb", ggtheme = ggplot2::theme(axis.text.x = ggplot2::element_text(colour = "red", angle = 30, hjust = 1)), line_col = col ) expect_list(res, len = 3, types = "ggplot") vdiffr::expect_doppelganger("mng01 with custom theme", res[[1]], ) bad_col <- c( "B: Placebo" = "black", "A: Drug X" = "blue" ) expect_error( mng01_main(pre_data, dataset = "adlb", line_col = bad_col), "Missing color matching for C: Combination", fixed = TRUE ) }) # mng01 ---- test_that("mng01 works as expected with custom color set", { col <- c( "B: Placebo" = "black", "A: Drug X" = "blue", "C: Combination" = "gray" ) proc_data <- syn_data res <- run(mng01, proc_data, dataset = "adlb", line_col = col) expect_list(res, len = 3, types = "ggplot") vdiffr::expect_doppelganger("run mng01 with custom color set", res[[1]]) res <- run(mng01, proc_data, dataset = "adlb", line_col = unname(col)) expect_list(res, len = 3, types = "ggplot") vdiffr::expect_doppelganger("run mng01 with custom unnamed color set", res[[1]]) }) test_that("mng01 works with table = NULL", { proc_data <- syn_data res <- run(mng01, proc_data, dataset = "adlb", table = NULL) expect_list(res, len = 3, types = "ggplot") vdiffr::expect_doppelganger("run mng01 without table", res[[1]]) }) test_that("mng01 works with combination of x variables", { proc_data <- syn_data res <- run( mng01, proc_data, dataset = "adlb", x_var = c("AVISIT", "AVISITN") ) expect_list(res, len = 3, types = "ggplot") vdiffr::expect_doppelganger("run mng01 with combination of x variables", res[[1]]) }) test_that("mng01 works with numeric x variable", { proc_data <- syn_data proc_data$adlb$AVISITN[1:20] <- 10 proc_data$adlb$AVISITN[21:40] <- -3 res <- run( mng01, proc_data, dataset = "adlb", x_var = c("AVISITN") ) expect_list(res, len = 3, types = "ggplot") vdiffr::expect_doppelganger("run mng01 with numeric x variables", res[[1]]) }) test_that("mng01 works with numeric jitter", { proc_data <- syn_data res <- run( mng01, proc_data, dataset = "adlb", jitter = 0.7 ) expect_list(res, len = 3, types = "ggplot") vdiffr::expect_doppelganger("run mng01 with jitter", res[[1]]) })