tests/testthat/test-measure.R

test_that("dependency got added", {
  expect_true(
    !is.na(Position(
      function(dep) dep$name == "leaflet-measure",
      addMeasure(leaflet())$dependencies
    ))
  )
})

test_that("call got added", {
  expect_true(
    !is.na(Position(
      function(cl) cl$method == "addMeasure",
      addMeasure(leaflet())$x$calls
    ))
  )
})

test_that("options added as expected", {
  expect_true(
    Filter(
      function(cl) cl$method == "addMeasure",
      addMeasure(leaflet(), position = "bottomleft")$x$calls
    )[[1]]$args[[1]]$position == "bottomleft"
  )
})

# are null options removed
# were options added as expected
test_that("null options removed", {
  expect_true(
    !("position" %in% names(Filter(
      function(cl) cl$method == "addMeasure"
      , addMeasure(leaflet(), position = NULL )$x$calls
    )[[1]]$args[[1]]))
  )
})

Try the leaflet package in your browser

Any scripts or data that you put into this service are public.

leaflet documentation built on Nov. 14, 2023, 1:08 a.m.