Skip to content

Commit b9d3014

Browse files
committed
Add unit test for print_plot.grob()
1 parent 432b03e commit b9d3014

File tree

5 files changed

+35
-84
lines changed

5 files changed

+35
-84
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
S3method(print_plot,"function")
44
S3method(print_plot,default)
55
S3method(print_plot,ggplot)
6+
S3method(print_plot,grob)
67
S3method(print_plot,recordedplot)
78
export(expect_doppelganger)
89
export(write_svg)
Lines changed: 23 additions & 0 deletions
Loading

tests/testthat/_snaps/expect-doppelganger/page-error1.svg

Lines changed: 0 additions & 41 deletions
Loading

tests/testthat/_snaps/expect-doppelganger/page-error2.svg

Lines changed: 0 additions & 41 deletions
Loading

tests/testthat/test-expect-doppelganger.R

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,20 @@ test_that("no 'svglite supports one page' error (#85)", {
7272
widths = unit(c(0.05, 0.9, 0.05), "npc"),
7373
heights = unit(c(0.05, 0.9, 0.05), "npc")
7474
)
75-
gt <- gtable_add_grob(gt, list(axes_grob), 2, 2, clip = "off")
76-
plot(gt)
75+
gtable_add_grob(gt, list(axes_grob), 2, 2, clip = "off")
7776
}
7877
environment(test_draw_axis) <- env(ns_env("ggplot2"))
7978

8079
expect_doppelganger("page-error1", test_draw_axis(FALSE))
8180
expect_doppelganger("page-error2", test_draw_axis(TRUE))
8281
})
82+
83+
test_that("supports `grob` objects (#36)", {
84+
circle <- grid::circleGrob(
85+
x = 0.5,
86+
y = 0.5,
87+
r = 0.5,
88+
gp = grid::gpar(col = "gray", lty = 3)
89+
)
90+
expect_doppelganger("grob", circle)
91+
})

0 commit comments

Comments
 (0)