Skip to content

Commit

Permalink
fix(common): use correct group separator for currency pipe (#18932)
Browse files Browse the repository at this point in the history
PR Close #18932
  • Loading branch information
ocombe authored and jasonaden committed Aug 30, 2017
1 parent 4fa6ae8 commit 4ec5e28
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/common/src/i18n/locale_data_api.ts
Expand Up @@ -325,7 +325,7 @@ export function getLocaleNumberSymbol(locale: string, symbol: NumberSymbol): str
if (symbol === NumberSymbol.CurrencyDecimal) {
return data[LocaleDataIndex.NumberSymbols][NumberSymbol.Decimal];
} else if (symbol === NumberSymbol.CurrencyGroup) {
return data[LocaleDataIndex.NumberSymbols][NumberSymbol.Decimal];
return data[LocaleDataIndex.NumberSymbols][NumberSymbol.Group];
}
}
return res;
Expand Down
7 changes: 7 additions & 0 deletions packages/common/test/pipes/number_pipe_spec.ts
Expand Up @@ -8,6 +8,7 @@

import localeEn from '../../locales/en';
import localeEsUS from '../../locales/es-US';
import localeFr from '../../locales/fr';
import {registerLocaleData, CurrencyPipe, DecimalPipe, PercentPipe} from '@angular/common';
import {beforeEach, describe, expect, it} from '@angular/core/testing/src/testing_internal';

Expand All @@ -16,6 +17,7 @@ export function main() {
beforeAll(() => {
registerLocaleData(localeEn);
registerLocaleData(localeEsUS);
registerLocaleData(localeFr);
});

function isNumeric(value: any): boolean { return !isNaN(value - parseFloat(value)); }
Expand Down Expand Up @@ -72,6 +74,8 @@ export function main() {
it('should return correct value for numbers', () => {
expect(pipe.transform(1.23)).toEqual('123%');
expect(pipe.transform(1.2, '.2')).toEqual('120.00%');
expect(pipe.transform(1.2, '4.2')).toEqual('0,120.00%');
expect(pipe.transform(1.2, '4.2', 'fr')).toEqual('0 120,00 %');
});

it('should not support other objects',
Expand All @@ -93,6 +97,9 @@ export function main() {
expect(pipe.transform(5.1234, 'USD', 'symbol')).toEqual('$5.12');
expect(pipe.transform(5.1234, 'CAD', 'symbol')).toEqual('CA$5.12');
expect(pipe.transform(5.1234, 'CAD', 'symbol-narrow')).toEqual('$5.12');
expect(pipe.transform(5.1234, 'CAD', 'symbol-narrow', '5.2-2')).toEqual('$00,005.12');
expect(pipe.transform(5.1234, 'CAD', 'symbol-narrow', '5.2-2', 'fr'))
.toEqual('00 005,12 $');
});

it('should not support other objects',
Expand Down

0 comments on commit 4ec5e28

Please sign in to comment.