Skip to content

Commit 2bbb5dc

Browse files
committed
improve the aforementioned test example and add a visual test
1 parent 71da78c commit 2bbb5dc

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed
Loading

tests/testthat/test-ggplot-hline.R

+8-5
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,31 @@ test_that("hline/vline/abline split on linetype/colour/size", {
5454
y = x * 0.95
5555
)
5656
gg <- ggplot(d, aes(x, y)) +
57+
geom_point() +
5758
geom_vline(xintercept = c(2.5, 3, 3.5), linetype = 1:3) +
5859
geom_hline(yintercept = c(2.5, 3, 3.5), size = 1:3) +
5960
geom_abline(slope = -1, intercept = c(2.5, 3, 3.5), colour = 1:3)
6061

61-
l <- plotly_build(gg)$x
62-
expect_length(l$data, 9)
62+
l <- expect_doppelganger_built(gg, "split-hline-vline-abline")
63+
expect_length(l$data, 10)
6364

6465
expect_equivalent(
65-
vapply(l$data, function(x) x$line$dash, character(1)),
66+
unlist(lapply(l$data, function(x) x$line$dash)),
6667
lty2dash(c(1:3, rep(1, 6)))
6768
)
6869

6970
expect_equivalent(
70-
unique(vapply(l$data, function(x) x$line$color, character(1))),
71+
unique(unlist(lapply(l$data, function(x) x$line$color))),
7172
# Default palette colors are changing in R4.0...
7273
# https://github.com/wch/r-source/commit/58eafa7#diff-038aeefcb87409db883f064615187949R2495
7374
toRGB(if (getRversion() >= "4.0.0") c("black", "#DF536B", "#61D04F") else c("black", "red", "green3"))
7475
)
7576

7677
expect_length(
77-
unique(vapply(l$data, function(x) x$line$width, numeric(1))), 4
78+
unique(unlist(lapply(l$data, function(x) x$line$width))), 4
7879
)
80+
81+
7982
})
8083

8184

0 commit comments

Comments
 (0)