1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-18 07:23:21 +01:00
metamask-extension/ui/app/conversion-util.test.js

23 lines
570 B
JavaScript
Raw Normal View History

2018-06-24 11:48:02 +02:00
import assert from 'assert'
import {addCurrencies} from './conversion-util'
describe('conversion utils', () => {
2018-06-24 11:51:31 +02:00
describe('addCurrencies()', () => {
2018-06-24 11:48:02 +02:00
it('add whole numbers', () => {
2018-06-24 11:56:07 +02:00
const result = addCurrencies(3, 9)
assert.equal(result.toNumber(), 12)
2018-06-24 11:48:02 +02:00
})
it('add decimals', () => {
2018-06-24 11:56:07 +02:00
const result = addCurrencies(1.3, 1.9)
assert.equal(result.toNumber(), 3.2)
2018-06-24 11:48:02 +02:00
})
it('add repeating decimals', () => {
2018-06-29 10:19:45 +02:00
const result = addCurrencies(1 / 3, 1 / 9)
2018-06-24 11:56:07 +02:00
assert.equal(result.toNumber(), 0.4444444444444444)
2018-06-24 11:48:02 +02:00
})
})
})