blob: d217d06b44a833117e32d60e2668ff1097be93d1 [file] [log] [blame]
JJ Allaire6da1bb62016-01-30 14:28:39 -05001test_theme <- function(theme) {
JJ Allaire6da1bb62016-01-30 14:28:39 -05002 test_that(paste(theme, "theme"), {
JJ Allaire6da1bb62016-01-30 14:28:39 -05003 # don't run on cran because pandoc is required
4 skip_on_cran()
5
6 # work in a temp directory
7 dir <- tempfile()
8 dir.create(dir)
9 oldwd <- setwd(dir)
10 on.exit(setwd(oldwd), add = TRUE)
11
12 # create a draft of a presentation
13 testdoc <- "testdoc.Rmd"
14 rmarkdown::draft(testdoc,
15 system.file("rmarkdown", "templates", "revealjs_presentation",
16 package = "revealjs"),
17 create_dir = FALSE,
18 edit = FALSE)
19
20 # render it with the specified theme
21 capture.output({
22 output_file <- tempfile(fileext = ".html")
23 output_format <- revealjs_presentation(theme = theme)
JJ Allaire091cb122016-02-09 13:04:23 -050024 rmarkdown::render(testdoc,
25 output_format = output_format,
christophe dervieux1b204832021-09-16 12:25:16 +020026 output_file = output_file,
27 quiet = TRUE)
JJ Allaire6da1bb62016-01-30 14:28:39 -050028 expect_true(file.exists(output_file))
29 })
30 })
31}
32
33# test all themes
34sapply(revealjs:::revealjs_themes(), test_theme)