@@ -736,6 +736,28 @@ test_that("geom elements are inherited correctly", {
736
736
expect_equal(p $ colour , " red" )
737
737
})
738
738
739
+ test_that(" theme elements are covered in `theme_sub_*()` functions" , {
740
+ # We use a snapshot test here to trigger when a new theme element is added
741
+ # or removed.
742
+ # A failure of this test should be taken as a prompt to see if the new
743
+ # theme element should be included in one of the `theme_sub_*` functions.
744
+
745
+ fmls <- paste0(" axis." , fn_fmls_names(theme_sub_axis ))
746
+ fmls <- c(fmls , paste0(" axis." , fn_fmls_names(theme_sub_axis_x ), " .x" ))
747
+ fmls <- c(fmls , paste0(" axis." , fn_fmls_names(theme_sub_axis_y ), " .y" ))
748
+ fmls <- c(fmls , paste0(" axis." , fn_fmls_names(theme_sub_axis_top ), " .x.top" ))
749
+ fmls <- c(fmls , paste0(" axis." , fn_fmls_names(theme_sub_axis_bottom ), " .x.bottom" ))
750
+ fmls <- c(fmls , paste0(" axis." , fn_fmls_names(theme_sub_axis_left ), " .y.left" ))
751
+ fmls <- c(fmls , paste0(" axis." , fn_fmls_names(theme_sub_axis_right ), " .y.right" ) )
752
+ fmls <- c(fmls , paste0(" legend." , fn_fmls_names(theme_sub_legend )))
753
+ fmls <- c(fmls , paste0(" plot." , fn_fmls_names(theme_sub_plot )))
754
+ fmls <- c(fmls , paste0(" panel." , fn_fmls_names(theme_sub_panel )))
755
+ fmls <- c(fmls , paste0(" strip." , fn_fmls_names(theme_sub_strip )))
756
+
757
+ extra_elements <- setdiff(fn_fmls_names(theme ), fmls )
758
+ expect_snapshot(extra_elements )
759
+ })
760
+
739
761
# Visual tests ------------------------------------------------------------
740
762
741
763
test_that(" element_polygon() can render a grob" , {
0 commit comments