Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Apr 19, 2024
1 parent 54e8393 commit 065a27a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 3 additions & 6 deletions tests/testthat/_snaps/navbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,13 @@
# data_navbar() can re-order default elements

Code
data_navbar(pkg)
data_navbar(pkg)[c("left", "right")]
Output
$type
[1] "default"
$left
[1] "<li>\n <a href=\"https://github.com/r-lib/pkgdown/\">\n <span class=\"fab fa-github fa-lg\"></span>\n \n </a>\n</li>\n<li>\n <a href=\"reference/index.html\">Reference</a>\n</li>"
[1] "<li class=\"nav-item\">\n <a class=\"nav-link\" href=\"https://github.com/r-lib/pkgdown/\" aria-label=\"github\">\n <span class=\"fab fa fab fa-github fa-lg\"></span>\n \n </a>\n</li>\n<li><form class=\"form-inline\" role=\"search\">\n<input type=\"search\" class=\"form-control\" name=\"search-input\" id=\"search-input\" autocomplete=\"off\" aria-label=\"Search site\" placeholder=\"Search for\" data-search-index=\"search.json\">\n</form></li>"
$right
[1] "<li>\n <a href=\"news/index.html\">Changelog</a>\n</li>"
[1] "<li class=\"nav-item\">\n <a class=\"nav-link\" href=\"news/index.html\">Changelog</a>\n</li>"

# data_navbar() can remove elements
Expand Down
8 changes: 5 additions & 3 deletions tests/testthat/test-navbar.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,20 @@ test_that("data_navbar() works by default", {

test_that("data_navbar() can re-order default elements", {
pkg <- local_pkgdown_site(meta = "
template:
bootstrap: 5
repo:
url:
home: https://github.com/r-lib/pkgdown/
navbar:
structure:
left: [github, reference]
right: news
left: [github, search]
right: [news]
")
file.create(file.path(pkg$src_path, "NEWS.md"))

expect_snapshot(data_navbar(pkg))
expect_snapshot(data_navbar(pkg)[c("left", "right")])
})

test_that("data_navbar() can remove elements", {
Expand Down

0 comments on commit 065a27a

Please sign in to comment.