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

23 lines
602 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', function () {
describe('addCurrencies()', function () {
it('add whole numbers', function () {
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', function () {
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', function () {
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
})
})
})