-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added some tests #17
added some tests #17
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ Imports: | |
yaml | ||
Suggests: | ||
knitr, | ||
testthat | ||
testthat (>= 3.0.0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
Description: Setting layout through 'YAML' headers in 'R-Markdown' documents, | ||
enabling their automatic generation. | ||
Functions and methods may summarize 'R' objects in automatic reports, for | ||
|
@@ -39,3 +39,4 @@ Collate: | |
'render_rmd.R' | ||
'update.R' | ||
'write_rmd.R' | ||
Config/testthat/edition: 3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This file is part of the standard setup for testthat. | ||
# It is recommended that you do not modify it. | ||
# | ||
# Where should you do additional test configuration? | ||
# Learn more about the roles of various files in: | ||
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview | ||
# * https://testthat.r-lib.org/articles/special-files.html | ||
|
||
library(testthat) | ||
library(yamlme) | ||
|
||
test_check("yamlme") | ||
Comment on lines
+1
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
test_that("as works correctly", { | ||
example_doc <- list( | ||
title = "To yamlme, or not to yamlme", | ||
author = "John Doe", | ||
output = "html_document", | ||
body = txt_body( | ||
"# To yamlme, or not to yamlme. That is the question.", | ||
"* just a test" | ||
)) | ||
|
||
example_doc <- as(example_doc, "rmd_doc") | ||
expect_s3_class(example_doc, "rmd_doc") | ||
|
||
example_doc <- as(example_doc, "list") | ||
expect_s3_class(example_doc, "list") | ||
}) | ||
Comment on lines
+1
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
test_that("body can be set to NULL", { | ||
my_document <- read_rmd( | ||
file = file.path(path.package("yamlme"), "inst/taxlistjourney.Rmd"), | ||
skip_head = TRUE | ||
) | ||
|
||
my_document <- update(my_document, | ||
title = "A journey in rOpenSci", | ||
author = "Miguel Alvarez", | ||
output = "html_document" | ||
) | ||
|
||
# Set body to NULL explicitly | ||
my_document$body <- NULL | ||
|
||
# Check that the body is NULL | ||
expect_null(my_document$body) | ||
|
||
# Check that header elements are still present and unchanged | ||
expect_equal(my_document$header$title, "A journey in rOpenSci") | ||
expect_equal(my_document$header$author, "Miguel Alvarez") | ||
expect_equal(my_document$header$output, "html_document") | ||
}) | ||
Comment on lines
+1
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accepting suggested changes.