Skip to content

Commit fed21b0

Browse files
committed
eslint fix
1 parent 53cbda1 commit fed21b0

File tree

3 files changed

+83
-95
lines changed

3 files changed

+83
-95
lines changed

karma.conf.js

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
11
// https://github.com/Nikku/karma-browserify
22

3-
module.exports = function(config) {
4-
5-
config.set({
6-
browsers: [
7-
'PhantomJS',
8-
// 'Chrome'
9-
],
10-
frameworks: ['jasmine'],
11-
files: ['spec/**/*.js'],
12-
reporters: ['spec'],
13-
preprocessors: {
14-
'spec/**/*.js': ['webpack']
15-
},
16-
webpack: {
17-
resolve: {
18-
alias: {
19-
'vue$': 'vue/dist/vue'
20-
}
21-
},
22-
module: {
23-
rules: [{
24-
test: /\.vue$/,
25-
loader: 'vue-loader'
26-
}, {
27-
test: /\.js$/,
28-
loader: 'babel-loader',
29-
exclude: /node_modules/
30-
}]
31-
}
32-
},
33-
// if you want to continuously re-run tests on file-save,
34-
// replace the following line with `autoWatch: true`
35-
singleRun: true
36-
})
3+
module.exports = config => {
4+
config.set({
5+
browsers: [
6+
'PhantomJS'
7+
// 'Chrome'
8+
],
9+
frameworks: ['jasmine'],
10+
files: ['spec/**/*.js'],
11+
reporters: ['spec'],
12+
preprocessors: {
13+
'spec/**/*.js': ['webpack']
14+
},
15+
webpack: {
16+
resolve: {
17+
alias: {
18+
'vue$': 'vue/dist/vue'
19+
}
20+
},
21+
module: {
22+
rules: [{
23+
test: /\.vue$/,
24+
loader: 'vue-loader'
25+
}, {
26+
test: /\.js$/,
27+
loader: 'babel-loader',
28+
exclude: /node_modules/
29+
}]
30+
}
31+
},
32+
// if you want to continuously re-run tests on file-save,
33+
// replace the following line with `autoWatch: true`
34+
singleRun: true
35+
})
3736
}

spec/vue_numeric.spec.js

Lines changed: 45 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
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+
})

src/vue-numeric.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ export default {
183183
let number = 0
184184
185185
if (this.separator === '.') {
186-
let cleanValue = value;
187-
if (typeof value != 'string') {
188-
cleanValue = this.numberToString(value);
186+
let cleanValue = value
187+
if (typeof value !== 'string') {
188+
cleanValue = this.numberToString(value)
189189
}
190190
number = Number(String(cleanValue).replace(/[^0-9-,]+/g, '').replace(',', '.'))
191191
} else {
@@ -250,7 +250,7 @@ export default {
250250
* @param {Number} value
251251
*/
252252
convertToNumber (value) {
253-
this.amount = this.numberToString(value);
253+
this.amount = this.numberToString(value)
254254
}
255255
},
256256
@@ -263,7 +263,7 @@ export default {
263263
numberValue (val, oldVal) {
264264
if (this.amountValue !== val && this.amountValue === oldVal) {
265265
this.convertToNumber(val)
266-
if (this.$el !== document.activeElement) {
266+
if (this.$refs.numeric !== document.activeElement) {
267267
this.formatValue(val)
268268
}
269269
}

0 commit comments

Comments
 (0)