Browse Source
Format ticker USD price with dollar symbol and two decimal placesrenovate/lint-staged-8.x
jackmallers
8 years ago
committed by
GitHub
3 changed files with 37 additions and 2 deletions
@ -0,0 +1,30 @@ |
|||
import { |
|||
formatUsd, |
|||
usdToBtc |
|||
} from '../../app/utils/usd' |
|||
|
|||
describe('usd', () => { |
|||
describe('formatUsd', () => { |
|||
it('should handle a string value', () => { |
|||
expect(formatUsd('42.0')).toBe('$42.00') |
|||
}) |
|||
|
|||
it('should handle a numerical value', () => { |
|||
expect(formatUsd(42.0)).toBe('$42.00') |
|||
}) |
|||
|
|||
it('should round to two decimal places', () => { |
|||
expect(formatUsd('42.416')).toBe('$42.42') |
|||
}) |
|||
}) |
|||
|
|||
describe('usdToBtc', () => { |
|||
it('should convert USD to BTC using rate', () => { |
|||
expect(usdToBtc(1, 50)).toBe('0.02000000') |
|||
}) |
|||
|
|||
it('should round to eight decimal places', () => { |
|||
expect(usdToBtc(2, 3)).toBe('0.66666667') |
|||
}) |
|||
}) |
|||
}) |
Loading…
Reference in new issue