Skip to content

Commit 8fce6cd

Browse files
committed
add test
1 parent b7e11e1 commit 8fce6cd

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/testthat/test-position-jitterdodge.R

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,24 @@ test_that("position_jitterdodge preserves widths", {
99
rep(0.45, nrow(ld))
1010
)
1111
})
12+
13+
test_that("position_jitterdodge can preserve total or single width", {
14+
15+
df <- data_frame(x = c("a", "b", "b"), y = 1:3)
16+
17+
# Total
18+
p <- ggplot(df, aes(x, y, group = y)) +
19+
geom_point(position = position_jitterdodge(
20+
preserve = "total", dodge.width = 1,
21+
jitter.width = 0, jitter.height = 0
22+
))
23+
expect_equal(get_layer_data(p)$x, new_mapped_discrete(c(1, 1.75, 2.25)))
24+
25+
# Single
26+
p <- ggplot(df, aes(x, y, group = y)) +
27+
geom_point(position = position_jitterdodge(
28+
preserve = "single", dodge.width = 1,
29+
jitter.width = 0, jitter.height = 0
30+
))
31+
expect_equal(get_layer_data(p)$x, new_mapped_discrete(c(0.75, 1.75, 2.25)))
32+
})

0 commit comments

Comments
 (0)