#===============================================================
# NOTE: The figures are generated with the following environment:
# - On workstation
#===============================================================


test_that("Sanity checks", {
  expect_error(
    VizForecastPDF(fcst, tercile.limits),
    "object 'fcst' not found")
  expect_error(
    VizForecastPDF(fcst, tercile.limits = c(0.25, 0.55)),
    "object 'fcst' not found")
  expect_error(
    VizForecastPDF(fcst, tercile.limits = 10),
    "object 'fcst' not found")
  expect_error(
    VizForecastPDF(fcst, tercile.limits = c(10, 20)),
    "object 'fcst' not found")
  fcsts2 <- array(rnorm(100),dim = c(member = 20, fcst = 5))
  expect_error(
    VizForecastPDF(fcst = fcsts2, tercile.limits),
    "object 'tercile.limits' not found")
  expect_error( 
    VizForecastPDF(fcst = fcsts2, tercile.limits = c(-0.5, 0.5), extreme.limits = NA),
    "Provide two extreme limits")
})


#-------------------------------------------------------------------

# Simple example
set.seed(1)
fcsts <- data.frame(fcst1 = rnorm(10), fcst2 = rnorm(10, 0.5, 1.2))

save_fun <- function(...) {
  path <- tempfile(fileext = ".png")
  do.call(VizForecastPDF, list(..., plotfile = path))
  path
}

test_that("2. Output", {
  expect_snapshot_file(
    save_fun(fcsts, c(-1, 1)),
    name = 'VizForecastPDF_1a.png' 
  )
})
