-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests(i18n): no ICU value given to preprocess #9384
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
587980c
Add test for ICU msg w/o values against preprocessMsgValues.
exterkamp 7b1896d
removed import because test changed!
exterkamp db5a70a
updated with another test. added var to error out.
exterkamp 9b73f54
Update lighthouse-core/test/lib/i18n/i18n-test.js
exterkamp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feels like this change should be accompanied by a test too if we want to change it here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should change the typedef below (https://github.com/GoogleChrome/lighthouse/pull/9384/files#diff-4f100f14d281ddfaff2dc4466fc78054R167) to
Record<string, any>
?I guess I'm just not sure why
is desirable.
Like why not just
if (!values) return {}
if we want to convert away fromundefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be misinterpreting your question, but this came up when adding the test.
_preprocessMessageValues
does the "all ICU replacements in the string have a value provided" check, which works fine if there are multiple replacements to be done and one value (or more) is missing. However if the values object is forgotten completely, this line skips the check, even if the string has replacements that will need values.It still ends up throwing, just in
intl-messageformat
, so if we are going to do a check here it made sense to do it for all strings that need replacements (instead of all strings that havevalues
passed in with them).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, oh, oh, I misread the
parsed.elements.forEach
line to beObject.values(values).forEach
, my bad!yes, yes this makes perfect sense!
Still would love a test for forgetting the
values
completely, but I gotcha now! 👍 :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! I added a new test, and made the error message a bit more helpful.