WA-230 Including balances reducer in store

This commit is contained in:
apanizo 2018-04-17 09:39:27 +02:00
parent 42f2e763b9
commit 5ddc5f7afe
3 changed files with 25 additions and 6 deletions

View File

@ -3,7 +3,7 @@ import { Map } from 'immutable'
import { type Match } from 'react-router-dom' import { type Match } from 'react-router-dom'
import { SAFE_REDUCER_ID } from '~/routes/safe/store/reducer/safe' import { SAFE_REDUCER_ID } from '~/routes/safe/store/reducer/safe'
import { type Safe } from '~/routes/safe/store/model/safe' import { type Safe } from '~/routes/safe/store/model/safe'
import { SafeFactory } from '~/routes/safe/store/test/builder/index.builder' import { SafeFactory } from '~/routes/safe/store/test/builder/safe.builder'
import { safeSelector } from '../selectors' import { safeSelector } from '../selectors'
const buildMathPropsFrom = (address): Match => ({ const buildMathPropsFrom = (address): Match => ({
@ -19,7 +19,11 @@ const safeSelectorTests = () => {
describe('Safe Selector[safeSelector]', () => { describe('Safe Selector[safeSelector]', () => {
it('should return empty list when no safes', () => { it('should return empty list when no safes', () => {
// GIVEN // GIVEN
const reduxStore = { [SAFE_REDUCER_ID]: Map(), providers: undefined } const reduxStore = {
[SAFE_REDUCER_ID]: Map(),
providers: undefined,
balances: undefined,
}
const match: Match = buildMathPropsFrom('fooAddress') const match: Match = buildMathPropsFrom('fooAddress')
// WHEN // WHEN
@ -38,7 +42,11 @@ const safeSelectorTests = () => {
const match: Match = buildMathPropsFrom('fooAddress') const match: Match = buildMathPropsFrom('fooAddress')
const undefMatch: Match = buildMathPropsFrom('inventedAddress') const undefMatch: Match = buildMathPropsFrom('inventedAddress')
const reduxStore = { [SAFE_REDUCER_ID]: map, providers: undefined } const reduxStore = {
[SAFE_REDUCER_ID]: map,
providers: undefined,
balances: undefined,
}
// WHEN // WHEN
const oneOwnerSafe = safeSelector(reduxStore, { match }) const oneOwnerSafe = safeSelector(reduxStore, { match })

View File

@ -2,14 +2,18 @@
import { List, Map } from 'immutable' import { List, Map } from 'immutable'
import { SAFE_REDUCER_ID } from '~/routes/safe/store/reducer/safe' import { SAFE_REDUCER_ID } from '~/routes/safe/store/reducer/safe'
import { type Safe } from '~/routes/safe/store/model/safe' import { type Safe } from '~/routes/safe/store/model/safe'
import { SafeFactory } from '~/routes/safe/store/test/builder/index.builder' import { SafeFactory } from '~/routes/safe/store/test/builder/safe.builder'
import { safesListSelector } from '../selectors' import { safesListSelector } from '../selectors'
const safesListSelectorTests = () => { const safesListSelectorTests = () => {
describe('Safes Selector[safesSelector]', () => { describe('Safes Selector[safesSelector]', () => {
it('should return empty list when no safes', () => { it('should return empty list when no safes', () => {
// GIVEN // GIVEN
const reduxStore = { [SAFE_REDUCER_ID]: Map(), providers: undefined } const reduxStore = {
[SAFE_REDUCER_ID]: Map(),
providers: undefined,
balances: undefined,
}
const emptyList = List([]) const emptyList = List([])
// WHEN // WHEN
@ -25,7 +29,11 @@ const safesListSelectorTests = () => {
map = map.set('fooAddress', SafeFactory.oneOwnerSafe) map = map.set('fooAddress', SafeFactory.oneOwnerSafe)
map = map.set('barAddress', SafeFactory.twoOwnersSafe) map = map.set('barAddress', SafeFactory.twoOwnersSafe)
const reduxStore = { [SAFE_REDUCER_ID]: map, providers: undefined } const reduxStore = {
[SAFE_REDUCER_ID]: map,
providers: undefined,
balances: undefined,
}
// WHEN // WHEN
const safes = safesListSelector(reduxStore) const safes = safesListSelector(reduxStore)

View File

@ -5,6 +5,7 @@ import { combineReducers, createStore, applyMiddleware, compose, type Reducer, t
import thunk from 'redux-thunk' import thunk from 'redux-thunk'
import provider, { PROVIDER_REDUCER_ID, type State as ProviderState } from '~/wallets/store/reducer/provider' import provider, { PROVIDER_REDUCER_ID, type State as ProviderState } from '~/wallets/store/reducer/provider'
import safe, { SAFE_REDUCER_ID, calculateInitialState, type State as SafeState } from '~/routes/safe/store/reducer/safe' import safe, { SAFE_REDUCER_ID, calculateInitialState, type State as SafeState } from '~/routes/safe/store/reducer/safe'
import balances, { BALANCE_REDUCER_ID, type State as BalancesState } from '~/routes/safe/store/reducer/balances'
export const history = createBrowserHistory() export const history = createBrowserHistory()
@ -18,12 +19,14 @@ const finalCreateStore = composeEnhancers(applyMiddleware(
export type GlobalState = { export type GlobalState = {
providers: ProviderState, providers: ProviderState,
safes: SafeState, safes: SafeState,
balances: BalancesState,
} }
const reducers: Reducer<GlobalState> = combineReducers({ const reducers: Reducer<GlobalState> = combineReducers({
routing: routerReducer, routing: routerReducer,
[PROVIDER_REDUCER_ID]: provider, [PROVIDER_REDUCER_ID]: provider,
[SAFE_REDUCER_ID]: safe, [SAFE_REDUCER_ID]: safe,
[BALANCE_REDUCER_ID]: balances,
}) })
const initialState = { [SAFE_REDUCER_ID]: calculateInitialState() } const initialState = { [SAFE_REDUCER_ID]: calculateInitialState() }