Skip to content

Commit 532d501

Browse files
committed
add tests
1 parent c0bb409 commit 532d501

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/testthat/test-scale-colour.R

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,34 @@ test_that("type argument is checked for proper input", {
1818
scale_colour_continuous(type = "abc")
1919
)
2020
})
21+
22+
test_that("palette arguments can take alternative input", {
23+
24+
cols <- c("red", "gold", "green", "cyan", "blue", "magenta")
25+
hex <- alpha(cols, 1)
26+
27+
sc <- scale_colour_continuous(palette = cols)
28+
test <- sc$palette(seq(0, 1, length.out = length(cols)))
29+
expect_equal(alpha(test, 1), hex)
30+
31+
sc <- scale_fill_continuous(palette = cols)
32+
test <- sc$palette(seq(0, 1, length.out = length(cols)))
33+
expect_equal(alpha(test, 1), hex)
34+
35+
sc <- scale_colour_binned(palette = cols)
36+
test <- sc$palette(seq_along(cols))
37+
expect_equal(alpha(test, 1), hex)
38+
39+
sc <- scale_fill_binned(palette = cols)
40+
test <- sc$palette(seq_along(cols))
41+
expect_equal(alpha(test, 1), hex)
42+
43+
sc <- scale_colour_discrete(palette = cols)
44+
test <- sc$palette(length(cols))
45+
expect_equal(alpha(test, 1), hex)
46+
47+
sc <- scale_fill_discrete(palette = cols)
48+
test <- sc$palette(length(cols))
49+
expect_equal(alpha(test, 1), hex)
50+
51+
})

0 commit comments

Comments
 (0)