diff --git a/tests/testthat/_snaps/print.md b/tests/testthat/_snaps/print.md index 44cdae9..6ebbc11 100644 --- a/tests/testthat/_snaps/print.md +++ b/tests/testthat/_snaps/print.md @@ -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 + + diff --git a/tests/testthat/_snaps/w_table.md b/tests/testthat/_snaps/w_table.md index 37747bb..cf0764b 100644 --- a/tests/testthat/_snaps/w_table.md +++ b/tests/testthat/_snaps/w_table.md @@ -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 + + diff --git a/tests/testthat/test-print.R b/tests/testthat/test-print.R index 68741ce..6660791 100644 --- a/tests/testthat/test-print.R +++ b/tests/testthat/test-print.R @@ -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)) +}) diff --git a/tests/testthat/test-w_table.R b/tests/testthat/test-w_table.R index ea0f79c..a214003 100644 --- a/tests/testthat/test-w_table.R +++ b/tests/testthat/test-w_table.R @@ -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)) +})