From f7f267f9fa391352d45a0ec82a00ee1673232832 Mon Sep 17 00:00:00 2001 From: Irfan Date: Sun, 17 Sep 2017 19:57:49 +0530 Subject: [PATCH 1/2] Add docblocks for separator watcher prop --- src/vue-numeric.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/vue-numeric.vue b/src/vue-numeric.vue index 3702dce..f2af4d1 100644 --- a/src/vue-numeric.vue +++ b/src/vue-numeric.vue @@ -263,8 +263,13 @@ export default { }) } }, - - separator(newValue, oldValue) { + + /** + * Immediately reflect separator changes + * @param {String} newValue + * @param {String} oldValue + */ + separator (newValue, oldValue) { if (newValue !== oldValue) { this.process(this.valueNumber) this.amount = this.format(this.valueNumber) From 3204dd7d283534af750232da23de9710c85f932f Mon Sep 17 00:00:00 2001 From: Irfan Date: Sun, 17 Sep 2017 19:46:29 +0530 Subject: [PATCH 2/2] Add test for separator prop watcher --- test/specs/vue-numeric.spec.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/specs/vue-numeric.spec.js b/test/specs/vue-numeric.spec.js index 2aab62f..40ec775 100644 --- a/test/specs/vue-numeric.spec.js +++ b/test/specs/vue-numeric.spec.js @@ -206,4 +206,10 @@ describe('vue-numeric.vue', () => { const wrapper = mount(component) expect(wrapper.data().total).to.equal(0) }) + + it('apply new separator immediately if it is changed', () => { + const wrapper = mount(VueNumeric, { propsData: { value: 2000, separator: "," } }) + wrapper.setProps({ separator: "." }) + expect(wrapper.data().amount).to.equal("2.000") + }) })