Created
April 21, 2020 22:06
-
-
Save anthanh/86d220afa05bca16fca7ad4ee535c1ee to your computer and use it in GitHub Desktop.
This file contains hidden or 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
describe('formatNumber function', () => { | |
it('works with strings', () => { | |
const formatted = formatNumber('12.45') | |
expect(formatted).toEqual('12,45') | |
}) | |
it('works with numbers', () => { | |
const formatted = formatNumber(12.45) | |
expect(formatted).toEqual('12,45') | |
}) | |
it('returns only 2 decimal places', () => { | |
const formatted = formatNumber(12.1111) | |
expect(formatted).toEqual('12,11') | |
}) | |
it('rounds decimals right', () => { | |
expect(formatNumber(12.665)).toEqual('12,67') | |
expect(formatNumber(12.664)).toEqual('12,66') | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment