Skip to content

Commit a77d53a

Browse files
authored
Merge pull request #107 from olivroy/no-sp
Add sp to suggests since leaflet will no longer import it by default
2 parents 7af1dcc + 93cce4f commit a77d53a

3 files changed

Lines changed: 27 additions & 25 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Imports:
3939
grDevices
4040
Suggests:
4141
colourvalues,
42+
sp,
4243
shiny,
4344
testthat (>= 2.1.0)
4445
URL: https://github.com/r-spatial/leafgl, https://r-spatial.github.io/leafgl/

tests/testthat/test-leafgl-addGlPolygons.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@ test_that("addGlPolygons works", {
2222
addGlPolygons(data = single_poly, group = NULL, src = TRUE, digits = 5)
2323
expect_is(m, "leaflet")
2424

25+
## Multi #########
26+
expect_error(
27+
leaflet() %>%
28+
addGlPolygons(data = gadm, digits = 5))
29+
expect_error(
30+
leaflet() %>%
31+
addGlPolygons(data = gadm, src = TRUE, digits = 5))
32+
2533
## Spatial Data #########
34+
skip_if_not_installed("sp")
2635
spatialdf <- as(single_poly, "Spatial")
2736
m = leaflet() %>%
2837
addGlPolygons(data = spatialdf, digits = 5)
@@ -31,13 +40,4 @@ test_that("addGlPolygons works", {
3140
m = leaflet() %>%
3241
addGlPolygons(data = spatialdf, src = TRUE, digits = 5)
3342
expect_is(m, "leaflet")
34-
35-
## Multi #########
36-
expect_error(
37-
leaflet() %>%
38-
addGlPolygons(data = gadm, digits = 5))
39-
expect_error(
40-
leaflet() %>%
41-
addGlPolygons(data = gadm, src = TRUE, digits = 5))
42-
4343
})

tests/testthat/test-leafgl-popup.R

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -504,22 +504,23 @@ test_that("popup-lines-table", {
504504
})
505505

506506
test_that("popup-lines-spatial", {
507-
popups <- suppressWarnings(sf::as_Spatial(storms))
508-
## SpatialLinesDataFrame ##############
507+
## Simple Feature ##############
508+
library(sf)
509509
m <- leaflet() %>% addTiles() %>%
510510
addGlPolylines(data = storms,
511-
popup = popups,
511+
popup = storms,
512512
opacity = 1)
513+
513514
expect_is(m, "leaflet")
514515
expect_true(yyjsonr::validate_json_str(m$x$calls[[2]]$args[[3]]))
515516

516-
## Simple Feature ##############
517-
library(sf)
517+
skip_if_not_installed("sp")
518+
popups <- suppressWarnings(sf::as_Spatial(storms))
519+
## SpatialLinesDataFrame ##############
518520
m <- leaflet() %>% addTiles() %>%
519521
addGlPolylines(data = storms,
520-
popup = storms,
522+
popup = popups,
521523
opacity = 1)
522-
523524
expect_is(m, "leaflet")
524525
expect_true(yyjsonr::validate_json_str(m$x$calls[[2]]$args[[3]]))
525526
})
@@ -717,22 +718,22 @@ test_that("popup-polygon-table", {
717718
})
718719

719720
test_that("popup-polygon-spatial", {
720-
## SpatialPolygonsDataFrame ##############
721-
popups <- suppressWarnings(sf::as_Spatial(gadm))
721+
## Simple Feature ##############
722+
library(sf)
722723
m <- leaflet() %>% addTiles() %>%
723724
addGlPolygons(data = gadm,
724-
popup = popups,
725-
opacity = 1)
725+
popup = gadm,
726+
opacity = 1)
727+
726728
expect_is(m, "leaflet")
727729
expect_true(yyjsonr::validate_json_str(m$x$calls[[2]]$args[[3]]))
728-
729-
## Simple Feature ##############
730-
library(sf)
730+
## SpatialPolygonsDataFrame ##############
731+
skip_if_not_installed("sp")
732+
popups <- suppressWarnings(sf::as_Spatial(gadm))
731733
m <- leaflet() %>% addTiles() %>%
732734
addGlPolygons(data = gadm,
733-
popup = gadm,
735+
popup = popups,
734736
opacity = 1)
735-
736737
expect_is(m, "leaflet")
737738
expect_true(yyjsonr::validate_json_str(m$x$calls[[2]]$args[[3]]))
738739
})

0 commit comments

Comments
 (0)