#TODO: Move to Utils.R?
save_fun <- function(fun, height = NULL, width = NULL, ...) {
  path <- tempfile(fileext = ".png")
  png(path, height = height, width = width)
  do.call(fun, list(...))
  dev.off()
  path
}

test_that("1_", {

 expect_snapshot_file(
   save_fun(fun = ColorBarDiscrete, height = 180, width = 360,
            brks = 0:4, cols = paste0("green", 1:4), title = "Greeness", vertical = F,
            labels = paste0("level ", 1:4)),
   name = 'ColorBarDiscrete_1a.png' 
 )

 expect_snapshot_file(
   save_fun(fun = ColorBarDiscrete, height = 360, width = 180,
            brks = c(0, 25, 50, 75, 100), cols = paste0("blue", 1:4), title = "Water (%)", 
            vertical = T),
   name = 'ColorBarDiscrete_1b.png'
 )

})

