jonathanpmartins / v-money3

Vue3 currency input/directive mask
MIT License
103 stars 27 forks source link

Input is unusable with US format and no prefix. #22

Closed AndrolGenhald closed 3 years ago

AndrolGenhald commented 3 years ago

https://codesandbox.io/s/v-money3-use-as-directive-forked-j6blc?file=/src/App.vue

Configuring decimal to ".", thousands to ",", and prefix to "", the input doesn't work properly. Entering 9 repeatedly increments it by 1 cent. Setting prefix to "$" or setting decimal to "," and thousands to "." avoids the issue.

jonathanpmartins commented 3 years ago

Thanks for reporting the issue! The old tests did not catch this problem!

Fixed in 3.14.1 version.

AndrolGenhald commented 3 years ago

Thanks for the quick fix!

jonathanpmartins commented 3 years ago

This was a strange problem. If you try to checkout the 3.13.9 tag/version...

git checkout tags/v3.13.9

Add this test:

test('Test if US format works correctly', async () => {
    const input = mountComponent({
        decimal: '.',
        thousands: ',',
        precision: 2,
    }).find('input');

    await input.setValue('1513.15');

    expect(input.element.value).toBe('1,513.15');
});

It will run and pass the test. Buuuuu :( In this version there is a clear problem in the browser that the vue-test-utils could not catch. I'm planning to create tests with puppeteer so this types of problems will no longer get shipped to production.