Skip to content

Commit

Permalink
small tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yjunechoe committed Oct 9, 2024
1 parent c94dda9 commit 9762179
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/testthat/test-sublayer-data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
library(ggplot2)

p <- ggplot(diamonds, aes(cut)) +
geom_bar(aes(fill = cut)) +
stat_count(geom = "label", aes(label = after_stat(count)))

test_that("sublayer data targeting works", {

expect_in(
c("x", "PANEL", "group"),
colnames(layer_before_stat(p))
)

expect_in(
c("count", "x", "PANEL", "group"),
colnames(layer_after_stat(p))
)

expect_in(
c("y", "x", "PANEL", "group"),
colnames(layer_before_geom(p))
)

expect_in(
c("alpha", "PANEL", "group"),
colnames(layer_after_scale(p))
)

})

0 comments on commit 9762179

Please sign in to comment.