tests/testthat/test-functions.R

test_that("collectFunNames works", {
    system.file("extdata", package = "pkgGraphR") |> 
        collectFunNames() |> 
        expect_type("list") |> 
        expect_length(1) |> 
        expect_named()
    file.path(system.file("extdata", package = "pkgGraphR"), "functions.r") |> 
        collectFunNames() |> 
        expect_type("list") |> 
        expect_length(1) |> 
        expect_named()
})

test_that("buildPackageGraph works", {
    system.file("extdata", package = "pkgGraphR") |> 
        buildPackageGraph() |> 
        expect_type("list") |> 
        expect_length(2) |> 
        expect_named()
    system.file("extdata", package = "pkgGraphR") |> 
        buildPackageGraph(unique.edges = FALSE, only.connected = TRUE) |> 
        expect_type("list") |> 
        expect_length(2) |> 
        expect_named()
})

test_that("plotPackageGraph works", {
    system.file("extdata", package = "pkgGraphR") |> 
        plotPackageGraph() |> 
        expect_error()
    tF <- system.file("extdata", package = "pkgGraphR") |> 
        collectFunNames()
    tG <- system.file("extdata", package = "pkgGraphR") |> 
        buildPackageGraph() 
    
    plotPackageGraph(graph = tG) |> 
        inherits("grViz") |> 
        expect_equal(TRUE)
    plotPackageGraph(graph = tG, use.subgraphs = TRUE) |> 
        expect_error()
    plotPackageGraph(graph = tG, fun.list = tF, use.subgraphs = TRUE) |> 
        inherits("grViz") |> 
        expect_equal(TRUE)
    plotPackageGraph(graph = tG, fun.list = tF, use.colors = TRUE) |> 
        inherits("grViz") |> 
        expect_equal(TRUE)
    plotPackageGraph(graph = tG, fun.list = tF, use.colors = TRUE, use.subgraphs = TRUE) |> 
        inherits("grViz") |> 
        expect_equal(TRUE)

})

Try the pkgGraphR package in your browser

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

pkgGraphR documentation built on April 4, 2025, 5:10 a.m.