Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
edelarua committed May 16, 2023
1 parent 90fc991 commit 87ec1ed
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/testthat/_snaps/summarize_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -1128,3 +1128,26 @@
Median NA 3.5 5.5
Min - Max NA 3.0 - 4.0 5.0 - 6.0

# `summarize_vars` na_level argument works with non-default input

Code
res
Output
all obs
———————————
n 4
a 2 (50%)
b 2 (50%)

---

Code
res
Output
all obs
—————————————
n 6
a 2 (33.3%)
b 2 (33.3%)
c 2 (33.3%)

20 changes: 20 additions & 0 deletions tests/testthat/test-summarize_variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,23 @@ testthat::test_that("`summarize_vars` works with empty named numeric variables",
res <- testthat::expect_silent(result)
testthat::expect_snapshot(res)
})

testthat::test_that("`summarize_vars` na_level argument works with non-default input", {
dta <- tibble::tibble(
foo = factor(c("a", "a", "b", "b", "c", "c"), levels = c("a", "b", "c"))
)

result <- basic_table() %>%
summarize_vars(vars = "foo", na_level = "c") %>%
build_table(dta)

res <- testthat::expect_silent(result)
testthat::expect_snapshot(res)

result <- basic_table() %>%
summarize_vars(vars = "foo", na_level = "c", na.rm = FALSE) %>%
build_table(dta)

res <- testthat::expect_silent(result)
testthat::expect_snapshot(res)
})

0 comments on commit 87ec1ed

Please sign in to comment.