From b90c0c278d6756f39c9c9af44a050f97f26b07b9 Mon Sep 17 00:00:00 2001 From: Emily Boyer Date: Fri, 10 Apr 2026 13:39:28 -0600 Subject: [PATCH 1/2] Added unit tests for utility, data loading, plot, and UI functions. --- tests/testthat/test-data_helpers.R | 53 +++++++ tests/testthat/test-data_loading.R | 135 ++++++++++++++++++ tests/testthat/test-getHoldoutsDrugChoices.R | 78 ++++++++++ tests/testthat/test-makeFeatureImportTable.R | 76 ++++++++++ tests/testthat/test-makeQuickStats.R | 41 ++++++ tests/testthat/test-normalize_species.R | 29 ++++ tests/testthat/test-plots.R | 142 +++++++++++++++++++ tests/testthat/test-ui_modules.R | 72 ++++++++++ 8 files changed, 626 insertions(+) create mode 100644 tests/testthat/test-data_helpers.R create mode 100644 tests/testthat/test-data_loading.R create mode 100644 tests/testthat/test-getHoldoutsDrugChoices.R create mode 100644 tests/testthat/test-makeFeatureImportTable.R create mode 100644 tests/testthat/test-makeQuickStats.R create mode 100644 tests/testthat/test-normalize_species.R create mode 100644 tests/testthat/test-plots.R create mode 100644 tests/testthat/test-ui_modules.R diff --git a/tests/testthat/test-data_helpers.R b/tests/testthat/test-data_helpers.R new file mode 100644 index 0000000..8973e2a --- /dev/null +++ b/tests/testthat/test-data_helpers.R @@ -0,0 +1,53 @@ +## Tests for internal data helper functions + +# ── .normalize_results_root ────────────────────────────────────────────────── + +test_that(".normalize_results_root returns NULL for invalid inputs", { + expect_null(.normalize_results_root(NULL)) + expect_null(.normalize_results_root(NA)) + expect_null(.normalize_results_root("")) + expect_null(.normalize_results_root(character(0))) + # Multiple values + expect_null(.normalize_results_root(c("/a", "/b"))) +}) + +test_that(".normalize_results_root normalizes a valid path", { + tmp <- tempdir() + result <- .normalize_results_root(tmp) + expect_type(result, "character") + expect_equal(nchar(result) > 0, TRUE) + # Should be an absolute path + expect_true(startsWith(result, "/") || grepl("^[A-Z]:", result)) +}) + +# ── .read_parquet_safe ─────────────────────────────────────────────────────── + +test_that(".read_parquet_safe returns empty tibble for missing file", { + result <- suppressMessages( + .read_parquet_safe("/nonexistent/path.parquet", verbose = FALSE) + ) + expect_s3_class(result, "tbl_df") + expect_equal(nrow(result), 0) +}) + +test_that(".read_parquet_safe returns empty tibble for NULL path", { + result <- suppressMessages( + .read_parquet_safe(NULL, verbose = FALSE) + ) + expect_s3_class(result, "tbl_df") + expect_equal(nrow(result), 0) +}) + +test_that(".read_parquet_safe reads a valid parquet file", { + extdata <- system.file("extdata", package = "amRshiny") + perf_files <- list.files( + extdata, + pattern = "_ML_perf\\.parquet$", + recursive = TRUE, full.names = TRUE + ) + skip_if(length(perf_files) == 0, "No demo parquet files found") + + result <- .read_parquet_safe(perf_files[1], verbose = FALSE) + expect_s3_class(result, "tbl_df") + expect_gt(nrow(result), 0) +}) diff --git a/tests/testthat/test-data_loading.R b/tests/testthat/test-data_loading.R new file mode 100644 index 0000000..01aeae3 --- /dev/null +++ b/tests/testthat/test-data_loading.R @@ -0,0 +1,135 @@ +## Tests for data loading functions: loadMLResults, loadTopFeat, +## listAmRmlSpeciesFolders, get_metadata_path, loadDrugClassMap + +# ── listAmRmlSpeciesFolders ────────────────────────────────────────────────── + +test_that("listAmRmlSpeciesFolders returns empty for NULL/invalid root", { + expect_equal(listAmRmlSpeciesFolders(NULL), character(0)) + expect_equal(listAmRmlSpeciesFolders(""), character(0)) + expect_equal( + listAmRmlSpeciesFolders("/nonexistent/path"), + character(0) + ) +}) + +test_that("listAmRmlSpeciesFolders discovers species dirs in extdata", { + extdata <- system.file("extdata", package = "amRshiny") + skip_if(!nzchar(extdata), "No extdata directory found") + + result <- listAmRmlSpeciesFolders(extdata, verbose = FALSE) + expect_type(result, "character") + expect_true(length(result) > 0) + expect_true(all(nzchar(names(result)))) +}) + +test_that("listAmRmlSpeciesFolders ignores dirs without perf parquets", { + tmp <- tempfile("test_species_") + dir.create(tmp) + on.exit(unlink(tmp, recursive = TRUE)) + + empty_dir <- file.path(tmp, "Empty_species") + dir.create(empty_dir) + + result <- listAmRmlSpeciesFolders(tmp, verbose = FALSE) + expect_equal(length(result), 0) +}) + +# ── loadMLResults ──────────────────────────────────────────────────────────── + +test_that("loadMLResults returns empty tibble when results_root given but no species_dirs", { + tmp <- tempdir() + result <- suppressMessages( + loadMLResults( + results_root = tmp, + species_dirs = NULL, + verbose = FALSE + ) + ) + expect_s3_class(result, "tbl_df") + expect_equal(nrow(result), 0) +}) + +test_that("loadMLResults loads demo data in fallback mode", { + result <- suppressMessages(loadMLResults(verbose = FALSE)) + expect_s3_class(result, "tbl_df") + expect_gt(nrow(result), 0) + expect_true("species" %in% names(result)) +}) + +test_that("loadMLResults loads from specific species_dirs", { + extdata <- system.file("extdata", package = "amRshiny") + skip_if(!nzchar(extdata), "No extdata directory found") + + folders <- listAmRmlSpeciesFolders(extdata, verbose = FALSE) + skip_if( + length(folders) == 0, + "No species dirs with baseline perf in extdata" + ) + + result <- suppressMessages( + loadMLResults( + results_root = extdata, + species_dirs = folders[1], + verbose = FALSE + ) + ) + expect_s3_class(result, "tbl_df") + expect_gt(nrow(result), 0) + expect_true("species_label" %in% names(result)) +}) + +# ── loadTopFeat ────────────────────────────────────────────────────────────── + +test_that("loadTopFeat returns empty tibble when results_root given but no species_dirs", { + tmp <- tempdir() + result <- suppressMessages( + loadTopFeat( + results_root = tmp, + species_dirs = NULL, + verbose = FALSE + ) + ) + expect_s3_class(result, "tbl_df") + expect_equal(nrow(result), 0) +}) + +test_that("loadTopFeat loads demo data in fallback mode", { + result <- suppressMessages(loadTopFeat(verbose = FALSE)) + expect_s3_class(result, "tbl_df") + expect_gt(nrow(result), 0) + expect_true("Variable" %in% names(result)) + expect_true("Importance" %in% names(result)) +}) + +# ── get_metadata_path ──────────────────────────────────────────────────────── + +test_that("get_metadata_path returns NULL for nonexistent species code", { + result <- get_metadata_path("Zzz") + expect_null(result) +}) + +test_that("get_metadata_path finds demo metadata parquet", { + extdata <- system.file("extdata", package = "amRshiny") + skip_if(!nzchar(extdata), "No extdata directory found") + + result <- get_metadata_path("Sfl") + if (!is.null(result)) { + expect_true(file.exists(result)) + expect_true(grepl("Sfl_metadata\\.parquet$", result)) + } +}) + +# ── loadDrugClassMap ───────────────────────────────────────────────────────── + +test_that("loadDrugClassMap returns a tibble with expected columns", { + result <- suppressMessages(loadDrugClassMap()) + expect_s3_class(result, "tbl_df") + expect_true("drug.antibiotic_name" %in% names(result)) + expect_true("drug_class" %in% names(result)) + expect_gt(nrow(result), 0) +}) + +test_that("loadDrugClassMap returns distinct rows", { + result <- suppressMessages(loadDrugClassMap()) + expect_equal(nrow(result), nrow(dplyr::distinct(result))) +}) diff --git a/tests/testthat/test-getHoldoutsDrugChoices.R b/tests/testthat/test-getHoldoutsDrugChoices.R new file mode 100644 index 0000000..5c0c301 --- /dev/null +++ b/tests/testthat/test-getHoldoutsDrugChoices.R @@ -0,0 +1,78 @@ +## Tests for getHoldoutsDrugChoices + +test_that("getHoldoutsDrugChoices returns empty for NULL input", { + expect_equal(getHoldoutsDrugChoices(NULL), character(0)) +}) + +test_that("getHoldoutsDrugChoices returns empty for empty data frame", { + expect_equal(getHoldoutsDrugChoices(data.frame()), character(0)) +}) + +test_that("getHoldoutsDrugChoices returns empty for zero-row tibble", { + df <- tibble::tibble( + strat_label = character(0), + drug_or_class = character(0), + species = character(0) + ) + expect_equal(getHoldoutsDrugChoices(df), character(0)) +}) + +test_that("getHoldoutsDrugChoices filters to stratified rows only", { + df <- tibble::tibble( + strat_label = c(NA_character_, "", "country", "year"), + drug_or_class = c( + "amoxicillin", "ampicillin", + "ciprofloxacin", "tetracycline" + ), + species = c("Sau", "Sau", "Sau", "Sau") + ) + result <- getHoldoutsDrugChoices(df) + expect_true("ciprofloxacin" %in% result) + expect_true("tetracycline" %in% result) + expect_false("amoxicillin" %in% result) + expect_false("ampicillin" %in% result) +}) + +test_that("getHoldoutsDrugChoices returns sorted unique values", { + df <- tibble::tibble( + strat_label = c("country", "country", "year"), + drug_or_class = c("tetracycline", "ampicillin", "tetracycline"), + species = c("Sau", "Sau", "Sau") + ) + result <- getHoldoutsDrugChoices(df) + expect_equal(result, c("ampicillin", "tetracycline")) +}) + +test_that("getHoldoutsDrugChoices filters by bug when provided", { + df <- tibble::tibble( + strat_label = c("country", "country", "country"), + drug_or_class = c( + "ampicillin", "ciprofloxacin", "tetracycline" + ), + species = c("Sau", "Kpn", "Sau") + ) + result <- getHoldoutsDrugChoices(df, bug = "Sau") + expect_true("ampicillin" %in% result) + expect_true("tetracycline" %in% result) + expect_false("ciprofloxacin" %in% result) +}) + +test_that("getHoldoutsDrugChoices normalizes species for comparison", { + df <- tibble::tibble( + strat_label = c("country", "country"), + drug_or_class = c("ampicillin", "ciprofloxacin"), + species = c("Esp.", "Esp") + ) + result <- getHoldoutsDrugChoices(df, bug = "Esp.") + expect_length(result, 2) +}) + +test_that("getHoldoutsDrugChoices excludes NA and blank drug_or_class", { + df <- tibble::tibble( + strat_label = c("country", "country", "country"), + drug_or_class = c("ampicillin", NA_character_, " "), + species = c("Sau", "Sau", "Sau") + ) + result <- getHoldoutsDrugChoices(df) + expect_equal(result, "ampicillin") +}) diff --git a/tests/testthat/test-makeFeatureImportTable.R b/tests/testthat/test-makeFeatureImportTable.R new file mode 100644 index 0000000..ae223cb --- /dev/null +++ b/tests/testthat/test-makeFeatureImportTable.R @@ -0,0 +1,76 @@ +## Tests for makeFeatureImportTable + +test_that("makeFeatureImportTable returns datatable for NULL input", { + result <- makeFeatureImportTable(NULL) + expect_s3_class(result, "datatables") +}) + +test_that("makeFeatureImportTable returns datatable for empty data", { + df <- tibble::tibble() + result <- makeFeatureImportTable(df) + expect_s3_class(result, "datatables") +}) + +test_that("makeFeatureImportTable formats numeric columns to scientific notation", { + df <- tibble::tibble( + species = c("Sau", "Kpn"), + drug_or_class = c("ampicillin", "tetracycline"), + Variable = c("gene1", "gene2"), + Importance = c(0.00123, 0.456) + ) + + result <- makeFeatureImportTable(df) + expect_s3_class(result, "datatables") +}) + +test_that("makeFeatureImportTable reorders columns by priority", { + df <- tibble::tibble( + Variable = c("gene1"), + Importance = c(0.5), + species = c("Sau"), + drug_or_class = c("ampicillin"), + feature_type = c("genes"), + feature_subtype = c("binary") + ) + + result <- makeFeatureImportTable(df) + expect_s3_class(result, "datatables") +}) + +test_that("makeFeatureImportTable adds hyperlinks for accession column", { + df <- tibble::tibble( + species = c("Sau"), + drug_or_class = c("ampicillin"), + accession = c("WP_001234567.1"), + Importance = c(0.5) + ) + + result <- makeFeatureImportTable(df) + expect_s3_class(result, "datatables") + expect_true(any(grepl("href", unlist(result$x$data)))) +}) + +test_that("makeFeatureImportTable adds hyperlinks for COG_name column", { + df <- tibble::tibble( + species = c("Sau"), + drug_or_class = c("ampicillin"), + COG_name = c("COG0001"), + Importance = c(0.5) + ) + + result <- makeFeatureImportTable(df) + expect_s3_class(result, "datatables") + expect_true(any(grepl("href", unlist(result$x$data)))) +}) + +test_that("makeFeatureImportTable replaces non-ARG in ARG_name column", { + df <- tibble::tibble( + species = c("Sau", "Sau"), + drug_or_class = c("ampicillin", "tetracycline"), + ARG_name = c("non-ARG", "blaOXA-1"), + Importance = c(0.5, 0.8) + ) + + result <- makeFeatureImportTable(df) + expect_s3_class(result, "datatables") +}) diff --git a/tests/testthat/test-makeQuickStats.R b/tests/testthat/test-makeQuickStats.R new file mode 100644 index 0000000..35d55fd --- /dev/null +++ b/tests/testthat/test-makeQuickStats.R @@ -0,0 +1,41 @@ +## Tests for makeQuickStats + +test_that("makeQuickStats returns a tagList with expected structure", { + df <- tibble::tibble( + genome_drug.genome_id = c("G1", "G1", "G2", "G3"), + genome_drug.antibiotic = c( + "ampicillin", "tetracycline", + "ampicillin", "ciprofloxacin" + ), + genome_drug.resistant_phenotype = c( + "Resistant", "Susceptible", + "Resistant", "Susceptible" + ), + drug_class = c( + "penicillins", "tetracyclines", + "penicillins", "fluoroquinolones" + ), + genome.isolation_country = c("USA", "UK", "USA", "Germany"), + species = c( + "staphylococcus aureus", "staphylococcus aureus", + "staphylococcus aureus", "staphylococcus aureus" + ) + ) + + result <- makeQuickStats(df) + expect_s3_class(result, "shiny.tag.list") +}) + +test_that("makeQuickStats handles single-row data", { + df <- tibble::tibble( + genome_drug.genome_id = "G1", + genome_drug.antibiotic = "ampicillin", + genome_drug.resistant_phenotype = "Resistant", + drug_class = "penicillins", + genome.isolation_country = "USA", + species = "staphylococcus aureus" + ) + + result <- makeQuickStats(df) + expect_s3_class(result, "shiny.tag.list") +}) diff --git a/tests/testthat/test-normalize_species.R b/tests/testthat/test-normalize_species.R new file mode 100644 index 0000000..98546c3 --- /dev/null +++ b/tests/testthat/test-normalize_species.R @@ -0,0 +1,29 @@ +test_that("normalize_species removes trailing dots", { + expect_equal(normalize_species("Esp."), "Esp") + expect_equal(normalize_species("Sau"), "Sau") + expect_equal(normalize_species("Kpn."), "Kpn") +}) + +test_that("normalize_species handles vectors", { + input <- c("Esp.", "Sau", "Kpn.", "Aba") + expected <- c("Esp", "Sau", "Kpn", "Aba") + expect_equal(normalize_species(input), expected) +}) + +test_that("normalize_species preserves NA", { + expect_equal(normalize_species(NA), NA_character_) + result <- normalize_species(c("Sau", NA, "Esp.")) + expect_equal(result, c("Sau", NA, "Esp")) +}) + +test_that("normalize_species handles empty strings", { + expect_equal(normalize_species(""), "") + expect_equal(normalize_species(character(0)), character(0)) +}) + +test_that("normalize_species only removes trailing dot", { + # Dot in the middle should remain + expect_equal(normalize_species("E.coli"), "E.coli") + # Multiple trailing dots: only last one removed + expect_equal(normalize_species("Esp.."), "Esp.") +}) diff --git a/tests/testthat/test-plots.R b/tests/testthat/test-plots.R new file mode 100644 index 0000000..72bd305 --- /dev/null +++ b/tests/testthat/test-plots.R @@ -0,0 +1,142 @@ +## Tests for plot generation functions + +# ── makeDatAvailabilityPlot ────────────────────────────────────────────────── + +test_that("makeDatAvailabilityPlot returns a ggplot object", { + df <- tibble::tibble( + genome_drug.antibiotic = c( + "ampicillin", "ampicillin", "tetracycline" + ), + genome_drug.resistant_phenotype = c( + "Resistant", "Susceptible", "Resistant" + ) + ) + + result <- makeDatAvailabilityPlot(df) + expect_s3_class(result, "gg") +}) + +# ── makeTimeSeriesAMRPlot ──────────────────────────────────────────────────── + +test_that("makeTimeSeriesAMRPlot returns a ggplot object", { + df <- tibble::tibble( + genome.collection_year = c(2018, 2019, 2020, 2018, 2019, 2020), + genome_drug.resistant_phenotype = rep( + c("Resistant", "Susceptible"), each = 3 + ), + n = c(10, 15, 20, 30, 25, 35) + ) + + result <- makeTimeSeriesAMRPlot(df, "ampicillin") + expect_s3_class(result, "gg") +}) + +test_that("makeTimeSeriesAMRPlot handles amr_drug = 'all'", { + df <- tibble::tibble( + genome.collection_year = c(2019, 2020), + genome_drug.resistant_phenotype = c("Resistant", "Susceptible"), + n = c(100, 200) + ) + + result <- makeTimeSeriesAMRPlot(df, "all") + expect_s3_class(result, "gg") +}) + +# ── makeHostIsolatePlot ────────────────────────────────────────────────────── + +test_that("makeHostIsolatePlot returns a ggplot object", { + df <- tibble::tibble( + genome_drug.antibiotic = c( + "ampicillin", "ampicillin", "tetracycline" + ), + genome.host_common_name = c("Human", "Bovine", "Human"), + genome.isolation_source = c("blood", "feces", "urine") + ) + + result <- makeHostIsolatePlot(df) + expect_s3_class(result, "gg") +}) + +# ── makeIsolationSourcesPlot ───────────────────────────────────────────────── + +test_that("makeIsolationSourcesPlot returns a ggplot object", { + df <- tibble::tibble( + genome_drug.antibiotic = c( + "ampicillin", "tetracycline", "ampicillin" + ), + genome.isolation_source = c("Blood", "Urine", "Stool") + ) + + result <- makeIsolationSourcesPlot(df) + expect_s3_class(result, "gg") +}) + +# ── makeModelPerformancePlot ───────────────────────────────────────────────── + +test_that("makeModelPerformancePlot returns ggplot for NULL data", { + result <- makeModelPerformancePlot( + data = NULL, bug = "Sau", model_scale = "genes", + data_type = "binary", metrics = "nmcc", + amr_drug_class = NULL, amr_drug = NULL + ) + expect_s3_class(result, "gg") +}) + +test_that("makeModelPerformancePlot returns ggplot for zero-row data", { + result <- makeModelPerformancePlot( + data = data.frame(), bug = "Sau", model_scale = "genes", + data_type = "binary", metrics = "nmcc", + amr_drug_class = NULL, amr_drug = NULL + ) + expect_s3_class(result, "gg") +}) + +test_that("makeModelPerformancePlot generates valid plot with demo data", { + perf <- suppressMessages(loadMLResults(verbose = FALSE)) + skip_if(nrow(perf) == 0, "No demo performance data") + + species <- unique(perf$species)[1] + scales <- unique(perf$feature_type) + subtypes <- unique(perf$feature_subtype) + + result <- makeModelPerformancePlot( + data = perf, + bug = species, + model_scale = scales, + data_type = subtypes, + metrics = "nmcc", + amr_drug_class = "all", + amr_drug = NULL + ) + expect_s3_class(result, "gg") +}) + +# ── makeFeatureImportancePlot ──────────────────────────────────────────────── + +test_that("makeFeatureImportancePlot returns NULL for empty data", { + result <- makeFeatureImportancePlot( + data = NULL, bug = "Sau", amr_drug = "ampicillin", + model_scale = "genes", data_type_ = "binary", + top_n_features = 10, + feature_importance_tabset = "across_bug" + ) + expect_null(result) +}) + +# ── makeCrossModelPerformancePlot ──────────────────────────────────────────── + +test_that("makeCrossModelPerformancePlot returns NULL for empty data", { + result <- makeCrossModelPerformancePlot( + perf_data = NULL, bug = "Sau", + drug = "ampicillin", cross_model = "country" + ) + expect_null(result) +}) + +test_that("makeCrossModelPerformancePlot returns NULL for zero-row data", { + result <- makeCrossModelPerformancePlot( + perf_data = data.frame(), bug = "Sau", + drug = "ampicillin", cross_model = "country" + ) + expect_null(result) +}) diff --git a/tests/testthat/test-ui_modules.R b/tests/testthat/test-ui_modules.R new file mode 100644 index 0000000..6e5278f --- /dev/null +++ b/tests/testthat/test-ui_modules.R @@ -0,0 +1,72 @@ +## Tests for UI module functions + +test_that("queryDataUI returns a shiny tabPanel", { + result <- queryDataUI() + expect_s3_class(result, "shiny.tag") + expect_true("shiny.tag" %in% class(result)) +}) + +test_that("metadataUI returns a shiny tabPanel", { + result <- metadataUI() + expect_s3_class(result, "shiny.tag") +}) + +test_that("modelPerfUI returns a shiny tabPanel", { + result <- modelPerfUI() + expect_s3_class(result, "shiny.tag") +}) + +test_that("featureImportanceUI returns a shiny tabPanel", { + result <- featureImportanceUI() + expect_s3_class(result, "shiny.tag") +}) + +test_that("crossModelComparisonUI returns a shiny tabPanel", { + result <- crossModelComparisonUI() + expect_s3_class(result, "shiny.tag") +}) + +# ── UI helper functions ────────────────────────────────────────────────────── + +test_that("quickStatBox returns a shiny tag", { + result <- quickStatBox("Test Title", "42") + expect_s3_class(result, "shiny.tag") +}) + +test_that("quickStatBox accepts custom colors", { + result <- quickStatBox( + "Title", "100", + bg_color = "#fff", text_color = "black" + ) + expect_s3_class(result, "shiny.tag") +}) + +test_that("amr_select returns a shiny tag with selectInput", { + result <- amr_select( + "test_id", "Test Label", choices = c("A", "B", "C") + ) + expect_s3_class(result, "shiny.tag") +}) + +test_that("amr_select respects multiple parameter", { + result_multi <- amr_select( + "id1", "Label", c("A", "B"), multiple = TRUE + ) + result_single <- amr_select( + "id2", "Label", c("A", "B"), multiple = FALSE + ) + expect_s3_class(result_multi, "shiny.tag") + expect_s3_class(result_single, "shiny.tag") +}) + +test_that("amr_button returns a shiny tag with actionButton", { + result <- amr_button( + "btn_id", "Click Me", "download", "btn-primary" + ) + expect_s3_class(result, "shiny.tag") +}) + +test_that("launchAMRDashboard returns a shiny.appobj", { + app <- launchAMRDashboard() + expect_s3_class(app, "shiny.appobj") +}) From 02249aa958b2cf7202caf613125cd2ae1f681217 Mon Sep 17 00:00:00 2001 From: eboyer221 Date: Fri, 10 Apr 2026 19:41:19 +0000 Subject: [PATCH 2/2] Style code (GHA) --- tests/testthat/test-plots.R | 3 ++- tests/testthat/test-ui_modules.R | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-plots.R b/tests/testthat/test-plots.R index 72bd305..62ce683 100644 --- a/tests/testthat/test-plots.R +++ b/tests/testthat/test-plots.R @@ -22,7 +22,8 @@ test_that("makeTimeSeriesAMRPlot returns a ggplot object", { df <- tibble::tibble( genome.collection_year = c(2018, 2019, 2020, 2018, 2019, 2020), genome_drug.resistant_phenotype = rep( - c("Resistant", "Susceptible"), each = 3 + c("Resistant", "Susceptible"), + each = 3 ), n = c(10, 15, 20, 30, 25, 35) ) diff --git a/tests/testthat/test-ui_modules.R b/tests/testthat/test-ui_modules.R index 6e5278f..ad292b1 100644 --- a/tests/testthat/test-ui_modules.R +++ b/tests/testthat/test-ui_modules.R @@ -43,17 +43,20 @@ test_that("quickStatBox accepts custom colors", { test_that("amr_select returns a shiny tag with selectInput", { result <- amr_select( - "test_id", "Test Label", choices = c("A", "B", "C") + "test_id", "Test Label", + choices = c("A", "B", "C") ) expect_s3_class(result, "shiny.tag") }) test_that("amr_select respects multiple parameter", { result_multi <- amr_select( - "id1", "Label", c("A", "B"), multiple = TRUE + "id1", "Label", c("A", "B"), + multiple = TRUE ) result_single <- amr_select( - "id2", "Label", c("A", "B"), multiple = FALSE + "id2", "Label", c("A", "B"), + multiple = FALSE ) expect_s3_class(result_multi, "shiny.tag") expect_s3_class(result_single, "shiny.tag")