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
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|