From 408cf440e6223a6faaf6c6dfe8363cb0ec26639f Mon Sep 17 00:00:00 2001 From: David <david.dorchies@inrae.fr> Date: Wed, 31 Jul 2024 08:27:06 +0200 Subject: [PATCH] test(plot.GRiwrm): add test for a single node network Refs #153 --- tests/testthat/test-plot.GRiwrm.R | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-plot.GRiwrm.R b/tests/testthat/test-plot.GRiwrm.R index 0622d39..24d4abe 100644 --- a/tests/testthat/test-plot.GRiwrm.R +++ b/tests/testthat/test-plot.GRiwrm.R @@ -11,7 +11,7 @@ test_that("Diverted ungauged nodes have correct color", { expect_true(any(grepl("id_54029 UpstreamUngaugedDiversion", strsplit(mmd, "\n\n")[[1]]))) }) -test_that("Unguaged nodes and donors are in a box!", { +test_that("Ungauged nodes and donors are in a box!", { nds <- loadSevernNodes() nds$donor <- as.character(NA) nds$model[nds$id %in% c("54001", "54032", "54029")] <- "Ungauged" @@ -23,3 +23,10 @@ test_that("Unguaged nodes and donors are in a box!", { s <- plot(g, display = FALSE) expect_equal(strsplit(s, "\n")[[1]][c(5,13)], c("subgraph donor_54095 [54095]", "end")) }) + +test_that("Single node plot does not crash", { + sgl_node <- loadSevernNodes()[1,] + g <- CreateGRiwrm(sgl_node) + mmd <- plot(g, display = FALSE) + expectfalse(grepl("-->", mmd, fixed = TRUE)) +}) -- GitLab