forked from animint/animint2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-renderer3-stat-bin.R
61 lines (58 loc) · 1.4 KB
/
test-renderer3-stat-bin.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
acontext("stat bin")
set.seed(1)
make <- function(count, stack, a_facet){
data.frame(count, row=1:count, stack, a_facet)
}
df <- rbind(
make(2, 1, 1),
make(5, 1, 1),
make(3, 2, 1),
make(4, 2, 1),
make(2, 2, 2),
make(5, 2, 2),
make(3, 1, 2),
make(4, 1, 2)
)
test_that("error for stat=bin and showSelected", {
gg <- a_plot() +
a_theme_bw()+
a_theme(panel.margin=grid::unit(0, "lines"))+
a_geom_bar(
a_aes(count, group=stack, fill=stack),
showSelected="a_facet",
binwidth=1,
data = df,
stat = "bin",
a_position="identity"
)
gg+a_facet_grid(a_facet~.)
complicated <- list(
plot = gg
)
expect_error({
animint2HTML(complicated)
}, "showSelected does not work with a_StatBin, problem: a_geom1_bar_plot")
})
test_that("no warning for stat=bin without showSelected", {
gg <- a_plot() +
a_theme_bw()+
a_theme(panel.margin=grid::unit(0, "lines"))+
a_geom_bar(
a_aes(count, group=stack, fill=stack),
binwidth=1,
data = df,
stat = "bin",
a_position="identity"
)+
a_facet_grid(a_facet~.)
complicated <- list(plot = gg)
expect_no_warning({
info <- animint2HTML(complicated)
})
for(panel in 1:2){
xpath <- sprintf('//g[@class="PANEL%d"]//rect', panel)
style.vec <- getStyleValue(info$html, xpath, "fill")
fill.counts <- table(style.vec)
expect_equal(length(fill.counts), 2)
}
})