Skip to content

Commit

Permalink
fix: When the value is cleared externally, maskedValue is not cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
lijufeng-patsnap committed Aug 31, 2023
1 parent 2c168e3 commit edce71c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/component.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default Vue.extend({
data() {
return {
maskedValue: this.value,
unmaskedValue: '' as Input | undefined
unmaskedValue: this.value as Input | undefined
}
},
computed: {
Expand Down
12 changes: 12 additions & 0 deletions tests/component/component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ describe('VueNumber', () => {
expect(wrapper.contains('input')).toBe(true)
})

test('When the value is cleared externally, maskedValue should also be cleared', async () => {
const wrapper = mount(VueNumber, {
propsData: {
value: '1234.536'
}
})

await wrapper.setProps({ value: '' })

expect(wrapper.vm.maskedValue).toBe('')
})

test('should emit input event with the new maskedValue and unmaskedValue on input', async () => {
const wrapper = mount(VueNumber, {
propsData: {
Expand Down

0 comments on commit edce71c

Please sign in to comment.