From 3818ada888c848a5dc9971170547b3354f4cc0a8 Mon Sep 17 00:00:00 2001 From: Jenny Bryan Date: Wed, 6 Nov 2024 16:13:29 -0800 Subject: [PATCH] Test custom formats are used --- tests/testthat/_snaps/links.md | 35 ++++++++++++++++++++++++++++++++++ tests/testthat/test-links.R | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/tests/testthat/_snaps/links.md b/tests/testthat/_snaps/links.md index 65d8d8425..e42524e30 100644 --- a/tests/testthat/_snaps/links.md +++ b/tests/testthat/_snaps/links.md @@ -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 @@ -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 @@ -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 @@ -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 @@ -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;; + diff --git a/tests/testthat/test-links.R b/tests/testthat/test-links.R index 3b52fb26a..aec64cace 100644 --- a/tests/testthat/test-links.R +++ b/tests/testthat/test-links.R @@ -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"), @@ -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"), @@ -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"), @@ -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"), @@ -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}") + }) +})