JJ Allaire | 6da1bb6 | 2016-01-30 14:28:39 -0500 | [diff] [blame] | 1 | |
| 2 | context("Themes") |
| 3 | |
| 4 | test_theme <- function(theme) { |
| 5 | |
| 6 | test_that(paste(theme, "theme"), { |
| 7 | |
| 8 | # don't run on cran because pandoc is required |
| 9 | skip_on_cran() |
| 10 | |
| 11 | # work in a temp directory |
| 12 | dir <- tempfile() |
| 13 | dir.create(dir) |
| 14 | oldwd <- setwd(dir) |
| 15 | on.exit(setwd(oldwd), add = TRUE) |
| 16 | |
| 17 | # create a draft of a presentation |
| 18 | testdoc <- "testdoc.Rmd" |
| 19 | rmarkdown::draft(testdoc, |
| 20 | system.file("rmarkdown", "templates", "revealjs_presentation", |
| 21 | package = "revealjs"), |
| 22 | create_dir = FALSE, |
| 23 | edit = FALSE) |
| 24 | |
| 25 | # render it with the specified theme |
| 26 | capture.output({ |
| 27 | output_file <- tempfile(fileext = ".html") |
| 28 | output_format <- revealjs_presentation(theme = theme) |
JJ Allaire | 091cb12 | 2016-02-09 13:04:23 -0500 | [diff] [blame] | 29 | rmarkdown::render(testdoc, |
| 30 | output_format = output_format, |
| 31 | output_file = output_file) |
JJ Allaire | 6da1bb6 | 2016-01-30 14:28:39 -0500 | [diff] [blame] | 32 | expect_true(file.exists(output_file)) |
| 33 | }) |
| 34 | }) |
| 35 | } |
| 36 | |
| 37 | # test all themes |
| 38 | sapply(revealjs:::revealjs_themes(), test_theme) |