tests/testthat/test-pivot.R

test_that("basic sanity checks for spec occur", {
  expect_snapshot({
    (expect_error(check_pivot_spec(1)))
    (expect_error(check_pivot_spec(mtcars)))
  })
})

test_that("`.name` column must be a character vector", {
  df <- tibble(.name = 1:2, .value = c("a", "b"))
  expect_snapshot((expect_error(check_pivot_spec(df))))
})

test_that("`.value` column must be a character vector", {
  df <- tibble(.name = c("x", "y"), .value = 1:2)
  expect_snapshot((expect_error(check_pivot_spec(df))))
})

test_that("`.name` column must be unique", {
  df <- tibble(.name = c("x", "x"), .value = c("a", "b"))
  expect_snapshot((expect_error(check_pivot_spec(df))))
})
hadley/tidyr documentation built on Feb. 3, 2024, 10:45 a.m.