tests/testthat/test-utils-clipboard.R

test_that("reprex_clipboard() works", {
  withr::local_options(list(reprex.clipboard = FALSE))
  expect_false(reprex_clipboard())
})

test_that("reprex_clipboard() insists on length one logical", {
  withr::local_options(list(reprex.clipboard = function() "wut"))
  expect_snapshot(error = TRUE, reprex_clipboard())
})

test_that("ingest_clipboard() copes when clipboard not available", {
  withr::local_options(list(reprex.clipboard = FALSE))
  local_reprex_loud()
  msg <- capture_messages(
    out <- ingest_clipboard()
  )
  expect_equal(out, character())
  expect_match(msg, "clipboard is not available")
})

Try the reprex package in your browser

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

reprex documentation built on Aug. 17, 2022, 9:07 a.m.