tests/testthat/test-get_output_and_render_func.R

context("getOutputAndRenderFunc")

describe("getOutputAndRenderFunc", {
  if(require("leaflet")){
    it ("returns output and render functions of a widget", {
      widget <- leaflet()
      res <- getOutputAndRenderFunc(widget)
      expect_named(res, c("outputFunc", "renderFunc", "useCombineWidgets"))
      expect_equal(res$outputFunc, leaflet::leafletOutput)
      expect_equal(res$renderFunc, leaflet::renderLeaflet)
      expect_equal(res$useCombineWidgets, FALSE)
    })

    it ("returns combineWidgets output and render functions if x is not an htmlwidget", {
      res <- getOutputAndRenderFunc("test")
      expect_named(res, c("outputFunc", "renderFunc", "useCombineWidgets"))
      expect_equal(res$outputFunc, combineWidgetsOutput)
      expect_equal(res$renderFunc, renderCombineWidgets)
      expect_equal(res$useCombineWidgets, TRUE)
    })
  }
})
rte-antares-rpackage/manipulateWidget documentation built on Oct. 5, 2021, 8:20 p.m.