aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-09-07 05:36:15 +0800
committerDan Finlay <dan@danfinlay.com>2017-09-07 05:36:15 +0800
commitf9a052deed8749a1c6dd544df561967a568749d9 (patch)
tree1f1280b4d7558e82f2ee17322b62c13407c34b77 /test
parent714df393b406c515b0bb3abd4fcd8bde4ad53fde (diff)
downloadtangerine-wallet-browser-f9a052deed8749a1c6dd544df561967a568749d9.tar.gz
tangerine-wallet-browser-f9a052deed8749a1c6dd544df561967a568749d9.tar.zst
tangerine-wallet-browser-f9a052deed8749a1c6dd544df561967a568749d9.zip
Add first passing balance calc test
Diffstat (limited to 'test')
-rw-r--r--test/unit/pending-balance-test.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/test/unit/pending-balance-test.js b/test/unit/pending-balance-test.js
index 845d6d552..dcf1926f0 100644
--- a/test/unit/pending-balance-test.js
+++ b/test/unit/pending-balance-test.js
@@ -8,21 +8,22 @@ describe('PendingBalanceCalculator', function () {
let nonceTracker
describe('if you have no pending txs and one ether', function () {
- const ether = '0x' + (new BN(1e18)).toString(16)
+ const ether = '0x' + (new BN(String(1e18))).toString(16)
beforeEach(function () {
- nonceTracker = generateNonceTrackerWith([], ether)
+ nonceTracker = generateBalaneCalcWith([], ether)
})
- it('returns the network balance', function () {
- const result = nonceTracker.getBalance()
- assert.equal(result, ether, 'returns one ether')
+ it('returns the network balance', async function () {
+ const result = await nonceTracker.getBalance()
+ assert.equal(result, ether, `gave ${result} needed ${ether}`)
})
})
})
function generateBalaneCalcWith (transactions, providerStub = '0x0') {
- const getPendingTransactions = () => transactions
+ const getPendingTransactions = () => Promise.resolve(transactions)
+ const getBalance = () => Promise.resolve(providerStub)
providerResultStub.result = providerStub
const provider = {
sendAsync: (_, cb) => { cb(undefined, providerResultStub) },
@@ -31,7 +32,7 @@ function generateBalaneCalcWith (transactions, providerStub = '0x0') {
},
}
return new PendingBalanceCalculator({
- provider,
+ getBalance,
getPendingTransactions,
})
}