tests/testthat/test-plot_interactive.R

# Tests for plot_interactive_ism()

test_that("plot_interactive_ism requires visNetwork", {
  skip_if_not_installed("visNetwork")

  adj <- matrix(c(0, 1, 0, 0), nrow = 2, byrow = TRUE)
  reach <- compute_reachability(adj)

  result <- plot_interactive_ism(reach)

  expect_s3_class(result, "visNetwork")
})

test_that("plot_interactive_ism handles custom labels", {
  skip_if_not_installed("visNetwork")

  adj <- matrix(c(0, 1, 0, 0), nrow = 2, byrow = TRUE)
  reach <- compute_reachability(adj)

  result <- plot_interactive_ism(reach, node_labels = c("Node A", "Node B"))

  expect_s3_class(result, "visNetwork")
})

test_that("plot_interactive_ism handles level_result", {
  skip_if_not_installed("visNetwork")

  adj <- matrix(c(0, 1, 0, 0), nrow = 2, byrow = TRUE)
  reach <- compute_reachability(adj)
  levels <- level_partitioning(reach)

  result <- plot_interactive_ism(reach, level_result = levels)

  expect_s3_class(result, "visNetwork")
})

test_that("plot_interactive_ism validates direction argument", {
  skip_if_not_installed("visNetwork")

  adj <- matrix(c(0, 1, 0, 0), nrow = 2, byrow = TRUE)
  reach <- compute_reachability(adj)

  # Valid directions
  expect_no_error(plot_interactive_ism(reach, direction = "UD"))
  expect_no_error(plot_interactive_ism(reach, direction = "LR"))
  expect_no_error(plot_interactive_ism(reach, direction = "DU"))
  expect_no_error(plot_interactive_ism(reach, direction = "RL"))

  # Invalid direction
  expect_error(plot_interactive_ism(reach, direction = "XX"),
               "'arg' should be one of")
})

Try the ISMtools package in your browser

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

ISMtools documentation built on March 13, 2026, 1:06 a.m.