tests/testthat/test-as_card.R

test_that("as_card() works", {
  expect_snapshot(
    data.frame(
      stat_name = c("N", "mean"),
      stat_label = c("N", "Mean"),
      stat = c(10, 0.5)
    ) |>
      as_card()
  )
})

test_that("as_card() does not affect 'card' objects", {
  my_ard <- ard_continuous(ADSL, by = "ARM", variables = "AGE")

  expect_identical(
    my_ard |> as_card(),
    my_ard
  )
})

test_that("as_card() error catching works correctly", {
  expect_snapshot(
    "notadataframe" |>
      as_card(),
    error = TRUE
  )
})

Try the cards package in your browser

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

cards documentation built on Oct. 4, 2024, 1:09 a.m.