Skip to content

Commit 9d5840f

Browse files
committed
add some tests
1 parent a7f09db commit 9d5840f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/testthat/test-ggplot-facets.R

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,27 @@ test_that("facet_wrap() doesn't create interior scales", {
9797
info <- save_outputs(g, "facet_wrap")
9898
expect_equal(unique(unlist(lapply(info$data, "[[", "yaxis"))), "y")
9999
})
100+
101+
102+
g <- ggplot(mtcars, aes(mpg, wt)) +
103+
geom_point() +
104+
facet_wrap( ~ am, labeller = label_both)
105+
106+
test_that("facet_wrap translates simple labeller function", {
107+
info <- save_outputs(g, "facet_wrap-labeller")
108+
txt <- sapply(info$layout$annotations, "[[", "text")
109+
expect_true(all(c("am: 0", "am: 1") %in% txt))
110+
})
111+
112+
g <- ggplot(mtcars, aes(mpg, wt)) +
113+
geom_point() +
114+
facet_grid(vs ~ am, labeller = label_both)
115+
116+
test_that("facet_grid translates simple labeller function", {
117+
info <- save_outputs(g, "facet_grid-labeller")
118+
txt <- sapply(info$layout$annotations, "[[", "text")
119+
expect_true(
120+
all(c("am: 0", "am: 1", "vs: 0", "vs: 1") %in% txt)
121+
)
122+
})
123+

0 commit comments

Comments
 (0)