File: test-html_document.R

package info (click to toggle)
r-cran-rmarkdown 2.20%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,028 kB
  • sloc: javascript: 5,656; sh: 24; makefile: 17
file content (26 lines) | stat: -rw-r--r-- 1,414 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# TODO: to remove when switching the package to edition 3
local_edition(3)

test_that("anchor_sections() adds correct component", {
  skip_if_not_pandoc("2.0")
  res <- list(args = NULL, lua_filters = NULL, extra_dependencies = NULL)
  expect_equal(add_anchor_sections(FALSE),
               list(args = NULL, lua_filters = NULL, extra_dependencies = NULL))
  expect_error(add_anchor_sections(list(dummy = "smg")), "a list with")
  expect_error(add_anchor_sections("dummy"), "a list with")
  components <- add_anchor_sections(TRUE)
  expect_match(components$lua_filters, "anchor-sections.lua$")
  expect_s3_class(components$extra_dependencies[[1]], "html_dependency")
  expect_equal(components$extra_dependencies[[1]]$name, "anchor-sections")
  expect_null(components$args)
  components <- add_anchor_sections(list(style = "icon"))
  expect_match(components$lua_filters, "anchor-sections.lua$")
  expect_s3_class(components$extra_dependencies[[1]], "html_dependency")
  expect_equal(components$extra_dependencies[[1]]$name, "anchor-sections")
  expect_null(components$args)
  components <- add_anchor_sections(list(depth = "3"))
  expect_match(components$lua_filters, "anchor-sections.lua$")
  expect_s3_class(components$extra_dependencies[[1]], "html_dependency")
  expect_equal(components$extra_dependencies[[1]]$name, "anchor-sections")
  expect_equal(components$args, c("--metadata", "rmd_anchor_depth=3"))
})