-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First draft of render_lg_table test; update documentation
- Loading branch information
1 parent
e7ee67d
commit 625a669
Showing
4 changed files
with
110 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
test_that("accurate number of split tables identified", { | ||
|
||
# make very wide table | ||
ft <- as.data.frame(faithful) |> | ||
t() |> | ||
as.data.frame() |> | ||
dplyr::select(1:50) |> | ||
flextable::flextable() | ||
|
||
dir.create("rda_files") | ||
|
||
# 0 essential columns | ||
tables_test1 <- render_lg_table(ft, | ||
essential_columns = 0, | ||
rda_dir = getwd(), | ||
plot_name = "test_plot1.rda") | ||
|
||
expect_equal(tables_test1, 5) | ||
|
||
# 2 essential columns | ||
tables_test2 <- render_lg_table(ft, | ||
essential_columns = 1:2, | ||
rda_dir = getwd(), | ||
plot_name = "test_plot2.rda") | ||
|
||
expect_equal(tables_test2, 5) | ||
|
||
|
||
|
||
# make very very wide table | ||
ft <- as.data.frame(faithful) |> | ||
t() |> | ||
as.data.frame() |> | ||
dplyr::select(1:70) |> | ||
flextable::flextable() | ||
|
||
# 0 essential columns | ||
tables_test3 <- render_lg_table(ft, | ||
essential_columns = 0, | ||
rda_dir = getwd(), | ||
plot_name = "test_plot3.rda") | ||
|
||
expect_equal(tables_test3, 7) | ||
|
||
# 3 essential columns | ||
tables_test4 <- render_lg_table(ft, | ||
essential_columns = 1:3, | ||
rda_dir = getwd(), | ||
plot_name = "test_plot4.rda") | ||
|
||
expect_equal(tables_test4, 7) | ||
|
||
|
||
# make slightly wide table | ||
ft <- as.data.frame(faithful) |> | ||
t() |> | ||
as.data.frame() |> | ||
dplyr::select(1:20) |> | ||
flextable::flextable() | ||
|
||
# 0 essential columns | ||
tables_test5 <- render_lg_table(ft, | ||
essential_columns = 0, | ||
rda_dir = getwd(), | ||
plot_name = "test_plot5.rda") | ||
|
||
expect_equal(tables_test5, 2) | ||
|
||
# 3 essential columns | ||
tables_test6 <- render_lg_table(ft, | ||
essential_columns = 1:3, | ||
rda_dir = getwd(), | ||
plot_name = "test_plot6.rda") | ||
|
||
expect_equal(tables_test6, 2) | ||
|
||
# erase temporary testing files | ||
unlink(fs::path(getwd(), "rda_files"), recursive = T) | ||
|
||
}) | ||
|
||
test_that("table_list saved as an rda", { | ||
|
||
# make very wide table | ||
ft <- as.data.frame(faithful) |> | ||
t() |> | ||
as.data.frame() |> | ||
dplyr::select(1:50) |> | ||
flextable::flextable() | ||
|
||
dir.create("rda_files") | ||
|
||
render_lg_table(ft, | ||
essential_columns = 0, | ||
rda_dir = getwd(), | ||
plot_name = "test_plot1.rda") | ||
|
||
expect_true(file.exists(fs::path(getwd(), | ||
"rda_files", | ||
"test_plot1_split.rda"))) | ||
|
||
# erase temporary testing files | ||
unlink(fs::path(getwd(), "rda_files"), recursive = T) | ||
|
||
}) |