jonathanpmartins / v-money3

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

`allowBlank = true` should still allow submitting a 0 value #36

Closed AndrolGenhald closed 3 years ago

AndrolGenhald commented 3 years ago

I added a test for this in #34, but it's not working as expected. The demo here currently works as I would expect, if the input is blank and the user types a 0, the input changes to "0.00" (formatted according to the config), but my test currently fails. I'm not sure if this is because the test is broken or if the demo is using older code.

jonathanpmartins commented 3 years ago

The demo is using 3.16.0. This is why I setup puppeteer to test in the browser environment, I don't trust vue-test-utils 100% anymore.

jonathanpmartins commented 3 years ago

Is this a thing after the new release? 3.17.0

AndrolGenhald commented 3 years ago

It was already working in 3.16.0, I just wasn't sure because I never figured out how to test it properly in puppeteer. I'd like to add a test to make sure it stays working.

jonathanpmartins commented 3 years ago

I don't think this will be possible.

Take a look at this line: https://github.com/jonathanpmartins/v-money3/blob/7af0299e4c6660adc7bfa4059f10f0a294dba18c/src/format.js#L50

When the value is zero, it will return a blank value.

Tests are always welcome, feel free to improve upon it.