😎 Give your xaringan slides some style
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

43 lines
1.7KB

  1. context("test-themes")
  2. test_theme_file <- function(theme = "duo", theme_file = paste0(theme, ".css"), ...) {
  3. theme_fun <- switch(
  4. theme,
  5. "duo" = duo,
  6. "duo_accent" = duo_accent,
  7. "duo_accent_inverse" = duo_accent_inverse,
  8. "mono_accent" = mono_accent,
  9. "mono_accent_inverse" = mono_accent_inverse,
  10. "mono_dark" = mono_dark,
  11. "mono_light" = mono_light,
  12. "solarized_dark" = solarized_dark,
  13. "solarized_light" = solarized_light,
  14. stop("Unknown theme")
  15. )
  16. tmpfile <- tempfile()
  17. theme_fun(outfile = tmpfile, ...)
  18. theme_css <- readLines(tmpfile)
  19. # Mask package version in test files
  20. theme_css <- sub("( \\* Version: )[\\d.-]+", "\\1a.b.c.d.eeee", theme_css, perl = TRUE)
  21. theme_css <- paste(theme_css, collapse = "\n")
  22. expect_known_output(cat(theme_css), test_path("css", theme_file))
  23. }
  24. test_that("duo()", test_theme_file("duo"))
  25. test_that("duo_accent()", test_theme_file("duo_accent"))
  26. test_that("duo_accent_inverse()", test_theme_file("duo_accent_inverse"))
  27. test_that("mono_accent()", test_theme_file("mono_accent"))
  28. test_that("mono_accent_inverse()", test_theme_file("mono_accent_inverse"))
  29. test_that("mono_dark()", test_theme_file("mono_dark"))
  30. test_that("mono_light()", test_theme_file("mono_light"))
  31. test_that("solarized_dark()", test_theme_file("solarized_dark"))
  32. test_that("solarized_light()", test_theme_file("solarized_light"))
  33. test_that("header_background_auto = TRUE", {
  34. test_theme_file("duo", "duo-header_bg.css", header_background_auto = TRUE)
  35. test_theme_file("mono_light", "mono_light-header_bg.css", header_background_auto = TRUE)
  36. test_theme_file("solarized_dark", "solarized_dark-header_bg.css", header_background_auto = TRUE)
  37. })