Skip to content

Commit

Permalink
Add test for theme_dune + change "local" to point to the filename
Browse files Browse the repository at this point in the history
Add test for `theme_dune` + change "local" to point to the filename itself
  • Loading branch information
lcpilling committed Mar 20, 2024
1 parent 2f923de commit bec84c9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/theme_dune.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ theme_dune <- function(dune_font = TRUE, ...){
# CUSTOM FONT: add a custom font from google fonts
font_family = ifelse(dune_font,"Dune_Rise","sans") # use this line if you have a custom font
if (dune_font) {
ThemePark:::initialize_font(name = "Dune_Rise", family = "Dune_Rise", local = "Dune_Rise")
ThemePark:::initialize_font(name = "Dune_Rise", family = "Dune_Rise", local = "Dune_Rise.ttf")
}

# CUSTOM THEME:
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ initialize_font <- function(name, family = name, local=NULL, ...) {
if (is.null(local)) {
sysfonts::font_add_google(name = name, family = family, ...)
} else {
sysfonts::font_add(local, paste0(path.package("ThemePark"), "/fonts/", local, ".ttf"))
sysfonts::font_add(family = family, paste0(path.package("ThemePark"), "/fonts/", local))
}
} else {
invisible(curr_families)
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-theme_dune.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
test_that("`theme_dune` runs", {
x <- theme_dune()

testthat::expect_equal(class(x), c('theme', 'gg'))
})

test_that("output of `theme_dune` is stable", {
testthat::skip_if_not_installed('vdiffr')
vdiffr::expect_doppelganger('A blank theme_dune plot', ggplot2::ggplot() + theme_dune())
})

0 comments on commit bec84c9

Please sign in to comment.