-
Notifications
You must be signed in to change notification settings - Fork 172
Expand file tree
/
Copy pathutils.test.ts
More file actions
39 lines (31 loc) · 1.15 KB
/
utils.test.ts
File metadata and controls
39 lines (31 loc) · 1.15 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
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import * as chains from '@app/constants/chains'
import { shouldOpenModal } from './utils'
describe('shouldOpenModal', () => {
beforeEach(() => {
vi.resetModules()
vi.clearAllMocks()
})
afterEach(() => {
vi.resetModules()
vi.clearAllMocks()
})
it('should return false when connectedChainId is not provided', () => {
const result = shouldOpenModal(undefined, 1)
expect(result).toBe(false)
})
it('should return false when accountChainId is not provided', () => {
const result = shouldOpenModal(1, undefined)
expect(result).toBe(false)
})
it('should return false when chain is not supported', () => {
vi.spyOn(chains, 'getSupportedChainById').mockReturnValue(undefined)
const result = shouldOpenModal(1, 999999)
expect(result).toBe(false)
})
it('should return true when connected chain id is different from account chain id and account chain id is supported', () => {
vi.spyOn(chains, 'getSupportedChainById').mockReturnValue({ id: 17000 } as any)
const result = shouldOpenModal(1, 17000)
expect(result).toBe(true)
})
})