1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-27 12:56:01 +01:00
metamask-extension/ui/app/helpers/utils/conversion-util.test.js

23 lines
572 B
JavaScript
Raw Normal View History

2018-06-24 11:48:02 +02:00
import assert from 'assert'
2019-12-03 21:50:55 +01:00
import { addCurrencies } from './conversion-util'
2018-06-24 11:48:02 +02:00
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
})
})
})