I would have expected (10000).toLocaleString('de-DE')
to return "10.000"
but instead I get "10000"
.
Is there a reason this is not supported? Are there better ways to format numbers?
The toLocaleString() method returns a string with a language-sensitive representation of this date. In implementations with Intl. DateTimeFormat API support, this method simply calls Intl. DateTimeFormat .
Return Value: The toLocaleString() method in TypeScript returns a human readable string representing the number using the locale of the environment.
It is a webkit issue, and PhantomJS doesn't want to maintain internationalization... so unfortunately we are stuck with this for some undisclosed time.
https://github.com/ariya/phantomjs/issues/12581
What I ended up doing is writing a custom matcher that checks for both, since I run in Chrome and PhantomJS.
jasmine.addMatchers({
isAnyOf: (util, customEqualityTesters) => {
return {
compare: (actual, expected) => {
let result = {};
for (let expect of expected) {
console.log(actual == expect);
if (expect == actual) {
result.pass = true;
return result;
}
}
result.pass = false
return result;
}
}
}
})
Then you can use it like
expect(actual).isAnyOf(['10000', '10.000']);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With