tests/testthat/test-utils.R

d <- data.table(
  name = c(
    "Isaiah    Nyabuto",
    "Isaiah Nyabuto  ",
    "   Isaiah Nyabuto"
  ),
  id = rep(123, 3)
)

test_that("names are correctly reviewed", {
  d <- d[, name := review_names(name)]
  expect_equal(d$name, rep("isaiah nyabuto", 3))
})

testd <- readr::read_csv("./test_data/current_program_a360_full_data.csv",
  col_types = paste0(rep("c", 43), collapse = "")
)
testd <- testd[1:1000, ]

test_that("has_phone_number checks for presence of any phone number", {
  d2 <- as.data.table(testd)
  d2 <- d2[is.na(`Phone Number`), ]
  expect_equal(has_phone_number(testd), T)
  expect_equal(has_phone_number(d2), F)
})

test_that("is_empty checks for nulls in list", {
  x <- list(NULL, y = NULL, z = 2)
  expect_equal(x[!is_empty(x)][[1]], 2)
})
psi-mis/a360connect documentation built on Nov. 22, 2022, 12:36 p.m.