Skip to content

Commit

Permalink
#10663: edit unit test in IntlNumberFormatControl-test.jsx to fix FE …
Browse files Browse the repository at this point in the history
…failure
  • Loading branch information
mahmoudadel54 committed Nov 12, 2024
1 parent 58e7e6c commit 462b679
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ describe('IntlNumberFormControl', () => {
TestUtils.Simulate.change(element, {target: {value: '12.'}});
expect(element.value).toBe("12");
TestUtils.Simulate.change(element, {target: {value: '12.0'}});
expect(element.value).toBe("12");
expect(element.value).toBe("12.0");
TestUtils.Simulate.change(element, {target: {value: '12.04'}});
expect(element.value).toBe("12.04");
TestUtils.Simulate.change(element, {target: {value: '12.402'}});
expect(element.value).toBe("12.402");
TestUtils.Simulate.change(element, {target: {value: '-12.04'}});
expect(element.value).toBe("-12.04");
TestUtils.Simulate.change(element, {target: {value: '-12.40'}});
expect(element.value).toBe("-12.4");
expect(element.value).toBe("-12.40");
TestUtils.Simulate.change(element, {target: {value: '-12.0'}});
expect(element.value).toBe("-12");
expect(element.value).toBe("-12.0");
});
it('check calling passed onkeydown, onkeyup events', () => {
const intl = {locale: "en-US"};
Expand Down
6 changes: 3 additions & 3 deletions web/client/libs/numeric-input/NumericInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,10 @@ class NumericInput extends Component {
const escapedDecimalSymbol = decimalSymbol.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const RE_TRAILING_DECIMAL_ZEROS = new RegExp(`\\d+${escapedDecimalSymbol}\\d*0+`);

// incomplete number
if (loose && RE_INCOMPLETE_NUMBER.test(stringValue)) {
// incomplete number or number contains decimal symbol [centesimal decimal numbers]
if ((loose && RE_INCOMPLETE_NUMBER.test(stringValue)) || RE_TRAILING_DECIMAL_ZEROS.test(stringValue)) {
attrs.input.value = stringValue;
} else if ((loose && stringValue && !RE_NUMBER.test(stringValue)) || RE_TRAILING_DECIMAL_ZEROS.test(stringValue)) {// Not a number and not empty (loose mode only) || if number contains decimal symbol [centesimal decimal numbers]
} else if ((loose && stringValue && !RE_NUMBER.test(stringValue))) {// Not a number and not empty (loose mode only)
attrs.input.value = stringValue;
} else if (state.value || state.value === 0) { // number
attrs.input.value = this._format(state.value);
Expand Down

0 comments on commit 462b679

Please sign in to comment.