1context("geom_bar")
2
3test_that("geom_bar removes bars with parts outside the plot limits", {
4  dat <- data_frame(x = c("a", "b", "b", "c", "c", "c"))
5
6  p <- ggplot(dat, aes(x)) + geom_bar()
7
8  expect_warning( # warning created at render stage
9    ggplotGrob(p + ylim(0, 2.5)),
10    "Removed 1 rows containing missing values"
11  )
12})
13
14test_that("geom_bar works in both directions", {
15  dat <- data_frame(x = c("a", "b", "b", "c", "c", "c"))
16
17  p <- ggplot(dat, aes(x)) + geom_bar()
18  x <- layer_data(p)
19  expect_false(x$flipped_aes[1])
20
21  p <- ggplot(dat, aes(y = x)) + geom_bar()
22  y <- layer_data(p)
23  expect_true(y$flipped_aes[1])
24
25  x$flipped_aes <- NULL
26  y$flipped_aes <- NULL
27  expect_identical(x, flip_data(y, TRUE))
28})
29