tests/testthat/test-plot.R

test_that("with_par() works", {
  skip_if_not(package_available("graphics"))
  skip_if_not(package_available("grDevices"))

  par0 <- graphics::par("mfrow")
  set.seed(42)
  df <- data.frame(a = stats::rnorm(100), b = stats::rnorm(100))
  # not testing for plot
  grDevices::dev.off()
  wuffle(with_par(
    graphics::plot(stats::lm(a ~ b, data = df)),
    ops = list(mfrow = c(2, 2))
  ))
  grDevices::dev.off()
  expect_identical(par0, graphics::par("mfrow"))
})
jmbarbone/jordan documentation built on April 1, 2024, 7:46 p.m.