Skip to content

Commit 46a9ab0

Browse files
committed
add test
1 parent 32ad61b commit 46a9ab0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/testthat/test-position_dodge.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ test_that("position_dodge() can reverse the dodge order", {
3838
expect_equal(ld$label[order(ld$x)], c("A", "A", "B", "B", "C"))
3939
})
4040

41+
test_that("position_dodge() can use the order aesthetic", {
42+
43+
major <- c(1,1,1,2,2,3,3,4,4,5,6,7)
44+
minor <- c(1:3, 1:2, 1, 3, 2:3, 1:3)
45+
df <- data_frame0(
46+
x = LETTERS[major],
47+
g = c("X", "Y", "Z")[minor]
48+
)
49+
ld <- layer_data(
50+
ggplot(df, aes(x, 1, colour = g, order = g)) +
51+
geom_point(position = position_dodge(preserve = "single", width = 0.6))
52+
)
53+
expect_equal(ld$x, major + c(-0.2, 0, 0.2)[minor], ignore_attr = TRUE)
54+
})
55+
4156
test_that("position_dodge warns about missing required aesthetics", {
4257

4358
# Bit of a contrived geom to not have a required 'x' aesthetic

0 commit comments

Comments
 (0)