swh:1:snp:bdc19e867479541d0f4994ceaa711217d0dc28ed
Tip revision: 74b598025322cd572dcd58326f0c5fb465f503ab authored by Hadley Wickham on 23 June 2022, 13:00:02 UTC
version 2.0.5
version 2.0.5
Tip revision: 74b5980
test-rmarkdown.R
test_that("render_rmarkdown copies image files in subdirectories", {
skip_if_no_pandoc()
tmp <- dir_create(file_temp())
pkg <- list(src_path = test_path("."), dst_path = tmp, bs_version = 3)
expect_output(
render_rmarkdown(pkg, "assets/vignette-with-img.Rmd", "test.html")
)
expect_equal(
as.character(path_rel(dir_ls(tmp, type = "file", recurse = TRUE), tmp)),
c("open-graph/logo.png", "test.html")
)
})
test_that("render_rmarkdown yields useful error", {
skip_on_cran() # fragile due to pandoc dependency
skip_if_no_pandoc("2.18")
tmp <- dir_create(file_temp())
pkg <- list(src_path = test_path("."), dst_path = tmp, bs_version = 3)
expect_snapshot(error = TRUE, {
render_rmarkdown(pkg, "assets/pandoc-fail.Rmd", "test.html",
output_format = rmarkdown::html_document(pandoc_args = "--fail-if-warnings"))
})
})
test_that("render_rmarkdown styles ANSI escapes", {
skip_if_no_pandoc()
tmp <- dir_create(file_temp())
pkg <- list(src_path = test_path("."), dst_path = tmp, bs_version = 5)
expect_output({
path <- render_rmarkdown(pkg,
input = "assets/vignette-with-crayon.Rmd",
output = "test.html"
)
})
html <- xml2::read_html(path)
expect_snapshot_output(xpath_xml(html, ".//code//span[@class='co']"))
})