fix(common): use correct pipe name in error messages (#19403)
Fixes #19373
This commit is contained in:
parent
f57b7df4d7
commit
f9b0863c8a
|
@ -49,7 +49,7 @@ export class DecimalPipe implements PipeTransform {
|
|||
const {str, error} = formatNumber(value, locale, NumberFormatStyle.Decimal, digits);
|
||||
|
||||
if (error) {
|
||||
throw invalidPipeArgumentError(CurrencyPipe, error);
|
||||
throw invalidPipeArgumentError(DecimalPipe, error);
|
||||
}
|
||||
|
||||
return str;
|
||||
|
@ -87,7 +87,7 @@ export class PercentPipe implements PipeTransform {
|
|||
const {str, error} = formatNumber(value, locale, NumberFormatStyle.Percent, digits);
|
||||
|
||||
if (error) {
|
||||
throw invalidPipeArgumentError(CurrencyPipe, error);
|
||||
throw invalidPipeArgumentError(PercentPipe, error);
|
||||
}
|
||||
|
||||
return str;
|
||||
|
|
|
@ -48,8 +48,11 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should not support other objects', () => {
|
||||
expect(() => pipe.transform({})).toThrowError();
|
||||
expect(() => pipe.transform('123abc')).toThrowError();
|
||||
expect(() => pipe.transform({}))
|
||||
.toThrowError(
|
||||
`InvalidPipeArgument: '[object Object] is not a number' for pipe 'DecimalPipe'`);
|
||||
expect(() => pipe.transform('123abc'))
|
||||
.toThrowError(`InvalidPipeArgument: '123abc is not a number' for pipe 'DecimalPipe'`);
|
||||
});
|
||||
|
||||
it('should throw if minFractionDigits is explicitly higher than maxFractionDigits', () => {
|
||||
|
@ -78,8 +81,11 @@ export function main() {
|
|||
expect(pipe.transform(1.2, '4.2', 'fr')).toEqual('0 120,00 %');
|
||||
});
|
||||
|
||||
it('should not support other objects',
|
||||
() => { expect(() => pipe.transform({})).toThrowError(); });
|
||||
it('should not support other objects', () => {
|
||||
expect(() => pipe.transform({}))
|
||||
.toThrowError(
|
||||
`InvalidPipeArgument: '[object Object] is not a number' for pipe 'PercentPipe'`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -102,8 +108,11 @@ export function main() {
|
|||
.toEqual('00 005,12 $');
|
||||
});
|
||||
|
||||
it('should not support other objects',
|
||||
() => { expect(() => pipe.transform({})).toThrowError(); });
|
||||
it('should not support other objects', () => {
|
||||
expect(() => pipe.transform({}))
|
||||
.toThrowError(
|
||||
`InvalidPipeArgument: '[object Object] is not a number' for pipe 'CurrencyPipe'`);
|
||||
});
|
||||
|
||||
it('should warn if you are using the v4 signature', () => {
|
||||
const warnSpy = spyOn(console, 'warn');
|
||||
|
|
Loading…
Reference in New Issue