tests/testthat/test_get_favorites.R

context("get_favorites")

test_that("get_favorites returns tweets data", {
  skip_on_cran()

  n <- 100
  x <- get_favorites("TwitterSupport", n = n)

  expect_equal(is.data.frame(x), TRUE)
  expect_named(x)
  expect_true("status_id" %in% names(x))
  expect_gt(nrow(x), 10)
  expect_gt(ncol(x), 15)
  expect_true(is.data.frame(data.frame(users_data(x))))
})

test_that("get_favorites throws an error if usernames have spaces in them", {
  skip_on_cran()
  n <- 2
  expect_error(get_favorites(c("elonmusk","elon musk"), n=n))
})
mkearney/rtw documentation built on Dec. 21, 2021, 7:05 p.m.