tests/testthat/test-fire_exp_dir_map.R

test_that("fire_exp_dir_map() input checks work", {
  exp <- exposure()
  v <- pol()
  pt <- pts(1)

  t_pt <- fire_exp_dir(exp, pt)
  t_pol <- fire_exp_dir(exp, v)
  expect_error(fire_exp_dir_map(2),
               "`transects` must be a SpatVector object")
  expect_error(fire_exp_dir_map(t_pt, title = 2),
               "`title` must be")
  expect_error(fire_exp_dir_map(t_pt, labels = "blah"),
               "`labels` must be") # not enough
  expect_error(fire_exp_dir_map(t_pt, labels = c("blah", "blah")),
               "`labels` must be") # not characters
  expect_error(suppressMessages(fire_exp_dir_map(t_pt, value = 2)),
               "`value` must be a SpatVector object")
})

test_that("fire_exp_dir_map() returns objects with correct class", {
  exp <- exposure()
  v <- pol()
  pt <- pts(1)

  t_pt <- fire_exp_dir(exp, pt)
  t_pol <- fire_exp_dir(exp, v)
  expect_s3_class(suppressMessages(fire_exp_dir_map(t_pt)), "ggplot")
})

test_that("fire_exp_dir_map() runs when input conditions are met", {
  exp <- exposure()
  v <- pol()
  pt <- pts(1)

  t_pt <- fire_exp_dir(exp, pt)
  t_pol <- fire_exp_dir(exp, v)
  expect_no_error(suppressMessages(fire_exp_dir_map(t_pt)))
  expect_no_error(suppressMessages(fire_exp_dir_map(t_pol)))
  expect_no_error(suppressMessages(fire_exp_dir_map(t_pol, value = v)))
  expect_no_error(suppressMessages(fire_exp_dir_map(t_pt,
                                                    labels = c("blah",
                                                               "blah",
                                                               "blah"))))
  expect_no_error(suppressMessages(fire_exp_dir_map(t_pt,
                                                    title = "blah blah blah")))
})

Try the fireexposuR package in your browser

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

fireexposuR documentation built on June 8, 2025, 1:48 p.m.