tests/testthat/test-history.R

test_that("history", {

  m <- leaflet() %>%
    addTiles(group = "base") %>%
    fitBounds(-72, 40, -70, 43) %>%
    addHistory()

  expect_is(m, "leaflet")

  deps <- findDependencies(m)
  expect_equal(deps[[length(deps) - 1]]$name, "font-awesome")
  expect_equal(deps[[length(deps)]]$name, "lfx-history")

  m <- m %>%
    goBackHistory()
  expect_equal(m$x$calls[[length(m$x$calls)]]$method,
               "goBackHistory")

  m <- m %>% goForwardHistory()
  expect_equal(m$x$calls[[length(m$x$calls)]]$method,
               "goForwardHistory")

  m <- m %>% clearFuture()
  expect_equal(m$x$calls[[length(m$x$calls)]]$method,
               "clearFuture")

  m <- m %>% clearHistory()
  expect_equal(m$x$calls[[length(m$x$calls)]]$method,
               "clearHistory")

})

Try the leaflet.extras2 package in your browser

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

leaflet.extras2 documentation built on Aug. 21, 2023, 5:08 p.m.