tests/testthat/test-reg-table.R

test_that("bcat_reg_table works with single lm model", {
  model <- lm(mpg ~ wt + hp, data = mtcars)
  result <- bcat_reg_table(model, doc_type = "html")
  html <- as.character(result)

  expect_true(inherits(result, "knitr_kable") || inherits(result, "kableExtra"))
  expect_true(grepl("Model 1", html, fixed = TRUE))
  expect_false(grepl("&nbsp;", html, fixed = TRUE))
  expect_false(grepl("&amp;nbsp;", html, fixed = TRUE))
})

test_that("bcat_reg_table works with list of models", {
  m1 <- lm(mpg ~ wt, data = mtcars)
  m2 <- lm(mpg ~ wt + hp, data = mtcars)
  result <- bcat_reg_table(list("(1)" = m1, "(2)" = m2), doc_type = "html")
  html <- as.character(result)

  expect_true(inherits(result, "knitr_kable") || inherits(result, "kableExtra"))
  expect_true(grepl("> \\(1\\) <", html))
  expect_true(grepl("> \\(2\\) <", html))
  expect_false(grepl("&nbsp;", html, fixed = TRUE))
  expect_false(grepl("&amp;nbsp;", html, fixed = TRUE))
})

test_that("bcat_reg_table respects stars = FALSE", {
  model <- lm(mpg ~ wt, data = mtcars)
  result <- bcat_reg_table(model, stars = FALSE, doc_type = "html")
  expect_true(inherits(result, "knitr_kable") || inherits(result, "kableExtra"))
})

Try the Rbearcat package in your browser

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

Rbearcat documentation built on March 21, 2026, 5:07 p.m.