1- import Vue from 'vue' ;
2- Vue . config . productionTip = false ;
3- import VueNumeric from './../src/vue-numeric.vue' ;
1+ /* global beforeEach, expect, it, describe */
42
5- function getInput ( Component , propsData ) {
3+ import Vue from 'vue'
4+ import VueNumeric from './../src/vue-numeric.vue'
5+ Vue . config . productionTip = false
6+
7+ function getInput ( Component , propsData ) {
68 const Ctor = Vue . extend ( Component )
79 const vm = new Ctor ( { propsData : propsData } ) . $mount ( )
8- return vm . $el ;
10+ return vm . $el
911}
1012
11- describe ( "vue-numeric" , function ( ) {
12-
13- let el ;
13+ describe ( 'vue-numeric' , ( ) => {
14+ let el
1415
1516 beforeEach ( ( ) => {
16- el = document . createElement ( 'div' ) ;
17+ el = document . createElement ( 'div' )
1718
18- document . body . appendChild ( el ) ;
19- } ) ;
19+ document . body . appendChild ( el )
20+ } )
2021
21- it ( "Uses the default decimal separator ," , done => {
22-
23- var input = getInput ( VueNumeric , { value : '2000' } ) ;
22+ it ( 'Uses the default decimal separator ,' , done => {
23+ var input = getInput ( VueNumeric , { value : '2000' } )
2424 Vue . nextTick ( ( ) => {
2525 expect ( input . value ) . toEqual ( ' 2,000' )
2626 done ( )
27- } ) ;
28-
29- } ) ;
27+ } )
28+ } )
3029
3130 it ( 'updates value with format if without focus' , done => {
3231 const vm = new Vue ( {
3332 el,
34- data : function ( ) {
33+ data ( ) {
3534 return {
3635 total : 0
3736 }
@@ -40,19 +39,18 @@ describe("vue-numeric", function() {
4039 components : { VueNumeric }
4140 } ) . $mount ( )
4241
43- vm . total = 3000 ;
42+ vm . total = 3000
4443
4544 Vue . nextTick ( ( ) => {
4645 expect ( vm . $el . firstChild . value . trim ( ) ) . toEqual ( '3,000' )
4746 done ( )
48- } ) ;
49-
50- } ) ;
47+ } )
48+ } )
5149
5250 it ( 'updates values decimals' , done => {
5351 const vm = new Vue ( {
5452 el,
55- data : function ( ) {
53+ data ( ) {
5654 return {
5755 total : 0
5856 }
@@ -64,27 +62,25 @@ describe("vue-numeric", function() {
6462 components : { VueNumeric }
6563 } ) . $mount ( )
6664
67- vm . total = 3000 ;
65+ vm . total = 3000
6866
6967 Vue . nextTick ( ( ) => {
70- const span = vm . $el . getElementsByTagName ( 'span' ) [ 0 ] ;
71- expect ( span . textContent . trim ( ) ) . toEqual ( '3000' ) ;
68+ const span = vm . $el . getElementsByTagName ( 'span' ) [ 0 ]
69+ expect ( span . textContent . trim ( ) ) . toEqual ( '3000' )
7270 expect ( vm . $el . firstChild . value . trim ( ) ) . toEqual ( '3.000,00' )
7371 done ( )
74- } ) ;
75-
76- } ) ;
77-
72+ } )
73+ } )
7874
7975 it ( 'accepts decimal values' , done => {
8076 const vm = new Vue ( {
8177 el,
82- data : function ( ) {
78+ data ( ) {
8379 return {
8480 total : 200.22 ,
85- subtotal : " 110.98" ,
86- large : " 10.000,1"
87- } ;
81+ subtotal : ' 110.98' ,
82+ large : ' 10.000,1'
83+ }
8884 } ,
8985 template : `<div>
9086 <vue-numeric v-model="large" separator="." precision="2"></vue-numeric>
@@ -99,15 +95,13 @@ describe("vue-numeric", function() {
9995 expect ( vm . $el . children [ 1 ] . value . trim ( ) ) . toEqual ( '200,22' )
10096 expect ( vm . $el . children [ 2 ] . value . trim ( ) ) . toEqual ( '110.98' )
10197 done ( )
102- } ) ;
103-
104- } ) ;
105-
98+ } )
99+ } )
106100
107101 it ( 'updates values with correct separator' , done => {
108102 const vm = new Vue ( {
109103 el,
110- data : function ( ) {
104+ data ( ) {
111105 return {
112106 total : 0
113107 }
@@ -119,22 +113,20 @@ describe("vue-numeric", function() {
119113 components : { VueNumeric }
120114 } ) . $mount ( )
121115
122- vm . total = 3000 ;
116+ vm . total = 3000
123117
124118 Vue . nextTick ( ( ) => {
125- const span = vm . $el . getElementsByTagName ( 'span' ) [ 0 ] ;
126- expect ( span . textContent . trim ( ) ) . toEqual ( '3000' ) ;
119+ const span = vm . $el . getElementsByTagName ( 'span' ) [ 0 ]
120+ expect ( span . textContent . trim ( ) ) . toEqual ( '3000' )
127121 expect ( vm . $el . firstChild . value . trim ( ) ) . toEqual ( '3.000' )
128122 done ( )
129- } ) ;
130-
131- } ) ;
132-
123+ } )
124+ } )
133125
134126 it ( 'updates value without format' , done => {
135127 const vm = new Vue ( {
136128 el,
137- data : function ( ) {
129+ data ( ) {
138130 return {
139131 total : 0
140132 }
@@ -143,15 +135,12 @@ describe("vue-numeric", function() {
143135 components : { VueNumeric }
144136 } ) . $mount ( )
145137
146- vm . $el . firstChild . focus ( ) ;
147- vm . total = 3000 ;
138+ vm . $el . firstChild . focus ( )
139+ vm . total = 3000
148140
149141 Vue . nextTick ( ( ) => {
150- expect ( vm . $el . firstChild . value . trim ( ) ) . toEqual ( '3000' ) ;
142+ expect ( vm . $el . firstChild . value . trim ( ) ) . toEqual ( '3000' )
151143 done ( )
152- } ) ;
153-
154- } ) ;
155-
156-
157- } ) ;
144+ } )
145+ } )
146+ } )
0 commit comments