Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand committed Jul 17, 2024
1 parent 3f9f3e2 commit 9a21647
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/testthat/test-labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ test_that("Labels can be extracted from attributes", {
expect_equal(labels$y, "disp")
})

test_that("Labels from static aesthetics are ignored (#6003)", {

df <- data.frame(x = 1, y = 1, f = 1)

p <- ggplot(df, aes(x, y, colour = f)) + geom_point()
labels <- ggplot_build(p)$plot$labels

expect_equal(labels$colour, "f")

p <- ggplot(df, aes(x, y, colour = f)) + geom_point(colour = "blue")
labels <- ggplot_build(p)$plot$labels

expect_null(labels$colour)
})

test_that("alt text is returned", {
p <- ggplot(mtcars, aes(mpg, disp)) +
geom_point()
Expand Down

0 comments on commit 9a21647

Please sign in to comment.