diff --git a/src/mask/number_mask.ts b/src/mask/number_mask.ts index 9b59dcbf72..76561463a2 100644 --- a/src/mask/number_mask.ts +++ b/src/mask/number_mask.ts @@ -77,7 +77,7 @@ export function splitString(str: string, reverse = false, n = 3): Array return arr; } -export function getNumberMaskedValue(str: string | number, mask: string, option?: INumberMaskOption): string { +export function getNumberMaskedValue(str: string | number, option?: INumberMaskOption): string { const decimalSeparator = option?.decimal || settings.numberOptions.decimal; const thousandsSeparator = option?.thousands || settings.numberOptions.thousands; const precision = option?.precision || settings.numberOptions.precision; @@ -93,7 +93,7 @@ export function getNumberMaskedValue(str: string | number, mask: string, option? } } -export function getNumberUnmaskedValue(str: string, mask: string, option?: INumberMaskOption): number { +export function getNumberUnmaskedValue(str: string, option?: INumberMaskOption): number { const decimalSeparator = option?.decimal || settings.numberOptions.decimal; const thousandsSeparator = option?.thousands || settings.numberOptions.thousands; const precision = option?.precision || settings.numberOptions.precision; @@ -115,12 +115,12 @@ export class InputMaskNumber extends InputMaskBase { } protected getMaskedValue(mask: string): string { - return getNumberMaskedValue(getNumberUnmaskedValue(this.input.value, mask, this.options), mask, this.options); + return getNumberMaskedValue(getNumberUnmaskedValue(this.input.value, this.options), this.options); } protected processMaskedValue(mask: string): IMaskedValue { // return processValueWithPattern(this.input.value, mask, this._prevSelectionStart, this.input.selectionStart); - const text = getNumberMaskedValue(getNumberUnmaskedValue(this.input.value, mask, this.options), mask, this.options); + const text = getNumberMaskedValue(getNumberUnmaskedValue(this.input.value, this.options), this.options); return { text: text, cursorPosition: this.input.selectionStart }; } } \ No newline at end of file diff --git a/tests/mask/mask_number_tests.ts b/tests/mask/mask_number_tests.ts index e3eb87963a..7709e2b8cf 100644 --- a/tests/mask/mask_number_tests.ts +++ b/tests/mask/mask_number_tests.ts @@ -43,26 +43,23 @@ QUnit.test("parsing numeric mask simple pattern", function(assert) { }); QUnit.test("get numeric masked valid text", function(assert) { - const customMask = "9+"; - assert.equal(getNumberMaskedValue(123, customMask), "123"); - assert.equal(getNumberMaskedValue(123456, customMask), "123,456"); - assert.equal(getNumberMaskedValue(123456.78, customMask), "123,456.78"); - assert.equal(getNumberMaskedValue(123456.789, customMask), "123,456.78"); + assert.equal(getNumberMaskedValue(123), "123"); + assert.equal(getNumberMaskedValue(123456), "123,456"); + assert.equal(getNumberMaskedValue(123456.78), "123,456.78"); + assert.equal(getNumberMaskedValue(123456.789), "123,456.78"); }); QUnit.test("get numeric masked invalid text", function(assert) { - const customMask = "9+"; - assert.equal(getNumberMaskedValue("", customMask), "0"); - assert.equal(getNumberMaskedValue("9", customMask), "9"); - assert.equal(getNumberMaskedValue("123A", customMask), "123"); - assert.equal(getNumberMaskedValue("123a", customMask), "123"); + assert.equal(getNumberMaskedValue(""), "0"); + assert.equal(getNumberMaskedValue("9"), "9"); + assert.equal(getNumberMaskedValue("123A"), "123"); + assert.equal(getNumberMaskedValue("123a"), "123"); }); QUnit.test("get numeric unmasked valid text", function(assert) { - const customMask = "9+"; - assert.equal(getNumberUnmaskedValue("123", customMask), 123); - assert.equal(getNumberUnmaskedValue("123,456", customMask), 123456); - assert.equal(getNumberUnmaskedValue("123,456.78", customMask), 123456.78); - assert.equal(getNumberUnmaskedValue("123,456.789", customMask), 123456.78); - assert.equal(getNumberUnmaskedValue("123,456,789,1011.12", customMask), 1234567891011.12); + assert.equal(getNumberUnmaskedValue("123"), 123); + assert.equal(getNumberUnmaskedValue("123,456"), 123456); + assert.equal(getNumberUnmaskedValue("123,456.78"), 123456.78); + assert.equal(getNumberUnmaskedValue("123,456.789"), 123456.78); + assert.equal(getNumberUnmaskedValue("123,456,789,101.12"), 123456789101.12); }); \ No newline at end of file