Skip to content

Commit

Permalink
2.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Ongko authored and Kevin Ongko committed Oct 13, 2017
1 parent 5ae893f commit 1ea3f2d
Show file tree
Hide file tree
Showing 6 changed files with 237 additions and 143 deletions.
2 changes: 1 addition & 1 deletion dist/vue-numeric.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ <h1 class="title is-4">

<script src="https://unpkg.com/accounting-js"></script>
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/vue-numeric"></script>
<script src="../dist/vue-numeric.min.js"></script>

<script>
Vue.use(VueNumeric.default)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-numeric",
"version": "2.2.2",
"version": "2.2.3",
"description": "Input field component to display currency value based on Vue.",
"author": "Kevin Ongko",
"main": "dist/vue-numeric.min.js",
Expand Down
8 changes: 7 additions & 1 deletion src/vue-numeric.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,13 @@ export default {
*/
onFocusHandler (e) {
this.$emit('focus', e)
this.amount = this.valueNumber
this.amount = accounting.formatMoney(this.valueNumber, {
symbol: '',
format: '%v',
thousand: '',
decimal: this.decimalSeparator,
precision: Number(this.precision)
})
},
/**
Expand Down
16 changes: 11 additions & 5 deletions test/specs/vue-numeric.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,25 @@ describe('vue-numeric.vue', () => {
expect(wrapper.data().amount).to.equal('2,000')
})

it('trigger onBlurHandler', () => {
it('format value on blur', () => {
const wrapper = mount(VueNumeric, {propsData: { value: 2000 }})
wrapper.trigger('blur')
expect(wrapper.data().amount).to.equal('2,000')
})

it('trigger onFocusHandler', () => {
const wrapper = mount(VueNumeric, {propsData: { value: 2000 }})
it('remove thousand separator and symbol on focus with , decimal', () => {
const wrapper = mount(VueNumeric, {propsData: { value: 2000.21, separator: '.', precision: 2 }})
wrapper.trigger('focus')
expect(wrapper.data().amount).to.equal('2000,21')
})

it('remove thousand separator and symbol on focus with . decimal', () => {
const wrapper = mount(VueNumeric, {propsData: { value: 2000.21, separator: ',', precision: 2 }})
wrapper.trigger('focus')
expect(wrapper.data().amount).to.equal(2000)
expect(wrapper.data().amount).to.equal('2000.21')
})

it('trigger onInputHandler', () => {
it('process value on input', () => {
const process = sinon.stub()
const wrapper = mount(VueNumeric, { propsData: { value: 2000 }, methods: { process }})
wrapper.trigger('input')
Expand Down
Loading

0 comments on commit 1ea3f2d

Please sign in to comment.