tests/testthat/helper-html.R

div <- htmltools::div

expect_html_class <- function(tag, class) {
  # 1. Capture object and label
  act <- quasi_label(rlang::enquo(tag), arg = "tag")

  reg <- paste0("(?:^|\\s)", class, "(?:$|\\s)")

  # 2. Call expect()
  act$class <- act$val$attribs$class
  expect(
    grepl(reg, act$class),
    sprintf("%s has class %s, could not find %s.", act$lab, act$class, class)
  )

  # 3. Invisibly return the value
  invisible(act$val)
}

Try the cascadess package in your browser

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

cascadess documentation built on Jan. 13, 2021, 5:10 p.m.