Skip to content

Commit

Permalink
adding broom.mixed test
Browse files Browse the repository at this point in the history
  • Loading branch information
ddsjoberg committed Apr 29, 2024
1 parent 07689a2 commit 7c0bb41
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Suggests:
aod (>= 1.3.3),
broom (>= 1.0.5),
broom.helpers (>= 1.15.0),
broom.mixed (>= 0.2.9),
car (>= 3.0-11),
effectsize (>= 0.6.0),
emmeans (>= 1.7.3),
Expand Down
16 changes: 15 additions & 1 deletion tests/testthat/test-ard_regression.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
skip_if_not(do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom.helpers", reference_pkg = "cardx")))
skip_if_not(is_pkg_installed(pkg = "broom.helpers", reference_pkg = "cardx"))

test_that("ard_regression() works", {
expect_snapshot(
Expand All @@ -21,6 +21,20 @@ test_that("ard_regression() works", {
)
})

test_that("ard_regression() works specifying custom tidier", {
skip_if_not(is_pkg_installed(pkg = c("lme4", "broom.mixed"), reference_pkg = "cardx"))
expect_snapshot(
lme4::lmer(mpg ~ hp + (1 | cyl), data = mtcars) |>
ard_regression(tidy_fun = broom.mixed::tidy) |>
as.data.frame() |>
dplyr::select(-context, -stat_label, -fmt_fn) |>
dplyr::filter(map_lgl(stat, is.numeric)) |>
dplyr::mutate(
stat = lapply(stat, function(x) ifelse(is.numeric(x), cards::round5(x, 3), x))
)
)
})

test_that("ard_regression() does not produce `variable_level` column where not applicable", {
expect_true(!"variable_level" %in% names(lm(mpg ~ hp, mtcars) |> ard_regression()))
})

0 comments on commit 7c0bb41

Please sign in to comment.