test-init.R
context("test-init.R")
test_that("extra.css and extra.js copied and linked", {
pkg <- test_path("assets/init-extra-2")
expect_output(init_site(pkg))
on.exit(clean_site(pkg))
expect_true(file_exists(path(pkg, "docs", "extra.css")))
expect_true(file_exists(path(pkg, "docs", "extra.js")))
skip_if_no_pandoc()
# Now check they actually get used .
expect_output(build_home(pkg))
html <- xml2::read_html(path(pkg, "docs", "index.html"))
links <- xml2::xml_find_all(html, ".//link")
paths <- xml2::xml_attr(links, "href")
expect_true("extra.css" %in% paths)
})
test_that("single extra.css correctly copied", {
pkg <- test_path("assets/init-extra-1")
expect_output(init_site(pkg))
on.exit(clean_site(pkg))
expect_true(file_exists(path(pkg, "docs", "extra.css")))
})
test_that("asset subdirectories are copied", {
pkg <- test_path("assets/init-asset-subdirs")
expect_output(init_site(pkg))
on.exit(clean_site(pkg))
expect_true(file_exists(path(pkg, "docs", "subdir1", "file1.txt")))
expect_true(file_exists(path(pkg, "docs", "subdir1", "subdir2", "file2.txt")))
})