diff --git a/tests/testthat/test-model_tests.R b/tests/testthat/test-model_tests.R index 318c8ed6..7c1ed197 100644 --- a/tests/testthat/test-model_tests.R +++ b/tests/testthat/test-model_tests.R @@ -60,8 +60,13 @@ test_that("cug plot works", { expect_s3_class(cugplot$layers[[1]], "ggproto") expect_s3_class(cugplot$layers[[1]]$geom, "GeomDensity") expect_s3_class(cugplot$layers[[1]]$stat, "StatDensity") - expect_identical(cugplot$labels$x, "Statistic") - expect_identical(cugplot$labels$y, "Density") + labels <- if ("get_labs" %in% getNamespaceExports("ggplot2")) { + ggplot2::get_labs(cugplot) + } else { + cugplot$labels + } + expect_identical(labels$x, "Statistic") + expect_identical(labels$y, "Density") }) qapplot <- plot(qaptest) @@ -70,6 +75,11 @@ test_that("qap plot works", { expect_s3_class(qapplot$layers[[1]], "ggproto") expect_s3_class(qapplot$layers[[1]]$geom, "GeomDensity") expect_s3_class(qapplot$layers[[1]]$stat, "StatDensity") - expect_identical(qapplot$labels$x, "Statistic") - expect_identical(qapplot$labels$y, "Density") + labels <- if ("get_labs" %in% getNamespaceExports("ggplot2")) { + ggplot2::get_labs(cugplot) + } else { + cugplot$labels + } + expect_identical(labels$x, "Statistic") + expect_identical(labels$y, "Density") })