1context("coord_map") 2 3us_map <- map_data("usa") 4p_us <- ggplot(us_map, aes(x = long, y = lat, group = group)) 5 6test_that("USA state map drawn", { 7 expect_doppelganger( 8 "USA mercator", 9 p_us + 10 geom_polygon(fill = NA, colour = "grey50") + 11 coord_map("mercator") 12 ) 13}) 14 15test_that("coord_map scale position can be switched", { 16 expect_doppelganger( 17 "coord_map switched scale position", 18 p_us + 19 geom_polygon(fill = NA, colour = "grey50") + 20 coord_map("mercator") + 21 scale_y_continuous(position = "right") + 22 scale_x_continuous(position = "top") 23 ) 24}) 25 26test_that("Inf is squished to range", { 27 d <- cdata( 28 ggplot(data_frame(x = 0, y = 0)) + 29 geom_point(aes(x,y)) + 30 annotate("text", -Inf, Inf, label = "Top-left") + 31 coord_map() 32 ) 33 34 expect_equal(d[[2]]$x, 0) 35 expect_equal(d[[2]]$y, 1) 36}) 37