Skip to content

Commit d710e91

Browse files
author
Dipak Sarkar
committed
updated default test
1 parent 55ff8f5 commit d710e91

File tree

1 file changed

+47
-49
lines changed

1 file changed

+47
-49
lines changed

tests/unit/number-format.default.spec.js

Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ describe('when the value is invalid with default config', () => {
1313
expect(numberFormat.format('!@#$%^&*()')).toEqual('')
1414
})
1515
it('should return as follows', () => {
16-
expect(numberFormat.clean().format('')).toEqual('')
17-
expect(numberFormat.clean().format('foo')).toEqual('')
18-
expect(numberFormat.clean().format('-foo')).toEqual('')
19-
expect(numberFormat.clean().format('-fo,o-')).toEqual('')
20-
expect(numberFormat.clean().format('!@#$%^&*()')).toEqual('')
16+
expect(numberFormat.clean(true).format('')).toEqual('')
17+
expect(numberFormat.clean(true).format('foo')).toEqual('')
18+
expect(numberFormat.clean(true).format('-foo')).toEqual('')
19+
expect(numberFormat.clean(true).format('-fo,o-')).toEqual('')
20+
expect(numberFormat.clean(true).format('!@#$%^&*()')).toEqual('')
2121
})
2222
it('should return as follows', () => {
2323
expect(numberFormat.unformat('')).toEqual('')
@@ -36,62 +36,60 @@ describe('format when options are default', () => {
3636
expect(numberFormat.format('0.10')).toEqual('0.10')
3737
expect(numberFormat.format('0.0-')).toEqual('0.0')
3838
expect(numberFormat.format('0.10-')).toEqual('-0.10')
39-
expect(numberFormat.format('12,345.54921')).toEqual('12,345.55')
40-
expect(numberFormat.format('--12,345.12345')).toEqual('-12,345.12')
41-
expect(numberFormat.format('12,345.54321.12345')).toEqual('12,345.54')
42-
expect(numberFormat.format('-12,345..54321-')).toEqual('-12,345.54')
39+
expect(numberFormat.format('12,345.54921')).toEqual('12,345.54921')
40+
expect(numberFormat.format('--12,345.12345')).toEqual('-12,345.12345')
41+
expect(numberFormat.format('12,345.54321.12345')).toEqual('12,345.5432112345')
42+
expect(numberFormat.format('-12,345..54321-')).toEqual('-12,345.54321')
4343
})
4444
it('format numerical value', () => {
45-
expect(numberFormat.format(0)).toEqual('0')
46-
expect(numberFormat.format(0.)).toEqual('0')
47-
expect(numberFormat.format(0.0)).toEqual('0')
45+
expect(numberFormat.format(0)).toEqual('')
46+
expect(numberFormat.format(0.)).toEqual('')
47+
expect(numberFormat.format(0.0)).toEqual('')
4848
expect(numberFormat.format(-0.10)).toEqual('-0.1')
49-
expect(numberFormat.format(-0.0)).toEqual('0')
49+
expect(numberFormat.format(-0.0)).toEqual('')
5050
expect(numberFormat.format(0.10)).toEqual('0.1')
51-
expect(numberFormat.format(12345.54921)).toEqual('12,345.55')
52-
expect(numberFormat.format(12345.12345)).toEqual('12,345.12')
53-
expect(numberFormat.format(12345.54321)).toEqual('12,345.54')
54-
expect(numberFormat.format(12345.54321)).toEqual('12,345.54')
51+
expect(numberFormat.format(12345.54921)).toEqual('12,345.54921')
52+
expect(numberFormat.format(12345.12345)).toEqual('12,345.12345')
53+
expect(numberFormat.format(12345.54321)).toEqual('12,345.54321')
54+
expect(numberFormat.format(12345.54321)).toEqual('12,345.54321')
5555
})
5656
it('format and clean numerical value', () => {
57-
expect(numberFormat.clean().format(0)).toEqual('0')
58-
expect(numberFormat.clean().format(0.)).toEqual('0')
59-
expect(numberFormat.clean().format(0.0)).toEqual('0')
60-
expect(numberFormat.clean().format(0.10)).toEqual('0.1')
61-
expect(numberFormat.clean().format(-0.0)).toEqual('0')
62-
expect(numberFormat.clean().format(-0.10)).toEqual('-0.1')
63-
expect(numberFormat.clean().format(12345.54921)).toEqual('12,345.55')
64-
expect(numberFormat.clean().format(12345.12345)).toEqual('12,345.12')
65-
expect(numberFormat.clean().format(12345.54321)).toEqual('12,345.54')
66-
expect(numberFormat.clean().format(12345.54321)).toEqual('12,345.54')
57+
expect(numberFormat.clean(true).format(0)).toEqual('')
58+
expect(numberFormat.clean(true).format(0.)).toEqual('')
59+
expect(numberFormat.clean(true).format(0.0)).toEqual('')
60+
expect(numberFormat.clean(true).format(0.10)).toEqual('0.1')
61+
expect(numberFormat.clean(true).format(-0.0)).toEqual('')
62+
expect(numberFormat.clean(true).format(-0.10)).toEqual('-0.1')
63+
expect(numberFormat.clean(true).format(12345.54921)).toEqual('12,345.55')
64+
expect(numberFormat.clean(true).format(12345.12345)).toEqual('12,345.12')
65+
expect(numberFormat.clean(true).format(12345.54321)).toEqual('12,345.54')
66+
expect(numberFormat.clean(true).format(12345.54321)).toEqual('12,345.54')
6767
})
6868
})
6969
describe('unformat when options are default', () => {
7070
const numberFormat = new NumberFormat({})
7171
it('unformat string value', () => {
72-
expect(numberFormat.unformat('0')).toEqual(0)
73-
expect(numberFormat.unformat('0.')).toEqual(0)
74-
expect(numberFormat.unformat('-0.0')).toEqual(0)
75-
expect(numberFormat.unformat('0.10')).toEqual(0.1)
76-
expect(numberFormat.unformat('0.0-')).toEqual(0)
77-
expect(numberFormat.unformat('0.10-')).toEqual(-0.1)
78-
expect(numberFormat.unformat('12,345.54921')).toEqual(12345.55)
79-
expect(numberFormat.unformat('--12,345.12345')).toEqual(-12345.12)
80-
expect(numberFormat.unformat('12,345.54321.12345')).toEqual(12345.54)
81-
expect(numberFormat.unformat('-12,345..54321-')).toEqual(-12345.54)
72+
expect(numberFormat.clean(true).unformat('0')).toEqual(0)
73+
expect(numberFormat.clean(true).unformat('0.')).toEqual(0)
74+
expect(numberFormat.clean(true).unformat('-0.0')).toEqual(0)
75+
expect(numberFormat.clean(true).unformat('0.10')).toEqual(0.1)
76+
expect(numberFormat.clean(true).unformat('0.0-')).toEqual(0)
77+
expect(numberFormat.clean(true).unformat('0.10-')).toEqual(-0.1)
78+
expect(numberFormat.clean(true).unformat('12,345.54921')).toEqual(12345.55)
79+
expect(numberFormat.clean(true).unformat('--12,345.12345')).toEqual(-12345.12)
80+
expect(numberFormat.clean(true).unformat('12,345.54321.12345')).toEqual(12345.54)
81+
expect(numberFormat.clean(true).unformat('-12,345..54321-')).toEqual(-12345.54)
8282
})
8383
it('unformat numerical value', () => {
84-
expect(numberFormat.unformat(0)).toEqual(0)
85-
expect(numberFormat.unformat(0.)).toEqual(0)
86-
expect(numberFormat.unformat(0.0)).toEqual(0)
87-
expect(numberFormat.unformat(-0.10)).toEqual(-0.1)
88-
expect(numberFormat.unformat(-0.0)).toEqual(0)
89-
expect(numberFormat.unformat(0.10)).toEqual(0.1)
90-
expect(numberFormat.unformat(12345.54921)).toEqual(12345.55)
91-
expect(numberFormat.unformat(12345.12345)).toEqual(12345.12)
92-
expect(numberFormat.unformat(12345.54321)).toEqual(12345.54)
93-
expect(numberFormat.unformat(12345.54321)).toEqual(12345.54)
84+
expect(numberFormat.clean(true).unformat(0)).toEqual('')
85+
expect(numberFormat.clean(true).unformat(0.)).toEqual('')
86+
expect(numberFormat.clean(true).unformat(0.0)).toEqual('')
87+
expect(numberFormat.clean(true).unformat(-0.10)).toEqual(-0.1)
88+
expect(numberFormat.clean(true).unformat(-0.0)).toEqual('')
89+
expect(numberFormat.clean(true).unformat(0.10)).toEqual(0.1)
90+
expect(numberFormat.clean(true).unformat(12345.54921)).toEqual(12345.55)
91+
expect(numberFormat.clean(true).unformat(12345.12345)).toEqual(12345.12)
92+
expect(numberFormat.clean(true).unformat(12345.54321)).toEqual(12345.54)
93+
expect(numberFormat.clean(true).unformat(12345.54321)).toEqual(12345.54)
9494
})
9595
})
96-
97-

0 commit comments

Comments
 (0)