Skip to content

Commit

Permalink
add snapshot test
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Apr 3, 2024
1 parent 9e3f13d commit 4974a45
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/testthat/_snaps/public_api-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,38 @@
----------------------------------------
Please review the changes carefully!

# messages have the correct width

Code
styled <- style_pkg(testthat_file("public-api", "xyzpackage"))
Output
Styling 3 files:
R/hello-world.R v
tests/testthat.R v
tests/testthat/test-package-xyz.R v
----------------------------------------
Status Count Legend
v 3 File unchanged.
i 0 File changed.
x 0 Styling threw an error.
----------------------------------------

---

Code
styled <- style_pkg(
testthat_file(
"public-api",
"xyzpackage"))
Output
Styling 3 files:
R/hello-world.R v
tests/testthat.R v
tests/testthat/test-package-xyz.R v
----------------------------------------
Status Count Legend
v 3 File unchanged.
i 0 File changed.
x 0 Styling threw an error.
----------------------------------------

10 changes: 10 additions & 0 deletions tests/testthat/test-public_api-1.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ test_that("messages (via cat()) of style_file are correct", {
}
})

test_that("messages have the correct width", {
expect_snapshot(
styled <- style_pkg(testthat_file("public-api", "xyzpackage"))
)
withr::local_options(width = 24)
expect_snapshot({
styled <- style_pkg(testthat_file("public-api", "xyzpackage"))
})
})

test_that("Messages can be suppressed", {
withr::with_options(
list(styler.quiet = TRUE),
Expand Down

0 comments on commit 4974a45

Please # to comment.