Skip to content

Commit 310ad84

Browse files
Merge pull request #109 from katilingban:dev
test UNICEF theme; fix #59
2 parents 23d30fb + 0f1023f commit 310ad84

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

tests/testthat/test-theme_unicef.R

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Tests for theme_unicef() -----------------------------------------------------
2+
3+
library(ggplot2)
4+
5+
test_that("theme_unicef works as expected", {
6+
## Test acdc_fonts class ----
7+
testthat::expect_type(unicef_fonts, "list")
8+
9+
## Test length of acdc fonts ----
10+
testthat::expect_equal(length(unicef_fonts), 4)
11+
12+
## Test output of set_acdc_font ----
13+
testthat::expect_type(set_unicef_font(), "character")
14+
testthat::expect_equal(length(set_unicef_font()), 1)
15+
16+
## test theme_unicef() ----
17+
18+
## scatterplot
19+
p <- ggplot(
20+
data = mtcars, mapping = aes(x = mpg, y = disp, colour = factor(cyl))
21+
) +
22+
geom_point(size = 3) +
23+
scale_colour_manual(
24+
name = "Cylinders",
25+
values = unicef_palettes$unicef_secondary
26+
) +
27+
labs(
28+
title = "UNICEF Theme",
29+
subtitle = "Using the UNICEF secondary palette",
30+
)
31+
32+
### Test main plotting api ----
33+
testthat::expect_silent(p + theme_unicef())
34+
testthat::expect_silent(p + theme_unicef())
35+
36+
### Test grid ----
37+
testthat::expect_silent(p + theme_unicef(grid = "X"))
38+
testthat::expect_silent(p + theme_unicef(grid = "Xx"))
39+
testthat::expect_silent(p + theme_unicef(grid = "Y"))
40+
testthat::expect_silent(p + theme_unicef(grid = "Yy"))
41+
testthat::expect_silent(p + theme_unicef(grid = "XxYy"))
42+
testthat::expect_silent(p + theme_unicef(grid = FALSE))
43+
44+
### Test axis ----
45+
testthat::expect_silent(p + theme_unicef(axis = TRUE))
46+
testthat::expect_silent(p + theme_unicef(axis = "x"))
47+
testthat::expect_silent(p + theme_unicef(axis = "y"))
48+
testthat::expect_silent(p + theme_unicef(axis = "xy"))
49+
50+
### Test ticks ----
51+
testthat::expect_silent(p + theme_unicef(ticks = TRUE))
52+
})
53+

0 commit comments

Comments
 (0)