tests/testthat/test-internal.R

# Offline tests for pure internal helpers used in query/URL building.

test_that(".axprism_compact drops only NULL entries", {
  out <- axprism:::.axprism_compact(list(a = 1, b = NULL, c = "x", d = NULL))
  expect_named(out, c("a", "c"))
  expect_identical(out$a, 1)
  expect_identical(out$c, "x")
})

test_that(".axprism_compact keeps falsy-but-present values", {
  out <- axprism:::.axprism_compact(list(a = 0, b = FALSE, c = "", d = NULL))
  expect_named(out, c("a", "b", "c"))
})

test_that(".axprism_compact returns an empty list when all entries are NULL", {
  expect_length(axprism:::.axprism_compact(list(a = NULL, b = NULL)), 0)
})

test_that("%||% falls back on NULL, empty, and blank values", {
  `%or%` <- axprism:::`%||%`
  expect_identical("fallback" , NULL %or% "fallback")
  expect_identical("fallback", character(0) %or% "fallback")
  expect_identical("fallback", "" %or% "fallback")
  expect_identical("value", "value" %or% "fallback")
})

Try the axprism package in your browser

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

axprism documentation built on July 8, 2026, 9:07 a.m.