Debian Codegraph @

tests/testthat/test-dplyr.R

raw
1 skimmed_iris <- skim(iris)
2
3 test_that("dplyr::filter works as expected", {
4 skip_if_not(l10n_info()$`UTF-8`)
5 withr::local_options(list(cli.unicode = FALSE))
6 expect_snapshot({
7 dplyr::filter(skimmed_iris, skim_type == "numeric")
8 # no rows
9 dplyr::filter(skimmed_iris, skim_type == "no_type")
10 })
11 })
12
13 test_that("dplyr::select works as expected", {
14 skip_if_not(l10n_info()$`UTF-8`)
15 withr::local_options(list(cli.unicode = FALSE))
16 with_type <- dplyr::select(skimmed_iris, skim_type, skim_variable)
17 expect_snapshot(with_type)
18 without_type <- dplyr::select(skimmed_iris, numeric.mean)
19 expect_snapshot(without_type)
20 })
21
22 test_that("dplyr::mutate works as expected", {
23 skip_if_not(l10n_info()$`UTF-8`)
24 withr::local_options(list(cli.unicode = FALSE))
25 input <- dplyr::mutate(skimmed_iris, mean2 = numeric.mean^2)
26 expect_snapshot(input)
27
28 no_variable <- dplyr::mutate(skimmed_iris, skim_variable = NULL)
29 identical(
30 capture.output(print(no_variable)),
31 capture.output(print(tibble::as_tibble(no_variable)))
32 )
33 })
34
35 test_that("dplyr::slice works as expected", {
36 skip_if_not(l10n_info()$`UTF-8`)
37 withr::local_options(list(cli.unicode = FALSE))
38 input <- dplyr::slice(skimmed_iris, 1:3)
39 expect_snapshot(input)
40 })
41
42 test_that("dplyr::arrange works as expected", {
43 skip_if_not(l10n_info()$`UTF-8`)
44 withr::local_options(list(cli.unicode = FALSE))
45 expect_snapshot(dplyr::arrange(skimmed_iris, desc(numeric.mean)))
46 })