Skip to content

Commit

Permalink
test get_index_regions() (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjyetman authored Apr 26, 2024
1 parent d8c62e9 commit 1c73bd5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/testthat/test-get_index_regions.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
test_that("returns an appropriate data frame", {
skip_if_offline()

logger::log_threshold("OFF")
result <- get_index_regions()

expect_s3_class(result, "tbl_df")
expect_identical(names(result), c("equity_market", "country", "country_iso"))
expect_true(nrow(result) > 0)

expect_type(result[["equity_market"]], "character")
expect_true(all(!is.na(result[["equity_market"]])))

expect_type(result[["country"]], "character")
expect_true(all(!is.na(result[["country"]])))
expect_true(all(!is.na(countrycode::countrycode(result[["country"]], "country.name", "iso2c"))))

expect_type(result[["country_iso"]], "character")
expect_true(all(!is.na(result[["country_iso"]])))
expect_true(all(result[["country_iso"]] %in% na.exclude(countrycode::codelist$iso2c)))
})

0 comments on commit 1c73bd5

Please sign in to comment.