chapter_numbering yaml option: turn numbering off or start at a value

The automatic chapter numbering can now be controlled from the yaml
header. The default TRUE numbers the # chapters from 1 as before.
chapter_numbering: false turns the numbering off -- headings keep
exactly what was typed, including manually typed numbers, and the
overview TOC shows the titles as typed (the numbering script is not
emitted at all). A number starts the enumeration at that value, e.g.
chapter_numbering: 5 for a continuation deck; references, appendix and
thank-you chapters stay excluded and uncounted in every mode.

Change-Id: I69af1414aedd14c9be09650c78b3219bf63c4d1a
diff --git a/tests/testthat/test-revealjs_presentation.R b/tests/testthat/test-revealjs_presentation.R
index ade1c9a..85ad022 100644
--- a/tests/testthat/test-revealjs_presentation.R
+++ b/tests/testthat/test-revealjs_presentation.R
@@ -18,3 +18,45 @@
     "TOC"
   )
 })
+
+test_that("chapter_numbering option controls the numbering script", {
+  skip_if_not_pandoc()
+  rmd <- local_temp_rmd_file(
+    "---",
+    "title: 'Chapter numbering test'",
+    "output: revealjs.ids::revealjs_presentation",
+    "---",
+    "",
+    "# One",
+    "",
+    "## a",
+    "",
+    "# Two"
+  )
+  on <- paste(.render_and_read(rmd, xml = FALSE), collapse = "\n")
+  expect_match(on, "function numberChapters", fixed = TRUE)
+  expect_match(on, "var start = 1;", fixed = TRUE)
+
+  off <- paste(.render_and_read(
+    rmd,
+    output_options = list(chapter_numbering = FALSE),
+    xml = FALSE
+  ), collapse = "\n")
+  expect_no_match(off, "function numberChapters", fixed = TRUE)
+
+  started <- paste(.render_and_read(
+    rmd,
+    output_options = list(chapter_numbering = 5),
+    xml = FALSE
+  ), collapse = "\n")
+  expect_match(started, "var start = 5;", fixed = TRUE)
+
+  expect_error(
+    .render_and_read(
+      rmd,
+      output_options = list(chapter_numbering = "yes"),
+      xml = FALSE
+    ),
+    "chapter_numbering"
+  )
+})