aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/ducks/tests
diff options
context:
space:
mode:
authorDan Miller <danjm.com@gmail.com>2018-11-14 00:36:52 +0800
committerDan Miller <danjm.com@gmail.com>2018-12-04 11:36:22 +0800
commit7f2c5c09de67a67972fcbaae254d39aac6c96f56 (patch)
tree827332f85c8086dbdb427d6addbf10eef03a9bb6 /ui/app/ducks/tests
parentfe535159bb3ec5849d670d9bc53067f5d6f330b7 (diff)
downloadtangerine-wallet-browser-7f2c5c09de67a67972fcbaae254d39aac6c96f56.tar.gz
tangerine-wallet-browser-7f2c5c09de67a67972fcbaae254d39aac6c96f56.tar.zst
tangerine-wallet-browser-7f2c5c09de67a67972fcbaae254d39aac6c96f56.zip
Uses more reliable api on main send screen; caches basic api results in modal
Diffstat (limited to 'ui/app/ducks/tests')
-rw-r--r--ui/app/ducks/tests/gas-duck.test.js34
1 files changed, 29 insertions, 5 deletions
diff --git a/ui/app/ducks/tests/gas-duck.test.js b/ui/app/ducks/tests/gas-duck.test.js
index 009758cde..dff154dea 100644
--- a/ui/app/ducks/tests/gas-duck.test.js
+++ b/ui/app/ducks/tests/gas-duck.test.js
@@ -19,7 +19,7 @@ const {
setCustomGasTotal,
setCustomGasErrors,
resetCustomGasState,
- fetchBasicGasEstimates,
+ fetchBasicGasAndTimeEstimates,
gasEstimatesLoadingStarted,
gasEstimatesLoadingFinished,
setPricesAndTimeEstimates,
@@ -100,6 +100,9 @@ describe('Gas Duck', () => {
gasEstimatesLoading: true,
priceAndTimeEstimates: [],
priceAndTimeEstimatesLastRetrieved: 0,
+ basicPriceAndTimeEstimates: [],
+ basicPriceAndTimeEstimatesLastRetrieved: 0,
+
}
const BASIC_GAS_ESTIMATE_LOADING_FINISHED = 'metamask/gas/BASIC_GAS_ESTIMATE_LOADING_FINISHED'
@@ -114,6 +117,7 @@ describe('Gas Duck', () => {
const SET_CUSTOM_GAS_TOTAL = 'metamask/gas/SET_CUSTOM_GAS_TOTAL'
const SET_PRICE_AND_TIME_ESTIMATES = 'metamask/gas/SET_PRICE_AND_TIME_ESTIMATES'
const SET_API_ESTIMATES_LAST_RETRIEVED = 'metamask/gas/SET_API_ESTIMATES_LAST_RETRIEVED'
+ const SET_BASIC_API_ESTIMATES_LAST_RETRIEVED = 'metamask/gas/SET_BASIC_API_ESTIMATES_LAST_RETRIEVED'
describe('GasReducer()', () => {
it('should initialize state', () => {
@@ -224,7 +228,7 @@ describe('Gas Duck', () => {
)
})
- it('should set priceAndTimeEstimatesLastRetrieved when receivinga SET_API_ESTIMATES_LAST_RETRIEVED action', () => {
+ it('should set priceAndTimeEstimatesLastRetrieved when receiving a SET_API_ESTIMATES_LAST_RETRIEVED action', () => {
assert.deepEqual(
GasReducer(mockState, {
type: SET_API_ESTIMATES_LAST_RETRIEVED,
@@ -234,6 +238,16 @@ describe('Gas Duck', () => {
)
})
+ it('should set priceAndTimeEstimatesLastRetrieved when receiving a SET_BASIC_API_ESTIMATES_LAST_RETRIEVED action', () => {
+ assert.deepEqual(
+ GasReducer(mockState, {
+ type: SET_BASIC_API_ESTIMATES_LAST_RETRIEVED,
+ value: 1700000000000,
+ }),
+ Object.assign({ basicPriceAndTimeEstimatesLastRetrieved: 1700000000000 }, mockState.gas)
+ )
+ })
+
it('should set errors when receiving a SET_CUSTOM_GAS_ERRORS action', () => {
assert.deepEqual(
GasReducer(mockState, {
@@ -272,10 +286,14 @@ describe('Gas Duck', () => {
})
})
- describe('fetchBasicGasEstimates', () => {
+ describe('fetchBasicGasAndTimeEstimates', () => {
const mockDistpatch = sinon.spy()
it('should call fetch with the expected params', async () => {
- await fetchBasicGasEstimates()(mockDistpatch)
+ await fetchBasicGasAndTimeEstimates()(mockDistpatch, () => ({ gas: Object.assign(
+ {},
+ initState,
+ { basicPriceAndTimeEstimatesLastRetrieved: 1000000 }
+ ) }))
assert.deepEqual(
mockDistpatch.getCall(0).args,
[{ type: BASIC_GAS_ESTIMATE_LOADING_STARTED} ]
@@ -294,8 +312,14 @@ describe('Gas Duck', () => {
},
]
)
+
assert.deepEqual(
mockDistpatch.getCall(1).args,
+ [{ type: SET_BASIC_API_ESTIMATES_LAST_RETRIEVED, value: 2000000 } ]
+ )
+
+ assert.deepEqual(
+ mockDistpatch.getCall(2).args,
[{
type: SET_BASIC_GAS_ESTIMATE_DATA,
value: {
@@ -314,7 +338,7 @@ describe('Gas Duck', () => {
}]
)
assert.deepEqual(
- mockDistpatch.getCall(2).args,
+ mockDistpatch.getCall(3).args,
[{ type: BASIC_GAS_ESTIMATE_LOADING_FINISHED }]
)
})