Skip to content

Commit

Permalink
add last tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed May 6, 2024
1 parent 12f9083 commit 5856343
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/testthat/test-element_marquee.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test_that("element_marquee() inserts aesthetics into the style", {
elem <- element_marquee("serif", colour = "red", size = 6, margin = ggplot2::margin(1, 1, 1, 1))
elem <- element_grob.element_marquee(elem, "test", hjust = "left", vjust = "center", margin_x = TRUE, margin_y = TRUE)
expect_equal(elem$text$family[1], "serif")
expect_equal(elem$text$color[1], "red")
expect_equal(elem$text$size[1], 6)
expect_equal(elem$text$padding_bottom, c(1, 0))
})
14 changes: 14 additions & 0 deletions tests/testthat/test-geom_marquee.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
test_that("geom_marquee inserts the aesthetics correctly", {
p <- ggplot2::ggplot(mtcars) +
geom_marquee(ggplot2::aes(disp, mpg, label = gear), family = "serif", size = 6, color = "red", fill = "blue", size.unit = "Pt")
p <- ggplot2::ggplotGrob(p)
grob <- p$grobs[[which(p$layout$name == "panel")]]$children[[3]]

expect_equal(grob$text$family[1], "serif")
expect_equal(grob$text$size[1], 6, tolerance = 0.1)
expect_equal(grob$text$color[1], "#FF0000")

expect_s3_class(grob$text$background[[1]], "marquee_skip_inherit")
expect_equal(as.vector(grob$text$background[[1]]), "blue")
expect_equal(grob$text$background[[2]], NA_character_)
})

0 comments on commit 5856343

Please sign in to comment.