@@ -49,6 +49,87 @@ describe("vue-numeric", function() {
4949
5050 } ) ;
5151
52+ it ( 'updates values decimals' , done => {
53+ const vm = new Vue ( {
54+ el,
55+ data : function ( ) {
56+ return {
57+ total : 0
58+ }
59+ } ,
60+ template : `<div>
61+ <vue-numeric v-model="total" separator="." precision="2"></vue-numeric>
62+ <span>{{total}}</span>
63+ </div>` ,
64+ components : { VueNumeric }
65+ } ) . $mount ( )
66+
67+ vm . total = 3000 ;
68+
69+ Vue . nextTick ( ( ) => {
70+ const span = vm . $el . getElementsByTagName ( 'span' ) [ 0 ] ;
71+ expect ( span . textContent . trim ( ) ) . toEqual ( '3000' ) ;
72+ expect ( vm . $el . firstChild . value . trim ( ) ) . toEqual ( '3.000,00' )
73+ done ( )
74+ } ) ;
75+
76+ } ) ;
77+
78+
79+ it ( 'accepts decimal values' , done => {
80+ const vm = new Vue ( {
81+ el,
82+ data : function ( ) {
83+ return {
84+ total : 200.22 ,
85+ subtotal : "110.98" ,
86+ large : "10.000,1"
87+ } ;
88+ } ,
89+ template : `<div>
90+ <vue-numeric v-model="large" separator="." precision="2"></vue-numeric>
91+ <vue-numeric v-model="total" separator="." precision="2"></vue-numeric>
92+ <vue-numeric v-model="subtotal" precision="2"></vue-numeric>
93+ </div>` ,
94+ components : { VueNumeric }
95+ } ) . $mount ( )
96+
97+ Vue . nextTick ( ( ) => {
98+ expect ( vm . $el . children [ 0 ] . value . trim ( ) ) . toEqual ( '10.000,10' )
99+ expect ( vm . $el . children [ 1 ] . value . trim ( ) ) . toEqual ( '200,22' )
100+ expect ( vm . $el . children [ 2 ] . value . trim ( ) ) . toEqual ( '110.98' )
101+ done ( )
102+ } ) ;
103+
104+ } ) ;
105+
106+
107+ it ( 'updates values with correct separator' , done => {
108+ const vm = new Vue ( {
109+ el,
110+ data : function ( ) {
111+ return {
112+ total : 0
113+ }
114+ } ,
115+ template : `<div>
116+ <vue-numeric v-model="total" separator="."></vue-numeric>
117+ <span>{{total}}</span>
118+ </div>` ,
119+ components : { VueNumeric }
120+ } ) . $mount ( )
121+
122+ vm . total = 3000 ;
123+
124+ Vue . nextTick ( ( ) => {
125+ const span = vm . $el . getElementsByTagName ( 'span' ) [ 0 ] ;
126+ expect ( span . textContent . trim ( ) ) . toEqual ( '3000' ) ;
127+ expect ( vm . $el . firstChild . value . trim ( ) ) . toEqual ( '3.000' )
128+ done ( )
129+ } ) ;
130+
131+ } ) ;
132+
52133
53134 it ( 'updates value without format' , done => {
54135 const vm = new Vue ( {
0 commit comments