# tests/testthat/test-plot_abundance_occupancy.R
test_that("plot_abundance_occupancy returns a ggplot and builds", {
  skip_if_not_installed("ggplot2")

  abundance_occupancy <- data.frame(
    otu = paste0("OTU", 1:100),
    otu_occ = round(runif(100, min = 0.05, max = 1), 8),
    otu_rel = round(runif(100, min = 0.0002, max = 0.05), 8),
    membership = sample(
      c("Core", "Not core"),
      size = 100,
      replace = TRUE,
      prob = c(0.4, 0.6)
    )
  )

  core_result_example <- list(
    abundance_occupancy = abundance_occupancy,
    increase_core = c("OTU3", "OTU100", "OTU15")
  )

  p <- plot_abundance_occupancy(
    core_result = core_result_example,
    core_set = "increase"
  )

  expect_s3_class(p, "ggplot")
  expect_silent(ggplot2::ggplot_build(p))
})
