tests/testthat/test-scales.R

test_that("scale_x_vctr can be added to a plot", {
  g <- ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
    geom_point()

  # Test object can be created
  sc <- scale_x_vctr()
  expect_is(sc, "ScaleContinuousVctr")

  # Test object is added to plot
  test <- g + sc
  expect_is(test$scales$get_scales("x"), "ScaleContinuousVctr")

  # Test plot can be build without errors
  expr <- substitute(ggplotGrob(test))
  expect_silent(eval(expr))
})

test_that("scale_y_vctr can be added to a plot", {
  g <- ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
    geom_point()

  # Test object can be created
  sc <- scale_y_vctr()
  expect_is(sc, "ScaleContinuousVctr")

  # Test object is added to plot
  test <- g + sc
  expect_is(test$scales$get_scales("y"), "ScaleContinuousVctr")

  # Test plot can be build without errors
  expr <- substitute(ggplotGrob(test))
  expect_silent(eval(expr))
})
teunbrand/ggvctrcoords documentation built on Jan. 12, 2020, 6:25 p.m.