Skip to content

Commit

Permalink
Merge pull request #66 from katilingban/dev
Browse files Browse the repository at this point in the history
update utils tests
  • Loading branch information
ernestguevarra authored Mar 12, 2024
2 parents 8cd0a59 + 2ec3af7 commit db4dc40
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions R/theme_unicef.R
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ set_unicef_font <- function(alt = paleta_fonts$paleta_noto) {
#' by what UNICEF font is available in the system via `set_unicef_font()`.
#' If none of the UNICEF fonts are available, the default becomes
#' *Noto Sans*.
#' @param base_size Base font size. Default is 11.5.
#' @param base_size Base font size. Default is 5.
#' @param plot_title_family Font family to use for the plot title. Default is
#' `base_family`.
#' @param plot_title_colour Colour of the plot title text. Default
Expand Down Expand Up @@ -214,7 +214,7 @@ set_unicef_font <- function(alt = paleta_fonts$paleta_noto) {
#' @export
#'
theme_unicef <- function(base_family = set_unicef_font(),
base_size = 11.5,
base_size = 5,
plot_title_family = base_family,
plot_title_colour = unicef_black,
subtitle_family = base_family,
Expand Down
4 changes: 2 additions & 2 deletions man/theme_unicef.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
## Test get colours function ----
testthat::expect_type(get_colours(pattern = "Blue"), "character")
testthat::expect_type(get_colours(pattern = "Blue", named = TRUE), "character")
testthat::expect_type(tint_colour(acdc_green, p = 0.2), "character")


## Test tint colours function ----
testthat::expect_type(tint_colour(acdc_green, p = 0.2), "character")
testthat::expect_type(tint_colours(c(acdc_green, acdc_gold), p = 0.2), "list")
testthat::expect_type(tint_colours(c(acdc_green, acdc_gold), p = 0.2, label = TRUE), "list")
testthat::expect_equal(
tint_colours(c(acdc_green, acdc_gold), p = 0.2, label = TRUE) |>
names() |>
length(),
2
)
testthat::expect_type(tint_colours(c(acdc_green, acdc_gold), p = c(0.2, 0.4)), "list")
testthat::expect_equal(
tint_colours(
Expand All @@ -23,6 +30,13 @@ testthat::expect_equal(
## Test shade colours function ----
testthat::expect_type(shade_colours(c(acdc_green, acdc_gold), p = 0.2), "list")
testthat::expect_type(shade_colours(c(acdc_green, acdc_gold), p = c(0.2, 0.4)), "list")
testthat::expect_type(shade_colours(c(acdc_green, acdc_gold), p = 0.2, label = TRUE), "list")
testthat::expect_equal(
shade_colours(c(acdc_green, acdc_gold), p = 0.2, label = TRUE) |>
names() |>
length(),
2
)
testthat::expect_equal(
shade_colours(
c(acdc_green, acdc_gold),
Expand Down
4 changes: 2 additions & 2 deletions vignettes/unicef.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ggplot(
subtitle = "UNICEF brights palette",
x = "Engine Shape", y = "Counts"
) +
theme_unicef(base_size = 10)
theme_unicef()
```

```{r unicef-theme-scatter, echo = FALSE, fig.align = "center", fig.height = 6, fig.width = 5}
Expand All @@ -82,6 +82,6 @@ ggplot(data = mtcars, mapping = aes(x = mpg, y = disp, colour = factor(cyl))) +
title = "UNICEF Theme",
subtitle = "UNICEF brights palette",
) +
theme_unicef(base_size = 10)
theme_unicef()
```

0 comments on commit db4dc40

Please sign in to comment.