Skip to content

Commit 9bd9940

Browse files
committed
add some basic tests for hex/map
1 parent 0e39f4b commit 9bd9940

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

tests/testthat/test-ggplot-hex.R

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
context("hex")
2+
3+
d <- ggplot(diamonds, aes(carat, price))
4+
5+
test_that("geom_hex", {
6+
g <- d + geom_hex()
7+
l <- save_outputs(g, "hex-basic")
8+
expect_true(length(l$data) > 1)
9+
})
10+
11+
12+
test_that("geom_hex with bins", {
13+
g <- d + geom_hex(bins = 10)
14+
l <- save_outputs(g, "hex-bins")
15+
expect_true(length(l$data) > 1)
16+
})
17+
18+
test_that("geom_hex with binwidth", {
19+
g <- d + geom_hex(binwidth = c(1, 1000))
20+
l <- save_outputs(g, "hex-binwidth")
21+
expect_true(length(l$data) > 1)
22+
})

tests/testthat/test-ggplot-map.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
context("maps")
2+
3+
crimes <- data.frame(state = tolower(rownames(USArrests)), USArrests)
4+
crimesm <- tidyr::gather(crimes, variable, value, -state)
5+
states_map <- map_data("state")
6+
g <- ggplot(crimesm, aes(map_id = state)) +
7+
geom_map(aes(fill = value), map = states_map) +
8+
expand_limits(x = states_map$long, y = states_map$lat) +
9+
facet_wrap( ~ variable)
10+
11+
12+
test_that("basic geom_map works", {
13+
l <- save_outputs(g, "map-facet")
14+
expect_true(length(l$data) > 1)
15+
})
16+

0 commit comments

Comments
 (0)