Add missing variable in templates regarding toc (#127)

Related to #123 and alignement with `html_document()` behavior
diff --git a/tests/testthat/helpers.R b/tests/testthat/helpers.R
new file mode 100644
index 0000000..ce5d6c4
--- /dev/null
+++ b/tests/testthat/helpers.R
@@ -0,0 +1,49 @@
+local_temp_rmd_file <- function(..., .env = parent.frame()) {
+  path <- withr::local_tempfile(.local_envir = .env, fileext = ".Rmd")
+  xfun::write_utf8(c(...), path)
+  path
+}
+
+local_temp_draft <- function(.env = parent.frame()) {
+  path <- withr::local_tempfile(.local_envir = .env, fileext = ".Rmd")
+  # TODO: Use `rmarkdown::draft()` when rmarkdown 2.12 is out.  
+  pkg_file <- getFromNamespace("pkg_file", "rmarkdown")
+  template_path <- pkg_file("rmarkdown", "templates", "revealjs_presentation", 
+                            package = "revealjs")
+  rmarkdown::draft(path, template_path, edit = FALSE)
+}
+
+.render_and_read <- function(input, xml = TRUE, ...) {
+  skip_if_not_pandoc()
+  output_file <- withr::local_tempfile(fileext = ".html")
+  res <- rmarkdown::render(input, output_file = output_file, quiet = TRUE, ...)
+  if (xml) {
+    xml2::read_html(res)
+  } else {
+    xfun::read_utf8(res)
+  }
+}
+
+# Use to test pandoc availability or version lower than
+skip_if_not_pandoc <- function(ver = NULL) {
+  if (!pandoc_available(ver)) {
+    msg <- if (is.null(ver)) {
+      "Pandoc is not available"
+    } else {
+      sprintf("Version of Pandoc is lower than %s.", ver)
+    }
+    skip(msg)
+  }
+}
+
+# Use to test version greater than
+skip_if_pandoc <- function(ver = NULL) {
+  if (pandoc_available(ver)) {
+    msg <- if (is.null(ver)) {
+      "Pandoc is available"
+    } else {
+      sprintf("Version of Pandoc is greater than %s.", ver)
+    }
+    skip(msg)
+  }
+}
\ No newline at end of file
diff --git a/tests/testthat/test-revealjs_presentation.R b/tests/testthat/test-revealjs_presentation.R
new file mode 100644
index 0000000..ade1c9a
--- /dev/null
+++ b/tests/testthat/test-revealjs_presentation.R
@@ -0,0 +1,20 @@
+test_that("toc argument works", {
+  skip_if_not_pandoc()
+  skip_if_not_installed("xml2")
+  rmd <- local_temp_draft()
+  html <- .render_and_read(
+    rmd,
+    output_options = list(
+      toc = TRUE,
+      pandoc_args = c(pandoc_variable_arg("toc-title", "TOC"))
+    )
+  )
+  toc <- xml2::xml_find_all(html, "//section[@id='TOC']")
+  expect_length(toc, 1)
+  expect_equal(
+    xml2::xml_text(
+      xml2::xml_find_all(toc, "./nav/*[contains(@id, 'toc-title')]")
+    ),
+    "TOC"
+  )
+})