Skip to content

Commit 53c88d0

Browse files
authored
Merge pull request #31 from PowerInside/propwatcher
Add watcher for currency prop
2 parents acb4113 + e453dce commit 53c88d0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/vue-numeric.vue

+7
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,13 @@ export default {
270270
separator () {
271271
this.process(this.valueNumber)
272272
this.amount = this.format(this.valueNumber)
273+
},
274+
/**
275+
* Immediately reflect currency changes
276+
*/
277+
currency () {
278+
this.process(this.valueNumber)
279+
this.amount = this.format(this.valueNumber)
273280
}
274281
},
275282

test/specs/vue-numeric.spec.js

+6
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,10 @@ describe('vue-numeric.vue', () => {
212212
wrapper.setProps({ separator: '.' })
213213
expect(wrapper.data().amount).to.equal('2.000')
214214
})
215+
216+
it('apply new currency prop immediately if it is changed', () => {
217+
const wrapper = mount(VueNumeric, { propsData: { value: 0, currency: '$' } })
218+
wrapper.setProps({ currency: 'USD' })
219+
expect(wrapper.data().amount).to.equal('USD 0')
220+
})
215221
})

0 commit comments

Comments
 (0)