tests/testthat/test-get_grob_component.R

test_that("get_grob_component() namespaces", {
  expect_true(requireNamespace("ggplotify", quietly = TRUE))
  expect_true(requireNamespace("ggplot2", quietly = TRUE))
  expect_true(requireNamespace("vdiffr", quietly = TRUE))
})

test_that("The returned list object is not NULL", {
  expect_snapshot({
    mtcars_plot <- ggplot2::ggplot(
      data = datasets::mtcars,
    ) +
      ggplot2::geom_point(aes(x = mpg, y = wt, color = cyl), size = 3)

    legend_right <- RplotterPkg::get_grob_component(
      a_plot = mtcars_plot,
      component_name = "guide-box-right"
    )
  })
  expect_true(!is.null(legend_right))
})

Try the RplotterPkg package in your browser

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

RplotterPkg documentation built on April 4, 2025, 2:04 a.m.