Skip to content

Commit 054df0a

Browse files
committed
updated test script
1 parent edfbeac commit 054df0a

10 files changed

+29
-208
lines changed

tests/component/component.custom.spec.ts

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { mount } from '@vue/test-utils'
22
import VueNumber from '../../src/component.vue'
33

44
describe('VueNumber custom config', () => {
5-
test('should emit input event with the new maskedValue on input', async () => {
5+
test('should emit input event with the new maskedValue and unmaskedValue on input', async () => {
66
const wrapper = mount(VueNumber, {
77
propsData: {
88
value: 123456.893,
@@ -16,53 +16,20 @@ describe('VueNumber custom config', () => {
1616
const input = wrapper.find('input')
1717

1818
await input.trigger('input')
19-
20-
expect(wrapper.vm.maskedValue).toBe('Rs.123.456,893%')
21-
22-
await input.trigger('blur')
23-
24-
expect(wrapper.vm.maskedValue).toBe('Rs.123.456,89%')
25-
26-
input.element.value = 1234.568
27-
28-
await input.trigger('input')
29-
30-
expect(wrapper.vm.maskedValue).toBe('Rs.1.234,568%')
31-
32-
await input.trigger('blur')
33-
34-
expect(wrapper.vm.maskedValue).toBe('Rs.1.234,57%')
35-
})
36-
37-
test('should emit input event with the new unmaskedValue on input', async () => {
38-
const wrapper = mount(VueNumber, {
39-
propsData: {
40-
value: 123456.893,
41-
decimal: ',',
42-
separator: '.',
43-
prefix: 'Rs.',
44-
suffix: '%'
45-
}
46-
})
47-
48-
const input = wrapper.find('input')
49-
50-
await input.trigger('input')
51-
5219
expect(wrapper.vm.unmaskedValue).toBe('123456.89')
20+
expect(wrapper.vm.maskedValue).toBe('Rs.123.456,89%')
5321

5422
await input.trigger('blur')
55-
5623
expect(wrapper.vm.unmaskedValue).toBe('123456.89')
24+
expect(wrapper.vm.maskedValue).toBe('Rs.123.456,89%')
5725

5826
input.element.value = 1234.568
59-
6027
await input.trigger('input')
61-
6228
expect(wrapper.vm.unmaskedValue).toBe('1234.57')
29+
expect(wrapper.vm.maskedValue).toBe('Rs.1.234,568%')
6330

6431
await input.trigger('blur')
65-
6632
expect(wrapper.vm.unmaskedValue).toBe('1234.57')
33+
expect(wrapper.vm.maskedValue).toBe('Rs.1.234,57%')
6734
})
6835
})

tests/component/component.minimumFractionDigits.spec.ts

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { mount } from '@vue/test-utils'
22
import VueNumber from '../../src/component.vue'
33

44
describe('VueNumber with minimum fraction digits', () => {
5-
test('should emit input event with the new maskedValue on input', async () => {
5+
test('should emit input event with the new maskedValue and unmaskedValue on input', async () => {
66
const wrapper = mount(VueNumber, {
77
propsData: {
88
value: 123456.893,
@@ -13,50 +13,20 @@ describe('VueNumber with minimum fraction digits', () => {
1313
const input = wrapper.find('input')
1414

1515
await input.trigger('input')
16-
17-
expect(wrapper.vm.maskedValue).toBe('123,456.893')
18-
19-
await input.trigger('blur')
20-
21-
expect(wrapper.vm.maskedValue).toBe('123,456.89')
22-
23-
input.element.value = '1234.5'
24-
25-
await input.trigger('input')
26-
27-
expect(wrapper.vm.maskedValue).toBe('1,234.5')
28-
29-
await input.trigger('blur')
30-
31-
expect(wrapper.vm.maskedValue).toBe('1,234.50')
32-
})
33-
34-
test('should emit input event with the new unmaskedValue on input', async () => {
35-
const wrapper = mount(VueNumber, {
36-
propsData: {
37-
value: 123456.893,
38-
minimumFractionDigits: 2
39-
}
40-
})
41-
42-
const input = wrapper.find('input')
43-
44-
await input.trigger('input')
45-
4616
expect(wrapper.vm.unmaskedValue).toBe('123456.89')
17+
expect(wrapper.vm.maskedValue).toBe('123,456.89')
4718

4819
await input.trigger('blur')
49-
5020
expect(wrapper.vm.unmaskedValue).toBe('123456.89')
21+
expect(wrapper.vm.maskedValue).toBe('123,456.89')
5122

5223
input.element.value = '1234.5'
53-
5424
await input.trigger('input')
55-
5625
expect(wrapper.vm.unmaskedValue).toBe('1234.5')
26+
expect(wrapper.vm.maskedValue).toBe('1,234.5')
5727

5828
await input.trigger('blur')
59-
6029
expect(wrapper.vm.unmaskedValue).toBe('1234.5')
30+
expect(wrapper.vm.maskedValue).toBe('1,234.50')
6131
})
6232
})

tests/component/component.range.spec.ts

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { mount } from '@vue/test-utils'
22
import VueNumber from '../../src/component.vue'
33

44
describe('VueNumber within range', () => {
5-
test('should emit input event with the new maskedValue on input', async () => {
5+
test('should emit input event with the new maskedValue and unmaskedValue on input', async () => {
66
const wrapper = mount(VueNumber, {
77
propsData: {
88
value: 1.893,
@@ -14,59 +14,22 @@ describe('VueNumber within range', () => {
1414
const input = wrapper.find('input')
1515

1616
await input.trigger('blur')
17-
18-
expect(wrapper.vm.maskedValue).toBe('1.89')
19-
20-
input.element.value = '1234.568'
21-
22-
await input.trigger('blur')
23-
24-
expect(wrapper.vm.maskedValue).toBe('50')
25-
26-
input.element.value = '-1234.568'
27-
28-
await input.trigger('blur')
29-
30-
expect(wrapper.vm.maskedValue).toBe('0')
31-
32-
input.element.value = '12.568'
33-
34-
await input.trigger('blur')
35-
36-
expect(wrapper.vm.maskedValue).toBe('12.57')
37-
})
38-
39-
test('should emit input event with the new unmaskedValue on input', async () => {
40-
const wrapper = mount(VueNumber, {
41-
propsData: {
42-
value: 1.893,
43-
min: 0,
44-
max: 50
45-
}
46-
})
47-
48-
const input = wrapper.find('input')
49-
50-
await input.trigger('blur')
51-
5217
expect(wrapper.vm.unmaskedValue).toBe('1.89')
18+
expect(wrapper.vm.maskedValue).toBe('1.89')
5319

5420
input.element.value = '1234.568'
55-
5621
await input.trigger('blur')
57-
5822
expect(wrapper.vm.unmaskedValue).toBe('50')
23+
expect(wrapper.vm.maskedValue).toBe('50')
5924

6025
input.element.value = '-1234.568'
61-
6226
await input.trigger('blur')
63-
6427
expect(wrapper.vm.unmaskedValue).toBe('0')
28+
expect(wrapper.vm.maskedValue).toBe('0')
6529

6630
input.element.value = '12.568'
67-
6831
await input.trigger('blur')
69-
7032
expect(wrapper.vm.unmaskedValue).toBe('12.57')
33+
expect(wrapper.vm.maskedValue).toBe('12.57')
7134
})
7235
})

tests/component/component.reverseFill.spec.ts

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { mount } from '@vue/test-utils'
22
import VueNumber from '../../src/component.vue'
33

44
describe('VueNumber reverse fill', () => {
5-
test('should emit input event with the new maskedValue on input', async () => {
5+
test('should emit input event with the new maskedValue and unmaskedValue on input', async () => {
66
const wrapper = mount(VueNumber, {
77
propsData: {
88
value: 123456.893,
@@ -13,50 +13,20 @@ describe('VueNumber reverse fill', () => {
1313
const input = wrapper.find('input')
1414

1515
await input.trigger('input')
16-
17-
expect(wrapper.vm.maskedValue).toBe('123,456.89')
18-
19-
await input.trigger('blur')
20-
21-
expect(wrapper.vm.maskedValue).toBe('123,456.89')
22-
23-
input.element.value = '1234568'
24-
25-
await input.trigger('input')
26-
27-
expect(wrapper.vm.maskedValue).toBe('12,345.68')
28-
29-
await input.trigger('blur')
30-
31-
expect(wrapper.vm.maskedValue).toBe('12,345.68')
32-
})
33-
34-
test('should emit input event with the new unmaskedValue on input', async () => {
35-
const wrapper = mount(VueNumber, {
36-
propsData: {
37-
value: 123456.893,
38-
reverseFill: true
39-
}
40-
})
41-
42-
const input = wrapper.find('input')
43-
44-
await input.trigger('input')
45-
4616
expect(wrapper.vm.unmaskedValue).toBe('123456.89')
17+
expect(wrapper.vm.maskedValue).toBe('123,456.89')
4718

4819
await input.trigger('blur')
49-
5020
expect(wrapper.vm.unmaskedValue).toBe('123456.89')
21+
expect(wrapper.vm.maskedValue).toBe('123,456.89')
5122

5223
input.element.value = '1234568'
53-
5424
await input.trigger('input')
55-
5625
expect(wrapper.vm.unmaskedValue).toBe('12345.68')
26+
expect(wrapper.vm.maskedValue).toBe('12,345.68')
5727

5828
await input.trigger('blur')
59-
6029
expect(wrapper.vm.unmaskedValue).toBe('12345.68')
30+
expect(wrapper.vm.maskedValue).toBe('12,345.68')
6131
})
6232
})

tests/component/component.spec.ts

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('VueNumber', () => {
1111
expect(wrapper.contains('input')).toBe(true)
1212
})
1313

14-
test('should emit input event with the new maskedValue on input', async () => {
14+
test('should emit input event with the new maskedValue and unmaskedValue on input', async () => {
1515
const wrapper = mount(VueNumber, {
1616
propsData: {
1717
value: 123456.893
@@ -21,49 +21,20 @@ describe('VueNumber', () => {
2121
const input = wrapper.find('input')
2222

2323
await input.trigger('input')
24-
25-
expect(wrapper.vm.maskedValue).toBe('123,456.893')
26-
27-
await input.trigger('blur')
28-
29-
expect(wrapper.vm.maskedValue).toBe('123,456.89')
30-
31-
input.element.value = '1234.568'
32-
33-
await input.trigger('input')
34-
35-
expect(wrapper.vm.maskedValue).toBe('1,234.568')
36-
37-
await input.trigger('blur')
38-
39-
expect(wrapper.vm.maskedValue).toBe('1,234.57')
40-
})
41-
42-
test('should emit input event with the new unmaskedValue on input', async () => {
43-
const wrapper = mount(VueNumber, {
44-
propsData: {
45-
value: 123456.893
46-
}
47-
})
48-
49-
const input = wrapper.find('input')
50-
51-
await input.trigger('input')
52-
5324
expect(wrapper.vm.unmaskedValue).toBe('123456.89')
25+
expect(wrapper.vm.maskedValue).toBe('123,456.89')
5426

5527
await input.trigger('blur')
56-
5728
expect(wrapper.vm.unmaskedValue).toBe('123456.89')
29+
expect(wrapper.vm.maskedValue).toBe('123,456.89')
5830

5931
input.element.value = '1234.568'
60-
6132
await input.trigger('input')
62-
6333
expect(wrapper.vm.unmaskedValue).toBe('1234.57')
34+
expect(wrapper.vm.maskedValue).toBe('1,234.568')
6435

6536
await input.trigger('blur')
66-
6737
expect(wrapper.vm.unmaskedValue).toBe('1234.57')
38+
expect(wrapper.vm.maskedValue).toBe('1,234.57')
6839
})
6940
})

tests/directive/directive.custom.spec.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,16 @@ describe('v-number directive', () => {
2424
const input = wrapper.find('input')
2525

2626
await input.trigger('input')
27-
28-
expect(input.element.value).toBe('Rs.123.456,893%')
27+
expect(input.element.value).toBe('Rs.123.456,89%')
2928

3029
await input.trigger('blur')
31-
3230
expect(input.element.value).toBe('Rs.123.456,89%')
3331

3432
input.element.value = 1234.568
35-
3633
await input.trigger('input')
37-
3834
expect(input.element.value).toBe('Rs.1.234,568%')
3935

4036
await input.trigger('blur')
41-
4237
expect(input.element.value).toBe('Rs.1.234,57%')
4338
})
4439
})

tests/directive/directive.minimumFractionDigits.spec.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,16 @@ describe('v-number directive', () => {
2121
const input = wrapper.find('input')
2222

2323
await input.trigger('input')
24-
25-
expect(input.element.value).toBe('123,456.893')
24+
expect(input.element.value).toBe('123,456.89')
2625

2726
await input.trigger('blur')
28-
2927
expect(input.element.value).toBe('123,456.89')
3028

3129
input.element.value = '1234.5'
32-
3330
await input.trigger('input')
34-
3531
expect(input.element.value).toBe('1,234.5')
3632

3733
await input.trigger('blur')
38-
3934
expect(input.element.value).toBe('1,234.50')
4035
})
4136
})

0 commit comments

Comments
 (0)