tests/testthat/helper-html-class.R

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 Oct. 30, 2024, 9:29 a.m.