Skip to content

Commit 1dff8c4

Browse files
committed
add more tests
1 parent b90670c commit 1dff8c4

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

spec/vue_numeric.spec.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,76 @@ describe('vue-numeric', () => {
189189
done()
190190
})
191191
})
192+
193+
it('allow minus value when minus props is true', done => {
194+
const vm = new Vue({
195+
el,
196+
data () {
197+
return {
198+
total: -100
199+
}
200+
},
201+
template: '<div><vue-numeric v-model="total" :minus="true"></vue-numeric></div>',
202+
components: { VueNumeric }
203+
}).$mount()
204+
205+
Vue.nextTick(() => {
206+
expect(vm.$el.firstChild.value.trim()).toEqual('-100')
207+
done()
208+
})
209+
})
210+
211+
it('disallow minus value when minus props is false', done => {
212+
const vm = new Vue({
213+
el,
214+
data () {
215+
return {
216+
total: -100
217+
}
218+
},
219+
template: '<div><vue-numeric v-model="total" :minus="false"></vue-numeric></div>',
220+
components: { VueNumeric }
221+
}).$mount()
222+
223+
Vue.nextTick(() => {
224+
expect(vm.$el.firstChild.value.trim()).toEqual('100')
225+
done()
226+
})
227+
})
228+
229+
it('value cannot exceed max props', done => {
230+
const vm = new Vue({
231+
el,
232+
data () {
233+
return {
234+
total: 150
235+
}
236+
},
237+
template: '<div><vue-numeric v-model="total" :max="100"></vue-numeric></div>',
238+
components: { VueNumeric }
239+
}).$mount()
240+
241+
Vue.nextTick(() => {
242+
expect(vm.$el.firstChild.value.trim()).toEqual('100')
243+
done()
244+
})
245+
})
246+
247+
it('value cannot below min props', done => {
248+
const vm = new Vue({
249+
el,
250+
data () {
251+
return {
252+
total: 150
253+
}
254+
},
255+
template: '<div><vue-numeric v-model="total" :min="200"></vue-numeric></div>',
256+
components: { VueNumeric }
257+
}).$mount()
258+
259+
Vue.nextTick(() => {
260+
expect(vm.$el.firstChild.value.trim()).toEqual('200')
261+
done()
262+
})
263+
})
192264
})

0 commit comments

Comments
 (0)