tests/testthat/test-hover_button.R

test_that("hover_action_button accepts class arguments", {
  make_button <- function(class) {
    if (missing(class)) {
      hover_action_button("id", "label")
    } else {
      hover_action_button("id", "label", class = class)
    }
  }
  act <- make_button()
  get_class <- function(act) {
    act_html <- format(act)
    regmatches(act_html, regexec("class=\"[^\"]\"", act_html))[[1]]
  }
  act_class <- get_class(act)
  expect_equal(
    get_class(make_button(NULL)), act_class
  )
  expect_equal(
    get_class(make_button(NA)), act_class
  )
  expect_equal(
    get_class(make_button("extra")), sub("\"$", " extra\"", act_class)
  )
  expect_equal(
    get_class(make_button("extra extra2")), sub("\"$", " extra extra2\"", act_class)
  )
})
tyluRp/hover documentation built on March 31, 2021, 4:37 a.m.