tests/testthat/test-spooky.R

testthat::test_that("numeric forecasting returns the documented structure", {
  x <- data.frame(a = sin(seq_len(60)), b = cos(seq_len(60)))
  fit <- spooky(x, seq_len = 3, lno = 1, n_samp = 1, n_windows = 2)
  testthat::expect_s3_class(fit, "spooky_fit")
  testthat::expect_named(fit, c("exploration", "history", "best_model", "time_log"))
  testthat::expect_equal(nrow(fit$best_model$testing_errors), 2)
})

testthat::test_that("categorical data is supported", {
  x <- data.frame(state = factor(rep(c("a", "b"), 30)))
  fit <- spooky(x, seq_len = 2, lno = 1, n_samp = 1, n_windows = 2)
  testthat::expect_s3_class(fit, "spooky_fit")
})

testthat::test_that("invalid mixed data is rejected", {
  testthat::expect_error(spooky(data.frame(a = 1:20, b = letters[1:20]), n_samp = 1))
})

Try the spooky package in your browser

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

spooky documentation built on Sept. 7, 2026, 9:07 a.m.