-
Notifications
You must be signed in to change notification settings - Fork 220
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
🐛Fix unformat number in react-i18n #1215
Conversation
|
||
const formatted = '123.456,7891'; | ||
|
||
expect(i18n.unformatNumber(formatted)).toBe(input.toString()); | ||
}); | ||
|
||
it('handles number with space as the thousand symbol', () => { | ||
formatNumber.mockImplementationOnce(() => '123 456,7'); |
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.
Could not find any examples of languages using a space for the thousand separator and a period for the decimal.
See: https://docs.oracle.com/cd/E19455-01/806-0169/overview-9/index.html
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.
LGTM, but I would add a test (or tests) for getSeparators()
@benoitzohar Actually, I'm not seeing any tests for helper functions such as |
@adjnor It's true. It might be nitpicking, let me know what you think about this. |
As we discussed IRL, I'll update the PR to move the logic from |
59baccf
to
faccd42
Compare
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.
Good catch and a nice fix. My only concern is the computational cost of numberSymbols
. I am not sure if we could memoize something or just define some one-time evaluated const, I assume the i18n formatting cannot change without reloading the page (and therefore the javascript).
faccd42
to
7e0df22
Compare
@lukashlavacka Good point, I added the |
7e0df22
to
e0da785
Compare
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.
Changes, tests and 🎩 LGTM!
e0da785
to
f4e5a4c
Compare
Description
Issue: https://github.com/Shopify/intl-new-commerce-patterns/issues/916
Fixes an issue with
unformatNumber
when the thousand separator symbol is a period.Ideally, we would use the formatToParts method to fix the issue but that is still experimental.
Before:
After:
Type of change
Checklist