fix(common): round currencies based on decimal digits in CurrencyPipe
(#21783)
By default, we now round currencies based on the number of decimal digits available for that currency instead of using the rouding defined in the number formats. More info about that can be found in http://www.unicode.org/cldr/charts/latest/supplemental/detailed_territory_currency_information.html#format_info Fixes #10189 PR Close #21783
This commit is contained in:

committed by
Miško Hevery

parent
0b2f7d13d0
commit
44154e71fd
@ -136,6 +136,16 @@ import {beforeEach, describe, expect, it} from '@angular/core/testing/src/testin
|
||||
expect(pipe.transform(5.1234, 'USD', 'Custom name')).toEqual('Custom name5.12');
|
||||
});
|
||||
|
||||
it('should round to the default number of digits if no digitsInfo', () => {
|
||||
// IDR has a default number of digits of 0
|
||||
expect(pipe.transform(5.1234, 'IDR')).toEqual('IDR5');
|
||||
expect(pipe.transform(5.1234, 'IDR', 'symbol', '.2')).toEqual('IDR5.12');
|
||||
expect(pipe.transform(5.1234, 'IDR', 'Custom name')).toEqual('Custom name5');
|
||||
// BHD has a default number of digits of 3
|
||||
expect(pipe.transform(5.1234, 'BHD')).toEqual('BHD5.123');
|
||||
expect(pipe.transform(5.1234, 'BHD', 'symbol', '.1-2')).toEqual('BHD5.12');
|
||||
});
|
||||
|
||||
it('should not support other objects', () => {
|
||||
expect(() => pipe.transform({}))
|
||||
.toThrowError(
|
||||
|
Reference in New Issue
Block a user