Skip to content

Commit d74707d

Browse files
committed
moving out the files
1 parent 750617a commit d74707d

20 files changed

+31
-16
lines changed

tests/testthat/setup.R

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
11
# Collection of functions and data pre-processing to help with testing
22

3-
# Utility function to manually test local snapshots ----------------------------
4-
skip_if_not_local_testing <- function(min_pandoc_version = "2", check_html = FALSE) {
5-
skip_on_cran() # When doing manual testing, it should be always skipped on CRAN
6-
local_edition(3, .env = parent.frame()) # Set the local_edition at 3
7-
skip_if_not_installed("doconv")
8-
skip_if_not(doconv::msoffice_available())
9-
if (!is.null(min_pandoc_version)) { # Can be turned off with NULL
10-
skip_if_not(rmarkdown::pandoc_version() >= numeric_version(min_pandoc_version))
11-
}
12-
if (isTRUE(check_html)) {
13-
skip_if_not_installed("webshot2")
14-
}
15-
invisible(TRUE)
16-
}
17-
18-
193
# xml related functions --------------------------------------------------------
204
get_docx_xml <- function(x) {
215
if (inherits(x, "flextable")) {
@@ -82,3 +66,34 @@ render_rmd <- function(file, rmd_format) {
8266
)
8367
sucess
8468
}
69+
70+
# Utility function to manually test local snapshots ----------------------------
71+
skip_if_not_local_testing <- function(min_pandoc_version = "2", check_html = FALSE) {
72+
skip_on_cran() # When doing manual testing, it should be always skipped on CRAN
73+
local_edition(3, .env = parent.frame()) # Set the local_edition at 3
74+
skip_if_not_installed("doconv")
75+
skip_if_not(doconv::msoffice_available())
76+
if (!is.null(min_pandoc_version)) { # Can be turned off with NULL
77+
skip_if_not(rmarkdown::pandoc_version() >= numeric_version(min_pandoc_version))
78+
}
79+
if (isTRUE(check_html)) {
80+
skip_if_not_installed("webshot2")
81+
}
82+
invisible(TRUE)
83+
}
84+
85+
# Getting snapshots in the _snaps folder for local testing if conditions are met
86+
test_that("setting up manual testing with msoffice", {
87+
skip_if_not_local_testing(check_html = TRUE)
88+
89+
# Folder where the snapshots are stored
90+
folder_to_copy <- system.file("snapshots_for_manual_tests", package = "flextable")
91+
92+
# Get the path to the tests/testthat directory
93+
path_to_testthat <- system.file("tests", "testthat", package = "flextable")
94+
95+
# Construct the path to the _snaps folder
96+
path_to_snaps <- file.path(path_to_testthat, "_snaps")
97+
98+
file.copy(folder_to_copy, path_to_snaps, recursive = TRUE, overwrite = TRUE)
99+
})

0 commit comments

Comments
 (0)