Skip to content

Commit

Permalink
Add simple tests of utils and custom_rows
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-dray committed Jan 9, 2024
1 parent 911abe6 commit 70655f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/testthat/test-a11ytable.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,23 @@ test_that("class validation works", {
x$sheet_type <- NA_character_
expect_error(as_a11ytable(x))

x <- demo_df
x$custom_rows <- NA_character_
expect_error(as_a11ytable(x))

x <- demo_df
x$custom_rows <- rep(list(1), nrow(x))
expect_error(as_a11ytable(x))

x <- demo_df
x[x$tab_title == "Table_2", "tab_title"] <-
"Lorem_ipsum_dolor_sit_amet__consectetur_adipiscing"
expect_warning(as_a11ytable(x))

x <- demo_df
x[x$tab_title == "Table_2", "tab_title"] <- "!?"
expect_warning(as_a11ytable(x))

x <- demo_df
x[x$sheet_type == "notes", "table"][[1]] <-
list(
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test_that("vector elements are converted to sentence form", {
expect_equal(.vector_to_sentence(LETTERS[1]), "A")
expect_equal(.vector_to_sentence(LETTERS[1:2]), "A and B")
expect_equal(.vector_to_sentence(LETTERS[1:3]), "A, B and C")
})

0 comments on commit 70655f9

Please sign in to comment.