Use waitForElement instead of sleep() in balances test

This commit is contained in:
Mikhail Mikheev 2019-09-14 18:37:58 +03:00
parent 2d05557df5
commit 5203ba3cfb
1 changed files with 5 additions and 7 deletions

View File

@ -1,4 +1,5 @@
// @flow
import { waitForElement } from '@testing-library/react'
import { List } from 'immutable'
import { aNewStore } from '~/store'
import { sleep } from '~/utils/timer'
@ -44,13 +45,11 @@ describe('DOM > Feature > Balances', () => {
const balanceRows = SafeDom.getAllByTestId(BALANCE_ROW_TEST_ID)
expect(balanceRows.length).toBe(2)
expect(balanceRows[1]).toHaveTextContent(`${tokensAmount} FTE`)
await waitForElement(() => SafeDom.getByText(`${tokensAmount} OMG`))
await sendTokenTo(safeAddress, tokensAmount)
await sleep(2000)
expect(balanceRows[2]).toHaveTextContent(`${parseInt(tokensAmount, 10) * 2} FTE`)
await waitForElement(() => SafeDom.getByText(`${parseInt(tokensAmount, 10) * 2} OMG`))
})
it('Updates ether balance automatically', async () => {
@ -65,11 +64,10 @@ describe('DOM > Feature > Balances', () => {
const balanceRows = SafeDom.getAllByTestId(BALANCE_ROW_TEST_ID)
expect(balanceRows.length).toBe(1)
expect(balanceRows[0]).toHaveTextContent(`${etherAmount} ETH`)
await waitForElement(() => SafeDom.getByText(`${etherAmount} ETH`))
await sendEtherTo(safeAddress, etherAmount)
await sleep(2000)
expect(balanceRows[0]).toHaveTextContent(`${parseInt(etherAmount, 10) * 2} ETH`)
await waitForElement(() => SafeDom.getByText(`${parseInt(etherAmount, 10) * 2} ETH`))
})
})