-
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
Conversation
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.
Perfect!
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Accepting suggested changes.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# 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") |
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.
👍
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") | ||
}) |
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.
👍
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") | ||
}) |
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.
👍
@@ -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 comment
The 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.
👍
added some tests to this package cause why not