File: test-coord-map.R

package info (click to toggle)
r-cran-ggplot2 3.3.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 8,184 kB
  • sloc: sh: 15; makefile: 5
file content (36 lines) | stat: -rw-r--r-- 857 bytes parent folder | download
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
context("coord_map")

us_map <- map_data("usa")
p_us <- ggplot(us_map, aes(x = long, y = lat, group = group))

test_that("USA state map drawn", {
  expect_doppelganger(
    "USA mercator",
    p_us +
      geom_polygon(fill = NA, colour = "grey50") +
      coord_map("mercator")
  )
})

test_that("coord_map scale position can be switched", {
  expect_doppelganger(
    "coord_map switched scale position",
    p_us +
      geom_polygon(fill = NA, colour = "grey50") +
      coord_map("mercator") +
      scale_y_continuous(position = "right") +
      scale_x_continuous(position = "top")
  )
})

test_that("Inf is squished to range", {
  d <- cdata(
    ggplot(data_frame(x = 0, y = 0)) +
      geom_point(aes(x,y)) +
      annotate("text", -Inf, Inf, label = "Top-left") +
      coord_map()
  )

  expect_equal(d[[2]]$x, 0)
  expect_equal(d[[2]]$y, 1)
})