Skip to content

Commit

Permalink
Add tests and NEWS.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonthegeek committed Nov 6, 2024
1 parent cc6ea44 commit dbed867
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# pkgdown (development version)

* The language of the site is set from the first `Language:` in the `DESCRIPTION` if it is available and no other language is specified (@jonthegeek, #2808).

# pkgdown 2.1.1

* Added keyboard shortcut, `/`, to focus search bar (#2423)
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/assets/reference-language/one/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Package: testpackage
Version: 1.0.0
Title: A test package
Description: A test package
Authors@R: person("Hadley Wickham")
RoxygenNote: 7.3.1
Language: fr
7 changes: 7 additions & 0 deletions tests/testthat/assets/reference-language/two/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Package: testpackage
Version: 1.0.0
Title: A test package
Description: A test package
Authors@R: person("Hadley Wickham")
RoxygenNote: 7.3.1
Language: en-US, fr
29 changes: 29 additions & 0 deletions tests/testthat/test-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,32 @@ test_that("malformed figures fail gracefully", {
expect_null(rd_lifecycle("{\\figure{deprecated.svg}}"))
expect_null(rd_lifecycle("{\\figure{}}"))
})

# language ---------------------------------------------------------------------

test_that("as_pkgdown sets language", {
# Default
pkg <- as_pkgdown(test_path("assets/reference"))
expect_equal(
pkg$lang,
"en"
)
# Single language specified in DESCRIPTION
pkg <- as_pkgdown(test_path("assets/reference-language/one"))
expect_equal(
pkg$lang,
"fr"
)
# Two languages specified in DESCRIPTION
pkg <- as_pkgdown(test_path("assets/reference-language/two"))
expect_equal(
pkg$lang,
"en-US"
)
# Language specified in _pkgdown.yml or override.
pkg <- as_pkgdown(test_path("assets/reference-language/two"), override = list(lang = "en-GB"))
expect_equal(
pkg$lang,
"en-GB"
)
})

0 comments on commit dbed867

Please sign in to comment.