@@ -54,7 +54,10 @@ test_that("ggsave uses theme background as image background", {
54
54
ggsave(path , p , device = " svg" , width = 5 , height = 5 )
55
55
img <- xml2 :: read_xml(path )
56
56
# Find background rect in svg
57
- bg <- as.character(xml2 :: xml_find_first(img , xpath = " */d1:rect/@style" ))
57
+ bg <- as.character(xml2 :: xml_find_first(img , xpath = " d1:rect/@style" ))
58
+ if (is.na(bg )) {
59
+ bg <- as.character(xml2 :: xml_find_first(img , xpath = " d1:g/d1:rect/@style" ))
60
+ }
58
61
expect_true(grepl(" fill: #00CCCC" , bg ))
59
62
})
60
63
@@ -69,7 +72,10 @@ test_that("ggsave can handle blank background", {
69
72
theme(plot.background = element_blank())
70
73
ggsave(path , p , device = " svg" , width = 5 , height = 5 )
71
74
img <- xml2 :: read_xml(path )
72
- bg <- as.character(xml2 :: xml_find_first(img , xpath = " */d1:rect/@style" ))
75
+ bg <- as.character(xml2 :: xml_find_first(img , xpath = " d1:rect/@style" ))
76
+ if (is.na(bg )) {
77
+ bg <- as.character(xml2 :: xml_find_first(img , xpath = " d1:g/d1:rect/@style" ))
78
+ }
73
79
expect_true(grepl(" fill: none" , bg ))
74
80
})
75
81
0 commit comments