WIP more markdown() tests

This commit is contained in:
Alan Dipert
2020-04-01 21:38:39 +00:00
parent 9e959a88f1
commit 1487720fd8
3 changed files with 30 additions and 4 deletions

View File

@@ -175,6 +175,6 @@ Collate:
'test-module.R'
'test.R'
'update-input.R'
RoxygenNote: 7.0.2
RoxygenNote: 7.1.0
Encoding: UTF-8
Roxygen: list(markdown = TRUE)

View File

@@ -2318,7 +2318,7 @@ missingOutput <- function(...) req(FALSE)
#' concatenated HTML is returned.
#' @param extensions Enable Github syntax extensions; defaults to `TRUE`.
#' @param .noWS Character vector used to omit some of the whitespace that would
#' normally be written around this HTML. Valid options include `before`,
#' normally be written around generated HTML. Valid options include `before`,
#' `after`, and `outside` (equivalent to `before` and `end`).
#' @param ... Additional arguments to pass to [commonmark::markdown_html()].
#' These arguments are _[dynamic][rlang::dyn-dots]_.

View File

@@ -1,5 +1,31 @@
context("inline-markdown")
test_that("Markdown without newlines is converted properly", {
expect_equivalent(markdown("# a top level"), HTML("<h1>a top level</h1>"))
test_that("Markdown without newlines translates", {
expect_equivalent(markdown("# a top level"), HTML("<h1>a top level</h1>\n"))
expect_equivalent(markdown("## a subheading"), HTML("<h2>a subheading</h2>\n"))
expect_equivalent(markdown("[rstudio](https://rstudio.com)"), HTML("<p><a href=\"https://rstudio.com\">rstudio</a></p>\n"))
})
test_that("HTML has correct attributes", {
html <- markdown("a paragraph", .noWS = "outside")
expect_is(html, "html")
expect_equal(attr(html, "noWS"), "outside")
})
test_that("Github extensions are on by default", {
html <- markdown("a ~paragraph~ with a link: https://example.com")
expect_equivalent(html, HTML("<p>a <del>paragraph</del> with a link: <a href=\"https://example.com\">https://example.com</a></p>\n"))
})
test_that("Github extensions can be disabled", {
html <- markdown("a ~paragraph~", extensions = FALSE)
expect_equivalent(html, HTML("<p>a ~paragraph~</p>\n"))
})
test_that("Additional options are respected", {
html <- markdown("a ~paragraph~", extensions = FALSE, sourcepos = TRUE)
expect_equivalent(html, HTML("<p data-sourcepos=\"1:1-1:13\">a ~paragraph~</p>\n"))
})
test_that("Multiline markdown works properly", {
})