fixes #4307 BigNumber casting issue

feature/default_network_editable
trejgun 6 years ago
parent 299abee666
commit 5d034006e8
  1. 2
      ui/app/conversion-util.js
  2. 23
      ui/app/conversion-util.test.js

@ -140,7 +140,7 @@ const addCurrencies = (a, b, options = {}) => {
bBase, bBase,
...conversionOptions ...conversionOptions
} = options } = options
const value = (new BigNumber(a, aBase)).add(b, bBase) const value = (new BigNumber(a.toString(), aBase)).add(b.toString(), bBase)
return converter({ return converter({
value, value,

@ -0,0 +1,23 @@
import assert from 'assert'
import {addCurrencies} from './conversion-util'
describe('conversion utils', () => {
describe.only('addCurrencies()', () => {
it('add whole numbers', () => {
const result = addCurrencies(3, 5)
assert.equal(result.toNumber(), 8)
})
it('add decimals', () => {
const result = addCurrencies(1.3, 1.5)
assert.equal(result.toNumber(), 2.8)
})
it('add repeating decimals', () => {
const result = addCurrencies(1/3, 1/7)
assert.equal(result.toNumber(), 0.47619047619047616)
})
})
})
Loading…
Cancel
Save