mirror of
https://github.com/status-im/safe-react.git
synced 2025-01-14 20:14:15 +00:00
Refactor provider reducer
This commit is contained in:
parent
461f3ef7d3
commit
5444e56401
@ -20,9 +20,9 @@ const providerReducerTests = () => {
|
|||||||
store = createStore(reducers, compose(...enhancers))
|
store = createStore(reducers, compose(...enhancers))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('reducer should return default Provider record when no Metamask is loaded', () => {
|
it('reducer should return default Provider record when no provider is loaded', () => {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
const emptyResponse: ProviderProps = {
|
const emptyProvider: ProviderProps = {
|
||||||
name: '',
|
name: '',
|
||||||
loaded: false,
|
loaded: false,
|
||||||
available: false,
|
available: false,
|
||||||
@ -31,17 +31,17 @@ const providerReducerTests = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
processProviderResponse(store.dispatch, emptyResponse)
|
processProviderResponse(store.dispatch, emptyProvider)
|
||||||
const provider = store.getState()[PROVIDER_REDUCER_ID]
|
const provider = store.getState()[PROVIDER_REDUCER_ID]
|
||||||
|
|
||||||
// THEN
|
// THEN
|
||||||
expect(makeProvider(emptyResponse)).toEqual(provider)
|
expect(makeProvider(emptyProvider)).toEqual(provider)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('reducer should return avaiable with its default value when is loaded but not available', () => {
|
it('reducer should return avaiable with its default value when is loaded but not available', () => {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
const metamaskLoaded: ProviderProps = {
|
const providerLoaded: ProviderProps = {
|
||||||
name: 'METAMASK',
|
name: 'SAFE',
|
||||||
loaded: true,
|
loaded: true,
|
||||||
available: false,
|
available: false,
|
||||||
account: '',
|
account: '',
|
||||||
@ -49,17 +49,17 @@ const providerReducerTests = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
processProviderResponse(store.dispatch, metamaskLoaded)
|
processProviderResponse(store.dispatch, providerLoaded)
|
||||||
const provider = store.getState()[PROVIDER_REDUCER_ID]
|
const provider = store.getState()[PROVIDER_REDUCER_ID]
|
||||||
|
|
||||||
// THEN
|
// THEN
|
||||||
expect(makeProvider(metamaskLoaded)).toEqual(provider)
|
expect(makeProvider(providerLoaded)).toEqual(provider)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('reducer should return metamask provider when it is loaded and available', () => {
|
it('reducer should return provider when it is loaded and available', () => {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
const metamask: ProviderProps = {
|
const providerLoaded: ProviderProps = {
|
||||||
name: 'METAMASK',
|
name: 'SAFE',
|
||||||
loaded: true,
|
loaded: true,
|
||||||
available: true,
|
available: true,
|
||||||
account: '',
|
account: '',
|
||||||
@ -67,11 +67,11 @@ const providerReducerTests = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
processProviderResponse(store.dispatch, metamask)
|
processProviderResponse(store.dispatch, providerLoaded)
|
||||||
const provider = store.getState()[PROVIDER_REDUCER_ID]
|
const provider = store.getState()[PROVIDER_REDUCER_ID]
|
||||||
|
|
||||||
// THEN
|
// THEN
|
||||||
expect(makeProvider(metamask)).toEqual(provider)
|
expect(makeProvider(providerLoaded)).toEqual(provider)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user