tests/testthat/test_grob_image.R

testthat::context(glue::glue("
  Testing various scenarios grob_image() must pass.
  "))

# Testing Variables ----

url = "https://logos-download.com/wp-content/uploads/2016/04/Sacramento_Kings_logo_white.png"
faulty_url = paste0(url, "aasdfsaf")

# Tests ----

testthat::test_that(
  desc = glue::glue("
    No errors when passing in a valid URL to a .png image.
    "),
  code = {
    
    url_gl = url %>%
      grob_image() %>%
      grob_col() %>%
      grob_row() %>%
      grob_layout()

    testthat::expect_true(grid::is.grob(url_gl$grob))
    
  })

testthat::test_that(
  desc = glue::glue("
    Errors when passing in a faulty URL to a .png image.
    "),
  code = {

    testthat::expect_error({
      
      faulty_url %>%
        grob_image()
      
    })
    
  })

Try the grobblR package in your browser

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

grobblR documentation built on Sept. 15, 2021, 1:07 a.m.