From 647d858c5ebdb4949e69b1f08c2b37f90b0bc112 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 31 Jan 2025 10:33:50 +0100 Subject: [PATCH] stabilise tests --- tests/testthat/test-model_tests.R | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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") })