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