File: test-data_peek.R

package info (click to toggle)
r-cran-datawizard 1.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,300 kB
  • sloc: sh: 13; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 1,075 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
32
33
34
35
test_that("data_peek works as expected", {
  out <- data_peek(iris)
  expect_named(out, c("Variable", "Type", "Values"))
  expect_identical(
    out$Variable,
    c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species")
  )
  expect_identical(dim(out), c(5L, 3L))
})

test_that("data_peek works as expected with select", {
  out <- data_peek(iris, select = 2:4)
  expect_named(out, c("Variable", "Type", "Values"))
  expect_identical(
    out$Variable,
    c("Sepal.Width", "Petal.Length", "Petal.Width")
  )
  expect_identical(dim(out), c(3L, 3L))
})

test_that("data_peek works as expetced with custom width", {
  out <- data_peek(iris, width = 130)
  expect_named(out, c("Variable", "Type", "Values"))
  expect_identical(
    out$Variable,
    c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species")
  )
  expect_identical(dim(out), c(5L, 3L))
})

test_that("data_peek snapshots look as expected", {
  expect_snapshot(data_peek(iris))
  expect_snapshot(data_peek(iris, select = 1:3))
  expect_snapshot(data_peek(iris, width = 130))
})