tests/testthat/test-s3-html.R

test_that("html", {
  skip_if_not_installed("htmltools")
  expect_snapshot({
    construct(htmltools::HTML("<b>x</b>"))
    construct(htmltools::HTML("<b>x</b>"), opts_html("next"))
    construct(htmltools::HTML(c("a", "b")))
    construct(htmltools::HTML(""))
    construct(htmltools::HTML("x", .noWS = c("before", "after")))
    # attributes to repair
    construct(structure(htmltools::HTML("x"), foo = 1))
    # corrupted
    construct(structure(c("a", "b"), html = TRUE, class = c("html", "character")))
  })
})

Try the constructive package in your browser

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

constructive documentation built on Oct. 22, 2026, 5:07 p.m.