Skip to content

Commit

Permalink
add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
maxheld83 committed Nov 20, 2024
1 parent 8672bfd commit e08966c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
12 changes: 12 additions & 0 deletions inst/examples/snaps2fig/multiple.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#' An example documentation with inserted snaps from multiple tags
#' @crowInsertSnaps
#' helpers
#' bins
#' FALSE
#' linux
#' @crowInsertSnaps
#' helpers
#' bins
#' FALSE
#' mac
bins_app <- function() examples_app()
17 changes: 14 additions & 3 deletions tests/testthat/_snaps/shiny2screenshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
# roxy_tag_crowInsertSnaps: can be parsed

Code
roxygen2::parse_text(example)[[1]]$tags
roxygen2::parse_text(single)[[1]]$tags
Output
[[1]]
[<text>: 1] @title 'An example documentation with inserted snaps' {parsed}
[<text>: 1] @title 'An example documentation with inserted snaps fr...' {parsed}
[[2]]
[<text>: 2] @crowInsertSnaps '...' {parsed}
Expand All @@ -58,13 +58,24 @@
[<text>: 7] @backref '<generated>' {parsed}

# roxy_tag_crowInsertSnaps: can be formatted
# roxy_tag_crowInsertSnaps: can be formatted with single tag

Code
topic$get_section("crowInsertSnaps")
Output
\section{Screenshots from Tests}{
\if{html}{\figure{crow_screenshots/helpers/bins.gif}{options: width='100\%' alt=Screenshot from App}}\if{latex}{Screenshots cannot be shown in this output format.}}

# roxy_tag_crowInsertSnaps: can be formatted with multiple tags joined

Code
topic$get_section("crowInsertSnaps")
Output
\section{Screenshots from Tests}{
\if{html}{\figure{crow_screenshots/helpers/bins.gif}{options: width='100\%' alt=Screenshot from App}}\if{latex}{Screenshots cannot be shown in this output format.}}
\section{Screenshots from Tests}{
\if{html}{\figure{crow_screenshots/helpers/bins.gif}{options: width='100\%' alt=Screenshot from App}}\if{latex}{Screenshots cannot be shown in this output format.}}

# snaps2fig and friends work: writes out markdown syntax
Expand Down
21 changes: 17 additions & 4 deletions tests/testthat/test-shiny2screenshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,33 @@ test_that("screenshots fail according to `strict` setting", {
})

describe("roxy_tag_crowInsertSnaps", {
example <- brio::read_file(
single <- brio::read_file(
fs::path_package(
package = "crow",
"examples", "snaps2fig", "single", ext = "R"
)
)
it(
"can be parsed",
expect_snapshot(roxygen2::parse_text(example)[[1]]$tags)
expect_snapshot(roxygen2::parse_text(single)[[1]]$tags)
)
it(
"can be formatted",
"can be formatted with single tag",
{
topic <- roxygen2::roc_proc_text(roxygen2::rd_roclet(), example)[[1]]
topic <- roxygen2::roc_proc_text(roxygen2::rd_roclet(), single)[[1]]
expect_snapshot(topic$get_section("crowInsertSnaps"))
}
)
multiple <- brio::read_file(
fs::path_package(
package = "crow",
"examples", "snaps2fig", "multiple", ext = "R"
)
)
it(
"can be formatted with multiple tags joined",
{
topic <- roxygen2::roc_proc_text(roxygen2::rd_roclet(), multiple)[[1]]
expect_snapshot(topic$get_section("crowInsertSnaps"))
}
)
Expand Down

0 comments on commit e08966c

Please sign in to comment.