sending tokens test wip

This commit is contained in:
mmv 2019-06-03 17:58:20 +04:00
parent 95dcce1684
commit 1d62ef700e
2 changed files with 7 additions and 5 deletions

View File

@ -1,14 +1,16 @@
// @flow
import { fireEvent, cleanup } from '@testing-library/react'
import { List } from 'immutable'
import { aNewStore } from '~/store'
import { aMinedSafe } from '~/test/builder/safe.redux.builder'
import { sendTokenTo, getFirstTokenContract, sendEtherTo } from '~/test/utils/tokenMovements'
import { EXPAND_BALANCE_INDEX, renderSafeView } from '~/test/builder/safe.dom.utils'
import { getWeb3, getBalanceInEtherOf } from '~/logic/wallets/getWeb3'
import { sendMoveTokensForm, dispatchTknBalance } from '~/test/utils/transactions/moveTokens.helper'
import { sendMoveTokensForm, dispatchAddTokenToList } from '~/test/utils/transactions/moveTokens.helper'
import { sleep } from '~/utils/timer'
import { ETH_ADDRESS } from '~/logic/tokens/utils/tokenHelpers'
import { calculateBalanceOf } from '~/routes/safe/store/actions/fetchTokenBalances'
import updateActiveTokens from '~/routes/safe/store/actions/updateActiveTokens'
import 'jest-dom/extend-expect'
afterEach(cleanup)
@ -68,8 +70,10 @@ describe('DOM > Feature > Funds', () => {
// GIVEN
const numTokens = '100'
const tokenAddress = await sendTokenTo(safeAddress, numTokens)
const safeTokenBalance = await calculateBalanceOf(tokenAddress, safeAddress, 18)
store.dispatch(updateActiveTokens(safeAddress, List([tokenAddress])))
await dispatchTknBalance(store, tokenAddress, safeAddress)
await dispatchAddTokenToList(store, tokenAddress, safeAddress)
// const StandardToken = await fetchBalancesAction.getStandardTokenContract()
// const myToken = await StandardToken.at(tokenAddress)
// console.log(await myToken.allowance(safeAddress, accounts[2]))

View File

@ -44,9 +44,8 @@ export const sendMoveTokensForm = async (
return whenExecuted(SafeDom, SendToken)
}
export const dispatchTknBalance = async (store: Store, tokenAddress: string, address: string) => {
export const dispatchAddTokenToList = async (store: Store, tokenAddress: string, address: string) => {
const fetchBalancesMock = jest.fn()
const balance = await calculateBalanceOf(tokenAddress, address, 18)
const balances: Map<string, Token> = Map().set(
'TKN',
makeToken({
@ -56,7 +55,6 @@ export const dispatchTknBalance = async (store: Store, tokenAddress: string, add
decimals: 18,
logoUri:
'https://github.com/TrustWallet/tokens/blob/master/images/0x6810e776880c02933d47db1b9fc05908e5386b96.png?raw=true',
balance,
}),
)
fetchBalancesMock.mockImplementation(() => store.dispatch(addTokens(address, balances)))