File: test-ansi-combine.R

package info (click to toggle)
r-cran-cli 3.6.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,288 kB
  • sloc: ansic: 16,412; cpp: 37; sh: 13; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 1,000 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

test_that("one style", {
  testthat::skip_on_covr() # because we are comparing functions
  expect_equal(
    combine_ansi_styles(col_red),
    col_red,
    ignore_function_env = TRUE
  )
  expect_equal(
    combine_ansi_styles(style_bold),
    style_bold,
    ignore_function_env = TRUE
  )
})

test_that_cli(configs = c("plain", "ansi"), "style objects", {
  expect_equal(
    combine_ansi_styles(col_red, style_bold)("blah"),
    col_red(style_bold("blah"))
  )
  expect_equal(
    combine_ansi_styles(col_red, style_bold, style_underline)("foo"),
    col_red(style_bold(style_underline("foo")))
  )
})

test_that_cli(configs = c("plain", "ansi"), "create styles on the fly", {
  expect_equal(
    combine_ansi_styles("darkolivegreen", style_bold)("blah"),
    make_ansi_style("darkolivegreen")((style_bold("blah")))
  )
  expect_equal(
    combine_ansi_styles(style_bold, "darkolivegreen", style_underline)("foo"),
    style_bold(make_ansi_style("darkolivegreen")(style_underline("foo")))
  )
})