WA-238 Add test safesByOnwer selector with casi insensitive comparing addresses
This commit is contained in:
parent
4a104830ae
commit
a16b5ed0f2
|
@ -30,7 +30,7 @@ const Layout = ({
|
|||
}: Props) => {
|
||||
const steps = getSteps()
|
||||
const initialValues = initialValuesFrom(userAccount)
|
||||
const finishedButton = <Stepper.FinishButton title="VISIT SAFS" component={Link} to={SAFELIST_ADDRESS} />
|
||||
const finishedButton = <Stepper.FinishButton title="VISIT SAFES" component={Link} to={SAFELIST_ADDRESS} />
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
|
|
|
@ -4,6 +4,7 @@ import { createSelector, type Selector } from 'reselect'
|
|||
import { type GlobalState } from '~/store/index'
|
||||
import { type Safe } from '~/routes/safe/store/model/safe'
|
||||
import { userAccountSelector } from '~/wallets/store/selectors/index'
|
||||
import { type Owner } from '~/routes/safe/store/model/owner'
|
||||
|
||||
export const safesMapSelector = (state: GlobalState): Map<string, Safe> => state.safes
|
||||
const safesListSelector: Selector<GlobalState, {}, List<Safe>> = createSelector(
|
||||
|
@ -16,5 +17,10 @@ export const safesByOwnerSelector: Selector<GlobalState, {}, List<Safe>> = creat
|
|||
safesListSelector,
|
||||
(userAddress: string, safes: List<Safe>): List<Safe> =>
|
||||
safes.filter((safe: Safe) =>
|
||||
safe.owners.filter(owner => owner.get('address') === userAddress).count() > 0),
|
||||
safe.owners.filter((owner: Owner) => {
|
||||
const ownerLower = owner.get('address').toLowerCase()
|
||||
const userLower = userAddress.toLowerCase()
|
||||
|
||||
return ownerLower === userLower
|
||||
}).count() > 0),
|
||||
)
|
||||
|
|
|
@ -90,6 +90,27 @@ const safesListSelectorTests = () => {
|
|||
expect(safes.count()).toEqual(2)
|
||||
expect(safes.get(0)).not.toEqual(safes.get(1))
|
||||
})
|
||||
|
||||
it('should return safes under owners case-insensitive', () => {
|
||||
// GIVEN
|
||||
let map: Map<string, Safe> = Map()
|
||||
const userAccountUpper = walletRecord.account.toUpperCase()
|
||||
map = map.set('fooAddress', SafeFactory.oneOwnerSafe(userAccountUpper))
|
||||
map = map.set('barAddress', SafeFactory.twoOwnersSafe('foo', userAccountUpper))
|
||||
|
||||
const reduxStore = {
|
||||
[SAFE_REDUCER_ID]: map,
|
||||
[PROVIDER_REDUCER_ID]: walletRecord,
|
||||
balances: undefined,
|
||||
}
|
||||
|
||||
// WHEN
|
||||
const safes = safesByOwnerSelector(reduxStore, {})
|
||||
|
||||
// THEN
|
||||
expect(safes.count()).toEqual(2)
|
||||
expect(safes.get(0)).not.toEqual(safes.get(1))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue