@@ -2,7 +2,16 @@ import { mount } from '@vue/test-utils'
22import VueNumber from '../../src/component.vue'
33
44describe ( 'VueNumber' , ( ) => {
5- test ( 'should emit input event with the new value on input' , async ( ) => {
5+ it ( 'renders an input element' , ( ) => {
6+ const wrapper = mount ( VueNumber , {
7+ propsData : {
8+ value : '123'
9+ }
10+ } )
11+ expect ( wrapper . contains ( 'input' ) ) . toBe ( true )
12+ } )
13+
14+ test ( 'should emit input event with the new maskedValue on input' , async ( ) => {
615 const wrapper = mount ( VueNumber , {
716 propsData : {
817 value : 123456.893
@@ -29,4 +38,32 @@ describe('VueNumber', () => {
2938
3039 expect ( wrapper . vm . maskedValue ) . toBe ( '1,234.57' )
3140 } )
41+
42+ test ( 'should emit input event with the new unmaskedValue on input' , async ( ) => {
43+ const wrapper = mount ( VueNumber , {
44+ propsData : {
45+ value : 123456.893
46+ }
47+ } )
48+
49+ const input = wrapper . find ( 'input' )
50+
51+ await input . trigger ( 'input' )
52+
53+ expect ( wrapper . vm . unmaskedValue ) . toBe ( '123456.89' )
54+
55+ await input . trigger ( 'blur' )
56+
57+ expect ( wrapper . vm . unmaskedValue ) . toBe ( '123456.89' )
58+
59+ input . element . value = '1234.568'
60+
61+ await input . trigger ( 'input' )
62+
63+ expect ( wrapper . vm . unmaskedValue ) . toBe ( '1234.57' )
64+
65+ await input . trigger ( 'blur' )
66+
67+ expect ( wrapper . vm . unmaskedValue ) . toBe ( '1234.57' )
68+ } )
3269} )
0 commit comments