Skip to content

Commit

Permalink
add missing skips
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed May 11, 2024
1 parent 7616b1c commit 396dad7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/testthat/test-cronbachs_alpha.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
test_that("cronbachs_alpha, data frame", {
skip_if_not_installed("parameters")

data(mtcars)
x <- mtcars[, c("cyl", "gear", "carb", "hp")]
expect_equal(cronbachs_alpha(x), 0.09463206, tolerance = 1e-3)
Expand All @@ -9,6 +11,8 @@ test_that("cronbachs_alpha", {
})

test_that("cronbachs_alpha, principal_components", {
skip_if_not_installed("parameters")

pca <- parameters::principal_components(mtcars[, c("cyl", "gear", "carb", "hp")], n = 2)
expect_equal(cronbachs_alpha(pca, verbose = FALSE), c(PC1 = 0.1101384), tolerance = 1e-3)
expect_message(cronbachs_alpha(pca), regex = "Too few")
Expand All @@ -19,11 +23,15 @@ test_that("cronbachs_alpha, principal_components", {
})

test_that("cronbachs_alpha, principal_components", {
skip_if_not_installed("parameters")

pca <- parameters::principal_components(mtcars, n = 2)
expect_equal(cronbachs_alpha(pca), c(PC1 = 0.4396, PC2 = -1.44331), tolerance = 1e-3)
})

test_that("cronbachs_alpha, matrix", {
skip_if_not_installed("parameters")

m <- as.matrix(mtcars[c("cyl", "gear", "carb", "hp")])
expect_equal(cronbachs_alpha(m), 0.09463206, tolerance = 1e-3)
})

0 comments on commit 396dad7

Please sign in to comment.