Skip to content

Commit

Permalink
add tests for get_links functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestguevarra committed Aug 18, 2024
1 parent 8f7c846 commit e78842c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
10 changes: 5 additions & 5 deletions R/eq_get.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#'
#' @examples
#' eq_get_table()
#' eq_get_links(.year = 2018)
#' eq_get_links()
#'
#' @rdname eq_get
#' @export
Expand Down Expand Up @@ -154,16 +154,16 @@ eq_get_links <- function(.url = "https://earthquake.phivolcs.dost.gov.ph/",
(\(x)
{
paste(
stringr::str_extract_all(
string = x, pattern = paste(month.name, collapse = "|"),
simplify = TRUE
stringr::str_extract(
string = x, pattern = paste(month.name, collapse = "|")
),
stringr::str_extract(
string = x, pattern = "[0-9]{4}"
)
)
}
)()
)() |>
(\(x)ifelse(x == "NA NA", format(Sys.Date(), format = "%B %Y"), x))()

names(url_list) <- url_list_names

Expand Down
2 changes: 1 addition & 1 deletion man/eq_get.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions tests/testthat/test-eq_get.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,24 @@ test_that("get table function outputs are as expected", {
test_that("tables are of the correct structure", {
expect_vector(tab_list, size = 1)
})

tab_list <- eq_get_links()

test_that("get table function outputs are as expected", {
expect_type(tab_list, "list")
})

test_that("tables are of the correct structure", {
expect_vector(tab_list, size = 1)
})

tab_list <- eq_get_links(.year = 2020)

test_that("get table function outputs are as expected", {
expect_type(tab_list, "list")
})

test_that("tables are of the correct structure", {
expect_vector(tab_list, size = 12)
expect_named(tab_list, expected = paste(month.name, 2020))
})

0 comments on commit e78842c

Please sign in to comment.