File: test-custom-handler.R

package info (click to toggle)
r-cran-cli 3.6.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,288 kB
  • sloc: ansic: 16,412; cpp: 37; sh: 13; makefile: 2
file content (13 lines) | stat: -rw-r--r-- 421 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13

test_that("custom handler works", {
  conds <- list()
  withr::with_options(
    list(cli.default_handler = function(msg) conds <<- c(conds, list(msg))),
    { cli_h1("title"); cli_h2("subtitle"); cli_text("text") }
  )
  expect_equal(length(conds), 3)
  lapply(conds, expect_s3_class, "cli_message")
  expect_equal(conds[[1]]$type, "h1")
  expect_equal(conds[[2]]$type, "h2")
  expect_equal(conds[[3]]$type, "text")
})