Skip to content

Commit 5449109

Browse files
committed
add tests
1 parent 71fa72c commit 5449109

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/testthat/test-layer.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,22 @@ test_that("layer warns for constant aesthetics", {
138138
expect_snapshot_warning(ggplot_build(p))
139139
})
140140

141+
test_that("layer names can be resolved", {
142+
143+
p <- ggplot() + geom_point() + geom_point()
144+
expect_equal(names(p$layers), c("geom_point", "geom_point...2"))
145+
146+
p <- ggplot() + geom_point(name = "foo") + geom_point(name = "bar")
147+
expect_equal(names(p$layers), c("foo", "bar"))
148+
149+
l <- geom_point(name = "foobar")
150+
expect_error(
151+
p + l + l,
152+
"names are duplicated"
153+
)
154+
})
155+
156+
141157
# Data extraction ---------------------------------------------------------
142158

143159
test_that("AsIs data passes unmodified", {

0 commit comments

Comments
 (0)