Unit test: Number.toLocaleString ()

I would expect (10000).toLocaleString('de-DE') return "10.000" , but instead get "10000" .

Is there a reason this is not supported? Are there any ways to format numbers?

+7
javascript phantomjs
source share
1 answer

This is a webkit problem, and PhantomJS does not want to support internationalization ... unfortunately, we have been stuck with this for some time.

https://github.com/ariya/phantomjs/issues/12581

What I ended up with is writing a custom match that checks 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 as

 expect(actual).isAnyOf(['10000', '10.000']); 
+1
source share

All Articles