Skip to content

Commit f6f67e2

Browse files
Add a test for outline.type
1 parent 1a5c225 commit f6f67e2

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/testthat/test-geom-ribbon.R

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,32 @@ test_that("geom_ribbon works in both directions", {
2626
y$flipped_aes <- NULL
2727
expect_identical(x, flip_data(y, TRUE)[,names(x)])
2828
})
29+
30+
test_that("outline.type option works", {
31+
df <- data_frame(x = 1:4, y = c(1, 1, 1, 1))
32+
33+
p <- ggplot(df, aes(x, ymin = -y, ymax = y))
34+
35+
g_ribbon_default <- layer_grob(p + geom_ribbon())[[1]]
36+
g_ribbon_upper <- layer_grob(p + geom_ribbon(outline.type = "upper"))[[1]]
37+
g_ribbon_legacy <- layer_grob(p + geom_ribbon(outline.type = "legacy"))[[1]]
38+
g_area_default <- layer_grob(ggplot(df, aes(x, y)) + geom_area())[[1]]
39+
40+
# default
41+
expect_s3_class(g_ribbon_default$children[[1]]$children[[1]], "polygon")
42+
expect_s3_class(g_ribbon_default$children[[1]]$children[[2]], "polyline")
43+
expect_equal(g_ribbon_default$children[[1]]$children[[2]]$id, rep(c(1L, 2L), each = 4))
44+
45+
# upper
46+
expect_s3_class(g_ribbon_upper$children[[1]]$children[[1]], "polygon")
47+
expect_s3_class(g_ribbon_upper$children[[1]]$children[[2]], "polyline")
48+
expect_equal(g_ribbon_upper$children[[1]]$children[[2]]$id, rep(c(1L, NA), each = 4))
49+
50+
# legacy
51+
expect_s3_class(g_ribbon_legacy$children[[1]], "polygon")
52+
53+
# geom_area()'s default is upper
54+
expect_s3_class(g_area_default$children[[1]]$children[[1]], "polygon")
55+
expect_s3_class(g_area_default$children[[1]]$children[[2]], "polyline")
56+
expect_equal(g_ribbon_default$children[[1]]$children[[2]]$id, rep(c(1L, NA), each = 4))
57+
})

0 commit comments

Comments
 (0)