From 4974a4560009a219ea6dad46be23120f9bd9f21a Mon Sep 17 00:00:00 2001 From: Olivier Roy Date: Wed, 3 Apr 2024 09:06:11 -0400 Subject: [PATCH] add snapshot test --- tests/testthat/_snaps/public_api-1.md | 35 +++++++++++++++++++++++++++ tests/testthat/test-public_api-1.R | 10 ++++++++ 2 files changed, 45 insertions(+) diff --git a/tests/testthat/_snaps/public_api-1.md b/tests/testthat/_snaps/public_api-1.md index da7b965ef..93d3351d9 100644 --- a/tests/testthat/_snaps/public_api-1.md +++ b/tests/testthat/_snaps/public_api-1.md @@ -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. + ---------------------------------------- + diff --git a/tests/testthat/test-public_api-1.R b/tests/testthat/test-public_api-1.R index e7297d2dd..1c2e90403 100644 --- a/tests/testthat/test-public_api-1.R +++ b/tests/testthat/test-public_api-1.R @@ -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),