currency-formatter
currency-formatter copied to clipboard
Error in format with code, locale & precision
I'm testing my application, and I have included some tests that cover the behaviour managed by currency-formatter
, and I'm having the following issue:
I have been digging a little bit into the problem by buffering the received value and the expected value, and I found out that there's a difference between both elements:
As you can see, there's a difference between the received value and the expected value. I have checked out the string encoding in each case, and under a certain circumstance, it's coded as windows-1251
. To reproduce this error, you have to call the format
method with the following configuration:
format(6500, {
code: 'EUR',
locale: 'es-ES',
precision: 0
})
This is the test I created to check out if it's failing or not:
it('Returns 6.500 € for es-ES, EUR and precision 0', () => {
var result = currencyFormatter.format(6500, {
code: 'EUR',
locale: 'es-ES',
precision: 0
})
assert.equal(result, '6.500 €')
})
Indeed there's something wrong, but I'm not sure if it's in the format function or in the accounting.formatMoney
function that is called on it.
Let me know if you need more information to reproduce the error.
Is it a no-break space vs normal space?