From 1c73bd523a9c882ace7b85b6793b029b6c41ce09 Mon Sep 17 00:00:00 2001 From: CJ Yetman Date: Fri, 26 Apr 2024 11:24:36 +0200 Subject: [PATCH] test `get_index_regions()` (#54) --- tests/testthat/test-get_index_regions.R | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/testthat/test-get_index_regions.R diff --git a/tests/testthat/test-get_index_regions.R b/tests/testthat/test-get_index_regions.R new file mode 100644 index 0000000..16031cb --- /dev/null +++ b/tests/testthat/test-get_index_regions.R @@ -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))) +})