tests/testthat/test-render.R

context("htmlwidget")

test_that("conversion", {
  expect_is(as.htmlwidget(formattable(mtcars)), c("formattable_widget", "htmlwidget"))
})

test_that("shiny", {
  # some preliminary testing for shiny functionality
  expect_is(renderFormattable(formattable(head(mtcars))), c("shiny.render.function", "function"))
  expect_is(formattableOutput(0), c("shiny.tag.list", "list"))
})

test_that("as.datatable", {
  f <- formattable(mtcars, list(
    mpg = color_tile("transparent", "lightgray"),
    cyl = color_bar("gray"),
    area(col = vs:carb) ~ formatter("span", style = x ~ style(color = ifelse(x > 0, "red", NA)))))
  dt <- as.datatable(f)
  expect_is(dt, c("datatables", "htmlwidget"))
})

Try the formattable package in your browser

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

formattable documentation built on Jan. 13, 2021, 7:17 a.m.