swh:1:snp:bdc19e867479541d0f4994ceaa711217d0dc28ed
Tip revision: 74b598025322cd572dcd58326f0c5fb465f503ab authored by Hadley Wickham on 23 June 2022, 13:00:02 UTC
version 2.0.5
version 2.0.5
Tip revision: 74b5980
test-build-search-docs.R
test_that("docsearch.json and sitemap.xml are valid", {
pkg <- local_pkgdown_site(test_path("assets/search-site"))
expect_output(build_site(pkg, new_process = FALSE))
json <- path(pkg$dst_path, "docsearch.json")
expect_true(jsonlite::validate(read_lines(json)))
xml <- path(pkg$dst_path, "sitemap.xml")
schema <- xml2::read_xml(path(pkg$src_path, "sitemaps-schema-0.9.xsd"))
expect_true(xml2::xml_validate(xml2::read_xml(xml), schema))
})
test_that("build_search() builds the expected search`.json with an URL", {
pkg <- local_pkgdown_site(test_path("assets/news"), '
url: https://example.com
template:
bootstrap: 5
news:
cran_dates: false
development:
mode: devel
')
expect_output(init_site(pkg))
expect_output(build_news(pkg))
expect_output(build_home(pkg))
expect_output(build_sitemap(pkg))
json_path <- withr::local_tempfile()
jsonlite::write_json(build_search_index(pkg), json_path, pretty = TRUE)
expect_snapshot_file(json_path, "search.json")
})
test_that("build_search() builds the expected search.json with no URL", {
pkg <- local_pkgdown_site(test_path("assets/news"), '
template:
bootstrap: 5
news:
cran_dates: false
development:
mode: devel
')
expect_output(init_site(pkg))
expect_output(build_news(pkg))
expect_output(build_home(pkg))
expect_output(build_sitemap(pkg))
json_path <- withr::local_tempfile()
jsonlite::write_json(build_search_index(pkg), json_path, pretty = TRUE)
expect_snapshot_file(json_path, "search-no-url.json")
})