Skip to content

Commit

Permalink
Add more tests to improve coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Jul 12, 2024
1 parent 41b6fce commit 7298e16
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/testthat/test-text_transform.R
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,37 @@ test_that("text_transform() works on row group labels", {
selection_text("[class='gt_group_heading']") %>%
expect_equal(c("SUPER POWERFUL", "POWERFUL"))
})


# text_*() other functions -----------------------------------------------------

test_that("text_case_when() + text_case_match() work", {
expect_no_error(
cw <- exibble %>%
gt() %>%
text_case_when(is.na(x) ~ "---")
)
# md is not really respected even if we use md("---")
expect_no_error(
cm <- exibble %>%
gt() %>%
text_case_match(NA ~ "---")
)
# they are not changing numeric NA
expect_equal(
render_as_html(cw),
render_as_html(cm)
)
})

test_that("text_replace() works", {
expect_no_error(
tr <- exibble %>%
gt() %>%
text_replace("NA", "---")
)
expect_match_html(
tr,
"---"
)
})

0 comments on commit 7298e16

Please sign in to comment.