tests/testthat/test-gt_highlight_cols.R

test_that("gt_highlight_row correct row is highlighted and is blue", {
  check_suggests()

  basic_col <-  gt::gt(head(mtcars)) %>%
    gt_highlight_cols(cyl, fill = "red", alpha = 0.5) %>%
    gt::as_raw_html() %>%
    rvest::read_html()

  high_col <- basic_col %>%
    rvest::html_nodes("td:nth-child(2)") %>%
    rvest::html_attr("style") %>%
    gsub(x = ., pattern = ".*background-color: ", "") %>%
    substr(1, 17)

  expect_equal(high_col, rep("rgba(255,0,0,0.5)", 6))

})

Try the gtExtras package in your browser

Any scripts or data that you put into this service are public.

gtExtras documentation built on Sept. 16, 2023, 1:08 a.m.