Skip to content

Commit

Permalink
Test and lint for emit change event (#94)
Browse files Browse the repository at this point in the history
Co-authored-by: Rodionov Maxim <m.rodionov@corp.mail.ru>
  • Loading branch information
subtronic and Rodionov Maxim committed Mar 19, 2021
1 parent dcf4e98 commit 5a6e946
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/vue-numeric.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<template>
<input
v-if="!readOnly"
ref="numeric"
:placeholder="placeholder"
v-model="amount"
type="tel"
@blur="onBlurHandler"
@input="onInputHandler"
@focus="onFocusHandler"
ref="numeric"
type="tel"
v-model="amount"
v-if="!readOnly"
@change="onChangeHandler"
>
<span
v-else
Expand Down Expand Up @@ -283,6 +284,13 @@ export default {
},
methods: {
/**
* Handle change event.
* @param {Object} e
*/
onChangeHandler (e) {
this.$emit('change', e)
},
/**
* Handle blur event.
* @param {Object} e
Expand Down
6 changes: 6 additions & 0 deletions test/specs/vue-numeric.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,10 @@ describe('vue-numeric.vue', () => {
})
expect(wrapper.data().amount).to.equal('1 000,94')
})
it('emit change event', () => {
const process = sinon.stub()
const wrapper = mount(VueNumeric, { propsData: { value: 2000 }, methods: { process }})
wrapper.trigger('change')
expect(process.called).to.equal(true)
})
})

0 comments on commit 5a6e946

Please sign in to comment.