AAE-39923 Placholeder is formatted according to the enableFractions (#11441)

* [AAE-39923] placholeder is formatted according to the enableFractions property

* [AAE-39923] unit tests for placeholder decimal part
This commit is contained in:
Tomek Hanaj
2025-12-10 15:01:22 +01:00
committed by GitHub
parent ec7ede3830
commit 68ab5b1c16
2 changed files with 40 additions and 1 deletions
@@ -890,6 +890,45 @@ describe('AmountWidgetComponent - rendering', () => {
const expectedValue = '5.000,00 €'.replace(' ', '\u00A0');
expect(widget.placeholder).toBe(expectedValue);
});
it('should format numeric placeholder with decimal digits', () => {
widget.field.placeholder = '1234.11';
widget.currency = 'USD';
widget.currencyDisplay = 'symbol';
widget.decimalProperty = widget.showDecimalDigits;
widget.enableDisplayBasedOnLocale = true;
widget.locale = 'de-DE';
const expected = '1.234,11 $'.replace(' ', '\u00A0');
expect(widget.placeholder).toBe(expected);
});
it('should format numeric placeholder without decimal digits', () => {
widget.field.placeholder = '1234.11';
widget.currency = 'USD';
widget.currencyDisplay = 'symbol';
widget.decimalProperty = widget.notShowDecimalDigits;
widget.enableDisplayBasedOnLocale = true;
widget.locale = 'de-DE';
const expected = '1.234 $'.replace(' ', '\u00A0');
expect(widget.placeholder).toBe(expected);
});
it('should format numeric placeholder without decimal digits and rounding', () => {
widget.field.placeholder = '1234.55';
widget.currency = 'USD';
widget.currencyDisplay = 'symbol';
widget.decimalProperty = widget.notShowDecimalDigits;
widget.enableDisplayBasedOnLocale = true;
widget.locale = 'de-DE';
const expected = '1.235 $'.replace(' ', '\u00A0');
expect(widget.placeholder).toBe(expected);
});
});
describe('checkIfEmptyStringOrOnlySpaces', () => {
@@ -83,7 +83,7 @@ export class AmountWidgetComponent extends WidgetComponent implements OnInit {
if (isNaN(stringConvertedToNumber)) {
return this.field.placeholder;
}
return this.currencyPipe.transform(this.field.placeholder, this.currency, this.currencyDisplay, this.showDecimalDigits, this.locale);
return this.currencyPipe.transform(this.field.placeholder, this.currency, this.currencyDisplay, this.decimalProperty, this.locale);
}
constructor(