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
|
|
|
|
|
|
|
|
2020-02-11 17:51:13 +01: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
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01: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
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01: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
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|