JJ Allaire | 6da1bb6 | 2016-01-30 14:28:39 -0500 | [diff] [blame] | 1 | test_theme <- function(theme) { |
JJ Allaire | 6da1bb6 | 2016-01-30 14:28:39 -0500 | [diff] [blame] | 2 | test_that(paste(theme, "theme"), { |
JJ Allaire | 6da1bb6 | 2016-01-30 14:28:39 -0500 | [diff] [blame] | 3 | # 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 Allaire | 091cb12 | 2016-02-09 13:04:23 -0500 | [diff] [blame] | 24 | rmarkdown::render(testdoc, |
| 25 | output_format = output_format, |
christophe dervieux | 1b20483 | 2021-09-16 12:25:16 +0200 | [diff] [blame^] | 26 | output_file = output_file, |
| 27 | quiet = TRUE) |
JJ Allaire | 6da1bb6 | 2016-01-30 14:28:39 -0500 | [diff] [blame] | 28 | expect_true(file.exists(output_file)) |
| 29 | }) |
| 30 | }) |
| 31 | } |
| 32 | |
| 33 | # test all themes |
| 34 | sapply(revealjs:::revealjs_themes(), test_theme) |