aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/ducks/tests
diff options
context:
space:
mode:
authorDan Miller <danjm.com@gmail.com>2018-10-10 00:35:54 +0800
committerDan Miller <danjm.com@gmail.com>2018-12-04 11:36:05 +0800
commita2bbf504b891a63f32070961118ec1ae6fa5fdd8 (patch)
tree60add1370c5d0ab38958ba96806d692bd87c5231 /ui/app/ducks/tests
parent2dbae581ac3f9190ddd1c3457bd51b41eef8051b (diff)
downloadtangerine-wallet-browser-a2bbf504b891a63f32070961118ec1ae6fa5fdd8.tar.gz
tangerine-wallet-browser-a2bbf504b891a63f32070961118ec1ae6fa5fdd8.tar.zst
tangerine-wallet-browser-a2bbf504b891a63f32070961118ec1ae6fa5fdd8.zip
Read only connection of gas price chart to redux
Diffstat (limited to 'ui/app/ducks/tests')
-rw-r--r--ui/app/ducks/tests/gas-duck.test.js69
1 files changed, 66 insertions, 3 deletions
diff --git a/ui/app/ducks/tests/gas-duck.test.js b/ui/app/ducks/tests/gas-duck.test.js
index 66cf376a7..464b122ae 100644
--- a/ui/app/ducks/tests/gas-duck.test.js
+++ b/ui/app/ducks/tests/gas-duck.test.js
@@ -10,7 +10,10 @@ import GasReducer, {
setCustomGasTotal,
setCustomGasErrors,
resetCustomGasState,
- fetchGasEstimates,
+ fetchBasicGasEstimates,
+ gasEstimatesLoadingStarted,
+ gasEstimatesLoadingFinished,
+ setPricesAndTimeEstimates,
} from '../gas.duck.js'
describe('Gas Duck', () => {
@@ -65,15 +68,21 @@ describe('Gas Duck', () => {
},
basicEstimateIsLoading: true,
errors: {},
+ gasEstimatesLoading: true,
+ priceAndTimeEstimates: [],
+
}
const BASIC_GAS_ESTIMATE_LOADING_FINISHED = 'metamask/gas/BASIC_GAS_ESTIMATE_LOADING_FINISHED'
const BASIC_GAS_ESTIMATE_LOADING_STARTED = 'metamask/gas/BASIC_GAS_ESTIMATE_LOADING_STARTED'
+ const GAS_ESTIMATE_LOADING_FINISHED = 'metamask/gas/GAS_ESTIMATE_LOADING_FINISHED'
+ const GAS_ESTIMATE_LOADING_STARTED = 'metamask/gas/GAS_ESTIMATE_LOADING_STARTED'
const RESET_CUSTOM_GAS_STATE = 'metamask/gas/RESET_CUSTOM_GAS_STATE'
const SET_BASIC_GAS_ESTIMATE_DATA = 'metamask/gas/SET_BASIC_GAS_ESTIMATE_DATA'
const SET_CUSTOM_GAS_ERRORS = 'metamask/gas/SET_CUSTOM_GAS_ERRORS'
const SET_CUSTOM_GAS_LIMIT = 'metamask/gas/SET_CUSTOM_GAS_LIMIT'
const SET_CUSTOM_GAS_PRICE = 'metamask/gas/SET_CUSTOM_GAS_PRICE'
const SET_CUSTOM_GAS_TOTAL = 'metamask/gas/SET_CUSTOM_GAS_TOTAL'
+ const SET_PRICE_AND_TIME_ESTIMATES = 'metamask/gas/SET_PRICE_AND_TIME_ESTIMATES'
describe('GasReducer()', () => {
it('should initialize state', () => {
@@ -111,6 +120,24 @@ describe('Gas Duck', () => {
)
})
+ it('should set gasEstimatesLoading to true when receiving a GAS_ESTIMATE_LOADING_STARTED action', () => {
+ assert.deepEqual(
+ GasReducer(mockState, {
+ type: GAS_ESTIMATE_LOADING_STARTED,
+ }),
+ Object.assign({gasEstimatesLoading: true}, mockState.gas)
+ )
+ })
+
+ it('should set gasEstimatesLoading to false when receiving a GAS_ESTIMATE_LOADING_FINISHED action', () => {
+ assert.deepEqual(
+ GasReducer(mockState, {
+ type: GAS_ESTIMATE_LOADING_FINISHED,
+ }),
+ Object.assign({gasEstimatesLoading: false}, mockState.gas)
+ )
+ })
+
it('should return a new object (and not just modify the existing state object)', () => {
assert.deepEqual(GasReducer(mockState), mockState.gas)
assert.notEqual(GasReducer(mockState), mockState.gas)
@@ -126,6 +153,16 @@ describe('Gas Duck', () => {
)
})
+ it('should set priceAndTimeEstimates when receiving a SET_PRICE_AND_TIME_ESTIMATES action', () => {
+ assert.deepEqual(
+ GasReducer(mockState, {
+ type: SET_PRICE_AND_TIME_ESTIMATES,
+ value: { someProp: 'someData123' },
+ }),
+ Object.assign({priceAndTimeEstimates: {someProp: 'someData123'} }, mockState.gas)
+ )
+ })
+
it('should set customData.price when receiving a SET_CUSTOM_GAS_PRICE action', () => {
assert.deepEqual(
GasReducer(mockState, {
@@ -194,10 +231,10 @@ describe('Gas Duck', () => {
})
})
- describe('fetchGasEstimates', () => {
+ describe('fetchBasicGasEstimates', () => {
const mockDistpatch = sinon.spy()
it('should call fetch with the expected params', async () => {
- await fetchGasEstimates()(mockDistpatch)
+ await fetchBasicGasEstimates()(mockDistpatch)
assert.deepEqual(
mockDistpatch.getCall(0).args,
[{ type: BASIC_GAS_ESTIMATE_LOADING_STARTED} ]
@@ -242,6 +279,32 @@ describe('Gas Duck', () => {
})
})
+ describe('gasEstimatesLoadingStarted', () => {
+ it('should create the correct action', () => {
+ assert.deepEqual(
+ gasEstimatesLoadingStarted(),
+ { type: GAS_ESTIMATE_LOADING_STARTED }
+ )
+ })
+ })
+
+ describe('gasEstimatesLoadingFinished', () => {
+ it('should create the correct action', () => {
+ assert.deepEqual(
+ gasEstimatesLoadingFinished(),
+ { type: GAS_ESTIMATE_LOADING_FINISHED }
+ )
+ })
+ })
+
+ describe('setPricesAndTimeEstimates', () => {
+ it('should create the correct action', () => {
+ assert.deepEqual(
+ setPricesAndTimeEstimates('mockPricesAndTimeEstimates'),
+ { type: SET_PRICE_AND_TIME_ESTIMATES, value: 'mockPricesAndTimeEstimates' }
+ )
+ })
+ })
describe('setBasicGasEstimateData', () => {
it('should create the correct action', () => {