1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-21 00:53:20 +02:00

(v2.1.1.9129) unit test fix

This commit is contained in:
2025-01-27 16:17:03 +01:00
parent 6efa317a81
commit 1149360b27
66 changed files with 94 additions and 80 deletions

View File

@ -27,6 +27,15 @@
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
# ==================================================================== #
tryCatch(!is.function(expect_stout), error = function(e) TRUE) {
expect_stout <<- testthat::expect_output
}
tryCatch(!is.function(expect_inherits), error = function(e) TRUE) {
expect_inherits <<- function(x, y, ...) testthat::expect(inherits(x, y),
failure_message = paste0("Expected class ", paste(y, collapse = "/"),
", got class ", paste(class(x), collapse = "/")))
}
expect_equal(AMR:::percentage(0.25), "25%")
expect_equal(AMR:::percentage(0.5), "50%")
expect_equal(AMR:::percentage(0.500, digits = 1), "50.0%")

View File

@ -37,7 +37,7 @@ suppressMessages(
species = "asburiae/cloacae")
)
)
expect_identical(as.character(as.mo("ENT_ASB_CLO")), "ENT_ASB_CLO")
expect_identical(mo_name("ENT_ASB_CLO"), "Enterobacter asburiae/cloacae")
expect_identical(mo_gramstain("ENT_ASB_CLO", language = NULL), "Gram-negative")

View File

@ -43,13 +43,15 @@ if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0", also_load = TRUE) &&
summarise_all(resistance) %>%
as.double()
)
expect_stdout(print(example_isolates %>%
select(AMC, CIP) %>%
ggplot_sir(x = "interpretation", facet = "antibiotic")))
expect_stdout(print(example_isolates %>%
select(AMC, CIP) %>%
ggplot_sir(x = "antibiotic", facet = "interpretation")))
expect_inherits(example_isolates %>%
select(AMC, CIP) %>%
ggplot_sir(x = "interpretation", facet = "antibiotic"),
"gg")
expect_inherits(example_isolates %>%
select(AMC, CIP) %>%
ggplot_sir(x = "antibiotic", facet = "interpretation"),
"gg")
expect_equal(
(example_isolates %>%