diff --git a/tests/testthat/test-scale_hdx.R b/tests/testthat/test-scale_hdx.R index 0c31b4b..7a97540 100644 --- a/tests/testthat/test-scale_hdx.R +++ b/tests/testthat/test-scale_hdx.R @@ -1,27 +1,37 @@ test_that("scale_colour matches scale_color", { + # Scale are environments with gnarly parentage. + # Convert these to lists to test for equality in a more straightforward + # manner + expect_equal_scale <- function(x, y, ...) { + x <- as.list(x) + y <- as.list(y) + x$call <- y$call <- NULL + expect_equal(x, y, ...) + } + # discrete color scales - expect_equal(scale_color_hdx_discrete(), scale_colour_hdx_discrete()) - expect_equal(scale_color_hdx_mint(), scale_colour_hdx_mint()) - expect_equal(scale_color_hdx_tomato(), scale_colour_hdx_tomato()) - expect_equal(scale_color_hdx_sapphire(), scale_colour_hdx_sapphire()) + expect_equal_scale(scale_color_hdx_discrete(), scale_colour_hdx_discrete()) + expect_equal_scale(scale_color_hdx_mint(), scale_colour_hdx_mint()) + expect_equal_scale(scale_color_hdx_tomato(), scale_colour_hdx_tomato()) + expect_equal_scale(scale_color_hdx_sapphire(), scale_colour_hdx_sapphire()) # continuous color scales - expect_equal(scale_color_gradient_hdx(), scale_colour_gradient_hdx()) - expect_equal( + expect_equal_scale(scale_color_gradient_hdx(), scale_colour_gradient_hdx()) + expect_equal_scale( scale_color_gradient_hdx_mint(), scale_colour_gradient_hdx_mint() ) - expect_equal( + expect_equal_scale( scale_color_gradient_hdx_tomato(), scale_colour_gradient_hdx_tomato() ) - expect_equal( + expect_equal_scale( scale_color_gradient_hdx_sapphire(), scale_colour_gradient_hdx_sapphire() ) # 2 gradient scale - expect_equal( + expect_equal_scale( scale_color_gradient2_hdx(), scale_colour_gradient2_hdx() )