currency-formatter icon indicating copy to clipboard operation
currency-formatter copied to clipboard

Error in format with code, locale & precision

Open LluisArevalo opened this issue 6 years ago • 1 comments

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:

Unexpected failure

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:

Buffered difference

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.

LluisArevalo avatar Apr 04 '18 17:04 LluisArevalo

Is it a no-break space vs normal space?

edorivai avatar Apr 04 '18 19:04 edorivai