tests/testthat/test-get_countries_by_region.R

test_that("get_countries_by_region returns correct data for a valid region",{
  result <- get_countries_by_region('Africa')

  expect_true(nrow(result) > 50) # we know that countries in Africa is morethan 50
  expect_equal(result$region[1], 'Africa')
})
#> future considering testing that handles invalid region
#>
#>
# test_that("get_countries_by_region handles invalid region gracefully", {
#   expect_warning(result <- get_countries_by_region("InvalidRegion"))
#   expect_true(is.null(result))
# })

Try the tidycountries package in your browser

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

tidycountries documentation built on Oct. 27, 2024, 9:07 a.m.