-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed input value replace by config null value
- Loading branch information
1 parent
b3e4f46
commit bb482d3
Showing
8 changed files
with
239 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import NumberFormat from '../../src/number-format' | ||
|
||
describe('should not throw error on empty config', () => { | ||
expect(() => new NumberFormat({})).not.toThrow() | ||
}) | ||
describe('unformat when options are default', () => { | ||
const numberFormat = new NumberFormat({ | ||
prefix: '$', | ||
separator: '.', | ||
decimal: ',', | ||
null_value: '', | ||
}) | ||
it('unformat string value', () => { | ||
expect(numberFormat.clean(true).unformat()).toEqual('') | ||
expect(numberFormat.clean(true).unformat('')).toEqual('') | ||
expect(numberFormat.clean(true).unformat('0')).toEqual('0') | ||
expect(numberFormat.clean(true).unformat('0,')).toEqual('0') | ||
expect(numberFormat.clean(true).unformat('-0,0')).toEqual('0') | ||
expect(numberFormat.clean(true).unformat('0,10')).toEqual('0.1') | ||
expect(numberFormat.clean(true).unformat('0,0-')).toEqual('0') | ||
expect(numberFormat.clean(true).unformat('0,10-')).toEqual('-0.1') | ||
expect(numberFormat.clean(true).unformat('12.345,54921')).toEqual( | ||
'12345.55' | ||
) | ||
expect(numberFormat.clean(true).unformat('--12.345,12345')).toEqual( | ||
'-12345.12' | ||
) | ||
expect(numberFormat.clean(true).unformat('12.345.54321,12345')).toEqual( | ||
'1234554321.12' | ||
) | ||
expect(numberFormat.clean(true).unformat('-12.345,,54321-')).toEqual( | ||
'-12345.54' | ||
) | ||
}) | ||
it('unformat numerical value', () => { | ||
expect(numberFormat.clean(true).unformat(0)).toEqual('0') | ||
expect(numberFormat.clean(true).unformat(0)).toEqual('0') | ||
expect(numberFormat.clean(true).unformat(0.0)).toEqual('0') | ||
expect(numberFormat.clean(true).unformat(-0.1)).toEqual('-0.1') | ||
expect(numberFormat.clean(true).unformat(-0.0)).toEqual('0') | ||
expect(numberFormat.clean(true).unformat(0.1)).toEqual('0.1') | ||
expect(numberFormat.clean(true).unformat(12345.54921)).toEqual('12345.55') | ||
expect(numberFormat.clean(true).unformat(12345.12345)).toEqual('12345.12') | ||
expect(numberFormat.clean(true).unformat(12345.54321)).toEqual('12345.54') | ||
expect(numberFormat.clean(true).unformat(12345.54321)).toEqual('12345.54') | ||
}) | ||
}) |
Oops, something went wrong.