Skip to content

Commit f90d9dd

Browse files
authored
Merge pull request #2 from PowerInside/fix_morloderex_pr
added tests and docblocks
2 parents dc28b47 + 3204dd7 commit f90d9dd

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/vue-numeric.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,18 @@ export default {
262262
this.$refs.readOnly.className = this.readOnlyClass
263263
})
264264
}
265+
},
266+
267+
/**
268+
* Immediately reflect separator changes
269+
* @param {String} newValue
270+
* @param {String} oldValue
271+
*/
272+
separator (newValue, oldValue) {
273+
if (newValue !== oldValue) {
274+
this.process(this.valueNumber)
275+
this.amount = this.format(this.valueNumber)
276+
}
265277
}
266278
},
267279

test/specs/vue-numeric.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,10 @@ describe('vue-numeric.vue', () => {
206206
const wrapper = mount(component)
207207
expect(wrapper.data().total).to.equal(0)
208208
})
209+
210+
it('apply new separator immediately if it is changed', () => {
211+
const wrapper = mount(VueNumeric, { propsData: { value: 2000, separator: "," } })
212+
wrapper.setProps({ separator: "." })
213+
expect(wrapper.data().amount).to.equal("2.000")
214+
})
209215
})

0 commit comments

Comments
 (0)