Skip to content

Commit ef52a17

Browse files
committed
updated test unit
1 parent 565e455 commit ef52a17

10 files changed

+39
-42
lines changed

tests/component/component.custom.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ describe('VueNumber custom config', () => {
1414
})
1515

1616
const input = wrapper.find('input')
17+
expect(input.element.value).toBe('Rs.123.456,89%')
1718

19+
input.element.value = 123456.893
1820
await input.trigger('input')
1921
expect(wrapper.vm.unmaskedValue).toBe('123456.89')
20-
expect(wrapper.vm.maskedValue).toBe('Rs.123.456,89%')
22+
expect(wrapper.vm.maskedValue).toBe('Rs.123.456,893%')
2123

2224
await input.trigger('blur')
2325
expect(wrapper.vm.unmaskedValue).toBe('123456.89')

tests/component/component.minimumFractionDigits.spec.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,24 @@ describe('VueNumber with minimum fraction digits', () => {
1111
})
1212

1313
const input = wrapper.find('input')
14+
expect(input.element.value).toBe('123,456.89')
1415

16+
input.element.value = '123456.893'
1517
await input.trigger('input')
1618
expect(wrapper.vm.unmaskedValue).toBe('123456.89')
17-
expect(wrapper.vm.maskedValue).toBe('123,456.89')
19+
expect(wrapper.vm.maskedValue).toBe('123,456.893')
1820

1921
await input.trigger('blur')
2022
expect(wrapper.vm.unmaskedValue).toBe('123456.89')
2123
expect(wrapper.vm.maskedValue).toBe('123,456.89')
2224

23-
input.element.value = '1234.5'
25+
input.element.value = '1234.509'
2426
await input.trigger('input')
25-
expect(wrapper.vm.unmaskedValue).toBe('1234.5')
26-
expect(wrapper.vm.maskedValue).toBe('1,234.5')
27+
expect(wrapper.vm.unmaskedValue).toBe('1234.51')
28+
expect(wrapper.vm.maskedValue).toBe('1,234.509')
2729

2830
await input.trigger('blur')
29-
expect(wrapper.vm.unmaskedValue).toBe('1234.5')
30-
expect(wrapper.vm.maskedValue).toBe('1,234.50')
31+
expect(wrapper.vm.unmaskedValue).toBe('1234.51')
32+
expect(wrapper.vm.maskedValue).toBe('1,234.51')
3133
})
3234
})

tests/component/component.range.spec.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,29 @@ describe('VueNumber within range', () => {
55
test('should emit input event with the new maskedValue and unmaskedValue on input', async () => {
66
const wrapper = mount(VueNumber, {
77
propsData: {
8-
value: 1.893,
8+
value: 1234.893,
99
min: 0,
10-
max: 50
10+
max: 2000
1111
}
1212
})
1313

1414
const input = wrapper.find('input')
15+
expect(input.element.value).toBe('1,234.89')
1516

17+
input.element.value = 1238.893
18+
await input.trigger('input')
1619
await input.trigger('blur')
17-
expect(wrapper.vm.unmaskedValue).toBe('1.89')
18-
expect(wrapper.vm.maskedValue).toBe('1.89')
20+
expect(wrapper.vm.unmaskedValue).toBe('1238.89')
21+
expect(wrapper.vm.maskedValue).toBe('1,238.89')
1922

2023
input.element.value = '1234.568'
2124
await input.trigger('blur')
22-
expect(wrapper.vm.unmaskedValue).toBe('50')
23-
expect(wrapper.vm.maskedValue).toBe('50')
25+
expect(wrapper.vm.unmaskedValue).toBe('1234.57')
26+
expect(wrapper.vm.maskedValue).toBe('1,234.57')
2427

2528
input.element.value = '-1234.568'
2629
await input.trigger('blur')
2730
expect(wrapper.vm.unmaskedValue).toBe('0')
2831
expect(wrapper.vm.maskedValue).toBe('0')
29-
30-
input.element.value = '12.568'
31-
await input.trigger('blur')
32-
expect(wrapper.vm.unmaskedValue).toBe('12.57')
33-
expect(wrapper.vm.maskedValue).toBe('12.57')
3432
})
3533
})

tests/component/component.reverseFill.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ describe('VueNumber reverse fill', () => {
1111
})
1212

