Skip to content

Commit

Permalink
moving out the files
Browse files Browse the repository at this point in the history
  • Loading branch information
Melkiades committed Mar 14, 2024
1 parent 750617a commit d74707d
Show file tree
Hide file tree
Showing 20 changed files with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
# Collection of functions and data pre-processing to help with testing

# Utility function to manually test local snapshots ----------------------------
skip_if_not_local_testing <- function(min_pandoc_version = "2", check_html = FALSE) {
skip_on_cran() # When doing manual testing, it should be always skipped on CRAN
local_edition(3, .env = parent.frame()) # Set the local_edition at 3
skip_if_not_installed("doconv")
skip_if_not(doconv::msoffice_available())
if (!is.null(min_pandoc_version)) { # Can be turned off with NULL
skip_if_not(rmarkdown::pandoc_version() >= numeric_version(min_pandoc_version))
}
if (isTRUE(check_html)) {
skip_if_not_installed("webshot2")
}
invisible(TRUE)
}


# xml related functions --------------------------------------------------------
get_docx_xml <- function(x) {
if (inherits(x, "flextable")) {
Expand Down Expand Up @@ -82,3 +66,34 @@ render_rmd <- function(file, rmd_format) {
)
sucess
}

# Utility function to manually test local snapshots ----------------------------
skip_if_not_local_testing <- function(min_pandoc_version = "2", check_html = FALSE) {
skip_on_cran() # When doing manual testing, it should be always skipped on CRAN
local_edition(3, .env = parent.frame()) # Set the local_edition at 3
skip_if_not_installed("doconv")
skip_if_not(doconv::msoffice_available())
if (!is.null(min_pandoc_version)) { # Can be turned off with NULL
skip_if_not(rmarkdown::pandoc_version() >= numeric_version(min_pandoc_version))
}
if (isTRUE(check_html)) {
skip_if_not_installed("webshot2")
}
invisible(TRUE)
}

# Getting snapshots in the _snaps folder for local testing if conditions are met
test_that("setting up manual testing with msoffice", {
skip_if_not_local_testing(check_html = TRUE)

# Folder where the snapshots are stored
folder_to_copy <- system.file("snapshots_for_manual_tests", package = "flextable")

# Get the path to the tests/testthat directory
path_to_testthat <- system.file("tests", "testthat", package = "flextable")

# Construct the path to the _snaps folder
path_to_snaps <- file.path(path_to_testthat, "_snaps")

file.copy(folder_to_copy, path_to_snaps, recursive = TRUE, overwrite = TRUE)
})

0 comments on commit d74707d

Please sign in to comment.