tests/testthat/test-plot_metab.R

# Test case for valid swmpr object and default arguments
test_that("plot_metab returns a ggplot object for a valid swmpr object with default arguments", {
  
  plot <- plot_metab(resmet)
  expect_s3_class(plot, "ggplot")
  
  plot <- plot_metab(resmetgrms)
  expect_s3_class(plot, "ggplot")  
  
})

# Test case for valid swmpr object and custom arguments
test_that("plot_metab returns a ggplot object for a valid swmpr object with custom arguments", {
  
  plot <- plot_metab(resmet, by = 'weeks', alpha = 0.01, width = 5, pretty = FALSE)
  expect_s3_class(plot, "ggplot")
  
  plot <- plot_metab(resmet, by = 100, width = 5, pretty = FALSE)
  expect_s3_class(plot, "ggplot")
  
})

# Test case for swmpr object without metabolism data
test_that("plot_metab throws an error for a swmpr object without metabolism data", {

  expect_error(plot_metab(wq), "No metabolism data, use the ecometab function")
  
})

Try the SWMPr package in your browser

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

SWMPr documentation built on July 26, 2023, 5:20 p.m.