Skip to content

Commit 2d488a5

Browse files
committed
Add test for ci
1 parent 9b4e7dd commit 2d488a5

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/testthat/test-preview.R

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
test_that("quarto_preview default functionality", {
2+
skip_if_no_quarto()
3+
skip_on_cran()
4+
5+
tmp_dir <- withr::local_tempdir()
6+
withr::local_dir(tmp_dir)
7+
xfun::write_utf8(c("---", "title: Test", "---", "", "# Hello"), "test.qmd")
8+
9+
expect_no_error({
10+
url <- withr::with_dir(tmp_dir, {
11+
quarto_preview("test.qmd", browse = FALSE, quiet = TRUE)
12+
})
13+
})
14+
15+
# Always clean up
16+
withr::defer(quarto_preview_stop())
17+
18+
if (exists("url")) {
19+
expect_true(grepl("^https?://", url))
20+
}
21+
})
22+
23+
test_that("quarto_preview can change port", {
24+
skip_if_no_quarto()
25+
skip_on_cran()
26+
27+
tmp_dir <- withr::local_tempdir()
28+
withr::local_dir(tmp_dir)
29+
xfun::write_utf8(c("---", "title: Test", "---", "", "# Hello"), "test.qmd")
30+
31+
expect_no_error({
32+
url <- withr::with_dir(tmp_dir, {
33+
quarto_preview("test.qmd", port = 8888, browse = FALSE, quiet = TRUE)
34+
})
35+
})
36+
37+
# Always clean up
38+
withr::defer(quarto_preview_stop())
39+
40+
if (exists("url")) {
41+
expect_true(grepl("^https?://", url))
42+
expect_true(grepl(":8888", url))
43+
}
44+
})

0 commit comments

Comments
 (0)