Skip to content
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

Merged
merged 2 commits into from
Jun 25, 2024
Merged

added some tests #17

merged 2 commits into from
Jun 25, 2024

Conversation

lucazdev189
Copy link
Contributor

added some tests to this package cause why not

Copy link
Owner

@kamapu kamapu left a 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)
Copy link
Owner

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +1 to +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")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +1 to +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")
})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +1 to +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")
})
Copy link
Owner

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Owner

@kamapu kamapu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@kamapu kamapu merged commit a71cd03 into kamapu:main Jun 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants