diff options
author | Dan Miller <danjm.com@gmail.com> | 2018-11-06 01:01:46 +0800 |
---|---|---|
committer | Dan Miller <danjm.com@gmail.com> | 2018-12-04 11:36:22 +0800 |
commit | b70886a99b466366e84d24271adbb890aebf6460 (patch) | |
tree | b4ce415c80ec78120306d358c20d4c51744c8db3 /ui/app/ducks | |
parent | a8259f7f6a26fe5ae21b26b2a5c05dfdb09e32bd (diff) | |
download | tangerine-wallet-browser-b70886a99b466366e84d24271adbb890aebf6460.tar tangerine-wallet-browser-b70886a99b466366e84d24271adbb890aebf6460.tar.gz tangerine-wallet-browser-b70886a99b466366e84d24271adbb890aebf6460.tar.bz2 tangerine-wallet-browser-b70886a99b466366e84d24271adbb890aebf6460.tar.lz tangerine-wallet-browser-b70886a99b466366e84d24271adbb890aebf6460.tar.xz tangerine-wallet-browser-b70886a99b466366e84d24271adbb890aebf6460.tar.zst tangerine-wallet-browser-b70886a99b466366e84d24271adbb890aebf6460.zip |
Fixes for components that break e2e gas customization tests, plus unit test updates.
Diffstat (limited to 'ui/app/ducks')
-rw-r--r-- | ui/app/ducks/tests/gas-duck.test.js | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/ui/app/ducks/tests/gas-duck.test.js b/ui/app/ducks/tests/gas-duck.test.js index 96c00383b..009758cde 100644 --- a/ui/app/ducks/tests/gas-duck.test.js +++ b/ui/app/ducks/tests/gas-duck.test.js @@ -1,7 +1,16 @@ import assert from 'assert' import sinon from 'sinon' +import proxyquire from 'proxyquire' -import GasReducer, { + +const GasDuck = proxyquire('../gas.duck.js', { + '../../lib/local-storage-helpers': { + loadLocalStorageData: sinon.spy(), + saveLocalStorageData: sinon.spy(), + }, +}) + +const { basicGasEstimatesLoadingStarted, basicGasEstimatesLoadingFinished, setBasicGasEstimateData, @@ -16,7 +25,8 @@ import GasReducer, { setPricesAndTimeEstimates, fetchGasEstimates, setApiEstimatesLastRetrieved, -} from '../gas.duck.js' +} = GasDuck +const GasReducer = GasDuck.default describe('Gas Duck', () => { let tempFetch @@ -312,6 +322,11 @@ describe('Gas Duck', () => { describe('fetchGasEstimates', () => { const mockDistpatch = sinon.spy() + + beforeEach(() => { + mockDistpatch.resetHistory() + }) + it('should call fetch with the expected params', async () => { global.fetch.resetHistory() await fetchGasEstimates(5)(mockDistpatch, () => ({ gas: Object.assign( @@ -377,6 +392,46 @@ describe('Gas Duck', () => { [{ type: GAS_ESTIMATE_LOADING_FINISHED }] ) }) + + it('should not call fetch if the estimates were retrieved < 75000 ms ago', async () => { + global.fetch.resetHistory() + await fetchGasEstimates(5)(mockDistpatch, () => ({ gas: Object.assign( + {}, + initState, + { + priceAndTimeEstimatesLastRetrieved: Date.now(), + priceAndTimeEstimates: [{ + expectedTime: '10', + expectedWait: 2, + gasprice: 50, + }], + } + ) })) + assert.deepEqual( + mockDistpatch.getCall(0).args, + [{ type: GAS_ESTIMATE_LOADING_STARTED} ] + ) + assert.equal(global.fetch.callCount, 0) + + assert.deepEqual( + mockDistpatch.getCall(1).args, + [{ + type: SET_PRICE_AND_TIME_ESTIMATES, + value: [ + { + expectedTime: '10', + expectedWait: 2, + gasprice: 50, + }, + ], + + }] + ) + assert.deepEqual( + mockDistpatch.getCall(2).args, + [{ type: GAS_ESTIMATE_LOADING_FINISHED }] + ) + }) }) describe('gasEstimatesLoadingStarted', () => { |