|
|
@ -2,22 +2,21 @@ import assert from 'assert' |
|
|
|
import {addCurrencies} from './conversion-util' |
|
|
|
import {addCurrencies} from './conversion-util' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe('conversion utils', () => { |
|
|
|
describe('conversion utils', () => { |
|
|
|
describe('addCurrencies()', () => { |
|
|
|
describe('addCurrencies()', () => { |
|
|
|
it('add whole numbers', () => { |
|
|
|
it('add whole numbers', () => { |
|
|
|
const result = addCurrencies(3, 5) |
|
|
|
const result = addCurrencies(3, 9) |
|
|
|
assert.equal(result.toNumber(), 8) |
|
|
|
assert.equal(result.toNumber(), 12) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
it('add decimals', () => { |
|
|
|
it('add decimals', () => { |
|
|
|
const result = addCurrencies(1.3, 1.5) |
|
|
|
const result = addCurrencies(1.3, 1.9) |
|
|
|
assert.equal(result.toNumber(), 2.8) |
|
|
|
assert.equal(result.toNumber(), 3.2) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
it('add repeating decimals', () => { |
|
|
|
it('add repeating decimals', () => { |
|
|
|
const result = addCurrencies(1/3, 1/7) |
|
|
|
const result = addCurrencies(1/3, 1/9) |
|
|
|
assert.equal(result.toNumber(), 0.47619047619047616) |
|
|
|
assert.equal(result.toNumber(), 0.4444444444444444) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|