tests/testthat/test-vizAnnualClimate.R

context("vizAnnualClimate")

## tests
library(aqp, quietly = TRUE)
suppressWarnings(library(cluster, quietly = TRUE))
suppressWarnings(library(dendextend, quietly = TRUE))
suppressWarnings(library(latticeExtra, quietly = TRUE))

test_that("vizAnnualClimate works as expected", {
  
  # use local data
  data("OSDexamples")
  a <- OSDexamples$climate.annual
  
  # with / without highlight
  res <- vizAnnualClimate(a)
  res <- vizAnnualClimate(a, s = 'ZOOK')
  
  # print(res$fig)
  
  # list of lattice + clustering
  expect_true(inherits(res, 'list'))
  expect_true(inherits(res$fig, 'trellis'))
  expect_true(inherits(res$clust, 'diana'))
  
  # try a singleton
  res <- vizAnnualClimate(a[1:8, ])
  expect_true(inherits(res, 'list'))
  expect_true(inherits(res$fig, 'trellis'))
  # no clustering possible, result is NULL
  expect_false(inherits(res$clust, 'diana'))
  
})
ncss-tech/sharpshootR documentation built on April 9, 2024, 4:27 a.m.