@@ -65,12 +65,28 @@ test_that("marker default shape is a circle", {
6565test_that(" plot panel border is translated correctly" , {
6666 ggpenguin <- penguin.base + theme_grey() # has no panel.border
6767 info <- expect_doppelganger_built(ggpenguin , " theme-panel-border-1" )
68-
68+
6969 red <- ggplot(palmerpenguins :: penguins ) +
7070 theme_grey() +
7171 geom_point(aes(bill_length_mm , bill_depth_mm )) +
7272 theme(panel.border = element_rect(colour = " red" , fill = NA ))
73-
73+
7474 info <- expect_doppelganger_built(red , " theme-panel-border-2" )
7575 expect_true(info $ layout $ shapes [[1 ]]$ line $ color == toRGB(" red" ))
7676})
77+
78+ test_that(" element_blank panel.border does not create empty shapes (#2455, #2460)" , {
79+ # theme_grey() has element_blank() panel.border - should NOT create a shape
80+ p_grey <- ggplot(mtcars , aes(wt , mpg )) + geom_point() + theme_grey()
81+ L_grey <- plotly_build(ggplotly(p_grey ))$ x
82+ # No panel border shapes should be created for element_blank
83+ grey_shapes <- Filter(function (s ) identical(s $ xref , " paper" ) && identical(s $ yref , " paper" ), L_grey $ layout $ shapes )
84+ expect_equal(length(grey_shapes ), 0 )
85+
86+ # theme_bw() has visible panel.border - SHOULD create a shape
87+ p_bw <- ggplot(mtcars , aes(wt , mpg )) + geom_point() + theme_bw()
88+ L_bw <- plotly_build(ggplotly(p_bw ))$ x
89+ bw_shapes <- Filter(function (s ) identical(s $ xref , " paper" ) && identical(s $ yref , " paper" ), L_bw $ layout $ shapes )
90+ expect_true(length(bw_shapes ) > 0 )
91+ expect_false(is.na(bw_shapes [[1 ]]$ line $ color ))
92+ })
0 commit comments