Debian Codegraph @

tests/testthat/test-summary.R

raw
1 test_that("Summary creates the correct summary object", {
2 withr::local_options(list(cli.unicode = FALSE))
3 # Test it creates the correct 4 parts
4 skim_input <- skim(iris)
5 summary_input <- summary(skim_input)
6 expect_named(
7 summary_input,
8 c(
9 "data_name", "counts", "types", "possible_groups",
10 "dt_key", "data_rows", "data_cols"
11 )
12 )
13 expect_identical(summary_input$data_name, "iris")
14 expect_identical(summary_input$types, c("factor", "numeric"))
15 expect_identical(summary_input$data_rows, 150L)
16 expect_identical(summary_input$data_cols, 5L)
17 })
18
19 test_that("The summary print method prints the correct object", {
20 skip_if_not(l10n_info()$`UTF-8`)
21 withr::local_options(list(cli.unicode = FALSE))
22 skim_summary_input <- summary(skim(iris))
23 expect_snapshot(skim_summary_input)
24 })
25
26 test_that("The summary print method prints the correct object when piped", {
27 skip_if_not(l10n_info()$`UTF-8`)
28 withr::local_options(list(cli.unicode = FALSE))
29 # Test that the correct lines are output, no name should be output.
30 summary_input <- iris |>
31 skim() |>
32 summary()
33 expect_snapshot(summary_input)
34 })
35
36 test_that("null object gets expected message", {
37 input <- NULL
38 expect_error(summary.skim_df(input), "dataframe is null.")
39 })