Skip to content

Commit 01fea1c

Browse files
committed
test: test module template output
1 parent 2043559 commit 01fea1c

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/testthat/test-module_template.R

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
test_that("Check module_template output", {
2+
tmp <- tempdir()
3+
4+
unlink(file.path(tmp, "test.R"))
5+
6+
module_template(
7+
name = "test",
8+
path = file.path(tmp, "test.R"),
9+
export = TRUE
10+
)
11+
12+
file_content <- readLines(file.path(tmp, "test.R"))
13+
14+
tags <- c(
15+
"@export",
16+
"@shinyModule",
17+
"@rdname mod_test"
18+
)
19+
20+
expect_true(
21+
sapply(
22+
tags,
23+
\(x) any(grepl(x, file_content))
24+
) |>
25+
all()
26+
)
27+
28+
unlink(file.path(tmp, "test.R"))
29+
30+
module_template(
31+
name = "test",
32+
path = file.path(tmp, "test.R"),
33+
export = FALSE
34+
)
35+
36+
file_content <- readLines(file.path(tmp, "test.R"))
37+
38+
tags <- c(
39+
"@noRd",
40+
"@shinyModule"
41+
)
42+
43+
expect_true(
44+
sapply(
45+
tags,
46+
\(x) any(grepl(x, file_content))
47+
) |>
48+
all()
49+
)
50+
})

0 commit comments

Comments
 (0)