From 4761c5e5281d97596f11cfa13188c25fa74a5408 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Tue, 16 Jan 2024 12:36:24 +0100 Subject: [PATCH] update tests --- tests/testthat/test-ggplot2_colour_layer.R | 12 ++++++++---- tests/testthat/test-ggplot2_fill_layer.R | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/testthat/test-ggplot2_colour_layer.R b/tests/testthat/test-ggplot2_colour_layer.R index 6e6b0fa..5a3c8ee 100644 --- a/tests/testthat/test-ggplot2_colour_layer.R +++ b/tests/testthat/test-ggplot2_colour_layer.R @@ -1,8 +1,8 @@ test_that("continuous colour scales are created", { for (palette in academic_colour_palette_names()) { function_value <- scale_colour_academic_c(palette) - colours <- academic_colour_palette(palette) - expected_value <- ggplot2::scale_colour_gradientn(colours = colours) + palette <- academic_colour_palette(palette) + expected_value <- ggplot2::scale_colour_gradientn(colours = palette) expect_equal( function_value, expected_value @@ -21,8 +21,12 @@ test_that("discrete colours scales are created", { scale_name = paste0("AcademicTheme: ", palette_name) ) expect_equal( - function_value, - expected_value + .subset2(function_value, "palette"), + .subset2(expected_value, "palette") + ) + expect_equal( + function_value$aesthetics, + expected_value$aesthetics, ) } }) diff --git a/tests/testthat/test-ggplot2_fill_layer.R b/tests/testthat/test-ggplot2_fill_layer.R index 218fe44..b22f251 100644 --- a/tests/testthat/test-ggplot2_fill_layer.R +++ b/tests/testthat/test-ggplot2_fill_layer.R @@ -1,8 +1,8 @@ test_that("continuous fill scales are created", { for (palette in academic_colour_palette_names()) { function_value <- scale_fill_academic_c(palette) - colours <- academic_colour_palette(palette) - expected_value <- ggplot2::scale_fill_gradientn(colours = colours) + palette <- academic_colour_palette(palette) + expected_value <- ggplot2::scale_fill_gradientn(colours = palette) expect_equal( function_value, expected_value @@ -21,8 +21,12 @@ test_that("discrete fill scales are created", { scale_name = paste0("AcademicTheme: ", palette_name) ) expect_equal( - function_value, - expected_value + .subset2(function_value, "palette"), + .subset2(expected_value, "palette") + ) + expect_equal( + function_value$aesthetics, + expected_value$aesthetics, ) } })