tests/testthat/test-next-bus.R

test_that("next bus returned for single stop", {
  skip_if_no_key()
  Sys.sleep(0.11)
  n <- next_bus(StopID = 2000474)
  expect_s3_class(n, "data.frame")
  expect_length(n, 8)
})

test_that("empty tibble returned without next bus", {
  skip_if_no_key()
  Sys.sleep(0.11)
  n <- mockr::with_mock(
    .env = as.environment("package:metro"),
    `no_data_now` = function(x) TRUE,
    expect_message(next_bus(StopID = 2000474))
  )
  expect_equal(nrow(n), 0)
  expect_s3_class(n, "data.frame")
})

Try the metro package in your browser

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

metro documentation built on Nov. 2, 2023, 6:06 p.m.