@@ -227,7 +227,9 @@ test_that("layer_data returns a data.frame", {
227227})
228228
229229test_that(" get_layer_data works with layer names" , {
230- p <- ggplot() + geom_point(name = " foo" ) + geom_point(name = " bar" )
230+ p <- ggplot() +
231+ annotate(" point" , x = 1 , y = 1 , name = " foo" ) +
232+ annotate(" line" , x = 1 : 2 , y = 1 : 2 , name = " bar" )
231233
232234 # name has higher precedence than index
233235 expect_identical(
@@ -237,13 +239,15 @@ test_that("get_layer_data works with layer names", {
237239})
238240
239241test_that(" get_layer_grob works with layer names" , {
240- p <- ggplot() + geom_point(name = " foo" ) + geom_point(name = " bar" )
242+ p <- ggplot() +
243+ annotate(" point" , x = 1 , y = 1 , name = " foo" ) +
244+ annotate(" line" , x = 1 : 2 , y = 1 : 2 , name = " bar" )
241245
242246 # name has higher precedence than index
243- expect_identical(
244- get_layer_grob(p , i = " bar " ),
245- get_layer_grob( p , i = 2L )
246- )
247+ named <- get_layer_grob( p , i = " bar " )
248+ nummed <- get_layer_grob(p , i = 2L )
249+ named [[ 1 ]] $ name <- nummed [[ 1 ]] $ name <- NULL # ignore grid's unique names
250+ expect_identical( named , nummed )
247251})
248252
249253test_that(" data.frames and matrix aesthetics survive the build stage" , {
0 commit comments