diff --git a/NEWS.md b/NEWS.md index d49a08e5..43535308 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,7 @@ - Fixed [#38](https://github.com/sportsdataverse/sportyR/issues/38) to natively support PWHL - Added titles to documentation +- Fixed [#48](https://github.com/sportsdataverse/sportyR/issues/48) to update ggplot2 tests # sportyR 2.2.2 diff --git a/tests/testthat/test-plots-and-features-baseball.R b/tests/testthat/test-plots-and-features-baseball.R index 4e2f8797..4886ce0e 100644 --- a/tests/testthat/test-plots-and-features-baseball.R +++ b/tests/testthat/test-plots-and-features-baseball.R @@ -3,9 +3,8 @@ test_that( # Create a baseball field plot mlb_field <- geom_baseball("mlb", rotation = -90) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(mlb_field)[1], "gg") - expect_equal(class(mlb_field)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(mlb_field)) } ) @@ -14,9 +13,8 @@ test_that( # Create a baseball field plot little_league_field <- geom_baseball("little league", field_units = "m") - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(little_league_field)[1], "gg") - expect_equal(class(little_league_field)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(little_league_field)) } ) @@ -35,8 +33,7 @@ test_that( ) ) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(ncaa_field)[1], "gg") - expect_equal(class(ncaa_field)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(ncaa_field)) } ) diff --git a/tests/testthat/test-plots-and-features-basketball.R b/tests/testthat/test-plots-and-features-basketball.R index baf2859c..0db1e8ce 100644 --- a/tests/testthat/test-plots-and-features-basketball.R +++ b/tests/testthat/test-plots-and-features-basketball.R @@ -9,11 +9,9 @@ test_that( ) ) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(nba_court)[1], "gg") - expect_equal(class(nba_court)[2], "ggplot") - expect_equal(class(ncaa_court)[1], "gg") - expect_equal(class(ncaa_court)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(nba_court)) + expect_true(ggplot2::is_ggplot(ncaa_court)) } ) @@ -22,9 +20,8 @@ test_that( # Create a basketball court plot fiba_court <- geom_basketball("fiba", court_units = "ft", rotation = 270) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(fiba_court)[1], "gg") - expect_equal(class(fiba_court)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(fiba_court)) } ) @@ -43,8 +40,7 @@ test_that( ) ) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(wnba_court)[1], "gg") - expect_equal(class(wnba_court)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(wnba_court)) } ) diff --git a/tests/testthat/test-plots-and-features-curling.R b/tests/testthat/test-plots-and-features-curling.R index bd43c1cd..e5dc7684 100644 --- a/tests/testthat/test-plots-and-features-curling.R +++ b/tests/testthat/test-plots-and-features-curling.R @@ -3,9 +3,8 @@ test_that( # Create a curling sheet plot wcf_sheet <- geom_curling("wcf") - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(wcf_sheet)[1], "gg") - expect_equal(class(wcf_sheet)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(wcf_sheet)) } ) @@ -14,9 +13,8 @@ test_that( # Create a curling sheet plot wcf_sheet <- geom_curling("wcf", sheet_units = "in", rotation = 270) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(wcf_sheet)[1], "gg") - expect_equal(class(wcf_sheet)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(wcf_sheet)) } ) @@ -31,8 +29,7 @@ test_that( ) ) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(wcf_sheet)[1], "gg") - expect_equal(class(wcf_sheet)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(wcf_sheet)) } ) diff --git a/tests/testthat/test-plots-and-features-football.R b/tests/testthat/test-plots-and-features-football.R index 56bb651c..c35ad9f6 100644 --- a/tests/testthat/test-plots-and-features-football.R +++ b/tests/testthat/test-plots-and-features-football.R @@ -3,9 +3,8 @@ test_that( # Create a football field plot nfl_field <- geom_football("nfl") - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(nfl_field)[1], "gg") - expect_equal(class(nfl_field)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(nfl_field)) } ) @@ -14,9 +13,8 @@ test_that( # Create a football field plot cfl_field <- geom_football("cfl", field_units = "m", rotation = 270) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(cfl_field)[1], "gg") - expect_equal(class(cfl_field)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(cfl_field)) } ) @@ -25,8 +23,7 @@ test_that( # Create a football field plot ncaa_field <- geom_football("ncaa") - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(ncaa_field)[1], "gg") - expect_equal(class(ncaa_field)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(ncaa_field)) } ) diff --git a/tests/testthat/test-plots-and-features-hockey.R b/tests/testthat/test-plots-and-features-hockey.R index a0496496..1bff440d 100644 --- a/tests/testthat/test-plots-and-features-hockey.R +++ b/tests/testthat/test-plots-and-features-hockey.R @@ -3,9 +3,8 @@ test_that( # Create a hockey rink plot nhl_rink <- geom_hockey("nhl") - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(nhl_rink)[1], "gg") - expect_equal(class(nhl_rink)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(nhl_rink)) } ) @@ -14,9 +13,8 @@ test_that( # Create a hockey rink plot iihf_rink <- geom_hockey("iihf", rink_units = "ft", rotation = 270) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(iihf_rink)[1], "gg") - expect_equal(class(iihf_rink)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(iihf_rink)) } ) @@ -35,8 +33,7 @@ test_that( ) ) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(phf_rink)[1], "gg") - expect_equal(class(phf_rink)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(phf_rink)) } ) diff --git a/tests/testthat/test-plots-and-features-lacrosse.R b/tests/testthat/test-plots-and-features-lacrosse.R index 0dead256..1b09e7ad 100644 --- a/tests/testthat/test-plots-and-features-lacrosse.R +++ b/tests/testthat/test-plots-and-features-lacrosse.R @@ -3,9 +3,8 @@ test_that( # Create a lacrosse field plot nll_field <- geom_lacrosse("nll") - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(nll_field)[1], "gg") - expect_equal(class(nll_field)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(nll_field)) } ) @@ -14,9 +13,8 @@ test_that( # Create a lacrosse field plot ncaaw_field <- geom_lacrosse("ncaaw", field_units = "ft", rotation = 270) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(ncaaw_field)[1], "gg") - expect_equal(class(ncaaw_field)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(ncaaw_field)) } ) @@ -35,9 +33,8 @@ test_that( ) ) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(pll_field)[1], "gg") - expect_equal(class(pll_field)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(pll_field)) } ) @@ -56,8 +53,7 @@ test_that( ) ) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(ncaam_field)[1], "gg") - expect_equal(class(ncaam_field)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(ncaam_field)) } ) diff --git a/tests/testthat/test-plots-and-features-soccer.R b/tests/testthat/test-plots-and-features-soccer.R index cba3b705..10a229e9 100644 --- a/tests/testthat/test-plots-and-features-soccer.R +++ b/tests/testthat/test-plots-and-features-soccer.R @@ -3,9 +3,8 @@ test_that( # Create a soccer pitch plot epl_pitch <- geom_soccer("epl") - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(epl_pitch)[1], "gg") - expect_equal(class(epl_pitch)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(epl_pitch)) } ) @@ -14,9 +13,8 @@ test_that( # Create a soccer pitch plot nwsl_pitch <- geom_soccer("nwsl", pitch_units = "in", rotation = 270) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(nwsl_pitch)[1], "gg") - expect_equal(class(nwsl_pitch)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(nwsl_pitch)) } ) @@ -30,9 +28,8 @@ test_that( ) ) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(nwsl_pitch)[1], "gg") - expect_equal(class(nwsl_pitch)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(nwsl_pitch)) } ) @@ -63,8 +60,7 @@ test_that( ) ) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(nwsl_pitch)[1], "gg") - expect_equal(class(nwsl_pitch)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(nwsl_pitch)) } ) diff --git a/tests/testthat/test-plots-and-features-tennis.R b/tests/testthat/test-plots-and-features-tennis.R index b5cf1735..b05ef907 100644 --- a/tests/testthat/test-plots-and-features-tennis.R +++ b/tests/testthat/test-plots-and-features-tennis.R @@ -3,9 +3,8 @@ test_that( # Create a tennis court plot itf_court <- geom_tennis("itf") - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(itf_court)[1], "gg") - expect_equal(class(itf_court)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(itf_court)) } ) @@ -14,8 +13,7 @@ test_that( # Create a tennis court plot ita_court <- geom_tennis("ita", court_units = "m", rotation = 270) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(ita_court)[1], "gg") - expect_equal(class(ita_court)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(ita_court)) } ) diff --git a/tests/testthat/test-plots-and-features-volleyball.R b/tests/testthat/test-plots-and-features-volleyball.R index 8468e0a4..94c2cc4d 100644 --- a/tests/testthat/test-plots-and-features-volleyball.R +++ b/tests/testthat/test-plots-and-features-volleyball.R @@ -3,9 +3,8 @@ test_that( # Create a volleyball court plot ncaa_court <- geom_volleyball("ncaa") - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(ncaa_court)[1], "gg") - expect_equal(class(ncaa_court)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(ncaa_court)) } ) @@ -14,8 +13,7 @@ test_that( # Create a volleyball court plot fivb_court <- geom_volleyball("fivb", court_units = "ft", rotation = 270) - # Check the class of the resulting plot. This should be "gg" and "ggplot" - expect_equal(class(fivb_court)[1], "gg") - expect_equal(class(fivb_court)[2], "ggplot") + # Check the class of the resulting plot. This should be a ggplot object + expect_true(ggplot2::is_ggplot(fivb_court)) } )