This refactors test-translate for preparation of refactoring the translation machinery.
translation pair of success/failure tests moved into expect_set_translate() function in helper-translate.R
expect_false(identical()) changed to expect_failure(expect_setequal()) to produce more informative error messages when they occur
expect_title_translate() checks that the <head><title> elements of generated pages have the expected title pattern of LESSON NAME: TRANSLATED TITLE
expect_h1_translate() checks that the <main><div><h1> elements of generated pages are identical to TRANSLATED TITLE
@foggleston has correctly pointed out that updating the translations in the future is going to be a bit of a slog because the developers would need to not only modify the translations used within the tr_() function, but also modify the expectations in tests/testthat/test-translate.R.
This refactors test-translate for preparation of refactoring the translation machinery.
expect_set_translate()
function in helper-translate.Rexpect_title_translate()
checks that the<head><title>
elements of generated pages have the expected title pattern ofLESSON NAME: TRANSLATED TITLE
expect_h1_translate()
checks that the<main><div><h1>
elements of generated pages are identical toTRANSLATED TITLE
@foggleston has correctly pointed out that updating the translations in the future is going to be a bit of a slog because the developers would need to not only modify the translations used within the
tr_()
function, but also modify the expectations intests/testthat/test-translate.R
.The solution is to pack all of the translated strings into a single file so that they could be evaluated later (see the commit comment on https://github.com/carpentries/sandpaper/commit/b7d380e5e43bf5fae39c6f5ed9970cd3a0b22189 for details). In order to do that, we should shore up the tests, which is what this PR does.