😎 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.

53 lines
1.4KB

  1. import <- function(x) paste0("@import url(", x, ");")
  2. # test_that("list2fonts()", {})
  3. describe("list2fonts()", {
  4. lato_url <- "https://fonts.googleapis.com/css?family=Lato&display=swap"
  5. worksans_url <- "https://fonts.googleapis.com/css?family=Work+Sans&display=swap"
  6. it("handles a list or c() of font urls", {
  7. expect_equal(
  8. list2fonts(list(lato_url, worksans_url)),
  9. import(c(lato_url, worksans_url))
  10. )
  11. expect_equal(list2fonts(c(lato_url, lato_url)), rep(import(lato_url), 2))
  12. })
  13. it("handles single character font name", {
  14. expect_equal(list2fonts(lato_url), import(lato_url))
  15. })
  16. it("handles list of google fonts", {
  17. expect_equal(
  18. list2fonts(list(google_font("Lato"), google_font("Work Sans"))),
  19. import(c(lato_url, worksans_url))
  20. )
  21. })
  22. it("handles mix of google_font() and bare string", {
  23. expect_equal(
  24. list2fonts(list(google_font("Lato"), worksans_url)),
  25. import(c(lato_url, worksans_url))
  26. )
  27. })
  28. it("handles bare google_font()", {
  29. expect_equal(
  30. list2fonts(google_font("Lato")),
  31. import(lato_url)
  32. )
  33. })
  34. it("throws an error when c() used to combine string and google_font()", {
  35. expect_error(
  36. list2fonts(c(lato_url, google_font("Lato"), google_font("Work Sans"))),
  37. "Multiple fonts"
  38. )
  39. expect_error(
  40. list2fonts(c(google_font("Lato"), google_font("Work Sans"))),
  41. "Multiple fonts"
  42. )
  43. })
  44. })