Skip to content

Commit

Permalink
test mismatch messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcaseb committed Nov 15, 2024
1 parent 882c6a8 commit ffc2faa
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/testthat/_snaps/geom_nfl_logos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# logo geom works

Code
out <- ggplotGrob(p4)
Message
! Can't find team abbreviation "LARRR". Will insert empty grob.

7 changes: 7 additions & 0 deletions tests/testthat/_snaps/geom_nfl_wordmarks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# wordmark geom works

Code
out <- ggplotGrob(p3)
Message
! Can't find team abbreviation "LARRR". Will insert empty grob.

20 changes: 20 additions & 0 deletions tests/testthat/_snaps/theme-elements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# logo element works

Code
out <- ggplotGrob(p3)
Message
! Can't find team abbreviation "LARRR". Will insert empty grob.
! Can't find team abbreviation "LARRR". Will insert empty grob.
! Can't find team abbreviation "LARRR". Will insert empty grob.
! Can't find team abbreviation "LARRR". Will insert empty grob.

---

Code
out <- ggplotGrob(p4)
Message
! No headshot available for gsis ID "00-0012345". Will insert placeholder.
! No headshot available for gsis ID "00-0012345". Will insert placeholder.
! No headshot available for gsis ID "00-0012345". Will insert placeholder.
! No headshot available for gsis ID "00-0012345". Will insert placeholder.

7 changes: 7 additions & 0 deletions tests/testthat/test-geom_nfl_logos.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,11 @@ test_that("logo geom works", {
vdiffr::expect_doppelganger("p1", p1)
vdiffr::expect_doppelganger("p2", p2)
vdiffr::expect_doppelganger("p3", p3)

# Team name mismatch
p4 <- data.frame(a = c("LAC", "LARRR"), b = 1:2, c = 10:11) |>
ggplot(aes(x = b, y = c)) +
geom_nfl_logos(aes(team_abbr = a), width = 0.4, hjust = 0)

expect_snapshot(out <- ggplotGrob(p4))
})
7 changes: 7 additions & 0 deletions tests/testthat/test-geom_nfl_wordmarks.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,11 @@ test_that("wordmark geom works", {

vdiffr::expect_doppelganger("p1", p1)
vdiffr::expect_doppelganger("p2", p2)

# Team name mismatch
p3 <- data.frame(a = c("LAC", "LARRR"), b = 1:2, c = 10:11) |>
ggplot(aes(x = b, y = c)) +
geom_nfl_wordmarks(aes(team_abbr = a), width = 0.4, hjust = 0)

expect_snapshot(out <- ggplotGrob(p3))
})
20 changes: 20 additions & 0 deletions tests/testthat/test-theme-elements.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,24 @@ test_that("logo element works", {

vdiffr::expect_doppelganger("p1", p1)
vdiffr::expect_doppelganger("p2", p2)

# Team name mismatch
p3 <- data.frame(a = c("LAC", "LARRR"), b = 1:2, c = 10:11) |>
ggplot(aes(x = b, y = c)) +
geom_point() +
facet_wrap(vars(a)) +
theme(
strip.text = element_nfl_wordmark()
)
expect_snapshot(out <- ggplotGrob(p3))

# GSIS ID mismatch
p4 <- data.frame(a = c("00-0033077", "00-0012345"), b = 1:2, c = 10:11) |>
ggplot(aes(x = b, y = c)) +
geom_point() +
facet_wrap(vars(a)) +
theme(
strip.text = element_nfl_headshot()
)
expect_snapshot(out <- ggplotGrob(p4))
})

0 comments on commit ffc2faa

Please sign in to comment.