From f27ef9cc6005a1801b6aede7940b3143b7f2d8ae Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Sat, 16 Dec 2023 00:37:02 +0100 Subject: [PATCH] Add visual test --- .../draw-keys/rotated-rich-text-keys.svg | 221 ++++++++++++++++++ tests/testthat/test-draw-keys.R | 18 ++ 2 files changed, 239 insertions(+) create mode 100644 tests/testthat/_snaps/draw-keys/rotated-rich-text-keys.svg create mode 100644 tests/testthat/test-draw-keys.R diff --git a/tests/testthat/_snaps/draw-keys/rotated-rich-text-keys.svg b/tests/testthat/_snaps/draw-keys/rotated-rich-text-keys.svg new file mode 100644 index 0000000..ef93642 --- /dev/null +++ b/tests/testthat/_snaps/draw-keys/rotated-rich-text-keys.svg @@ -0,0 +1,221 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +5 +6 +7 +8 + + + + + + + + + + +2.0 +2.5 +3.0 +3.5 +4.0 +4.5 +Sepal.Width +Sepal.Length + +Species + + +Iris +setosa + + +Iris +versicolor + + +Iris +virginica +Rotated rich text keys + + diff --git a/tests/testthat/test-draw-keys.R b/tests/testthat/test-draw-keys.R new file mode 100644 index 0000000..1366b6d --- /dev/null +++ b/tests/testthat/test-draw-keys.R @@ -0,0 +1,18 @@ +test_that("visual test", { + skip_if_not(packageVersion("ggplot2") >= "3.5.0") + + p <- ggplot(iris, aes(Sepal.Width, Sepal.Length, colour = Species)) + + geom_point(key_glyph = "richtext") + + scale_colour_discrete( + labels = NULL, + guide = guide_legend(override.aes = list( + label = paste0( + "Iris", + c("
setosa", " versicolor", "
virginica"), "
" + ), + size = 11 / .pt, hjust = c(1, 0.5, 0), angle = c(-45, 0, 45), + label.colour = "blue" + )) + ) + expect_doppelganger("Rotated rich text keys", p) +})