tests/testthat/test-parse_project.R

context("test-.parse_project")

test_that(".parse_project returns a tibble", {
  html_path <-
    system.file("extdata", "1_example.html",
                package = "phsparsr", mustWork = TRUE)
  table_rows <- .get_rows_from_html(html_path)
  project_list <- .split_by_project(table_rows)
  parsed <- .parse_project(project_list[[1]])

  expect_true(tibble::is_tibble(parsed))
})

test_that(".parse_project returns expected tibble", {
  html_path <-
    system.file("extdata", "1_example.html",
                package = "phsparsr", mustWork = TRUE)
  table_rows <- .get_rows_from_html(html_path)
  project_list <- .split_by_project(table_rows)
  parsed <- .parse_project(project_list[[1]])

  expected <-
    structure(
      list(phs = c("phs000007", "phs000007"),
           expiration = c("2019-02-29", "2019-02-29"),
           consent_code = c("Health/Medical/Biomedical (IRB, MDS)",
                            "Health/Medical/Biomedical (IRB, NPU, MDS)")),
      row.names = c(NA, -2L),
      class = c("tbl_df", "tbl", "data.frame")
      )

  expect_identical(parsed, expected)
})
UW-GAC/phsparsr documentation built on Dec. 23, 2019, 10:08 p.m.