Skip to content

Commit

Permalink
Merge pull request #663 from olivroy/partial-match
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi authored Dec 20, 2023
2 parents d1b5b8e + 299f12e commit dbb1b06
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion tests/testthat/test-collapsing.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ test_that("both-ends", {
})
})

test_that_cli(config = c("plain", "ansi"), "both-ends with formatting", {
test_that_cli(configs = c("plain", "ansi"), "both-ends with formatting", {
v <- function(n, t = 5) {
cli_vec(
seq_len(n),
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-diff.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test_that("format.cli_diff_chr context", {
expect_snapshot(print(d2, context = Inf))
})

test_that_cli(config = c("plain", "ansi"), "diff_str", {
test_that_cli(configs = c("plain", "ansi"), "diff_str", {
str1 <- "abcdefghijklmnopqrstuvwxyz"
str2 <- "PREabcdefgMIDDLEnopqrstuvwxyzPOST"
d <- diff_str(str1, str2)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-format-conditions.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test_that_cli("format_message", {
}))
})

test_that_cli(config = "ansi", "color in RStudio", {
test_that_cli(configs = "ansi", "color in RStudio", {
mockery::stub(
get_rstudio_fg_color0,
"rstudio_detect",
Expand Down Expand Up @@ -90,7 +90,7 @@ test_that_cli(config = "ansi", "color in RStudio", {
expect_null(get_rstudio_fg_color0())
})

test_that_cli(config = "ansi", "update_rstudio_color", {
test_that_cli(configs = "ansi", "update_rstudio_color", {
mockery::stub(
update_rstudio_color,
"get_rstudio_fg_color",
Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test-inline-2.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test_that_cli(
}
)

test_that_cli(config = c("plain", "ansi"), "quoting weird names, still", {
test_that_cli(configs = c("plain", "ansi"), "quoting weird names, still", {
nb <- function(x) gsub("\u00a0", " ", x, fixed = TRUE)
expect_snapshot(local({
cat_line(nb(quote_weird_name("good")))
Expand All @@ -28,7 +28,7 @@ test_that_cli(config = c("plain", "ansi"), "quoting weird names, still", {
}))
})

test_that_cli(config = c("ansi"), "~/ files are not weird", {
test_that_cli(configs = c("ansi"), "~/ files are not weird", {
nb <- function(x) gsub("\u00a0", " ", x, fixed = TRUE)
expect_snapshot(local({
cat_line(nb(quote_weird_name("~/good")))
Expand Down Expand Up @@ -106,7 +106,7 @@ test_that("line breaks", {
expect_snapshot(ansi_strwrap(txt2, width = 60))
})

test_that_cli(config = "ansi", "double ticks", {
test_that_cli(configs = "ansi", "double ticks", {
x <- c("a", "`x`", "b")
cli_div(theme = list(
.code = list(color = "red"),
Expand All @@ -127,13 +127,13 @@ test_that("do not inherit 'transform' issue #422", {
})
})

test_that_cli(config = c("ansi", "plain"), "no inherit color, issue #474", {
test_that_cli(configs = c("ansi", "plain"), "no inherit color, issue #474", {
expect_snapshot({
cli::cli_text("pre {.val x {'foo'} y} post")
})
})

test_that_cli(config = c("ansi", "plain"), "\\f at the end, issue #491", {
test_that_cli(configs = c("ansi", "plain"), "\\f at the end, issue #491", {
expect_snapshot({
cli_fmt(cli::cli_text("{.val a}{.val b}"))
cli_fmt(cli::cli_text("\f{.val a}{.val b}"))
Expand All @@ -152,7 +152,7 @@ test_that("truncate vectors at 20", {
)
})

test_that_cli(config = "ansi", "brace expresssion edge cases", {
test_that_cli(configs = "ansi", "brace expresssion edge cases", {
foo <- "foo"
bar <- "bar"
expect_snapshot({
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-inline.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ withr::local_options(cli.theme = NULL, cli.user_theme = NULL)
start_app()
on.exit(stop_app(), add = TRUE)

test_that_cli(config = c("plain", "ansi"), "inline classes", {
test_that_cli(configs = c("plain", "ansi"), "inline classes", {
classes <- c(
"emph", "strong", "code", "pkg", "fun", "arg", "key", "file", "path",
"email", "url", "var", "envvar", "cls")
Expand Down
30 changes: 15 additions & 15 deletions tests/testthat/test-links.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

# -- {.email} -------------------------------------------------------------

test_that_cli(config = c("plain", "fancy"), links = c("all", "none"),
test_that_cli(configs = c("plain", "fancy"), links = c("all", "none"),
"{.email}", {

expect_snapshot({
cli_text("{.email [email protected]}")
})
})

test_that_cli(config = c("plain", "fancy"), links = c("all", "none"),
test_that_cli(configs = c("plain", "fancy"), links = c("all", "none"),
"{.email} vectors", {

expect_snapshot({
Expand All @@ -20,7 +20,7 @@ test_that_cli(config = c("plain", "fancy"), links = c("all", "none"),

# -- {.file} and {.path} --------------------------------------------------

test_that_cli(config = c("plain", "fancy"), links = c("all", "none"),
test_that_cli(configs = c("plain", "fancy"), links = c("all", "none"),
"{.file} and {.path}", {

withr::local_envvar(R_CLI_HYPERLINK_STYLE = NA_character_)
Expand Down Expand Up @@ -114,7 +114,7 @@ test_that_cli(config = c("plain", "fancy"), links = c("all", "none"),

# -- {.fun} ---------------------------------------------------------------

test_that_cli(config = "plain", links = c("all", "none"),
test_that_cli(configs = "plain", links = c("all", "none"),
"{.fun}", {

expect_snapshot({
Expand All @@ -128,7 +128,7 @@ test_that_cli(config = "plain", links = c("all", "none"),
})
})

test_that_cli(config = "plain", links = "all", "turning off help", {
test_that_cli(configs = "plain", links = "all", "turning off help", {
withr::local_options(cli.hyperlink_help = FALSE)
expect_snapshot({
cli_text("{.fun pkg::func}")
Expand All @@ -137,7 +137,7 @@ test_that_cli(config = "plain", links = "all", "turning off help", {

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

test_that_cli(config = "plain", links = c("all", "none"),
test_that_cli(configs = "plain", links = c("all", "none"),
"{.help}", {

expect_snapshot({
Expand All @@ -153,7 +153,7 @@ test_that_cli(config = "plain", links = c("all", "none"),

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

test_that_cli(config = "plain", links = c("all", "none"),
test_that_cli(configs = "plain", links = c("all", "none"),
"{.href}", {
expect_snapshot({
cli_text("{.href https://cli.r-lib.org}")
Expand All @@ -162,7 +162,7 @@ test_that_cli(config = "plain", links = c("all", "none"),
})
})

test_that_cli(config = "plain", links = c("all", "none"),
test_that_cli(configs = "plain", links = c("all", "none"),
"{.href} vectors", {
expect_snapshot({
url <- paste0("https://cli.r-lib.org/", 1:3)
Expand All @@ -172,15 +172,15 @@ test_that_cli(config = "plain", links = c("all", "none"),

# -- {.run} ---------------------------------------------------------------

test_that_cli(config = "plain", links = c("all", "none"),
test_that_cli(configs = "plain", links = c("all", "none"),
"{.run}", {
expect_snapshot({
cli_text("{.run pkg::fun(param)}")
cli_text("{.run [run(p1, p2)](pkg::fun(p1, p2, other = 'foo'))}")
})
})

test_that_cli(config = "plain", links = c("all", "none"),
test_that_cli(configs = "plain", links = c("all", "none"),
"{.run} vectors", {
expect_snapshot({
codes <- paste0("pkg::fun", 1:3, "()")
Expand All @@ -190,7 +190,7 @@ test_that_cli(config = "plain", links = c("all", "none"),

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

test_that_cli(config = "plain", links = c("all", "none"),
test_that_cli(configs = "plain", links = c("all", "none"),
"{.topic}", {

expect_snapshot({
Expand All @@ -206,22 +206,22 @@ test_that_cli(config = "plain", links = c("all", "none"),

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

test_that_cli(config = c("plain", "fancy"), links = c("all", "none"),
test_that_cli(configs = c("plain", "fancy"), links = c("all", "none"),
"{.url}", {
expect_snapshot({
cli_text("{.url https://cli.r-lib.org}")
})
})

test_that_cli(config = c("plain", "fancy"), links = c("all", "none"),
test_that_cli(configs = c("plain", "fancy"), links = c("all", "none"),
"{.url} vector", {
expect_snapshot({
urls <- paste0("https://cli.r-lib.org/", 1:3)
cli_text("{.url {urls}}")
})
})

test_that_cli(config = "plain", links = "all", "linked {.url}", {
test_that_cli(configs = "plain", links = "all", "linked {.url}", {
expect_snapshot({
link <- c(
"https://cli.r-lib.org",
Expand All @@ -239,7 +239,7 @@ test_that("make_link_url", {

# -- {.vignette} ----------------------------------------------------------

test_that_cli(config = "plain", links = c("all", "none"),
test_that_cli(configs = "plain", links = c("all", "none"),
"{.vignette}", {

expect_snapshot({
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-rlang-errors.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ test_that("cli_abort width in RStudio", {
}))
})

test_that_cli(config = "ansi", "color in RStudio", {
test_that_cli(configs = "ansi", "color in RStudio", {
mockery::stub(
get_rstudio_fg_color0,
"rstudio_detect",
Expand Down Expand Up @@ -123,7 +123,7 @@ test_that_cli(config = "ansi", "color in RStudio", {
expect_null(get_rstudio_fg_color0())
})

test_that_cli(config = "ansi", "update_rstudio_color", {
test_that_cli(configs = "ansi", "update_rstudio_color", {
mockery::stub(
update_rstudio_color,
"get_rstudio_fg_color",
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-vt.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test_that("scroll up", {
)
})

test_that_cli(config = "ansi", "ANSI SGR", {
test_that_cli(configs = "ansi", "ANSI SGR", {
expect_snapshot(
vt_output("12\033[31m34\033[1m56\033[39m78\033[21m90", width = 20, height = 2)
)
Expand Down

0 comments on commit dbb1b06

Please sign in to comment.