File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -28,5 +28,49 @@ describe("vue-numeric", function() {
2828
2929 } ) ;
3030
31+ it ( 'updates value with format if without focus' , done => {
32+ const vm = new Vue ( {
33+ el,
34+ data : function ( ) {
35+ return {
36+ total : 0
37+ }
38+ } ,
39+ template : '<div><vue-numeric v-model="total"></vue-numeric></div>' ,
40+ components : { VueNumeric }
41+ } ) . $mount ( )
42+
43+ vm . total = 3000 ;
44+
45+ Vue . nextTick ( ( ) => {
46+ expect ( vm . $el . firstChild . value . trim ( ) ) . toEqual ( '3,000' )
47+ done ( )
48+ } ) ;
49+
50+ } ) ;
51+
52+
53+ it ( 'updates value without format' , done => {
54+ const vm = new Vue ( {
55+ el,
56+ data : function ( ) {
57+ return {
58+ total : 0
59+ }
60+ } ,
61+ template : '<div><vue-numeric v-model="total"></vue-numeric></div>' ,
62+ components : { VueNumeric }
63+ } ) . $mount ( )
64+
65+ vm . $el . firstChild . focus ( ) ;
66+ vm . total = 3000 ;
67+
68+ Vue . nextTick ( ( ) => {
69+ expect ( vm . $el . firstChild . value . trim ( ) ) . toEqual ( '3000' ) ;
70+ done ( )
71+ } ) ;
72+
73+ } ) ;
74+
3175
3276} ) ;
Original file line number Diff line number Diff line change @@ -251,6 +251,9 @@ export default {
251251 numberValue (val , oldVal ) {
252252 if (this .amountValue !== val && this .amountValue === oldVal) {
253253 this .convertToNumber (val)
254+ if (this .$el !== document .activeElement ) {
255+ this .formatValue (val)
256+ }
254257 }
255258 }
256259 },
You can’t perform that action at this time.
0 commit comments