Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand committed Jan 21, 2025
1 parent 912c29e commit 4fd2ce3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/testthat/test-theme.R
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,26 @@ test_that("margin_part() mechanics work as expected", {
expect_equal(as.numeric(test), c(5.5, 5.5, 11, 5.5))
})

test_that("geom elements are inherited correctly", {

GeomFoo <- ggproto("GeomFoo", GeomPoint)
GeomBar <- ggproto("GeomBar", GeomFoo)

p <- ggplot(data.frame(x = 1), aes(x, x)) +
stat_identity(geom = GeomBar) +
theme(
geom = element_geom(pointshape = 15),
geom.point = element_geom(borderwidth = 2, ink = "blue"),
geom.foo = element_geom(pointsize = 2),
geom.bar = element_geom(ink = "red")
)
p <- layer_data(p)
expect_equal(p$shape, 15)
expect_equal(p$stroke, 2)
expect_equal(p$size, 2)
expect_equal(p$colour, "red")
})

# Visual tests ------------------------------------------------------------

test_that("aspect ratio is honored", {
Expand Down

0 comments on commit 4fd2ce3

Please sign in to comment.