Skip to content

Commit

Permalink
add waitFor
Browse files Browse the repository at this point in the history
  • Loading branch information
frontendphil committed Feb 3, 2025
1 parent cee2d8c commit 49fc29f
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions deployables/app/app/routes/tokens/send.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
disconnectWallet,
render,
} from '@/test-utils'
import { screen } from '@testing-library/react'
import { screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { randomAddress } from '@zodiac/test-utils'
import { encodeFunctionData, erc20Abi, getAddress } from 'viem'
Expand Down Expand Up @@ -135,27 +135,29 @@ describe('Send Tokens', { concurrent: false, sequential: true }, () => {

await userEvent.click(screen.getByRole('button', { name: 'Send' }))

expect(fetch).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining({
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'eth_sendTransaction',
params: [
{
data: encodeFunctionData({
abi: erc20Abi,
functionName: 'transfer',
args: [recipient, 1234n],
}),
from: getAddress('0xd6be23396764a212e04399ca31c0ad7b7a3df8fc'),
to: tokenAddress,
},
],
await waitFor(() => {
expect(fetch).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining({
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'eth_sendTransaction',
params: [
{
data: encodeFunctionData({
abi: erc20Abi,
functionName: 'transfer',
args: [recipient, 1234n],
}),
from: getAddress('0xd6be23396764a212e04399ca31c0ad7b7a3df8fc'),
to: tokenAddress,
},
],
}),
}),
}),
)
)
})
})

it('displays how many tokens are available', async () => {
Expand Down

0 comments on commit 49fc29f

Please sign in to comment.