mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Add test template
This commit is contained in:
parent
351db952c5
commit
714df393b4
37
test/unit/pending-balance-test.js
Normal file
37
test/unit/pending-balance-test.js
Normal file
@ -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,
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user