File: test-skim_tee.R

package info (click to toggle)
r-cran-skimr 2.1.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,188 kB
  • sloc: sh: 13; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 1,158 bytes parent folder | download
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
test_that("Using skim_tee prints returns the object", {
  skip_if_not(l10n_info()$`UTF-8`)
  input <- testthat::capture_output(skim_object <- skim_tee(chickwts))
  expect_matches_file(input, "skim_tee/skim_tee.txt")
  expect_identical(chickwts, skim_object)
})

test_that("skim_tee prints only selected columns, but returns full object", {
  skip_if_not(l10n_info()$`UTF-8`)
  input <- testthat::capture_output(obj <- skim_tee(iris, Species))
  expect_matches_file(input, "skim_tee/species.txt")
  expect_identical(obj, iris)
})

test_that("skim_tee supports dplyr helpers", {
  skip_if_not(l10n_info()$`UTF-8`)
  input <- testthat::capture_output(obj <- skim_tee(iris, starts_with("Sepal")))
  expect_matches_file(input, "skim_tee/sepal.txt")
  expect_identical(obj, iris)
})

test_that("Skim_tee works with groups", {
  skip_if_not(l10n_info()$`UTF-8`)
  iris_grouped <- dplyr::group_by(iris, Species)
  my_skim <- skim_with(numeric = sfl(hist = NULL))
  input <- testthat::capture_output(
    obj <- skim_tee(iris_grouped, Sepal.Length, skim_fun = my_skim)
  )
  expect_matches_file(input, "skim_tee/grouped.txt")
  expect_identical(obj, iris_grouped)
})