tests/testit/test-json_test.R

testit::assert("Compares test and ref json for function supplied as function: pass", {
  test_function <- function(x){ list(names(x)) }
  out <- capture.output(json_test(func = test_function,
                                  package = "json2test",
                                  test_id = "test_cases",
                                  list_as_args = TRUE,
                                  fail_if_not_exists = FALSE),
                        type = "message")
  any(grepl("\u2713", out))
})

testit::assert("Compares test and ref json for function supplied as function: fail", {
  test_function <- function(x){ list(lapply(x, is.numeric)) }
  out <- capture.output(json_test(func = test_function,
                                  package = "json2test",
                                  test_id = "test_cases",
                                  list_as_args = TRUE,
                                  fail_if_not_exists = FALSE),
                        type = "message")
  !any(grepl("\u2713", out))
  any(grepl("\\[ \\]", out))
})
InsightRX/json2test documentation built on May 12, 2021, 9:49 p.m.