Skip to content

Commit

Permalink
Issue #956 Add Failing Test
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinabrock committed Dec 6, 2024
1 parent bd78cf8 commit 4165d84
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/testit/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ assert('prepend_chapter_title() adds the chapter title to the page title', {
})

assert('source_files() handles several configurations correctly', {
get_files = function(files = NULL, dirs = NULL, ...) {
source_files(config = list(rmd_files = files, rmd_subdir = dirs), ...)
get_files = function(files = NULL, dirs = NULL, md = NULL, ...) {
source_files(config = list(rmd_files = files, rmd_subdir = dirs, include_md = md), ...)
}

# create dummy project
Expand All @@ -63,7 +63,7 @@ assert('source_files() handles several configurations correctly', {
files = c(
'index.Rmd', '_ignored.Rmd', '01-first.Rmd',
'subdir/other.Rmd', 'subdir/_ignore.Rmd', 'subdir2/last.Rmd',
'abc/def.Rmd', 'abc/ghi.Rmd'
'abc/def.Rmd', 'abc/ghi.Rmd', 'subdir/jkl.md'
)
lapply(unique(dirname(files)), dir.create, FALSE, recursive = TRUE)
file.create(files)
Expand All @@ -79,7 +79,7 @@ assert('source_files() handles several configurations correctly', {
(get_files(files[4:1]) %==% files[c(1, 4, 3)])

# format allows to filter selected files
(get_files(list(html = 'index.Rmd'), NULL, 'html') %==% files[1])
(get_files(list(html = 'index.Rmd'), NULL, NULL, 'html') %==% files[1])

# rmd_subdir allows subdir contents and root Rmds
(get_files(, TRUE) %==% files[c(1, 3, 7:8, 4, 6)])
Expand All @@ -93,6 +93,10 @@ assert('source_files() handles several configurations correctly', {
(get_files(files[3], dirname(files[c(4, 6)])) %==% files[c(3, 4, 6)])
(get_files(files[3], dirname(files[c(4, 6, 7)])) %==% files[c(3, 4, 6, 7:8)])

# include_md toggles inclusion of md files
(get_files(files[3], dirname(files[c(4, 6, 7)]), FALSE) %==% files[c(3, 4, 6, 7:8)])
(get_files(files[3], dirname(files[c(4, 6, 7)]), TRUE) %==% files[c(3, 4, 6, 7:9)])

# clean tests
unlink(project, recursive = TRUE); rm(project)
setwd(old); rm(old)
Expand Down

0 comments on commit 4165d84

Please sign in to comment.