Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Imports:
grDevices
Suggests:
colourvalues,
sp,
shiny,
testthat (>= 2.1.0)
URL: https://github.com/r-spatial/leafgl, https://r-spatial.github.io/leafgl/
Expand Down
18 changes: 9 additions & 9 deletions tests/testthat/test-leafgl-addGlPolygons.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ test_that("addGlPolygons works", {
addGlPolygons(data = single_poly, group = NULL, src = TRUE, digits = 5)
expect_is(m, "leaflet")

## Multi #########
expect_error(
leaflet() %>%
addGlPolygons(data = gadm, digits = 5))
expect_error(
leaflet() %>%
addGlPolygons(data = gadm, src = TRUE, digits = 5))

## Spatial Data #########
skip_if_not_installed("sp")
spatialdf <- as(single_poly, "Spatial")
m = leaflet() %>%
addGlPolygons(data = spatialdf, digits = 5)
Expand All @@ -31,13 +40,4 @@ test_that("addGlPolygons works", {
m = leaflet() %>%
addGlPolygons(data = spatialdf, src = TRUE, digits = 5)
expect_is(m, "leaflet")

## Multi #########
expect_error(
leaflet() %>%
addGlPolygons(data = gadm, digits = 5))
expect_error(
leaflet() %>%
addGlPolygons(data = gadm, src = TRUE, digits = 5))

})
33 changes: 17 additions & 16 deletions tests/testthat/test-leafgl-popup.R
Original file line number Diff line number Diff line change
Expand Up @@ -504,22 +504,23 @@ test_that("popup-lines-table", {
})

test_that("popup-lines-spatial", {
popups <- suppressWarnings(sf::as_Spatial(storms))
## SpatialLinesDataFrame ##############
## Simple Feature ##############
library(sf)
m <- leaflet() %>% addTiles() %>%
addGlPolylines(data = storms,
popup = popups,
popup = storms,
opacity = 1)

expect_is(m, "leaflet")
expect_true(yyjsonr::validate_json_str(m$x$calls[[2]]$args[[3]]))

## Simple Feature ##############
library(sf)
skip_if_not_installed("sp")
popups <- suppressWarnings(sf::as_Spatial(storms))
## SpatialLinesDataFrame ##############
m <- leaflet() %>% addTiles() %>%
addGlPolylines(data = storms,
popup = storms,
popup = popups,
opacity = 1)

expect_is(m, "leaflet")
expect_true(yyjsonr::validate_json_str(m$x$calls[[2]]$args[[3]]))
})
Expand Down Expand Up @@ -717,22 +718,22 @@ test_that("popup-polygon-table", {
})

test_that("popup-polygon-spatial", {
## SpatialPolygonsDataFrame ##############
popups <- suppressWarnings(sf::as_Spatial(gadm))
## Simple Feature ##############
library(sf)
m <- leaflet() %>% addTiles() %>%
addGlPolygons(data = gadm,
popup = popups,
opacity = 1)
popup = gadm,
opacity = 1)

expect_is(m, "leaflet")
expect_true(yyjsonr::validate_json_str(m$x$calls[[2]]$args[[3]]))

## Simple Feature ##############
library(sf)
## SpatialPolygonsDataFrame ##############
skip_if_not_installed("sp")
popups <- suppressWarnings(sf::as_Spatial(gadm))
m <- leaflet() %>% addTiles() %>%
addGlPolygons(data = gadm,
popup = gadm,
popup = popups,
opacity = 1)

expect_is(m, "leaflet")
expect_true(yyjsonr::validate_json_str(m$x$calls[[2]]$args[[3]]))
})
Expand Down
Loading