tests/testthat/test-parse_people.R

test_that("parse_people person_to_schema method", {
  p <- person_to_schema("Carl Boettiger")
  expect_gt(length(p), 1)
  p <- person_to_schema("")
  expect_null(p)
})

test_that("parse_people", {
  cm <- new_codemeta()
  p <- parse_people("Carl Boettiger", cm)
  expect_gt(length(p$author), 0)

  p <- parse_people("", cm)
  expect_null(p$author)
})

test_that("person_has_no_role works", {
  expect_error(person_has_no_role())
  expect_error(person_has_no_role("Maria"))

  expect_true(person_has_no_role(person("Maria")))
  expect_false(person_has_no_role(person("Maria", role = "aut")))
})

test_that("person_has_role works", {
  expect_error(person_has_role())
  expect_error(person_has_role("Maria"))
  expect_error(person_has_role(person("Maria")))

  expect_true(person_has_role(person("Maria", role = "aut"), "aut"))
  expect_false(person_has_role(person("Maria", role = "aut"), "abc"))
})

Try the codemeta package in your browser

Any scripts or data that you put into this service are public.

codemeta documentation built on Dec. 22, 2021, 1:06 a.m.