-
Notifications
You must be signed in to change notification settings - Fork 172
Expand file tree
/
Copy pathNetworkNotifications.test.tsx
More file actions
46 lines (38 loc) · 1.29 KB
/
NetworkNotifications.test.tsx
File metadata and controls
46 lines (38 loc) · 1.29 KB
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
import { mockFunction, render, screen } from '@app/test-utils'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { useAccount, useChainId } from 'wagmi'
import { NetworkNotifications } from './NetworkNotifications'
import { shouldOpenModal } from './utils'
vi.mock('wagmi')
const mockUseAccount = mockFunction(useAccount)
const mockUseChainId = mockFunction(useChainId)
vi.mock('./utils', async (importOriginal) => {
const actual = await importOriginal<any>()
return {
...actual,
shouldOpenModal: vi.fn(),
}
})
describe('NetworkNotifications', () => {
beforeEach(() => {
vi.clearAllMocks()
})
it('should show notification if shouldOpenModal sets true', () => {
vi.mocked(shouldOpenModal).mockReturnValue(true)
mockUseAccount.mockReturnValue({
chainId: 1,
})
mockUseChainId.mockReturnValue(1)
render(<NetworkNotifications />)
expect(screen.getByTestId('toast-desktop')).toBeInTheDocument()
})
it('should not show notification if shouldOpenModal sets false', () => {
vi.mocked(shouldOpenModal).mockReturnValue(false)
mockUseAccount.mockReturnValue({
chainId: 1,
})
mockUseChainId.mockReturnValue(1)
render(<NetworkNotifications />)
expect(screen.queryByTestId('toast-desktop')).not.toBeInTheDocument()
})
})