File: test-ansi-palette.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 (48 lines) | stat: -rw-r--r-- 982 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
37
38
39
40
41
42
43
44
45
46
47
48

test_that("ansi_palette_show", {
  local_clean_cli_context()
  expect_snapshot(
    ansi_palette_show(colors = truecolor)
  )

  withr::local_options(cli.palette = "iterm-snazzy")
  expect_snapshot(
    ansi_palette_show(colors = truecolor)
  )
})

test_that("error", {
  expect_snapshot(
    error = TRUE,
    withr::with_options(
      list(cli.palette = "foobar12"),
      ansi_palette_show(colors = 256)
    )
  )
})

test_that("custom palettes", {
  withr::local_options(
    cli.num_colors = 256,
    cli.palette = "iterm-snazzy"
  )
  expect_snapshot({
    col_black("black")
    col_red("red")
    col_green("green")
    col_yellow("yellow")
    col_blue("blue")
    col_magenta("magenta")
    col_cyan("cyan")
    col_white("white")

    col_br_black("br_black")
    col_br_red("br_red")
    col_br_green("br_green")
    col_br_yellow("br_yellow")
    col_br_blue("br_blue")
    col_br_magenta("br_magenta")
    col_br_cyan("br_cyan")
    col_br_white("br_white")
  })
})