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
@ -13,7 +13,7 @@ import localeZh from '@angular/common/locales/zh';
|
||||
import localeFrCA from '@angular/common/locales/fr-CA';
|
||||
import localeEnAU from '@angular/common/locales/en-AU';
|
||||
import {registerLocaleData} from '../../src/i18n/locale_data';
|
||||
import {findLocaleData, getCurrencySymbol, getLocaleDateFormat, FormatWidth} from '../../src/i18n/locale_data_api';
|
||||
import {findLocaleData, getCurrencySymbol, getLocaleDateFormat, FormatWidth, getNbOfCurrencyDigits} from '../../src/i18n/locale_data_api';
|
||||
|
||||
{
|
||||
describe('locale data api', () => {
|
||||
@ -74,6 +74,15 @@ import {findLocaleData, getCurrencySymbol, getLocaleDateFormat, FormatWidth} fro
|
||||
});
|
||||
});
|
||||
|
||||
describe('getNbOfCurrencyDigits', () => {
|
||||
it('should return the correct value', () => {
|
||||
expect(getNbOfCurrencyDigits('USD')).toEqual(2);
|
||||
expect(getNbOfCurrencyDigits('IDR')).toEqual(0);
|
||||
expect(getNbOfCurrencyDigits('BHD')).toEqual(3);
|
||||
expect(getNbOfCurrencyDigits('unexisting_ISO_code')).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getLastDefinedValue', () => {
|
||||
it('should find the last defined date format when format not defined',
|
||||
() => { expect(getLocaleDateFormat('zh', FormatWidth.Long)).toEqual('y年M月d日'); });
|
||||
|
Reference in New Issue
Block a user