diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-01-17 10:17:28 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@gmail.com> | 2018-01-17 10:17:28 +0800 |
commit | 81f86cfab6da37f1a87f3243c6a082f8835ab81b (patch) | |
tree | 6af56231142544c5983bbe24d74644011596d003 /test/unit/components/balance-component-test.js | |
parent | aa76c5c73c5a9f0507ef69d88a43cf3bee5d60c0 (diff) | |
parent | 77eb7b2db692cc40bf5f8e36c5e695e8f82c76ec (diff) | |
download | tangerine-wallet-browser-81f86cfab6da37f1a87f3243c6a082f8835ab81b.tar tangerine-wallet-browser-81f86cfab6da37f1a87f3243c6a082f8835ab81b.tar.gz tangerine-wallet-browser-81f86cfab6da37f1a87f3243c6a082f8835ab81b.tar.bz2 tangerine-wallet-browser-81f86cfab6da37f1a87f3243c6a082f8835ab81b.tar.lz tangerine-wallet-browser-81f86cfab6da37f1a87f3243c6a082f8835ab81b.tar.xz tangerine-wallet-browser-81f86cfab6da37f1a87f3243c6a082f8835ab81b.tar.zst tangerine-wallet-browser-81f86cfab6da37f1a87f3243c6a082f8835ab81b.zip |
Merge branch 'uat' into uat-master-011618
Diffstat (limited to 'test/unit/components/balance-component-test.js')
-rw-r--r-- | test/unit/components/balance-component-test.js | 45 |
1 files changed, 45 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..9b1e82acf --- /dev/null +++ b/test/unit/components/balance-component-test.js @@ -0,0 +1,45 @@ +const assert = require('assert') +const h = require('react-hyperscript') +const { createMockStore } = require('redux-test-utils') +const { shallowWithStore } = require('../../lib/shallow-with-store') +const BalanceComponent = require('../../../ui/app/components/balance-component') +const mockState = { + metamask: { + accounts: { abc: {} }, + network: 1, + selectedAddress: 'abc', + } +} + +describe('BalanceComponent', function () { + let balanceComponent + let store + let component + beforeEach(function () { + store = createMockStore(mockState) + component = shallowWithStore(h(BalanceComponent), store) + balanceComponent = component.dive() + }) + + it('shows token balance and convert to fiat value based on conversion rate', function () { + const formattedBalance = '1.23 ETH' + + const tokenBalance = balanceComponent.instance().getTokenBalance(formattedBalance, false) + const fiatDisplayNumber = balanceComponent.instance().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.instance().getTokenBalance(formattedBalance, false) + const fiatDisplayNumber = balanceComponent.instance().getFiatDisplayNumber(formattedBalance, 0) + + assert.equal('1.23 ETH', tokenBalance) + assert.equal('N/A', fiatDisplayNumber) + }) + +}) + |