tests/testthat/test.nhl_plot_rink.R

context("plot_rink")

expect_image_equal <- function(object, expected, ...) {
  # compare svg character vs reference
  # helpers are defined in setup.R
  stopifnot(is.character(expected) && file.exists(expected))
  testthat::expect_equal(
    round_svg_numbers(ignore_svg_id(plot_image(object))),
    round_svg_numbers(ignore_svg_id(readLines(expected))),
    ...
  )
}

testthat::test_that(
  "Rink generated with plot_rink() is equal to prototype", {
    testthat::skip_if(skipSelectedTests)

    expect_image_equal(
      nhl_plot_rink(),
      "prototype/rink.svg"
    )
  }
)

Try the nhlapi package in your browser

Any scripts or data that you put into this service are public.

nhlapi documentation built on Feb. 20, 2021, 9:06 a.m.