@@ -26,3 +26,32 @@ test_that("geom_ribbon works in both directions", {
26
26
y $ flipped_aes <- NULL
27
27
expect_identical(x , flip_data(y , TRUE )[,names(x )])
28
28
})
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