diff options
author | Frankie <frankie.diamond@gmail.com> | 2018-11-17 02:34:08 +0800 |
---|---|---|
committer | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2018-11-17 02:34:08 +0800 |
commit | ce147bf6d8431f4f0cb5b4de46a5af9628b3e9e2 (patch) | |
tree | 3e8752c040bf25095f99a73e0c9c38c8679c8016 /test/unit/app/controllers/transactions/tx-controller-test.js | |
parent | af873129bb3beea559d69b52ce0f4f76dbacd199 (diff) | |
download | tangerine-wallet-browser-ce147bf6d8431f4f0cb5b4de46a5af9628b3e9e2.tar tangerine-wallet-browser-ce147bf6d8431f4f0cb5b4de46a5af9628b3e9e2.tar.gz tangerine-wallet-browser-ce147bf6d8431f4f0cb5b4de46a5af9628b3e9e2.tar.bz2 tangerine-wallet-browser-ce147bf6d8431f4f0cb5b4de46a5af9628b3e9e2.tar.lz tangerine-wallet-browser-ce147bf6d8431f4f0cb5b4de46a5af9628b3e9e2.tar.xz tangerine-wallet-browser-ce147bf6d8431f4f0cb5b4de46a5af9628b3e9e2.tar.zst tangerine-wallet-browser-ce147bf6d8431f4f0cb5b4de46a5af9628b3e9e2.zip |
Tx controller now uses safe event emitter (#5769)
* transactions - use safe-event-emitter over events
* tests - pass a platform object on init with a noop showTransactionNotification
* test - fix for tx-state-history-helper trying to reduce an empty array
* deps - safe-event-emitter
* lint
Diffstat (limited to 'test/unit/app/controllers/transactions/tx-controller-test.js')
-rw-r--r-- | test/unit/app/controllers/transactions/tx-controller-test.js | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/test/unit/app/controllers/transactions/tx-controller-test.js b/test/unit/app/controllers/transactions/tx-controller-test.js index 7f1d8e6f5..b76f256b9 100644 --- a/test/unit/app/controllers/transactions/tx-controller-test.js +++ b/test/unit/app/controllers/transactions/tx-controller-test.js @@ -52,9 +52,9 @@ describe('Transaction Controller', function () { describe('#getUnapprovedTxCount', function () { it('should return the number of unapproved txs', function () { txController.txStateManager._saveTxList([ - { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] }, - { id: 2, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] }, - { id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] }, + { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 2, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, ]) const unapprovedTxCount = txController.getUnapprovedTxCount() assert.equal(unapprovedTxCount, 3, 'should be 3') @@ -64,9 +64,9 @@ describe('Transaction Controller', function () { describe('#getPendingTxCount', function () { it('should return the number of pending txs', function () { txController.txStateManager._saveTxList([ - { id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] }, - { id: 2, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] }, - { id: 3, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] }, + { id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 2, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 3, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, ]) const pendingTxCount = txController.getPendingTxCount() assert.equal(pendingTxCount, 3, 'should be 3') @@ -82,15 +82,15 @@ describe('Transaction Controller', function () { 'to': '0xc684832530fcbddae4b4230a47e991ddcec2831d', } txController.txStateManager._saveTxList([ - {id: 0, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [] }, - {id: 1, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [] }, - {id: 2, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [] }, - {id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams, history: [] }, - {id: 4, status: 'rejected', metamaskNetworkId: currentNetworkId, txParams, history: [] }, - {id: 5, status: 'approved', metamaskNetworkId: currentNetworkId, txParams, history: [] }, - {id: 6, status: 'signed', metamaskNetworkId: currentNetworkId, txParams, history: [] }, - {id: 7, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [] }, - {id: 8, status: 'failed', metamaskNetworkId: currentNetworkId, txParams, history: [] }, + {id: 0, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, + {id: 1, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, + {id: 2, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, + {id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, + {id: 4, status: 'rejected', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, + {id: 5, status: 'approved', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, + {id: 6, status: 'signed', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, + {id: 7, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, + {id: 8, status: 'failed', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, ]) }) @@ -112,7 +112,7 @@ describe('Transaction Controller', function () { id: 1, metamaskNetworkId: currentNetworkId, txParams, - history: [], + history: [{}], } txController.txStateManager._saveTxList([txMeta]) stub = sinon.stub(txController, 'addUnapprovedTransaction').callsFake(() => { @@ -232,7 +232,7 @@ describe('Transaction Controller', function () { from: '0xc684832530fcbddae4b4230a47e991ddcec2831d', to: '0xc684832530fcbddae4b4230a47e991ddcec2831d', }, - history: [], + history: [{}], } providerResultStub.eth_gasPrice = '4a817c800' providerResultStub.eth_getBlockByNumber = { gasLimit: '47b784' } @@ -423,7 +423,7 @@ describe('Transaction Controller', function () { data: '0x0', } txController.txStateManager._saveTxList([ - { id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [] }, + { id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, ]) txController.retryTransaction(1) .then((txMeta) => { @@ -462,12 +462,12 @@ describe('Transaction Controller', function () { beforeEach(function () { txController.txStateManager._saveTxList([ { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }, - { id: 2, status: 'rejected', metamaskNetworkId: currentNetworkId, txParams: {} }, - { id: 3, status: 'approved', metamaskNetworkId: currentNetworkId, txParams: {} }, - { id: 4, status: 'signed', metamaskNetworkId: currentNetworkId, txParams: {} }, - { id: 5, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {} }, - { id: 6, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams: {} }, - { id: 7, status: 'failed', metamaskNetworkId: currentNetworkId, txParams: {} }, + { id: 2, status: 'rejected', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 3, status: 'approved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 4, status: 'signed', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 5, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 6, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 7, status: 'failed', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, ]) }) it('should show only submitted and approved transactions as pending transasction', function () { |