tests/testthat/test-safe_ggplot.R

context("test-safe_ggplot")

test_that("safe_ggplot (no error) works", {

  session <- shiny::MockShinySession$new()

  p <- safe_ggplot(
    expr = rlang::expr(ggplot(iris) + geom_histogram(aes(Sepal.Length))),
    session = session
  )
  expect_is(p, "ggplot_built")
  expect_null(session$userData$esquisse_notifications)

})

test_that("safe_ggplot (error) works", {

  session <- shiny::MockShinySession$new()

  p <- safe_ggplot(
    expr = rlang::expr(ggplot(iris) + geom_histogram(aes(DONOTEXIST))),
    session = session
  )

  expect_is(p, "list")
  expect_false(is.null(session$userData$esquisse_notifications))

})

Try the esquisse package in your browser

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

esquisse documentation built on Sept. 18, 2024, 5:09 p.m.