Skip to content

Commit

Permalink
Test for scale equality differently (#20)
Browse files Browse the repository at this point in the history
test for scale equality differently
  • Loading branch information
teunbrand authored Jan 19, 2024
1 parent 2e07fc8 commit 604f95b
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions tests/testthat/test-scale_hdx.R
Original file line number Diff line number Diff line change
@@ -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()
)
Expand Down

0 comments on commit 604f95b

Please sign in to comment.