-
Notifications
You must be signed in to change notification settings - Fork 131
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
Theme element unit tests #2081
Theme element unit tests #2081
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.
Thank you @Meghansaha for the PR!!! I left a few comments to address.
# This only works when a theme is set explicitly | ||
# And not when it is just temporarily set with 'with_gtsummary_theme' | ||
# Is this intentional behavior? | ||
expect_true(grepl("|:-", gts_4) |> any()) |
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 may be easier to read as a snapshot test
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.
Now that I'm understanding the print engine thing a bit better, I reverted back to the original test I tried to do when I first started. I can change it to a snapshot if you'd prefer that?
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.
addressed your comments. Let me know if something's not right, or if I missed anything!
test_that("pkgwide-str:language works", { | ||
|
||
# Test that the CI has the correct pattern somewhere# | ||
expect_snapshot( |
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.
Was trying to test that translated columns names were returned. Not sure why I did this either, so changed it!
# This only works when a theme is set explicitly | ||
# And not when it is just temporarily set with 'with_gtsummary_theme' | ||
# Is this intentional behavior? | ||
expect_true(grepl("|:-", gts_4) |> any()) |
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.
Now that I'm understanding the print engine thing a bit better, I reverted back to the original test I tried to do when I first started. I can change it to a snapshot if you'd prefer that?
## pkgwide-lgl:quiet------------------------------------------------------------ | ||
test_that("pkgwide-lgl:quiet works", { | ||
|
||
# Test that the lgl value can be found# | ||
expect_silent( | ||
with_gtsummary_theme( | ||
x = my_theme_2, | ||
expr = get_theme_element("pkgwide-lgl:quiet") | ||
) | ||
) | ||
} | ||
) |
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.
These quiet arguments have been deprecated, so I am going to go ahead and delete this section. Sorry!
Thanks @Meghansaha for the contribution!! I did a little cleaning up, ie one testthat chunk per theme element that we're testing, within that chunk adding a test for every place that theme element is used in the package (this actually found a mistake where it wasn't being applied 😱 ). I did delete a couple of tests that would have taken me too long to comprehensively test, but we can add those back in other PRs. Thanks again! |
What changes are proposed in this pull request?
Added unit test coverage for pkgwide theme elements
If there is an GitHub issue associated with this pull request, please provide link.
#1959
Reviewer Checklist (if item does not apply, mark is as complete)
pkgdown::build_site()
. Check the R console for errors, and review the rendered website.devtools::test_coverage()
usethis::use_spell_check()
runs with no spelling errors in documentationWhen the branch is ready to be merged into master:
NEWS.md
with the changes from this pull request under the heading "# gtsummary (development version)
". If there is an issue associated with the pull request, reference it in parentheses at the end update (seeNEWS.md
for examples).usethis::use_version(which = "dev")
usethis::use_spell_check()
again