1313
const input = wrapper.find('input')
14+
expect(input.element.value).toBe('123,456.89')
1415

16+
input.element.value = 123456.893
1517
await input.trigger('input')
16-
expect(wrapper.vm.unmaskedValue).toBe('123456.89')
17-
expect(wrapper.vm.maskedValue).toBe('123,456.89')
18+
expect(wrapper.vm.unmaskedValue).toBe('1234568.93')
19+
expect(wrapper.vm.maskedValue).toBe('1,234,568.93')
1820

1921
await input.trigger('blur')
20-
expect(wrapper.vm.unmaskedValue).toBe('123456.89')
21-
expect(wrapper.vm.maskedValue).toBe('123,456.89')
22+
expect(wrapper.vm.unmaskedValue).toBe('1234568.93')
23+
expect(wrapper.vm.maskedValue).toBe('1,234,568.93')
2224

2325
input.element.value = '1234568'
2426
await input.trigger('input')

tests/component/component.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ describe('VueNumber', () => {
1919
})
2020

2121
const input = wrapper.find('input')
22+
expect(input.element.value).toBe('123,456.89')
2223

24+
input.element.value = 123456.893
2325
await input.trigger('input')
2426
expect(wrapper.vm.unmaskedValue).toBe('123456.89')
25-
expect(wrapper.vm.maskedValue).toBe('123,456.89')
27+
expect(wrapper.vm.maskedValue).toBe('123,456.893')
2628

2729
await input.trigger('blur')
2830
expect(wrapper.vm.unmaskedValue).toBe('123456.89')

tests/directive/directive.custom.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ describe('v-number directive', () => {
2222
})
2323

2424
const input = wrapper.find('input')
25-
26-
await input.trigger('input')
2725
expect(input.element.value).toBe('Rs.123.456,89%')
2826

2927
await input.trigger('blur')

tests/directive/directive.minimumFractionDigits.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ describe('v-number directive', () => {
1919
})
2020

2121
const input = wrapper.find('input')
22-
23-
await input.trigger('input')
2422
expect(input.element.value).toBe('123,456.89')
2523

2624
await input.trigger('blur')

tests/directive/directive.range.spec.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,28 @@ describe('v-number directive', () => {
1010
},
1111
data() {
1212
return {
13-
value: 1.53,
13+
value: 1234.53,
1414
options: {
1515
min: 0,
16-
max: 50
16+
max: 2000
1717
}
1818
}
1919
}
2020
})
2121

2222
const input = wrapper.find('input')
23+
expect(input.element.value).toBe('1,234.53')
2324

24-
await input.trigger('input')
25-
expect(input.element.value).toBe('1.53')
26-
27-
input.element.value = '1234.529'
25+
input.element.value = '2234.529'
2826
await input.trigger('blur')
29-
expect(input.element.value).toBe('50')
27+
expect(input.element.value).toBe('2,000')
3028

3129
input.element.value = '-1234.568'
3230
await input.trigger('blur')
3331
expect(input.element.value).toBe('0')
3432

35-
input.element.value = '12.568'
33+
input.element.value = '1234.568'
3634
await input.trigger('blur')
37-
expect(input.element.value).toBe('12.57')
35+
expect(input.element.value).toBe('1,234.57')
3836
})
3937
})

tests/directive/directive.reverseFill.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ describe('v-number directive', () => {
1919
})
2020

2121
const input = wrapper.find('input')
22-
await input.trigger('input')
2322
expect(input.element.value).toBe('1,234.50')
2423

2524
input.element.value = '1234.529'

tests/directive/directive.spec.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,21 @@ describe('v-number directive', () => {
1010
},
1111
data() {
1212
return {
13-
value: '',
13+
value: '1234.536',
1414
options: {}
1515
}
1616
}
1717
})
1818

1919
const input = wrapper.find('input')
20-
21-
input.element.value = '1234'
22-
await input.trigger('input')
23-
expect(input.element.value).toBe('1,234')
20+
expect(input.element.value).toBe('1,234.54')
2421

2522
input.element.value = '1234.529'
2623
await input.trigger('input')
2724
expect(input.element.value).toBe('1,234.529')
2825

2926
await input.trigger('blur')
3027
expect(input.element.value).toBe('1,234.53')
28+
expect(input.element.oldValue).toBe('1,234.53')
3129
})
3230
})

0 commit comments

Comments
 (0)