WA-230 Including in tests decimal eth for testing balances

This commit is contained in:
apanizo 2018-04-17 12:01:29 +02:00
parent 01977f91cd
commit c866afcf56
2 changed files with 7 additions and 7 deletions

View File

@ -6,10 +6,10 @@ import { getWeb3 } from '~/wallets/getWeb3'
import { promisify } from '~/utils/promisify' import { promisify } from '~/utils/promisify'
import { aDeployedSafe } from './builder/deployedSafe.builder' import { aDeployedSafe } from './builder/deployedSafe.builder'
const addOneEtherTo = async (address: string) => { const addEtherTo = async (address: string, eth: string) => {
const web3 = getWeb3() const web3 = getWeb3()
const accounts = await promisify(cb => web3.eth.getAccounts(cb)) const accounts = await promisify(cb => web3.eth.getAccounts(cb))
const txData = { from: accounts[0], to: address, value: web3.toWei('1', 'ether') } const txData = { from: accounts[0], to: address, value: web3.toWei(eth, 'ether') }
return promisify(cb => web3.eth.sendTransaction(txData, cb)) return promisify(cb => web3.eth.sendTransaction(txData, cb))
} }
@ -34,19 +34,19 @@ const balanceReducerTests = () => {
expect(balances.get(address)).toBe('0') expect(balances.get(address)).toBe('0')
}) })
it('reducer should return 1 ETH as funds to safe with 1 ETH', async () => { it('reducer should return 1.3456 ETH as funds to safe with 1 ETH', async () => {
// GIVEN // GIVEN
const safeTx = await aDeployedSafe(store) const safeTx = await aDeployedSafe(store)
const address = safeTx.contractAddress const address = safeTx.contractAddress
// WHEN // WHEN
await addOneEtherTo(address) await addEtherTo(address, '1.3456')
await store.dispatch(fetchBalance(address)) await store.dispatch(fetchBalance(address))
// THEN // THEN
const balances = store.getState()[BALANCE_REDUCER_ID] const balances = store.getState()[BALANCE_REDUCER_ID]
expect(balances).not.toBe(undefined) expect(balances).not.toBe(undefined)
expect(balances.get(address)).toBe('1') expect(balances.get(address)).toBe('1.3456')
}) })
}) })
} }

View File

@ -49,11 +49,11 @@ const balanceSelectorTests = () => {
const store = aNewStore() const store = aNewStore()
// WHEN // WHEN
await store.dispatch(addBalance(safeAddress, '1')) await store.dispatch(addBalance(safeAddress, '1.3456'))
const balance = balanceSelector(store.getState(), { match }) const balance = balanceSelector(store.getState(), { match })
// THEN // THEN
expect(balance).toBe('1') expect(balance).toBe('1.3456')
}) })
}) })
} }