| 1 |
test_that("tbl_format_footer() results", { |
| 2 |
local_colors() |
| 3 |
|
| 4 |
expect_snapshot({ |
| 5 |
tbl_format_footer(tbl_format_setup(new_tbl(as.list(set_names(letters))), width = 80)) |
| 6 |
|
| 7 |
tbl_format_footer(tbl_format_setup(new_tbl(as.list(set_names(letters))), width = 30)) |
| 8 |
}) |
| 9 |
}) |
| 10 |
|
| 11 |
test_that("wrapping column names with spaces in the footer", { |
| 12 |
expect_snapshot({ |
| 13 |
tbl_format_footer(tbl_format_setup( |
| 14 |
new_tbl(list2(!!!set_names(letters), !!paste(letters, collapse = " ") := 2)), |
| 15 |
width = 70 |
| 16 |
)) |
| 17 |
}) |
| 18 |
}) |
| 19 |
|
| 20 |
test_that("overflow", { |
| 21 |
expect_snapshot({ |
| 22 |
tbl_format_footer(tbl_format_setup( |
| 23 |
new_tbl(list2(!!!set_names(rep(letters, 6)))), |
| 24 |
width = 70 |
| 25 |
)) |
| 26 |
}) |
| 27 |
}) |
| 28 |
|
| 29 |
test_that("max_footer_lines option", { |
| 30 |
new_footer_tbl <- function(prefix) { |
| 31 |
names <- outer(letters[1:2], letters, paste0) |
| 32 |
x <- setNames(as.list(seq_along(names)), paste0(prefix, names)) |
| 33 |
new_tbl(x) |
| 34 |
} |
| 35 |
|
| 36 |
expect_identical( |
| 37 |
local({ |
| 38 |
local_pillar_option_max_footer_lines(3) |
| 39 |
tbl_format_footer(tbl_format_setup(new_footer_tbl(""))) |
| 40 |
}), |
| 41 |
tbl_format_footer( |
| 42 |
tbl_format_setup(new_footer_tbl(""), max_footer_lines = 3) |
| 43 |
) |
| 44 |
) |
| 45 |
|
| 46 |
expect_snapshot({ |
| 47 |
tbl_format_footer( |
| 48 |
tbl_format_setup(new_footer_tbl("")) |
| 49 |
) |
| 50 |
tbl_format_footer( |
| 51 |
tbl_format_setup(new_footer_tbl("prefix_")) |
| 52 |
) |
| 53 |
tbl_format_footer( |
| 54 |
tbl_format_setup(new_footer_tbl("a_very_long_prefix_")) |
| 55 |
) |
| 56 |
|
| 57 |
tbl_format_footer( |
| 58 |
tbl_format_setup(new_footer_tbl(""), max_footer_lines = 3) |
| 59 |
) |
| 60 |
tbl_format_footer( |
| 61 |
tbl_format_setup(new_footer_tbl("prefix_"), max_footer_lines = 3) |
| 62 |
) |
| 63 |
tbl_format_footer( |
| 64 |
tbl_format_setup(new_footer_tbl("a_very_long_prefix_"), max_footer_lines = 3) |
| 65 |
) |
| 66 |
|
| 67 |
tbl_format_footer( |
| 68 |
tbl_format_setup(new_footer_tbl(""), max_footer_lines = Inf) |
| 69 |
) |
| 70 |
tbl_format_footer( |
| 71 |
tbl_format_setup(new_footer_tbl("prefix_"), max_footer_lines = Inf) |
| 72 |
) |
| 73 |
tbl_format_footer( |
| 74 |
tbl_format_setup(new_footer_tbl("a_very_long_prefix_"), max_footer_lines = Inf) |
| 75 |
) |
| 76 |
}) |
| 77 |
}) |
| 78 |
|
| 79 |
test_that("pillar.advice option (#575)", { |
| 80 |
local_options(pillar.advice = TRUE) |
| 81 |
expect_snapshot({ |
| 82 |
tbl_format_footer(tbl_format_setup(new_tbl(as.list(set_names(letters))), width = 80)) |
| 83 |
}) |
| 84 |
}) |
| 85 |
|
| 86 |
test_that("colnames() hint (#622)", { |
| 87 |
local_options(pillar.advice = TRUE) |
| 88 |
letters2 <- do.call(paste0, expand.grid(letters, letters)) |
| 89 |
expect_snapshot({ |
| 90 |
tbl_format_footer(tbl_format_setup(new_tbl(as.list(set_names(letters2))), width = 80)) |
| 91 |
}) |
| 92 |
}) |
| 93 |
|
| 94 |
test_that("advice when interactive (#575)", { |
| 95 |
local_interactive() |
| 96 |
expect_snapshot({ |
| 97 |
tbl_format_footer(tbl_format_setup(new_tbl(as.list(set_names(letters))), width = 80)) |
| 98 |
tbl_format_footer(tbl_format_setup(new_tbl(list(a = 1:30)), width = 80)) |
| 99 |
}) |
| 100 |
}) |