Skip to content

Commit

Permalink
Fix readme and test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-imbi committed Nov 24, 2023
1 parent c4ea7f7 commit 0506d82
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- badges: start -->
[![R-CMD-check](https://github.com/imbi-heidelberg/DescrTab2/workflows/R-CMD-check/badge.svg)](https://github.com/imbi-heidelberg/DescrTab2/actions)
[![R-CMD-check](https://github.com/imbi-heidelberg/DescrTab2/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/imbi-heidelberg/DescrTab2/actions/workflows/R-CMD-check.yaml)
[![codecov](https://codecov.io/gh/imbi-heidelberg/DescrTab2/branch/master/graph/badge.svg)](https://app.codecov.io/gh/imbi-heidelberg/DescrTab2)
[![Github version](https://img.shields.io/github/r-package/v/imbi-heidelberg/DescrTab2/master?label=Github%20version%20%40master)](https://github.com/imbi-heidelberg/DescrTab2/tree/master)
[![CRAN Version](https://www.r-pkg.org/badges/version/DescrTab2)](https://www.r-pkg.org/badges/version/DescrTab2)
Expand Down
13 changes: 12 additions & 1 deletion tests/testthat/test_html.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# write_in_tmpfile_for_cran() <- FALSE
library(dplyr, quietly=TRUE, warn.conflicts=FALSE)
dat <- iris[, c("Species", "Sepal.Length")]
dat <- dat |> mutate(animal = c("Mammal", "Fish") |> rep(75) %>% factor())
dat <- dat |> mutate(food = c("fries", "wedges") |> sample(150, TRUE) |> factor())

test_that(
"knit an html file with DescrTab2 tables", {
Expand All @@ -21,4 +24,12 @@ test_that("Outputformat html produces no errors",{
group_labels = list(setosa = "My custom group label"),
var_options = list(Sepal.Length = list(label = "My custom variable label"))
) %>% print(print_format="html", silent=FALSE)), NA)

expect_error(capture_output(descr(
dat,
"animal",
group_labels = list(setosa = "My custom group label"),
format_options = list(print_CI=TRUE),
var_options = list(Sepal.Length = list(label = "My custom variable label"))
) |> print(print_format="html", silent=FALSE)), NA)
})
14 changes: 13 additions & 1 deletion tests/testthat/test_tex.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
library(dplyr, quietly=TRUE, warn.conflicts=FALSE)
dat <- iris[, c("Species", "Sepal.Length")]
dat <- dat |> mutate(animal = c("Mammal", "Fish") |> rep(75) %>% factor())
dat <- dat |> mutate(food = c("fries", "wedges") |> sample(150, TRUE) |> factor())

test_that("knit a tex file with DescrTab2 tables", {
skip_on_cran()
# skip_on_ci()
Expand All @@ -18,5 +23,12 @@ test_that("Outputformat .tex produces no errors",{
"Species",
group_labels = list(setosa = "My custom group label"),
var_options = list(Sepal.Length = list(label = "My custom variable label"))
) %>% print(print_format="tex", silent=FALSE)), NA)
) |> print(print_format="tex", silent=FALSE)), NA)
expect_error(capture_output(descr(
dat,
"animal",
group_labels = list(setosa = "My custom group label"),
format_options = list(print_CI=TRUE),
var_options = list(Sepal.Length = list(label = "My custom variable label"))
) |> print(print_format="tex", silent=FALSE)), NA)
})

0 comments on commit 0506d82

Please sign in to comment.