tests/testthat/test-plugins.R

library(testthat)

context("Various plugins")

test_that("Drag nodes", {
  nodes <- sg_make_nodes(20)
  edges <- sg_make_edges(nodes, 35)
  
  sg <- sigmajs() %>%
    sg_nodes(nodes, id, label, size) %>%
    sg_edges(edges, id, source, target) %>%
    sg_drag_nodes()
  
  expect_true(sg$x$dragNodes)
})

test_that("Export", {
  nodes <- sg_make_nodes(20)
  edges <- sg_make_edges(nodes, 35)
  
  sg <- sigmajs() %>%
    sg_nodes(nodes, id, label, size) %>%
    sg_edges(edges, id, source, target) 
  
  svg <- sg %>%
    sg_export_svg()
  
  expect_length(svg$x$exportSVG, 7)
  
  img <- sg %>% 
    sg_export_img()
  
  expect_length(img$x$exportIMG, 5)
})

Try the sigmajs package in your browser

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

sigmajs documentation built on July 8, 2020, 5:16 p.m.