diff --git a/tests/testthat/test_get_legend.R b/tests/testthat/test_get_legend.R index f431794..1f1115d 100644 --- a/tests/testthat/test_get_legend.R +++ b/tests/testthat/test_get_legend.R @@ -10,6 +10,6 @@ test_that("get legend", { expect_equal(l$name, "guide-box") # return null legend if no legend - expect_null(get_legend(p + theme(legend.position = "none"))) + expect_s3_class(get_legend(p + theme(legend.position = "none")), "zeroGrob") }) diff --git a/tests/testthat/test_plot_components.R b/tests/testthat/test_plot_components.R index f2f7d0b..347f946 100644 --- a/tests/testthat/test_plot_components.R +++ b/tests/testthat/test_plot_components.R @@ -9,6 +9,13 @@ test_that("plot components", { "axis-b", "spacer", "axis-r", "spacer", "xlab-t", "xlab-b", "ylab-l", "ylab-r", "guide-box", "subtitle", "title", "caption", "tag" ) + if (inherits(guide_legend(), "Guide")) { # proxy testing for ggplot2 3.5.0+ + component_names <- setdiff(component_names, c("guide-box", "tag")) + component_names <- union( + component_names, + paste0("guide-box-", c("left", "right", "top", "bottom", "inside")) + ) + } expect_type(plot_component_names(p), "character") expect_true(all(component_names %in% plot_component_names(p)))