From 9b9df417246dbf332f0a7d8afadb664544ceb484 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Fri, 8 Sep 2017 14:24:40 -0700 Subject: more tests and craete a getPendingTransactions function --- test/unit/tx-controller-test.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/unit/tx-controller-test.js') diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js index f969752ec..937ac55de 100644 --- a/test/unit/tx-controller-test.js +++ b/test/unit/tx-controller-test.js @@ -37,6 +37,28 @@ describe('Transaction Controller', function () { txController.txProviderUtils = new TxGasUtils(txController.provider) }) + describe('#getState', function () { + it('should return a state object with the right keys and datat types', function (){ + const exposedState = txController.getState() + assert('unapprovedTxs' in exposedState, 'state should have the key unapprovedTxs') + assert('selectedAddressTxList' in exposedState, 'state should have the key selectedAddressTxList') + assert(typeof exposedState.unapprovedTxs === 'object', 'should be an object') + assert(Array.isArray(exposedState.selectedAddressTxList), 'should be an array') + }) + }) + + describe('#getUnapprovedTxCount', function () { + it('should return the number of unapproved txs', function () { + txController.txStateManager._saveTxList([ + { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }, + { id: 2, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }, + { id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }, + ]) + const unapprovedTxCount = txController.getUnapprovedTxCount() + assert.equal(unapprovedTxCount, 3, 'should be 3') + }) + }) + describe('#newUnapprovedTransaction', function () { let stub, txMeta, txParams beforeEach(function () { -- cgit