Skip to content

Commit 80a8a9a

Browse files
Merge pull request #117 from katilingban:dev
test theme_gnc; fix #116
2 parents 078ef52 + 0e8775e commit 80a8a9a

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

tests/testthat/test-theme_gnc.R

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Tests for theme_gnc ----------------------------------------------------------
2+
3+
library(ggplot2)
4+
5+
test_that("theme_gnc works as expected", {
6+
## Test acdc_fonts class ----
7+
testthat::expect_type(gnc_fonts, "list")
8+
9+
## Test length of acdc fonts ----
10+
testthat::expect_equal(length(gnc_fonts), 4)
11+
12+
## Test output of set_acdc_font ----
13+
testthat::expect_type(set_gnc_font(), "character")
14+
testthat::expect_equal(length(set_gnc_font()), 1)
15+
16+
## test theme_gnc() ----
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 = gnc_palettes$gnc_secondary
26+
) +
27+
labs(
28+
title = "GNC Theme",
29+
subtitle = "Using the GNC secondary palette",
30+
)
31+
32+
### Test main plotting api ----
33+
testthat::expect_silent(p + theme_gnc())
34+
testthat::expect_silent(p + theme_gnc())
35+
36+
### Test grid ----
37+
testthat::expect_silent(p + theme_gnc(grid = "X"))
38+
testthat::expect_silent(p + theme_gnc(grid = "Xx"))
39+
testthat::expect_silent(p + theme_gnc(grid = "Y"))
40+
testthat::expect_silent(p + theme_gnc(grid = "Yy"))
41+
testthat::expect_silent(p + theme_gnc(grid = "XxYy"))
42+
testthat::expect_silent(p + theme_gnc(grid = FALSE))
43+
44+
### Test axis ----
45+
testthat::expect_silent(p + theme_gnc(axis = TRUE))
46+
testthat::expect_silent(p + theme_gnc(axis = "x"))
47+
testthat::expect_silent(p + theme_gnc(axis = "y"))
48+
testthat::expect_silent(p + theme_gnc(axis = "xy"))
49+
50+
### Test ticks ----
51+
testthat::expect_silent(p + theme_gnc(ticks = TRUE))
52+
})

0 commit comments

Comments
 (0)