Skip to content

Commit

Permalink
Merge pull request #799 from vincentarelbundock/test_796
Browse files Browse the repository at this point in the history
snapshot test for issue 796
  • Loading branch information
vincentarelbundock committed Dec 11, 2023
2 parents f3e0668 + 6f31e50 commit 05b7cf8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
21 changes: 21 additions & 0 deletions tests/testthat/_snaps/bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Issue #796

Code
kable_styling(kbl(mtcars[1:3, 1:4], caption = "Demo table", booktabs = TRUE,
format = "latex"), latex_options = c("striped", "hold_position"))
Output
\begin{table}[!h]
\centering
\caption{Demo table}
\centering
\begin{tabular}[t]{lrrrr}
\toprule
& mpg & cyl & disp & hp\\
\midrule
\cellcolor{gray!10}{Mazda RX4} & \cellcolor{gray!10}{21.0} & \cellcolor{gray!10}{6} & \cellcolor{gray!10}{160} & \cellcolor{gray!10}{110}\\
Mazda RX4 Wag & 21.0 & 6 & 160 & 110\\
\cellcolor{gray!10}{Datsun 710} & \cellcolor{gray!10}{22.8} & \cellcolor{gray!10}{4} & \cellcolor{gray!10}{108} & \cellcolor{gray!10}{93}\\
\bottomrule
\end{tabular}
\end{table}

11 changes: 10 additions & 1 deletion tests/testthat/test-bugfix.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
test_that("Issue #796", {
expect_snapshot(
kbl(mtcars[1:3, 1:4], caption = "Demo table", booktabs = TRUE, format = "latex") |>
kable_styling(latex_options = c("striped", "hold_position"))
)
})


# Issue #658: column_spec() fails at single-row headerless tables in latex format.
dat <- data.frame(x = 1, y = 1)
dat <- setNames(dat, NULL)
Expand Down Expand Up @@ -42,4 +50,5 @@ expect_s3_class(tab, "kableExtra")
# kable_styling(bootstrap_options = c("striped", "hover", "condensed"), font_size = 12, full_width = TRUE) |>
# scroll_box(width = "100%", height = "500px") |>
# column_spec(1, width = "40em", include_thead = FALSE)
# expect_s3_class(tab, "kableExtra")
# expect_s3_class(tab, "kableExtra")

0 comments on commit 05b7cf8

Please sign in to comment.