diff options
author | Simon Liang <simon@divby0.io> | 2017-08-08 20:15:30 +0800 |
---|---|---|
committer | Simon Liang <simon@divby0.io> | 2017-08-08 20:15:30 +0800 |
commit | 0db627d9793d91e2e3000a0650f6659a5d5dd67a (patch) | |
tree | bdf211f961e515e5a1d0b8f3260b7cdf44b3fcfa /test | |
parent | e8ade42f2aa3af6e0091e939beef3fdf769a2606 (diff) | |
download | tangerine-wallet-browser-0db627d9793d91e2e3000a0650f6659a5d5dd67a.tar tangerine-wallet-browser-0db627d9793d91e2e3000a0650f6659a5d5dd67a.tar.gz tangerine-wallet-browser-0db627d9793d91e2e3000a0650f6659a5d5dd67a.tar.bz2 tangerine-wallet-browser-0db627d9793d91e2e3000a0650f6659a5d5dd67a.tar.lz tangerine-wallet-browser-0db627d9793d91e2e3000a0650f6659a5d5dd67a.tar.xz tangerine-wallet-browser-0db627d9793d91e2e3000a0650f6659a5d5dd67a.tar.zst tangerine-wallet-browser-0db627d9793d91e2e3000a0650f6659a5d5dd67a.zip |
refactored and added unit test
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/components/balance-component-test.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/unit/components/balance-component-test.js b/test/unit/components/balance-component-test.js new file mode 100644 index 000000000..c32a8ab2b --- /dev/null +++ b/test/unit/components/balance-component-test.js @@ -0,0 +1,32 @@ +var assert = require('assert') +var BalanceComponent = require('../../../ui/app/components/balance-component') + +describe('BalanceComponent', function () { + let balanceComponent + + beforeEach(function () { + balanceComponent = new BalanceComponent() + }) + + it('shows token balance and convert to fiat value based on conversion rate', function () { + const formattedBalance = '1.23 ETH' + + const tokenBalance = balanceComponent.getTokenBalance(formattedBalance, false) + const fiatDisplayNumber = balanceComponent.getFiatDisplayNumber(formattedBalance, 2) + + assert.equal('1.23 ETH', tokenBalance) + assert.equal(2.46, fiatDisplayNumber) + }) + + it('shows only the token balance when conversion rate is not available', function () { + const formattedBalance = '1.23 ETH' + + const tokenBalance = balanceComponent.getTokenBalance(formattedBalance, false) + const fiatDisplayNumber = balanceComponent.getFiatDisplayNumber(formattedBalance, 0) + + assert.equal('1.23 ETH', tokenBalance) + assert.equal('N/A', fiatDisplayNumber) + }) + +}) + |