blob: ff0f98ca792f438229c085dd03bec59fba05ac8e [file] [log] [blame]
Will Beasley883d0e02017-07-22 02:15:15 -05001library(testthat)
2library(knitr)
3
4dt <- mtcars[1:5, 1:8]
5
6
7# ---- styling -----------------------------------------------------------------
8testthat::context("styling")
9
10test_that("dry_run", {
11 observed <- dt[1:3] %>%
12 kable(format = "latex", booktabs = T, caption = "xxx") %>%
13 kable_styling(latex_options = c("striped", "hold_position"), font_size = 6, position = "float_left")
Hao Zhu53e240f2017-09-04 20:04:29 -040014 dput(observed)
Will Beasley883d0e02017-07-22 02:15:15 -050015
Hao Zhufb57e452017-08-03 10:25:59 -040016 expected <- structure("\\rowcolors{2}{gray!6}{white}\n\\begin{wraptable}{l}{6.6cm}\n\n\\caption{\\label{tab:}xxx}\n\\centering\n\\fontsize{6}{8}\\selectfont\n\\begin{tabular}[t]{lrrr}\n\\hiderowcolors\n\\toprule\n & mpg & cyl & disp\\\\\n\\midrule\n\\showrowcolors\nMazda RX4 & 21.0 & 6 & 160\\\\\nMazda RX4 Wag & 21.0 & 6 & 160\\\\\nDatsun 710 & 22.8 & 4 & 108\\\\\nHornet 4 Drive & 21.4 & 6 & 258\\\\\nHornet Sportabout & 18.7 & 8 & 360\\\\\n\\bottomrule\n\\end{tabular}\n\\end{wraptable}\n\\rowcolors{2}{white}{white}", format = "latex", class = "knitr_kable", kable_meta = structure(list(
17 tabular = "tabular", booktabs = TRUE, align = "lrrr", valign = "[t]",
18 ncol = 4L, nrow = 6, colnames = c(" ", "mpg", "cyl", "disp"
19 ), rownames = c("", "Mazda", "Mazda", "Datsun", "Hornet",
Hao Zhu53e240f2017-09-04 20:04:29 -040020 "Hornet"), caption = "\\label{tab:}xxx", caption.short = NULL,
21 contents = c(" & mpg & cyl & disp", "Mazda RX4 & 21.0 & 6 & 160",
22 "Mazda RX4 Wag & 21.0 & 6 & 160", "Datsun 710 & 22.8 & 4 & 108",
23 "Hornet 4 Drive & 21.4 & 6 & 258", "Hornet Sportabout & 18.7 & 8 & 360"
24 ), centering = TRUE, table_env = TRUE, align_vector = c("l",
25 "r", "r", "r"), align_vector_origin = c("l", "r", "r", "r"
26 ), valign2 = "\\[t\\]", valign3 = "t", begin_tabular = "\\\\begin\\{tabular\\}\\[t\\]",
27 end_tabular = "\\\\end\\{tabular\\}"), .Names = c("tabular",
28 "booktabs", "align", "valign", "ncol", "nrow", "colnames", "rownames",
29 "caption", "caption.short", "contents", "centering", "table_env",
30 "align_vector", "align_vector_origin", "valign2", "valign3",
31 "begin_tabular", "end_tabular")))
Will Beasley883d0e02017-07-22 02:15:15 -050032
33 expect_equal(observed, expected)
34})