Skip to content

Commit 7cbf067

Browse files
Copilotrempsyc
andcommitted
Revert nice_modindices function to original state and add skip checks to tests
Co-authored-by: rempsyc <[email protected]>
1 parent f61e308 commit 7cbf067

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

R/nice_modindices.R

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,11 @@ nice_modindices <- function(fit,
6666
rownames(x) <- NULL
6767

6868
if (is.null(labels)) {
69-
if (requireNamespace("sjlabelled", quietly = TRUE)) {
70-
dat <- insight::get_data(fit)
71-
labels <- sjlabelled::get_label(dat)
72-
if (all(labels == "")) {
73-
labels <- NULL
74-
}
69+
insight::check_if_installed("sjlabelled")
70+
dat <- insight::get_data(fit)
71+
labels <- sjlabelled::get_label(dat)
72+
if (all(labels == "")) {
73+
labels <- NULL
7574
}
7675
}
7776
if (!is.null(labels)) {

tests/testthat/test-nice_modindices.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ test_that("nice_modindices auto-labels", {
6767
# Additional tests to improve coverage
6868

6969
test_that("nice_modindices without labels", {
70+
skip_if_not_installed("sjlabelled")
7071
# Test the path when no labels are available
7172
result <- nice_modindices(fit, maximum.number = 5)
7273
expect_s3_class(result, "data.frame")
@@ -75,6 +76,7 @@ test_that("nice_modindices without labels", {
7576
})
7677

7778
test_that("nice_modindices with sort = FALSE", {
79+
skip_if_not_installed("sjlabelled")
7880
# Test the sort parameter
7981
result <- nice_modindices(fit, sort = FALSE, maximum.number = 5)
8082
expect_s3_class(result, "data.frame")
@@ -142,6 +144,7 @@ test_that("nice_modindices with no matching labels", {
142144
})
143145

144146
test_that("nice_modindices with additional lavaan parameters", {
147+
skip_if_not_installed("sjlabelled")
145148
# Test passing additional parameters to lavaan::modindices
146149
result <- nice_modindices(fit, minimum.value = 1, maximum.number = 3)
147150
expect_s3_class(result, "data.frame")

0 commit comments

Comments
 (0)