diff --git a/packages/dnb-eufemia/src/components/input-masked/__tests__/InputMasked.test.tsx b/packages/dnb-eufemia/src/components/input-masked/__tests__/InputMasked.test.tsx index b692d72b639..760fd63d89d 100644 --- a/packages/dnb-eufemia/src/components/input-masked/__tests__/InputMasked.test.tsx +++ b/packages/dnb-eufemia/src/components/input-masked/__tests__/InputMasked.test.tsx @@ -1412,6 +1412,33 @@ describe('InputMasked component as_currency', () => { expect(document.querySelector('input').value).toBe('12 345,67 kr') }) + it('should prevent a comma when decimalLimit=0', () => { + render() + + const preventDefault = jest.fn() + const event = { preventDefault } + + const newValue = '12 345' + + fireEvent.change(document.querySelector('input'), { + target: { value: newValue }, + ...event, + }) + + const pressDotAndUseItAscomma = () => { + const keyCode = 188 // comma + fireEvent.keyDown(document.querySelector('input'), { + keyCode, + ...event, + }) + } + + pressDotAndUseItAscomma() + pressDotAndUseItAscomma() // try a second time + + expect(document.querySelector('input').value).toBe('12 345 kr') + }) + it('should inherit currency_mask from provider', () => { const { rerender } = render(