tests/testthat/test-extract_models.R

test_that("extract_model throws an error when `step` = NULL", {
  data(ho_et_al)

  ho_et_al$condition_c <- build_contrast(ho_et_al$condition,
                                         "Low discrimination",
                                         "High discrimination")
  model <- mdt_simple(data = ho_et_al,
                      IV   = condition_c,
                      DV   = hypodescent,
                      M    = linkedfate)

  expect_error(extract_model(model))
})

test_that("extract_model does not throw an error when used as intented", {
  data(ho_et_al)

  ho_et_al$condition_c <- build_contrast(ho_et_al$condition,
                                         "Low discrimination",
                                         "High discrimination")
  model <- mdt_simple(data = ho_et_al,
                      IV   = condition_c,
                      DV   = hypodescent,
                      M    = linkedfate)

  expect_silent(extract_model(model, 1))
})

test_that("extract_models does not throw an error when used as intented", {
  data(ho_et_al)

  ho_et_al$condition_c <- build_contrast(ho_et_al$condition,
                                         "Low discrimination",
                                         "High discrimination")
  model <- mdt_simple(data = ho_et_al,
                      IV   = condition_c,
                      DV   = hypodescent,
                      M    = linkedfate)

  expect_silent(extract_models(model))
})

test_that("extract_models does not throw an error when used as intented", {
  data(ho_et_al)

  ho_et_al$condition_c <- build_contrast(ho_et_al$condition,
                                         "Low discrimination",
                                         "High discrimination")
  model <- mdt_simple(data = ho_et_al,
                      IV   = condition_c,
                      DV   = hypodescent,
                      M    = linkedfate)

  expect_silent(extract_tidy_models(model))
})

Try the JSmediation package in your browser

Any scripts or data that you put into this service are public.

JSmediation documentation built on Feb. 16, 2023, 7:25 p.m.