😎 Give your xaringan slides some style
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

48 lines
2.0KB

  1. context("test-themes")
  2. test_theme_file <- function(theme = "duo", theme_file = paste0(theme, ".css"), ...) {
  3. theme_fun <- switch(
  4. theme,
  5. "duo" = style_duo,
  6. "duo_accent" = style_duo_accent,
  7. "duo_accent_inverse" = style_duo_accent_inverse,
  8. "mono_accent" = style_mono_accent,
  9. "mono_accent_inverse" = style_mono_accent_inverse,
  10. "mono_dark" = style_mono_dark,
  11. "mono_light" = style_mono_light,
  12. "solarized_dark" = style_solarized_dark,
  13. "solarized_light" = style_solarized_light,
  14. "xaringan" = style_xaringan,
  15. stop("Unknown theme")
  16. )
  17. tmpfile <- tempfile()
  18. theme_fun(outfile = tmpfile, ..., text_font_google = google_font("Noto Serif"))
  19. theme_css <- readLines(tmpfile)
  20. # Mask package version in test files
  21. theme_css <- sub("( \\* Version: )[\\d.-]+", "\\1a.b.c.d.eeee", theme_css, perl = TRUE)
  22. theme_css <- paste(theme_css, collapse = "\n")
  23. expect_known_output(cat(theme_css), test_path("css", theme_file))
  24. }
  25. test_that("style_duo()", test_theme_file("duo"))
  26. test_that("style_duo_accent()", test_theme_file("duo_accent"))
  27. test_that("style_duo_accent_inverse()", test_theme_file("duo_accent_inverse"))
  28. test_that("style_mono_accent()", test_theme_file("mono_accent"))
  29. test_that("style_mono_accent_inverse()", test_theme_file("mono_accent_inverse"))
  30. test_that("style_mono_dark()", test_theme_file("mono_dark"))
  31. test_that("style_mono_light()", test_theme_file("mono_light"))
  32. test_that("style_solarized_dark()", test_theme_file("solarized_dark"))
  33. test_that("style_solarized_light()", test_theme_file("solarized_light"))
  34. test_that("header_background_auto = TRUE", {
  35. test_theme_file("duo", "duo-header_bg.css", header_background_auto = TRUE)
  36. test_theme_file("mono_light", "mono_light-header_bg.css", header_background_auto = TRUE)
  37. test_theme_file("solarized_dark", "solarized_dark-header_bg.css", header_background_auto = TRUE)
  38. })
  39. test_that("style colors are added to themes", {
  40. test_theme_file("xaringan", colors = c('light-blue' = "#bad4ed"))
  41. })