Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dusadrian committed Nov 26, 2023
1 parent bb486b4 commit b1e6d87
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/testthat/_snaps/print.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,17 @@
7 A7
# ... plus 3 more labels, use labels() to print them all.

# w_table works with a variable having all values NA

Code
print(tstable)
Output
fre rel per vld cpd
----------------------------
--
NA 5 1.000 100.0
----------------------------
5 1.000 100.0

14 changes: 14 additions & 0 deletions tests/testthat/_snaps/w_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,17 @@
Total 89 126 215

# w_table works with a variable having all values NA

Code
w_table(tst)
Output
fre rel per vld cpd
----------------------------
--
NA 5 1.000 100.0
----------------------------
5 1.000 100.0

14 changes: 14 additions & 0 deletions tests/testthat/test-print.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,17 @@ xlarge <- declared(
test_that("very many labels are truncated at print", {
expect_snapshot(print(xlarge))
})



tst <- declared(
c(rep(NA, 5)),
labels = c(A = 1, Refusal = -91),
na_values = -91
)

tstable <- w_table(tst)

test_that("w_table works with a variable having all values NA", {
expect_snapshot(print(tstable))
})
10 changes: 10 additions & 0 deletions tests/testthat/test-w_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,13 @@ test_that("tests have the same output", {
expect_snapshot(using(DF, w_table(Gender, vlabel = TRUE)))
expect_snapshot(using(DF, w_table(Gender, Area, vlabel = TRUE)))
})

tst <- declared(
c(rep(NA, 5)),
labels = c(A = 1, Refusal = -91),
na_values = -91
)

test_that("w_table works with a variable having all values NA", {
expect_snapshot(w_table(tst))
})

0 comments on commit b1e6d87

Please sign in to comment.