Skip to content

Commit

Permalink
Test custom formats are used
Browse files Browse the repository at this point in the history
  • Loading branch information
jennybc committed Nov 7, 2024
1 parent 5d1f44c commit 3818ada
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/testthat/_snaps/links.md
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,13 @@
Message
`pkg::func()`

# .fun with custom format [plain-all]

Code
cli_text("{.fun pkg::func}")
Message
`]8;;aaa-pkg::func-zzzpkg::func]8;;()`

# {.help} [plain-none]

Code
Expand Down Expand Up @@ -857,6 +864,13 @@
Message
]8;;x-r-help:pkg::fun1pkg::fun1]8;;, ]8;;x-r-help:pkg::fun2pkg::fun2]8;;, and ]8;;x-r-help:pkg::fun3pkg::fun3]8;;

# .help with custom format [plain-all]

Code
cli_text("{.help pkg::fun}")
Message
]8;;aaa-pkg::fun-zzzpkg::fun]8;;

# {.href} [plain-none]

Code
Expand Down Expand Up @@ -943,6 +957,13 @@
Message
]8;;x-r-run:pkg::fun1()pkg::fun1()]8;;, ]8;;x-r-run:pkg::fun2()pkg::fun2()]8;;, and ]8;;x-r-run:pkg::fun3()pkg::fun3()]8;;

# .run with custom format [plain-all]

Code
cli_text("{.run devtools::document()}")
Message
]8;;aaa-devtools::document()-zzzdevtools::document()]8;;

# {.topic} [plain-none]

Code
Expand Down Expand Up @@ -981,6 +1002,13 @@
Message
]8;;x-r-help:pkg::topic1pkg::topic1]8;;, ]8;;x-r-help:pkg::topic2pkg::topic2]8;;, and ]8;;x-r-help:pkg::topic3pkg::topic3]8;;

# .topic with custom format [plain-all]

Code
cli_text("{.topic pkg::fun}")
Message
]8;;aaa-pkg::fun-zzzpkg::fun]8;;

# {.url} [plain-none]

Code
Expand Down Expand Up @@ -1092,3 +1120,10 @@
Message
]8;;x-r-vignette:pkg::topic1pkg::topic1]8;;, ]8;;x-r-vignette:pkg::topic2pkg::topic2]8;;, and ]8;;x-r-vignette:pkg::topic3pkg::topic3]8;;

# .vignette with custom format [plain-all]

Code
cli_text("{.vignette pkgdown::accessibility}")
Message
]8;;aaa-pkgdown::accessibility-zzzpkgdown::accessibility]8;;

35 changes: 35 additions & 0 deletions tests/testthat/test-links.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ test_that_cli(configs = "plain", links = "all", "turning off help", {
})
})

test_that_cli(configs = "plain", links = "all", ".fun with custom format", {
withr::local_options(cli.hyperlink_help_url_format = "aaa-{topic}-zzz")
expect_snapshot({
cli_text("{.fun pkg::func}")
})
})

# -- {.help} --------------------------------------------------------------

test_that_cli(configs = "plain", links = c("all", "none"),
Expand All @@ -151,6 +158,13 @@ test_that_cli(configs = "plain", links = c("all", "none"),
})
})

test_that_cli(configs = "plain", links = "all", ".help with custom format", {
withr::local_options(cli.hyperlink_help_url_format = "aaa-{topic}-zzz")
expect_snapshot({
cli_text("{.help pkg::fun}")
})
})

# -- {.href} --------------------------------------------------------------

test_that_cli(configs = "plain", links = c("all", "none"),
Expand Down Expand Up @@ -188,6 +202,13 @@ test_that_cli(configs = "plain", links = c("all", "none"),
})
})

test_that_cli(configs = "plain", links = "all", ".run with custom format", {
withr::local_options(cli.hyperlink_run_url_format = "aaa-{code}-zzz")
expect_snapshot({
cli_text("{.run devtools::document()}")
})
})

# -- {.topic} -------------------------------------------------------------

test_that_cli(configs = "plain", links = c("all", "none"),
Expand All @@ -204,6 +225,13 @@ test_that_cli(configs = "plain", links = c("all", "none"),
})
})

test_that_cli(configs = "plain", links = "all", ".topic with custom format", {
withr::local_options(cli.hyperlink_help_url_format = "aaa-{topic}-zzz")
expect_snapshot({
cli_text("{.topic pkg::fun}")
})
})

# -- {.url} ---------------------------------------------------------------

test_that_cli(configs = c("plain", "fancy"), links = c("all", "none"),
Expand Down Expand Up @@ -252,3 +280,10 @@ test_that_cli(configs = "plain", links = c("all", "none"),
cli_text("{.vignette {vignettes}}")
})
})

test_that_cli(configs = "plain", links = "all", ".vignette with custom format", {
withr::local_options(cli.hyperlink_vignette_url_format = "aaa-{vignette}-zzz")
expect_snapshot({
cli_text("{.vignette pkgdown::accessibility}")
})
})

0 comments on commit 3818ada

Please sign in to comment.