library(testthat)
library(esviz)

path <- "/home/Earth/abatalla/ESVIZ_RS_GIT/esviz/R/"
ff <- lapply(list.files(path), function(x) paste0(path, x))
invisible(lapply(ff, source))

test_check("test-VizEquiMap.R")
testthat::test_file()
testthat::test_file("tests/testthat/test-VizEquiMap.R")


#===============================================================
# data
#===============================================================

# data1
set.seed(0)
data1 <- array(rep(0:10, each = 120),dim = c(lat = 30, lon = 44))
lons1 <- -10:33
lats1 <- 31:60
cols_white_red1 <- s2dv::clim.palette("bluered")(41)[21:41]



#===============================================================
# tests
#===============================================================


test_that("1. Input checks", {
  
  expect_error(
    VizEquiMap(lon = c()), 
    "Parameters 'lon' and 'lat' must be numeric vectors."
  )
  expect_error(
    VizEquiMap(lon = lons1, lat = c()), 
    "Parameters 'lon' and 'lat' must be numeric vectors."
  )
  expect_error(
    VizEquiMap(var = NULL, lon = lons1, lat = lats1), 
    "Parameter 'var' cannot be NULL."
  )
  expect_error(
    VizEquiMap(var = data1, lon = lons1, lat = lats1, varu = "test1"), 
    "Only one of the components 'varu' or 'varv' has been provided. Both must be provided."
  )
  expect_error(
    VizEquiMap(var = data1, lon = lons1, lat = lats1, varu = "test1", varv = "test2"), 
    "Parameter 'varu' must be a numerical array with two dimensions."
  )
  
})

