diff --git a/tests/testthat/test-cronbachs_alpha.R b/tests/testthat/test-cronbachs_alpha.R index d7a34e6b4..fcc6e743d 100644 --- a/tests/testthat/test-cronbachs_alpha.R +++ b/tests/testthat/test-cronbachs_alpha.R @@ -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) @@ -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") @@ -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) })