fix(common): initialize currencyCode in currencyPipe (#40505)
currencyCode should be initialized with the injected default currency code PR Close #40505
This commit is contained in:
parent
c964ad66d4
commit
374fa2c26f
|
@ -253,7 +253,7 @@ export class CurrencyPipe implements PipeTransform {
|
|||
display?: 'code'|'symbol'|'symbol-narrow'|string|boolean, digitsInfo?: string,
|
||||
locale?: string): string|null;
|
||||
transform(
|
||||
value: number|string|null|undefined, currencyCode?: string,
|
||||
value: number|string|null|undefined, currencyCode: string = this._defaultCurrencyCode,
|
||||
display: 'code'|'symbol'|'symbol-narrow'|string|boolean = 'symbol', digitsInfo?: string,
|
||||
locale?: string): string|null {
|
||||
if (!isValue(value)) return null;
|
||||
|
|
|
@ -140,6 +140,11 @@ import {ɵregisterLocaleData, ɵunregisterLocaleData} from '@angular/core';
|
|||
expect(pipe.transform(5.1234, 'DKK', '', '', 'da')).toEqual('5,12');
|
||||
});
|
||||
|
||||
it('should use the injected default currency code if none is provided', () => {
|
||||
const clpPipe = new CurrencyPipe('en-US', 'CLP');
|
||||
expect(clpPipe.transform(1234)).toEqual('CLP1,234');
|
||||
});
|
||||
|
||||
it('should support any currency code name', () => {
|
||||
// currency code is unknown, default formatting options will be used
|
||||
expect(pipe.transform(5.1234, 'unexisting_ISO_code', 'symbol'))
|
||||
|
|
Loading…
Reference in New Issue