aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-09-07 05:27:21 +0800
committerDan Finlay <dan@danfinlay.com>2017-09-07 05:27:21 +0800
commit714df393b406c515b0bb3abd4fcd8bde4ad53fde (patch)
tree551c80bebbce431f90c1f7e434588d7f6be253a2 /test/unit
parent351db952c52950b2702f1bd7c9d0f165df34def2 (diff)
downloadtangerine-wallet-browser-714df393b406c515b0bb3abd4fcd8bde4ad53fde.tar
tangerine-wallet-browser-714df393b406c515b0bb3abd4fcd8bde4ad53fde.tar.gz
tangerine-wallet-browser-714df393b406c515b0bb3abd4fcd8bde4ad53fde.tar.bz2
tangerine-wallet-browser-714df393b406c515b0bb3abd4fcd8bde4ad53fde.tar.lz
tangerine-wallet-browser-714df393b406c515b0bb3abd4fcd8bde4ad53fde.tar.xz
tangerine-wallet-browser-714df393b406c515b0bb3abd4fcd8bde4ad53fde.tar.zst
tangerine-wallet-browser-714df393b406c515b0bb3abd4fcd8bde4ad53fde.zip
Add test template
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/pending-balance-test.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/unit/pending-balance-test.js b/test/unit/pending-balance-test.js
new file mode 100644
index 000000000..845d6d552
--- /dev/null
+++ b/test/unit/pending-balance-test.js
@@ -0,0 +1,37 @@
+const assert = require('assert')
+const PendingBalanceCalculator = require('../../app/scripts/lib/pending-balance-calculator')
+const MockTxGen = require('../lib/mock-tx-gen')
+const BN = require('ethereumjs-util').BN
+let providerResultStub = {}
+
+describe('PendingBalanceCalculator', function () {
+ let nonceTracker
+
+ describe('if you have no pending txs and one ether', function () {
+ const ether = '0x' + (new BN(1e18)).toString(16)
+
+ beforeEach(function () {
+ nonceTracker = generateNonceTrackerWith([], ether)
+ })
+
+ it('returns the network balance', function () {
+ const result = nonceTracker.getBalance()
+ assert.equal(result, ether, 'returns one ether')
+ })
+ })
+})
+
+function generateBalaneCalcWith (transactions, providerStub = '0x0') {
+ const getPendingTransactions = () => transactions
+ providerResultStub.result = providerStub
+ const provider = {
+ sendAsync: (_, cb) => { cb(undefined, providerResultStub) },
+ _blockTracker: {
+ getCurrentBlock: () => '0x11b568',
+ },
+ }
+ return new PendingBalanceCalculator({
+ provider,
+ getPendingTransactions,
+ })
+}