| 1 |
test_that("Skim prints a header for the entire output and each type", { |
| 2 |
withr::local_options(list(cli.unicode = FALSE)) |
| 3 |
skip_if_not(l10n_info()$`UTF-8`) |
| 4 |
expect_snapshot({ |
| 5 |
input <- skim(iris) |
| 6 |
input |
| 7 |
input$numeric.hist <- NULL |
| 8 |
input |
| 9 |
}) |
| 10 |
}) |
| 11 |
|
| 12 |
test_that("Skim prints a special header for grouped data frames", { |
| 13 |
skip_if_not(l10n_info()$`UTF-8`) |
| 14 |
skip_on_os("mac") |
| 15 |
withr::local_options(list(cli.unicode = FALSE)) |
| 16 |
expect_snapshot( skim(dplyr::group_by(iris, Species))) |
| 17 |
}) |
| 18 |
|
| 19 |
test_that("Skim lists print as expected", { |
| 20 |
skip_if_not(l10n_info()$`UTF-8`) |
| 21 |
withr::local_options(list(cli.unicode = FALSE)) |
| 22 |
skimmed <- skim(iris) |
| 23 |
expect_snapshot(partition(skimmed)) |
| 24 |
}) |
| 25 |
|
| 26 |
test_that("knit_print produces expected results", { |
| 27 |
skip_if_not(l10n_info()$`UTF-8`) |
| 28 |
withr::local_options(list(cli.unicode = FALSE)) |
| 29 |
skimmed <- skim(iris) |
| 30 |
input <- knit_print(skimmed) |
| 31 |
expect_s3_class(input, "knit_asis") |
| 32 |
expect_length(input, 1) |
| 33 |
expect_snapshot(cat(input)) |
| 34 |
}) |
| 35 |
|
| 36 |
test_that("knit_print works with skim summaries", { |
| 37 |
withr::local_options(list(cli.unicode = FALSE)) |
| 38 |
skimmed <- skim(iris) |
| 39 |
summarized <- summary(skimmed) |
| 40 |
expect_snapshot(cat(knitr::knit_print(summarized))) |
| 41 |
}) |
| 42 |
|
| 43 |
test_that("knit_print appropriately falls back to tibble printing", { |
| 44 |
withr::local_options(list(cli.unicode = FALSE)) |
| 45 |
skimmed <- skim(iris) |
| 46 |
reduced <- dplyr::select(skimmed, skim_variable, numeric.mean) |
| 47 |
expect_snapshot({ |
| 48 |
input <- knitr::knit_print(reduced) |
| 49 |
}) |
| 50 |
expect_s3_class(input, "data.frame") |
| 51 |
}) |
| 52 |
|
| 53 |
test_that("Summaries can be suppressed within knitr", { |
| 54 |
skip_if_not(l10n_info()$`UTF-8`) |
| 55 |
withr::local_options(list(cli.unicode = FALSE)) |
| 56 |
skimmed <- skim(iris) |
| 57 |
options <- list(skimr_include_summary = FALSE) |
| 58 |
expect_snapshot(cat(knitr::knit_print(skimmed, options = options))) |
| 59 |
}) |
| 60 |
|
| 61 |
test_that("Skim lists have a separate knit_print method", { |
| 62 |
skip_if_not(l10n_info()$`UTF-8`) |
| 63 |
withr::local_options(list(cli.unicode = FALSE)) |
| 64 |
skimmed <- skim(iris) |
| 65 |
skim_list <- partition(skimmed) |
| 66 |
expect_snapshot(cat(knit_print(skim_list))) |
| 67 |
}) |
| 68 |
|
| 69 |
test_that("You can yank a type from a skim_df and call knit_print", { |
| 70 |
withr::local_options(list(cli.unicode = FALSE)) |
| 71 |
skimmed <- skim(iris) |
| 72 |
skim_one <- yank(skimmed, "factor") |
| 73 |
expect_snapshot(cat(knit_print(skim_one))) |
| 74 |
}) |
| 75 |
|
| 76 |
test_that("Skim falls back to tibble::print.tbl() appropriately", { |
| 77 |
withr::local_options(list(cli.unicode = FALSE)) |
| 78 |
|
| 79 |
expect_snapshot({ |
| 80 |
input <- skim(iris) |
| 81 |
dplyr::select(input, numeric.mean) |
| 82 |
}) |
| 83 |
}) |
| 84 |
|
| 85 |
test_that("Print focused objects appropriately", { |
| 86 |
withr::local_options(list(cli.unicode = FALSE)) |
| 87 |
skip_if_not(l10n_info()$`UTF-8`) |
| 88 |
skimmed <- skim(iris) |
| 89 |
expect_snapshot(focus(skimmed, n_missing)) |
| 90 |
}) |
| 91 |
|
| 92 |
test_that("Support for smaller consoles can be set with the width option", { |
| 93 |
withr::local_options(list(cli.unicode = FALSE)) |
| 94 |
skip_if_not(l10n_info()$`UTF-8`) |
| 95 |
expect_snapshot(skim(iris)) |
| 96 |
}) |
| 97 |
|
| 98 |
test_that("Table header width can be controlled by an option", { |
| 99 |
withr::local_options(list(cli.unicode = FALSE)) |
| 100 |
skip_if_not(l10n_info()$`UTF-8`) |
| 101 |
skimmed <- skim(iris) |
| 102 |
expect_snapshot(skimmed) |
| 103 |
}) |
| 104 |
|
| 105 |
test_that("skimr creates appropriate output for Jupyter", { |
| 106 |
withr::local_options(list(cli.unicode = FALSE)) |
| 107 |
skip_if_not(l10n_info()$`UTF-8`) |
| 108 |
skimmed <- skim(iris) |
| 109 |
expect_snapshot(skimmed) |
| 110 |
}) |