Skip to content

Commit

Permalink
unit-test clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
kkholst committed Dec 9, 2023
1 parent 7c6b47e commit 40f0467
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions tests/testthat/test-model.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,28 +86,29 @@ test_that("Graph attributes", {
m <- lvm(y~x)
suppressMessages(g1 <- graph::updateGraph(plot(m,noplot=TRUE)))
m1 <- graph2lvm(g1)
testthat::expect_equivalent(m1$M,m$M)

col <- "blue"; v <- "y"
g1 <- lava::addattr(g1,"fill",v,col)
testthat::expect_true(col==graph::nodeRenderInfo(g1)$fill[v])
nodecolor(m,v) <- "blue"
g2 <- Graph(m,add=TRUE)
testthat::expect_equivalent(m1$M, m$M)

col <- "blue"
v <- "y"
g1 <- lava::addattr(g1, "fill", v, col)
testthat::expect_true(col == graph::nodeRenderInfo(g1)$fill[[v]])
nodecolor(m, v) <- "blue"
g2 <- Graph(m, add=TRUE)
testthat::expect_true(inherits(g2,"graph"))
testthat::expect_true(col==graph::nodeRenderInfo(g2)$fill[v])
testthat::expect_true(addattr(g2,"fill")["y"]=="blue")
testthat::expect_true(col == graph::nodeRenderInfo(g2)$fill[[v]])
testthat::expect_true(addattr(g2, "fill")[[v]] == "blue")
graph::graphRenderInfo(g2)$rankdir <- "LR"
Graph(m) <- g2
testthat::expect_true(graph::graphRenderInfo(Graph(m))$rankdir=="LR")

## Labels
labels(m) <- c(y="Y")
addattr(Graph(m,add=TRUE),"label")
testthat::expect_true(addattr(finalize(m),"label")[["y"]]=="Y")
labels(g2) <- c(y="Y")
labels(m) <- c(y = "Y")
addattr(Graph(m, add=TRUE), "label")
testthat::expect_true(addattr(finalize(m), "label")[["y"]]=="Y")
labels(g2) <- c(y = "Y")
testthat::expect_true(!is.null(graph::nodeRenderInfo(g2)$label["y"]))

edgelabels(m,y~x) <- "a"
edgelabels(m, y~x) <- "a"
testthat::expect_true(!is.null(edgelabels(finalize(m))))
})

Expand Down

0 comments on commit 40f0467

Please sign in to comment.