Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #26 from nutriverse/dev
Browse files Browse the repository at this point in the history
add more tests
  • Loading branch information
ernestguevarra authored Feb 22, 2024
2 parents 9b70117 + a88a1f5 commit 0c579db
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/testthat/test-muac-check.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,20 @@ testthat::expect_true(
"std_dev_class", "quality_score", "quality_class") %in% names(muac_check))
)
testthat::expect_equal(nrow(muac_check), nrow(muac_data))


## Test check function - recode sex

muac_check <- muac_data |>
dplyr::mutate(sex = ifelse(sex == 1, "m", "f")) |>
ipc_muac_check(
sex_recode = c("m", "f"), muac_units = "cm", oedema_recode = c(1, 2)
)

testthat::expect_type(muac_check, "list")
testthat::expect_vector(muac_check)
testthat::expect_named(
muac_check,
c("Age Ratio", "Sex Ratio", "Digit Preference",
"Standard Deviation", "Data Quality")
)
21 changes: 21 additions & 0 deletions tests/testthat/test-muac-prevalence.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Test MUAC prevalence ---------------------------------------------------------

muac_prevalence <- ipc_muac_check(
df = muac_data, muac_units = "cm", oedema_recode = c(1, 2), .summary = FALSE
) |>
ipc_calculate_prevalence(status = "sam")


testthat::expect_type(muac_prevalence, "double")


muac_prevalence <- muac_data |>
dplyr::mutate(sex = ifelse(sex == 1, "m", "f")) |>
ipc_muac_check(
sex_recode = c("m", "f"), muac_units = "cm",
oedema_recode = c(1, 2), .summary = FALSE
) |>
ipc_calculate_prevalence(status = "mam")


testthat::expect_type(muac_prevalence, "double")

0 comments on commit 0c579db

Please sign in to comment.