tests/testthat/test-plot_colonisation.R

test_that("plot_colonisation runs silent without error with crown age", {
  phylod <- create_test_phylod(test_scenario = 15)
  island_tbl <- extract_island_species(
    phylod = phylod,
    extraction_method = "min"
  )
  expect_silent(plot_colonisation(
    island_tbl = island_tbl,
    island_age = 1,
    include_crown_age = TRUE
  ))
})

test_that("plot_colonisation runs silent without error without crown age", {
  phylod <- create_test_phylod(test_scenario = 15)
  island_tbl <- extract_island_species(
    phylod = phylod,
    extraction_method = "min"
  )
  expect_silent(plot_colonisation(
    island_tbl = island_tbl,
    island_age = 1,
    include_crown_age = FALSE
  ))
})

test_that("plot_colonisation fails correctly with incorrect island_tbl", {
  phylod <- create_test_phylod(test_scenario = 15)
  island_tbl <- extract_island_species(
    phylod = phylod,
    extraction_method = "min"
  )
  expect_error(
    object = plot_colonisation(
    island_tbl = data.frame(),
    island_age = 1,
    include_crown_age = TRUE
  ), regexp = "island_tbl must be an object of class Island_tbl")
})

test_that("plot_colonisation fails correctly with incorrect island_age", {
  phylod <- create_test_phylod(test_scenario = 15)
  island_tbl <- extract_island_species(
    phylod = phylod,
    extraction_method = "min"
  )
  expect_error(
    object = plot_colonisation(
      island_tbl = island_tbl,
      island_age = "1",
      include_crown_age = TRUE
    ), regexp = "island_age must be numeric")
})

test_that("plot_colonisation fails correctly with incorrect include_crown_age", {
  phylod <- create_test_phylod(test_scenario = 15)
  island_tbl <- extract_island_species(
    phylod = phylod,
    extraction_method = "min"
  )
  expect_error(
    object = plot_colonisation(
      island_tbl = island_tbl,
      island_age = 1,
      include_crown_age = "TRUE"
    ), regexp = "include_crown_age must be either TRUE or FALSE")
})

Try the DAISIEprep package in your browser

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

DAISIEprep documentation built on April 3, 2025, 9:26 p.m.