From 59d550c911cbf611b29b424dd629413caa760d40 Mon Sep 17 00:00:00 2001 From: "David J. Bosak" Date: Sun, 17 Mar 2024 09:08:01 -0400 Subject: [PATCH] Blank spaces issue #130 --- tests/testthat/test-docx.R | 38 ++++++++++++++++++++ tests/testthat/test-html.R | 38 ++++++++++++++++++++ tests/testthat/test-rtf2.R | 72 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+) diff --git a/tests/testthat/test-docx.R b/tests/testthat/test-docx.R index 2169d5d..6e2efc4 100644 --- a/tests/testthat/test-docx.R +++ b/tests/testthat/test-docx.R @@ -1951,6 +1951,44 @@ test_that("docx55: Top margin 1.5 works as expected.", { }) +test_that("docx-56: Multi page table removes blank spaces.", { + + if (dev == TRUE) { + + + fp <- file.path(base_path, "docx/test56.docx") + + dat1 <- iris[1:10, ] + dat2 <- iris[11:20, ] + dat3 <- iris[21:30, ] + + + tbl1 <- create_table(dat1, borders = "none") %>% + titles("Table 1.0", "My Nice Irises1") + + tbl2 <- create_table(dat2, borders = "none") %>% + titles("Table 1.0", "My Nice Irises2") + + tbl3 <- create_table(dat3, borders = "none") %>% + titles("Table 1.0", "My Nice Irises3") + + rpt <- create_report(fp, output_type = "DOCX", font = fnt, + font_size = 12, orientation = "landscape") %>% + set_margins(top = 1, bottom = 1) %>% + add_content(tbl1, blank_row = "none") |> + add_content(tbl2, blank_row = "none") |> + add_content(tbl3, blank_row = "none") + + + res <- write_report(rpt) + + expect_equal(file.exists(fp), TRUE) + expect_equal(res$pages, 3) + + } else + expect_equal(TRUE, TRUE) +}) + # User Tests -------------------------------------------------------------- diff --git a/tests/testthat/test-html.R b/tests/testthat/test-html.R index a2b3eaa..11479cb 100644 --- a/tests/testthat/test-html.R +++ b/tests/testthat/test-html.R @@ -1499,6 +1499,44 @@ test_that("html43: Page by with wrap works as expected.", { }) +test_that("html-44: Multi page table removes blank spaces.", { + + if (dev == TRUE) { + + + fp <- file.path(base_path, "html/test44.html") + + dat1 <- iris[1:10, ] + dat2 <- iris[11:20, ] + dat3 <- iris[21:30, ] + + + tbl1 <- create_table(dat1, borders = "none") %>% + titles("Table 1.0", "My Nice Irises1") + + tbl2 <- create_table(dat2, borders = "none") %>% + titles("Table 1.0", "My Nice Irises2") + + tbl3 <- create_table(dat3, borders = "none") %>% + titles("Table 1.0", "My Nice Irises3") + + rpt <- create_report(fp, output_type = "HTML", font = fnt, + font_size = 12, orientation = "landscape") %>% + set_margins(top = 1, bottom = 1) %>% + add_content(tbl1, blank_row = "none") |> + add_content(tbl2, blank_row = "none") |> + add_content(tbl3, blank_row = "none") + + + res <- write_report(rpt) + + expect_equal(file.exists(fp), TRUE) + expect_equal(res$pages, 3) + + } else + expect_equal(TRUE, TRUE) +}) + # User Tests -------------------------------------------------------------- diff --git a/tests/testthat/test-rtf2.R b/tests/testthat/test-rtf2.R index 0cc8d20..331e211 100644 --- a/tests/testthat/test-rtf2.R +++ b/tests/testthat/test-rtf2.R @@ -3482,6 +3482,78 @@ test_that("rtf2-97: Page X of Y works as expected.", { expect_equal(TRUE, TRUE) }) +test_that("rtf2-98: Title header blank rows work as expected.", { + + + fp <- file.path(base_path, "rtf2/test98.rtf") + + dat <- iris + + tbl <- create_table(dat, width = 8.9, borders = "all") %>% + title_header("Table 1.0", "My Nice Table", + right = c("Right1", + "Right2", "Page [pg] of [tpg]"), + blank_row = "both", borders = "all") + + + rpt <- create_report(fp, output_type = "RTF", font = "Arial", + font_size = 10, orientation = "landscape") %>% + page_header("Left", "Right", blank_row = "below") %>% + set_margins(top = 1, bottom = 1) %>% + add_content(tbl) %>% + footnotes("My footnote 1", "My footnote 2") %>% + page_footer("Left1", "Center1", "Right1") + + res <- write_report(rpt) + res + res$column_widths + + expect_equal(file.exists(fp), TRUE) + expect_equal(res$pages, 7) + expect_equal(length(res$column_widths[[1]]), 5) + + +}) + + +test_that("rtf2-99: Multi page table removes blank spaces.", { + + if (dev == TRUE) { + + + fp <- file.path(base_path, "rtf2/test99.rtf") + + dat1 <- iris[1:10, ] + dat2 <- iris[11:20, ] + dat3 <- iris[21:30, ] + + + tbl1 <- create_table(dat1, borders = "none") %>% + titles("Table 1.0", "My Nice Irises1") + + tbl2 <- create_table(dat2, borders = "none") %>% + titles("Table 1.0", "My Nice Irises2") + + tbl3 <- create_table(dat3, borders = "none") %>% + titles("Table 1.0", "My Nice Irises3") + + rpt <- create_report(fp, output_type = "RTF", font = fnt, + font_size = 12, orientation = "landscape") %>% + set_margins(top = 1, bottom = 1) %>% + add_content(tbl1, blank_row = "none") |> + add_content(tbl2, blank_row = "none") |> + add_content(tbl3, blank_row = "none") + + + res <- write_report(rpt) + + expect_equal(file.exists(fp), TRUE) + expect_equal(res$pages, 3) + + } else + expect_equal(TRUE, TRUE) +}) + # User Tests --------------------------------------------------------------