tests/testthat/test_get_titles.R

context("get_titles")

test_that("get titles", {
  df <- data.frame(x = 1:3, y = 1:3)
  p <- ggplot(df, aes(x, y)) + geom_point()

  expect_s3_class(get_title(p), "zeroGrob")
  expect_s3_class(get_subtitle(p), "zeroGrob")

  p <- p + labs(title = "Title", subtitle = "Subtitle")

  expect_s3_class(get_title(p), "titleGrob")
  expect_s3_class(get_subtitle(p), "titleGrob")
})

Try the cowplot package in your browser

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

cowplot documentation built on Dec. 30, 2020, 5:07 p.m.