From d4812f1b3a12c7aa696ef543a8ec3f6f0e0eb8b0 Mon Sep 17 00:00:00 2001 From: Mitchell O'Hara-Wild Date: Thu, 16 Jan 2025 19:21:34 +1100 Subject: [PATCH] Add test for rendering documents --- tests/testthat/documents/quiz.Rmd | 26 +++++++++++++++++++++++++ tests/testthat/test-moodlequiz-format.R | 3 +++ 2 files changed, 29 insertions(+) create mode 100644 tests/testthat/documents/quiz.Rmd create mode 100644 tests/testthat/test-moodlequiz-format.R diff --git a/tests/testthat/documents/quiz.Rmd b/tests/testthat/documents/quiz.Rmd new file mode 100644 index 0000000..9de446d --- /dev/null +++ b/tests/testthat/documents/quiz.Rmd @@ -0,0 +1,26 @@ +--- +output: moodlequiz::moodlequiz +title: Multi-question example +--- + +## Start + +```{r, include = FALSE} +library(moodlequiz) +``` + +What is 2 + 2? `r cloze(4)` + +What is 2 + 3? `r cloze(5)` + + +```{r} +hist(rnorm(100)) +``` + +What is the command for calculating the average? `r cloze("mean")` + +## Easy + +Lucky dip, pick a number on the dice! +`r cloze(sample(1:6, 1))` diff --git a/tests/testthat/test-moodlequiz-format.R b/tests/testthat/test-moodlequiz-format.R new file mode 100644 index 0000000..73998ba --- /dev/null +++ b/tests/testthat/test-moodlequiz-format.R @@ -0,0 +1,3 @@ +test_that("Moodlequiz format", { + expect_message(rmarkdown::render("documents/quiz.Rmd", output_file = quiz_xml <- tempfile()), "Output created") +})