Skip to content

Commit e97ee3a

Browse files
committed
rect test fails
1 parent ed8461e commit e97ee3a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/testthat/test-ggplot-rect.R

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
context("geom_rect")
2+
3+
expect_traces <- function(gg, n.traces, name){
4+
stopifnot(is.ggplot(gg))
5+
stopifnot(is.numeric(n.traces))
6+
save_outputs(gg, paste0("rects-", name))
7+
L <- gg2list(gg)
8+
is.trace <- names(L) == ""
9+
all.traces <- L[is.trace]
10+
no.data <- sapply(all.traces, function(tr) {
11+
is.null(tr[["x"]]) && is.null(tr[["y"]])
12+
})
13+
has.data <- all.traces[!no.data]
14+
expect_equal(length(has.data), n.traces)
15+
list(traces=has.data, kwargs=L$kwargs)
16+
}
17+
18+
df <- data.frame(
19+
x = sample(10, 20, replace = TRUE),
20+
y = sample(10, 20, replace = TRUE)
21+
)
22+
23+
gg <- ggplot(df, aes(xmin = x, xmax = x + 1, ymin = y, ymax = y + 2)) +
24+
geom_rect()
25+
26+
test_that('geom_rect becomes traces with mode "lines" with fill "tozerox"', {
27+
expect_traces(gg, 1, "black")
28+
})

0 commit comments

Comments
 (0)