-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSendTip.test.tsx
50 lines (44 loc) · 1.2 KB
/
SendTip.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import * as React from 'react'
import { beforeEach, describe, expect, it } from 'vitest'
import {
UserEvent,
addressRegex,
render,
screen,
userEvent,
waitFor,
} from '../test'
import { Connect } from './Connect'
import { SendTip } from './SendTip'
describe('<SendTip />', () => {
let user: UserEvent
beforeEach(() => {
user = userEvent.setup()
})
it('sends tip', async () => {
render(
<>
<Connect />
<SendTip />
</>,
)
// "Send Tip" button disabled when wallet is not connected
const sendTipButton = screen.getByRole('button', { name: 'Send Tip' })
expect(sendTipButton).toBeDisabled()
// Connect to wallet
const connectButton = screen.getByRole('button', { name: 'Mock' })
user.click(connectButton)
await waitFor(() =>
expect(screen.getByText(addressRegex)).toBeInTheDocument(),
)
// Send transaction
await waitFor(() => expect(sendTipButton).not.toBeDisabled())
user.click(sendTipButton)
await waitFor(() =>
expect(screen.getByText(/transaction pending/i)).toBeInTheDocument(),
)
await waitFor(() =>
expect(screen.getByText(/transaction confirmed/i)).toBeInTheDocument(),
)
})
})